offhands 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/daemon.mjs +46 -36
- package/package.json +1 -1
package/dist/daemon.mjs
CHANGED
|
@@ -4959,6 +4959,51 @@ var AsyncEventQueue = class {
|
|
|
4959
4959
|
|
|
4960
4960
|
// ../daemon/src/runners/claude-code.ts
|
|
4961
4961
|
var APPROVAL_MCP_PATH = join(dirname(fileURLToPath(import.meta.url)), "..", "approval-mcp.mjs");
|
|
4962
|
+
var CLAUDE_PREALLOWED_OFFHAND_TOOLS = [
|
|
4963
|
+
"mcp__offhand__offhand_status_update",
|
|
4964
|
+
"mcp__offhand__offhand_context"
|
|
4965
|
+
];
|
|
4966
|
+
function buildClaudeArgs(run, approvalUrl2) {
|
|
4967
|
+
const args2 = ["-p", run.prompt, "--output-format", "stream-json", "--verbose", "--include-partial-messages"];
|
|
4968
|
+
if (run.model) args2.push("--model", run.model);
|
|
4969
|
+
if (run.resumeConversationId) args2.push("--resume", run.resumeConversationId);
|
|
4970
|
+
const mode = run.permissionMode ?? "guarded";
|
|
4971
|
+
if (mode === "bypass") {
|
|
4972
|
+
args2.push("--permission-mode", "bypassPermissions");
|
|
4973
|
+
} else if (approvalUrl2) {
|
|
4974
|
+
if (mode === "plan") args2.push("--permission-mode", "plan");
|
|
4975
|
+
else if (mode === "acceptEdits") args2.push("--permission-mode", "acceptEdits");
|
|
4976
|
+
const mcpConfig = {
|
|
4977
|
+
mcpServers: {
|
|
4978
|
+
offhand: {
|
|
4979
|
+
command: process.execPath,
|
|
4980
|
+
args: [APPROVAL_MCP_PATH],
|
|
4981
|
+
// OFFHAND_STATUS_URL is derived from approvalUrl rather than a
|
|
4982
|
+
// second constructor param — same daemon, same port, one fewer
|
|
4983
|
+
// thing to keep in sync as approvalUrl already carries the
|
|
4984
|
+
// host:port everything else here needs.
|
|
4985
|
+
env: {
|
|
4986
|
+
OFFHAND_APPROVAL_URL: approvalUrl2,
|
|
4987
|
+
OFFHAND_STATUS_URL: approvalUrl2.replace(/\/approval$/, "/status"),
|
|
4988
|
+
OFFHAND_SESSION_ID: run.sessionId
|
|
4989
|
+
}
|
|
4990
|
+
}
|
|
4991
|
+
}
|
|
4992
|
+
};
|
|
4993
|
+
args2.push(
|
|
4994
|
+
"--mcp-config",
|
|
4995
|
+
JSON.stringify(mcpConfig),
|
|
4996
|
+
"--strict-mcp-config",
|
|
4997
|
+
"--permission-prompt-tool",
|
|
4998
|
+
"mcp__offhand__approval_prompt",
|
|
4999
|
+
"--allowedTools",
|
|
5000
|
+
CLAUDE_PREALLOWED_OFFHAND_TOOLS.join(",")
|
|
5001
|
+
);
|
|
5002
|
+
} else {
|
|
5003
|
+
args2.push("--permission-mode", "acceptEdits");
|
|
5004
|
+
}
|
|
5005
|
+
return args2;
|
|
5006
|
+
}
|
|
4962
5007
|
var ClaudeCodeRunner = class {
|
|
4963
5008
|
constructor(broker2, approvalUrl2) {
|
|
4964
5009
|
this.broker = broker2;
|
|
@@ -5012,42 +5057,7 @@ var ClaudeCodeRunner = class {
|
|
|
5012
5057
|
}
|
|
5013
5058
|
};
|
|
5014
5059
|
const detachBroker = this.broker?.attach((ev) => queue.push(ev));
|
|
5015
|
-
const args2 =
|
|
5016
|
-
if (run.model) args2.push("--model", run.model);
|
|
5017
|
-
if (run.resumeConversationId) args2.push("--resume", run.resumeConversationId);
|
|
5018
|
-
const mode = run.permissionMode ?? "guarded";
|
|
5019
|
-
if (mode === "bypass") {
|
|
5020
|
-
args2.push("--permission-mode", "bypassPermissions");
|
|
5021
|
-
} else if (this.broker && this.approvalUrl) {
|
|
5022
|
-
if (mode === "plan") args2.push("--permission-mode", "plan");
|
|
5023
|
-
else if (mode === "acceptEdits") args2.push("--permission-mode", "acceptEdits");
|
|
5024
|
-
const mcpConfig = {
|
|
5025
|
-
mcpServers: {
|
|
5026
|
-
offhand: {
|
|
5027
|
-
command: process.execPath,
|
|
5028
|
-
args: [APPROVAL_MCP_PATH],
|
|
5029
|
-
// OFFHAND_STATUS_URL is derived from approvalUrl rather than a
|
|
5030
|
-
// second constructor param — same daemon, same port, one fewer
|
|
5031
|
-
// thing to keep in sync as this.approvalUrl already carries the
|
|
5032
|
-
// host:port everything else here needs.
|
|
5033
|
-
env: {
|
|
5034
|
-
OFFHAND_APPROVAL_URL: this.approvalUrl,
|
|
5035
|
-
OFFHAND_STATUS_URL: this.approvalUrl.replace(/\/approval$/, "/status"),
|
|
5036
|
-
OFFHAND_SESSION_ID: run.sessionId
|
|
5037
|
-
}
|
|
5038
|
-
}
|
|
5039
|
-
}
|
|
5040
|
-
};
|
|
5041
|
-
args2.push(
|
|
5042
|
-
"--mcp-config",
|
|
5043
|
-
JSON.stringify(mcpConfig),
|
|
5044
|
-
"--strict-mcp-config",
|
|
5045
|
-
"--permission-prompt-tool",
|
|
5046
|
-
"mcp__offhand__approval_prompt"
|
|
5047
|
-
);
|
|
5048
|
-
} else {
|
|
5049
|
-
args2.push("--permission-mode", "acceptEdits");
|
|
5050
|
-
}
|
|
5060
|
+
const args2 = buildClaudeArgs(run, this.broker && this.approvalUrl ? this.approvalUrl : void 0);
|
|
5051
5061
|
const thinking = { low: 0, medium: 8e3, high: 16e3, max: 31999 };
|
|
5052
5062
|
const env = run.effort !== void 0 ? { ...process.env, MAX_THINKING_TOKENS: String(thinking[run.effort]) } : process.env;
|
|
5053
5063
|
try {
|