@zixt/host 0.0.14 → 0.0.15
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/index.js +66 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ import { homedir } from "node:os";
|
|
|
31
31
|
// package.json
|
|
32
32
|
var package_default = {
|
|
33
33
|
name: "@zixt/host",
|
|
34
|
-
version: "0.0.
|
|
34
|
+
version: "0.0.15",
|
|
35
35
|
type: "module",
|
|
36
36
|
exports: {
|
|
37
37
|
".": "./src/client.ts",
|
|
@@ -14872,6 +14872,16 @@ var MemberApprovalRequestContext = ApprovalRequestContext.extend({
|
|
|
14872
14872
|
}),
|
|
14873
14873
|
acting: ApprovalRequestContext.shape.acting.extend({ providerPrincipal: external_exports.null() })
|
|
14874
14874
|
});
|
|
14875
|
+
var QuestionChoice = external_exports.object({
|
|
14876
|
+
label: external_exports.string().trim().min(1).max(120),
|
|
14877
|
+
description: external_exports.string().trim().min(1).max(500).optional()
|
|
14878
|
+
}).strict();
|
|
14879
|
+
var QuestionChoices = external_exports.array(QuestionChoice).min(2).max(5).superRefine((choices, ctx) => {
|
|
14880
|
+
const labels = choices.map(({ label }) => label.toLocaleLowerCase());
|
|
14881
|
+
if (new Set(labels).size !== labels.length) {
|
|
14882
|
+
ctx.addIssue({ code: "custom", message: "question choice labels must be unique" });
|
|
14883
|
+
}
|
|
14884
|
+
});
|
|
14875
14885
|
var Approval = external_exports.object({
|
|
14876
14886
|
id: ApprovalId,
|
|
14877
14887
|
orgId: OrgId,
|
|
@@ -14882,6 +14892,8 @@ var Approval = external_exports.object({
|
|
|
14882
14892
|
summary: external_exports.string().min(1).max(500),
|
|
14883
14893
|
/** The concrete action payload, rendered verbatim for review (GR-3). */
|
|
14884
14894
|
payload: external_exports.string().max(5e4),
|
|
14895
|
+
/** Present only when ask_user supplied a bounded multiple-choice question. */
|
|
14896
|
+
questionChoices: QuestionChoices.optional(),
|
|
14885
14897
|
status: ApprovalStatus,
|
|
14886
14898
|
deliveryStatus: ApprovalDeliveryStatus,
|
|
14887
14899
|
/** Why delivery became impossible; null while pending or after delivery. */
|
|
@@ -18455,7 +18467,9 @@ var ApprovalRequest = external_exports.object({
|
|
|
18455
18467
|
category: external_exports.string(),
|
|
18456
18468
|
summary: external_exports.string().min(1).max(500),
|
|
18457
18469
|
/** Concrete action payload rendered verbatim on the approval card (GR-3). */
|
|
18458
|
-
payload: external_exports.string().max(5e4)
|
|
18470
|
+
payload: external_exports.string().max(5e4),
|
|
18471
|
+
/** Optional structured answers for agent.question; absent means free text. */
|
|
18472
|
+
questionChoices: QuestionChoices.optional()
|
|
18459
18473
|
});
|
|
18460
18474
|
var JournalAppend = external_exports.object({
|
|
18461
18475
|
type: external_exports.literal("journal.append"),
|
|
@@ -20565,7 +20579,7 @@ var HostClient = class _HostClient {
|
|
|
20565
20579
|
const { provider: _provider, ...legacyGrant } = grant;
|
|
20566
20580
|
return legacyGrant;
|
|
20567
20581
|
};
|
|
20568
|
-
const requestApproval = (category, summary, payload) => {
|
|
20582
|
+
const requestApproval = (category, summary, payload, questionChoices) => {
|
|
20569
20583
|
if (authorityController.signal.aborted) {
|
|
20570
20584
|
return Promise.resolve({ approved: false, guidance: "task was cancelled" });
|
|
20571
20585
|
}
|
|
@@ -20577,7 +20591,8 @@ var HostClient = class _HostClient {
|
|
|
20577
20591
|
requestId,
|
|
20578
20592
|
category: safe(category, 200),
|
|
20579
20593
|
summary: safe(summary, 500),
|
|
20580
|
-
payload: safe(payload, 5e4)
|
|
20594
|
+
payload: safe(payload, 5e4),
|
|
20595
|
+
...questionChoices ? { questionChoices: [...questionChoices] } : {}
|
|
20581
20596
|
});
|
|
20582
20597
|
return new Promise((resolve13) => {
|
|
20583
20598
|
const waiters = this.approvalWaiters.get(cancelKey) ?? /* @__PURE__ */ new Map();
|
|
@@ -30709,7 +30724,7 @@ var CADENCE_PROPS = {
|
|
|
30709
30724
|
var TOOLS = [
|
|
30710
30725
|
{
|
|
30711
30726
|
name: "ask_user",
|
|
30712
|
-
description: "Ask the human supervising this task a question and wait for their answer. Use it whenever you need a decision, missing context, or plan approval before proceeding. The answer arrives as text.",
|
|
30727
|
+
description: "Ask the human supervising this task a question and wait for their answer. Use it whenever you need a decision, missing context, or plan approval before proceeding. When there are 2-5 concrete alternatives, provide them as choices; the person can still enter another answer. The answer arrives as text.",
|
|
30713
30728
|
inputSchema: {
|
|
30714
30729
|
type: "object",
|
|
30715
30730
|
properties: {
|
|
@@ -30717,9 +30732,35 @@ var TOOLS = [
|
|
|
30717
30732
|
context: {
|
|
30718
30733
|
type: "string",
|
|
30719
30734
|
description: "Optional supporting detail shown alongside the question."
|
|
30735
|
+
},
|
|
30736
|
+
choices: {
|
|
30737
|
+
type: "array",
|
|
30738
|
+
minItems: 2,
|
|
30739
|
+
maxItems: 5,
|
|
30740
|
+
description: "Optional concrete answers. Omit when the person should type freely.",
|
|
30741
|
+
items: {
|
|
30742
|
+
type: "object",
|
|
30743
|
+
properties: {
|
|
30744
|
+
label: {
|
|
30745
|
+
type: "string",
|
|
30746
|
+
minLength: 1,
|
|
30747
|
+
maxLength: 120,
|
|
30748
|
+
description: "Short answer label."
|
|
30749
|
+
},
|
|
30750
|
+
description: {
|
|
30751
|
+
type: "string",
|
|
30752
|
+
minLength: 1,
|
|
30753
|
+
maxLength: 500,
|
|
30754
|
+
description: "Optional consequence or detail that helps the person choose."
|
|
30755
|
+
}
|
|
30756
|
+
},
|
|
30757
|
+
required: ["label"],
|
|
30758
|
+
additionalProperties: false
|
|
30759
|
+
}
|
|
30720
30760
|
}
|
|
30721
30761
|
},
|
|
30722
|
-
required: ["question"]
|
|
30762
|
+
required: ["question"],
|
|
30763
|
+
additionalProperties: false
|
|
30723
30764
|
}
|
|
30724
30765
|
},
|
|
30725
30766
|
{
|
|
@@ -31242,7 +31283,22 @@ function createAskUserServer() {
|
|
|
31242
31283
|
}
|
|
31243
31284
|
try {
|
|
31244
31285
|
const context = typeof args["context"] === "string" ? args["context"] : "";
|
|
31245
|
-
|
|
31286
|
+
const rawChoices = args["choices"];
|
|
31287
|
+
const parsedChoices = rawChoices === void 0 ? void 0 : QuestionChoices.safeParse(rawChoices);
|
|
31288
|
+
if (parsedChoices && !parsedChoices.success) {
|
|
31289
|
+
toolText(
|
|
31290
|
+
"Choices must contain 2-5 unique, non-empty labels with optional descriptions.",
|
|
31291
|
+
true
|
|
31292
|
+
);
|
|
31293
|
+
return;
|
|
31294
|
+
}
|
|
31295
|
+
toolText(
|
|
31296
|
+
await handlers.askUser(
|
|
31297
|
+
question,
|
|
31298
|
+
context,
|
|
31299
|
+
parsedChoices?.success ? parsedChoices.data : void 0
|
|
31300
|
+
)
|
|
31301
|
+
);
|
|
31246
31302
|
} catch (err) {
|
|
31247
31303
|
toolText(`The question could not be delivered: ${String(err)}`, true);
|
|
31248
31304
|
}
|
|
@@ -33428,13 +33484,14 @@ function createCliRunner(adapter, opts = {}) {
|
|
|
33428
33484
|
throw new Error("prepared provider workspace does not match the task assignment");
|
|
33429
33485
|
}
|
|
33430
33486
|
askUserServer.register(runToken, {
|
|
33431
|
-
askUser: async (question, context) => {
|
|
33487
|
+
askUser: async (question, context, choices) => {
|
|
33432
33488
|
pendingAsks++;
|
|
33433
33489
|
try {
|
|
33434
33490
|
const decision = await task.requestApproval(
|
|
33435
33491
|
"agent.question",
|
|
33436
33492
|
question.slice(0, 500),
|
|
33437
|
-
(context || question).slice(0, MAX_APPROVAL_PAYLOAD)
|
|
33493
|
+
(context || question).slice(0, MAX_APPROVAL_PAYLOAD),
|
|
33494
|
+
choices
|
|
33438
33495
|
);
|
|
33439
33496
|
return decision.guidance ?? (decision.approved ? "Approved. Proceed." : "No. Do not proceed.");
|
|
33440
33497
|
} finally {
|