|
|
|
|
@ -81,6 +81,17 @@
@@ -81,6 +81,17 @@
|
|
|
|
|
} |
|
|
|
|
pump(); |
|
|
|
|
} |
|
|
|
|
function executeOne(call) { |
|
|
|
|
return BRIDGE.sendCall(call).then(function (res) { |
|
|
|
|
var e = res && !res.ok && res.error; |
|
|
|
|
var needConfirm = e && e.code === "E_NEEDS_CONFIRM" && e.extra && e.extra.confirmToken; |
|
|
|
|
if (needConfirm) { |
|
|
|
|
console.log("[dsh-memory] needs confirm, retrying", call.tool); |
|
|
|
|
return BRIDGE.sendCall({ tool: call.tool, args: call.args, confirmToken: e.extra.confirmToken }); |
|
|
|
|
} |
|
|
|
|
return res; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
function pump() { |
|
|
|
|
if (pumping) return; |
|
|
|
|
if (queue.length === 0) return; |
|
|
|
|
@ -91,7 +102,7 @@
@@ -91,7 +102,7 @@
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
var call = queue.shift(); |
|
|
|
|
BRIDGE.sendCall(call).then(function (res) { |
|
|
|
|
executeOne(call).then(function (res) { |
|
|
|
|
if (res) { |
|
|
|
|
if (res.ok) { |
|
|
|
|
console.log("[dsh-memory] call ok", call.tool, res.durationMs); |
|
|
|
|
@ -142,7 +153,12 @@
@@ -142,7 +153,12 @@
|
|
|
|
|
if (pending.size > 0) schedule(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
BRIDGE.hasToken().then(function (has) { |
|
|
|
|
BRIDGE.isEnabled().then(function (enabled) { |
|
|
|
|
if (!enabled) { |
|
|
|
|
console.warn("[dsh-memory] disabled (dsh-memory-enabled=false), idle"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
return BRIDGE.hasToken().then(function (has) { |
|
|
|
|
if (!has) { |
|
|
|
|
console.warn("[dsh-memory] no bridge token, idle"); |
|
|
|
|
return; |
|
|
|
|
@ -154,4 +170,5 @@
@@ -154,4 +170,5 @@
|
|
|
|
|
}); |
|
|
|
|
console.log("[dsh-memory] content.js active"); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
})(); |
|
|
|
|
|