handsoff 0.1.2 → 0.1.3
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/gateway/process.js +29 -29
- package/dist/gateway/process.js.map +1 -1
- package/package.json +1 -1
package/dist/gateway/process.js
CHANGED
|
@@ -167,7 +167,7 @@ function buildPermissionCard(input) {
|
|
|
167
167
|
behaviors: [
|
|
168
168
|
{
|
|
169
169
|
type: "callback",
|
|
170
|
-
value: { action: btn.value }
|
|
170
|
+
value: { action: btn.value, requestId: input.requestId }
|
|
171
171
|
}
|
|
172
172
|
]
|
|
173
173
|
};
|
|
@@ -6362,25 +6362,16 @@ function sendJson(res, statusCode, data) {
|
|
|
6362
6362
|
}
|
|
6363
6363
|
function formatHookResponse(eventType, toolName, result) {
|
|
6364
6364
|
const isAskUserQuestion = toolName === "AskUserQuestion";
|
|
6365
|
-
|
|
6365
|
+
const buildAskUserQuestionUpdatedInput = () => {
|
|
6366
6366
|
const questions = result._toolInput?.questions;
|
|
6367
6367
|
const question = questions?.[0];
|
|
6368
6368
|
const selectedValueStr = result.selectedValues && result.selectedValues.length > 0 ? result.selectedValues.map(String).join(", ") : void 0;
|
|
6369
6369
|
const answerValue = result.customInput ?? selectedValueStr ?? "";
|
|
6370
|
-
|
|
6370
|
+
return {
|
|
6371
6371
|
...result._toolInput,
|
|
6372
6372
|
answers: question?.question ? { [question.question]: answerValue } : {}
|
|
6373
6373
|
};
|
|
6374
|
-
|
|
6375
|
-
hookSpecificOutput: {
|
|
6376
|
-
hookEventName: "PermissionRequest",
|
|
6377
|
-
decision: {
|
|
6378
|
-
behavior: "allow",
|
|
6379
|
-
updatedInput
|
|
6380
|
-
}
|
|
6381
|
-
}
|
|
6382
|
-
});
|
|
6383
|
-
}
|
|
6374
|
+
};
|
|
6384
6375
|
if (eventType === "PermissionRequest") {
|
|
6385
6376
|
let updatedPermissions;
|
|
6386
6377
|
if (result.permissionUpdates && result.permissionUpdates.length > 0) {
|
|
@@ -6393,27 +6384,36 @@ function formatHookResponse(eventType, toolName, result) {
|
|
|
6393
6384
|
...rule.directories && { directories: rule.directories }
|
|
6394
6385
|
}));
|
|
6395
6386
|
}
|
|
6387
|
+
const decision = {
|
|
6388
|
+
behavior: result.action === "select" ? "allow" : result.action,
|
|
6389
|
+
...result.message !== void 0 && { message: result.message },
|
|
6390
|
+
...result.selectedValues !== void 0 && {
|
|
6391
|
+
data: result.selectedValues.map(String).join(", ")
|
|
6392
|
+
},
|
|
6393
|
+
...updatedPermissions !== void 0 && { updatedPermissions }
|
|
6394
|
+
};
|
|
6395
|
+
if (isAskUserQuestion) {
|
|
6396
|
+
decision.updatedInput = buildAskUserQuestionUpdatedInput();
|
|
6397
|
+
}
|
|
6396
6398
|
return JSON.stringify({
|
|
6397
6399
|
hookSpecificOutput: {
|
|
6398
6400
|
hookEventName: "PermissionRequest",
|
|
6399
|
-
decision
|
|
6400
|
-
behavior: result.action === "select" ? "allow" : result.action,
|
|
6401
|
-
...result.message !== void 0 && { message: result.message },
|
|
6402
|
-
...result.selectedValues !== void 0 && {
|
|
6403
|
-
data: result.selectedValues.map(String).join(", ")
|
|
6404
|
-
},
|
|
6405
|
-
...updatedPermissions !== void 0 && { updatedPermissions }
|
|
6406
|
-
}
|
|
6401
|
+
decision
|
|
6407
6402
|
}
|
|
6408
6403
|
});
|
|
6409
6404
|
}
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6405
|
+
const permissionDecision = result.action === "allow" ? "allow" : "deny";
|
|
6406
|
+
const hookSpecificOutput = {
|
|
6407
|
+
hookEventName: "PreToolUse",
|
|
6408
|
+
permissionDecision
|
|
6409
|
+
};
|
|
6410
|
+
if (result.message !== void 0) {
|
|
6411
|
+
hookSpecificOutput.permissionDecisionReason = result.message;
|
|
6412
|
+
}
|
|
6413
|
+
if (isAskUserQuestion) {
|
|
6414
|
+
hookSpecificOutput.updatedInput = buildAskUserQuestionUpdatedInput();
|
|
6415
|
+
}
|
|
6416
|
+
return JSON.stringify({ hookSpecificOutput });
|
|
6417
6417
|
}
|
|
6418
6418
|
function setupRoutes(httpServer, gateway, getClientCount) {
|
|
6419
6419
|
httpServer.registerRoute("GET", "/health", (_req, res) => {
|
|
@@ -11469,7 +11469,7 @@ var FeishuChannel = class extends (_a4 = BaseChannel) {
|
|
|
11469
11469
|
{ text: "\u274C Deny", type: "danger_filled", value: "reject", confirm: { title: "\u786E\u8BA4\u62D2\u7EDD", text: "\u786E\u8BA4\u62D2\u7EDD\u8BE5\u5DE5\u5177\u8C03\u7528\uFF1F" } },
|
|
11470
11470
|
{ text: "\u{1F513} Always Allow", type: "default", value: "always_allow", confirm: { title: "\u786E\u8BA4\u603B\u662F\u5141\u8BB8", text: "\u603B\u662F\u5141\u8BB8\u5C06\u653E\u884C\u8BE5\u5DE5\u5177\u7684\u6240\u6709\u8C03\u7528\uFF0C\u8BF7\u786E\u8BA4\u3002" } }
|
|
11471
11471
|
];
|
|
11472
|
-
const cardContent = this.formatter.formatPermissionCard({ title: this.getTitleForContext(message.context), content, buttons });
|
|
11472
|
+
const cardContent = this.formatter.formatPermissionCard({ title: this.getTitleForContext(message.context), content, buttons, requestId });
|
|
11473
11473
|
await this.sendCardRaw(cardContent, message);
|
|
11474
11474
|
} else if (eventType === "question:request") {
|
|
11475
11475
|
const question = interaction?.question;
|