@owlmeans/viable-sdk 0.1.18-rc.1
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/README.md +128 -0
- package/build/api/index.d.ts +2 -0
- package/build/api/index.d.ts.map +1 -0
- package/build/api/index.js +2 -0
- package/build/api/index.js.map +1 -0
- package/build/api/remote.d.ts +14 -0
- package/build/api/remote.d.ts.map +1 -0
- package/build/api/remote.js +123 -0
- package/build/api/remote.js.map +1 -0
- package/build/consts.d.ts +47 -0
- package/build/consts.d.ts.map +1 -0
- package/build/consts.js +47 -0
- package/build/consts.js.map +1 -0
- package/build/context/index.d.ts +22 -0
- package/build/context/index.d.ts.map +1 -0
- package/build/context/index.js +92 -0
- package/build/context/index.js.map +1 -0
- package/build/errors.d.ts +21 -0
- package/build/errors.d.ts.map +1 -0
- package/build/errors.js +36 -0
- package/build/errors.js.map +1 -0
- package/build/executor/boot-check.d.ts +73 -0
- package/build/executor/boot-check.d.ts.map +1 -0
- package/build/executor/boot-check.js +155 -0
- package/build/executor/boot-check.js.map +1 -0
- package/build/executor/env.d.ts +25 -0
- package/build/executor/env.d.ts.map +1 -0
- package/build/executor/env.js +77 -0
- package/build/executor/env.js.map +1 -0
- package/build/executor/errors.d.ts +69 -0
- package/build/executor/errors.d.ts.map +1 -0
- package/build/executor/errors.js +80 -0
- package/build/executor/errors.js.map +1 -0
- package/build/executor/files.d.ts +124 -0
- package/build/executor/files.d.ts.map +1 -0
- package/build/executor/files.js +529 -0
- package/build/executor/files.js.map +1 -0
- package/build/executor/git.d.ts +52 -0
- package/build/executor/git.d.ts.map +1 -0
- package/build/executor/git.js +353 -0
- package/build/executor/git.js.map +1 -0
- package/build/executor/health.d.ts +92 -0
- package/build/executor/health.d.ts.map +1 -0
- package/build/executor/health.js +98 -0
- package/build/executor/health.js.map +1 -0
- package/build/executor/index.d.ts +39 -0
- package/build/executor/index.d.ts.map +1 -0
- package/build/executor/index.js +173 -0
- package/build/executor/index.js.map +1 -0
- package/build/executor/integrity.d.ts +17 -0
- package/build/executor/integrity.d.ts.map +1 -0
- package/build/executor/integrity.js +59 -0
- package/build/executor/integrity.js.map +1 -0
- package/build/executor/layout.d.ts +61 -0
- package/build/executor/layout.d.ts.map +1 -0
- package/build/executor/layout.js +98 -0
- package/build/executor/layout.js.map +1 -0
- package/build/executor/shell.d.ts +89 -0
- package/build/executor/shell.d.ts.map +1 -0
- package/build/executor/shell.js +280 -0
- package/build/executor/shell.js.map +1 -0
- package/build/executor/spawn.d.ts +111 -0
- package/build/executor/spawn.d.ts.map +1 -0
- package/build/executor/spawn.js +314 -0
- package/build/executor/spawn.js.map +1 -0
- package/build/harness/index.d.ts +28 -0
- package/build/harness/index.d.ts.map +1 -0
- package/build/harness/index.js +83 -0
- package/build/harness/index.js.map +1 -0
- package/build/harness/templates.d.ts +30 -0
- package/build/harness/templates.d.ts.map +1 -0
- package/build/harness/templates.js +162 -0
- package/build/harness/templates.js.map +1 -0
- package/build/index.d.ts +13 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +12 -0
- package/build/index.js.map +1 -0
- package/build/project/env.d.ts +108 -0
- package/build/project/env.d.ts.map +1 -0
- package/build/project/env.js +233 -0
- package/build/project/env.js.map +1 -0
- package/build/project/marker.d.ts +34 -0
- package/build/project/marker.d.ts.map +1 -0
- package/build/project/marker.js +54 -0
- package/build/project/marker.js.map +1 -0
- package/build/project/setup.d.ts +62 -0
- package/build/project/setup.d.ts.map +1 -0
- package/build/project/setup.js +190 -0
- package/build/project/setup.js.map +1 -0
- package/build/run/index.d.ts +75 -0
- package/build/run/index.d.ts.map +1 -0
- package/build/run/index.js +150 -0
- package/build/run/index.js.map +1 -0
- package/build/run/serve.d.ts +18 -0
- package/build/run/serve.d.ts.map +1 -0
- package/build/run/serve.js +148 -0
- package/build/run/serve.js.map +1 -0
- package/build/run/state.d.ts +75 -0
- package/build/run/state.d.ts.map +1 -0
- package/build/run/state.js +136 -0
- package/build/run/state.js.map +1 -0
- package/build/session/index.d.ts +17 -0
- package/build/session/index.d.ts.map +1 -0
- package/build/session/index.js +226 -0
- package/build/session/index.js.map +1 -0
- package/build/session/questions.d.ts +16 -0
- package/build/session/questions.d.ts.map +1 -0
- package/build/session/questions.js +17 -0
- package/build/session/questions.js.map +1 -0
- package/build/session/queue.d.ts +54 -0
- package/build/session/queue.d.ts.map +1 -0
- package/build/session/queue.js +102 -0
- package/build/session/queue.js.map +1 -0
- package/build/session/tasks.d.ts +15 -0
- package/build/session/tasks.d.ts.map +1 -0
- package/build/session/tasks.js +16 -0
- package/build/session/tasks.js.map +1 -0
- package/build/task/driver.d.ts +30 -0
- package/build/task/driver.d.ts.map +1 -0
- package/build/task/driver.js +120 -0
- package/build/task/driver.js.map +1 -0
- package/build/task/envelope.d.ts +35 -0
- package/build/task/envelope.d.ts.map +1 -0
- package/build/task/envelope.js +230 -0
- package/build/task/envelope.js.map +1 -0
- package/build/task/index.d.ts +4 -0
- package/build/task/index.d.ts.map +1 -0
- package/build/task/index.js +4 -0
- package/build/task/index.js.map +1 -0
- package/build/task/inquiry.d.ts +53 -0
- package/build/task/inquiry.d.ts.map +1 -0
- package/build/task/inquiry.js +232 -0
- package/build/task/inquiry.js.map +1 -0
- package/build/tools/catalogue.d.ts +17 -0
- package/build/tools/catalogue.d.ts.map +1 -0
- package/build/tools/catalogue.js +1169 -0
- package/build/tools/catalogue.js.map +1 -0
- package/build/tools/index.d.ts +7 -0
- package/build/tools/index.d.ts.map +1 -0
- package/build/tools/index.js +7 -0
- package/build/tools/index.js.map +1 -0
- package/build/tools/jobs.d.ts +12 -0
- package/build/tools/jobs.d.ts.map +1 -0
- package/build/tools/jobs.js +60 -0
- package/build/tools/jobs.js.map +1 -0
- package/build/tools/mcp.d.ts +43 -0
- package/build/tools/mcp.d.ts.map +1 -0
- package/build/tools/mcp.js +131 -0
- package/build/tools/mcp.js.map +1 -0
- package/build/tools/platform.d.ts +77 -0
- package/build/tools/platform.d.ts.map +1 -0
- package/build/tools/platform.js +316 -0
- package/build/tools/platform.js.map +1 -0
- package/build/tools/refusal.d.ts +66 -0
- package/build/tools/refusal.d.ts.map +1 -0
- package/build/tools/refusal.js +377 -0
- package/build/tools/refusal.js.map +1 -0
- package/build/tools/types.d.ts +83 -0
- package/build/tools/types.d.ts.map +1 -0
- package/build/tools/types.js +38 -0
- package/build/tools/types.js.map +1 -0
- package/build/types.d.ts +174 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +2 -0
- package/build/types.js.map +1 -0
- package/package.json +105 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ConnectHarness, InquiryAnswerPayload, InquiryPayload } from '@owlmeans/viable-common';
|
|
2
|
+
/**
|
|
3
|
+
* The two values a confirmed and a refused question answer with.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors `CONFIRM_YES` / `CONFIRM_NO` in `@owlmeans/llm-common` — the package that reads the
|
|
6
|
+
* answer — value for value, and is deliberately a copy rather than an import: this package is
|
|
7
|
+
* installed by developers to drive their own machine and must not carry the model runtime, which
|
|
8
|
+
* is the same reason {@link ConnectInquiryKind} mirrors `InquiryKind`. The two must stay equal, or
|
|
9
|
+
* a person's "yes" reaches the asker as a value it has never heard of.
|
|
10
|
+
*/
|
|
11
|
+
export declare const CONFIRM_YES = "yes";
|
|
12
|
+
export declare const CONFIRM_NO = "no";
|
|
13
|
+
export interface QuestionEnvelopeOptions {
|
|
14
|
+
/** Which parent agent is reading this. Recorded rather than branched on — see below. */
|
|
15
|
+
harness: ConnectHarness;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* What `next_question` hands the parent agent.
|
|
19
|
+
*
|
|
20
|
+
* Text, and in the same order a model task's envelope uses: how to handle it, what to call
|
|
21
|
+
* afterwards, then the material — so a model that stops reading early has still read the
|
|
22
|
+
* instruction. The question id appears at the top and in the follow-up call because it is the only
|
|
23
|
+
* thing that routes an answer back.
|
|
24
|
+
*
|
|
25
|
+
* The one thing this envelope says that the task envelope inverts: **do not isolate it**. A model
|
|
26
|
+
* task is handed to a clean subagent precisely so no context leaks into it; a question is handed to
|
|
27
|
+
* a PERSON, and a subagent has none. So there is no harness-specific isolation wording here at
|
|
28
|
+
* all — the harness is carried only because the caller has it and a future difference would belong
|
|
29
|
+
* beside the rest.
|
|
30
|
+
*
|
|
31
|
+
* The declined line is present on every question, whatever its kind. A parent whose user is not
|
|
32
|
+
* available has to have a way to say so: without one it either waits out a 45-minute timeout or
|
|
33
|
+
* invents an answer, and the second is worse.
|
|
34
|
+
*/
|
|
35
|
+
export declare const renderQuestionEnvelope: (inquiry: InquiryPayload, _opts: QuestionEnvelopeOptions) => string;
|
|
36
|
+
export interface ParsedAnswer {
|
|
37
|
+
answer?: InquiryAnswerPayload;
|
|
38
|
+
/** Present when what came back is not something this question can accept. Quoted back verbatim. */
|
|
39
|
+
problem?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Check what the parent sent against the question that asked for it, before the platform sees it.
|
|
43
|
+
*
|
|
44
|
+
* The same rule the model-task parser follows, for the same reason: a refusal caught here is a
|
|
45
|
+
* sentence the parent can act on immediately, with the person still in front of it, while one the
|
|
46
|
+
* platform catches costs a round trip on a question a human already answered. So a mismatch comes
|
|
47
|
+
* back as a `problem` rather than a throw, and every problem names what WOULD be accepted.
|
|
48
|
+
*
|
|
49
|
+
* `declined` short-circuits everything. It is a real answer — somebody saw the question and chose
|
|
50
|
+
* not to decide — and reading anything else beside it would let a parent both decline and answer.
|
|
51
|
+
*/
|
|
52
|
+
export declare const parseAnswer: (inquiry: InquiryPayload, raw: Record<string, unknown>) => ParsedAnswer;
|
|
53
|
+
//# sourceMappingURL=inquiry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inquiry.d.ts","sourceRoot":"","sources":["../../src/task/inquiry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAEnG;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,QAAQ,CAAA;AAChC,eAAO,MAAM,UAAU,OAAO,CAAA;AAiE9B,MAAM,WAAW,uBAAuB;IACtC,wFAAwF;IACxF,OAAO,EAAE,cAAc,CAAA;CACxB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,sBAAsB,YACxB,cAAc,SAAS,uBAAuB,KACtD,MAiDF,CAAA;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,oBAAoB,CAAA;IAC7B,mGAAmG;IACnG,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAeD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,YACb,cAAc,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KACpD,YAiFF,CAAA"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { ConnectInquiryKind, CONNECT_INQUIRY_MAX_TEXT } from '@owlmeans/viable-common';
|
|
2
|
+
/**
|
|
3
|
+
* The two values a confirmed and a refused question answer with.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors `CONFIRM_YES` / `CONFIRM_NO` in `@owlmeans/llm-common` — the package that reads the
|
|
6
|
+
* answer — value for value, and is deliberately a copy rather than an import: this package is
|
|
7
|
+
* installed by developers to drive their own machine and must not carry the model runtime, which
|
|
8
|
+
* is the same reason {@link ConnectInquiryKind} mirrors `InquiryKind`. The two must stay equal, or
|
|
9
|
+
* a person's "yes" reaches the asker as a value it has never heard of.
|
|
10
|
+
*/
|
|
11
|
+
export const CONFIRM_YES = 'yes';
|
|
12
|
+
export const CONFIRM_NO = 'no';
|
|
13
|
+
/** What a parent may send for a confirm question, beyond the two values themselves. */
|
|
14
|
+
const CONFIRM_WORDS = {
|
|
15
|
+
yes: CONFIRM_YES,
|
|
16
|
+
y: CONFIRM_YES,
|
|
17
|
+
true: CONFIRM_YES,
|
|
18
|
+
ok: CONFIRM_YES,
|
|
19
|
+
no: CONFIRM_NO,
|
|
20
|
+
n: CONFIRM_NO,
|
|
21
|
+
false: CONFIRM_NO,
|
|
22
|
+
};
|
|
23
|
+
/** Whether this question actually carries values a parent can pick from. */
|
|
24
|
+
const hasOptions = (inquiry) => inquiry.options != null && inquiry.options.length > 0;
|
|
25
|
+
/**
|
|
26
|
+
* The call lines a question of THIS kind is answered with.
|
|
27
|
+
*
|
|
28
|
+
* Every line printed here has to be a call the parent can actually make. The value placeholder
|
|
29
|
+
* used to be one line for every kind — `"<one of the values below>"` — and a `Confirm` carries no
|
|
30
|
+
* options, so it pointed at nothing: the parent had to already know the two words, which is the
|
|
31
|
+
* one thing an envelope exists to make unnecessary. A confirm therefore prints its two values in
|
|
32
|
+
* the call itself, and a `Text` question — which has no values either — leads with the field it is
|
|
33
|
+
* actually answered in.
|
|
34
|
+
*
|
|
35
|
+
* A `Choice` that arrived with NO options is the same defect in the remaining kind, and it is a
|
|
36
|
+
* shape that reaches here: `InquiryPayload.options` is optional and only the free-flight
|
|
37
|
+
* `ask_user` tool enforces the "between 2 and max" rule, so nothing on the wire does. It is
|
|
38
|
+
* therefore read as a text question in both directions — the call prints `text`, and
|
|
39
|
+
* {@link parseAnswer} takes text back — rather than pointing "below" at an OPTIONS section the
|
|
40
|
+
* envelope will not print.
|
|
41
|
+
*
|
|
42
|
+
* The two confirm words are the same pair {@link parseAnswer} reads back, and it reads them in any
|
|
43
|
+
* case a parent sends, so a printed value is always an accepted one.
|
|
44
|
+
*/
|
|
45
|
+
const answerCalls = (inquiry) => {
|
|
46
|
+
const call = (body) => `answer_question { "questionId": "${inquiry.id}", ${body} }`;
|
|
47
|
+
const lines = [];
|
|
48
|
+
if (inquiry.kind === ConnectInquiryKind.Confirm) {
|
|
49
|
+
lines.push(` ${call(`"answer": "${CONFIRM_YES}"`)} (they agreed)`, ` or ${call(`"answer": "${CONFIRM_NO}"`)} (they did not)`);
|
|
50
|
+
}
|
|
51
|
+
else if (inquiry.kind === ConnectInquiryKind.Text || !hasOptions(inquiry)) {
|
|
52
|
+
lines.push(` ${call('"text": "<what they said>"')} (their own words)`);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
lines.push(` ${call('"answer": "<one of the values below>"')}`);
|
|
56
|
+
if (inquiry.multiple === true) {
|
|
57
|
+
lines.push(` or ${call('"answer": ["<value>", "<value>"]')} (several)`);
|
|
58
|
+
}
|
|
59
|
+
if (inquiry.allowText === true) {
|
|
60
|
+
lines.push(` or ${call('"text": "<what they said>"')} (their own words)`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Present on every question whatever its kind: a parent whose user is not available has to have
|
|
64
|
+
// a way to say so, or it waits out the timeout or invents an answer.
|
|
65
|
+
lines.push(` or ${call('"declined": true')} (nobody can decide)`);
|
|
66
|
+
return lines;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* What `next_question` hands the parent agent.
|
|
70
|
+
*
|
|
71
|
+
* Text, and in the same order a model task's envelope uses: how to handle it, what to call
|
|
72
|
+
* afterwards, then the material — so a model that stops reading early has still read the
|
|
73
|
+
* instruction. The question id appears at the top and in the follow-up call because it is the only
|
|
74
|
+
* thing that routes an answer back.
|
|
75
|
+
*
|
|
76
|
+
* The one thing this envelope says that the task envelope inverts: **do not isolate it**. A model
|
|
77
|
+
* task is handed to a clean subagent precisely so no context leaks into it; a question is handed to
|
|
78
|
+
* a PERSON, and a subagent has none. So there is no harness-specific isolation wording here at
|
|
79
|
+
* all — the harness is carried only because the caller has it and a future difference would belong
|
|
80
|
+
* beside the rest.
|
|
81
|
+
*
|
|
82
|
+
* The declined line is present on every question, whatever its kind. A parent whose user is not
|
|
83
|
+
* available has to have a way to say so: without one it either waits out a 45-minute timeout or
|
|
84
|
+
* invents an answer, and the second is worse.
|
|
85
|
+
*/
|
|
86
|
+
export const renderQuestionEnvelope = (inquiry, _opts) => {
|
|
87
|
+
const traits = [
|
|
88
|
+
...(inquiry.multiple === true ? ['pick one or more'] : []),
|
|
89
|
+
...(inquiry.allowText === true ? ['their own words are accepted instead of an option'] : []),
|
|
90
|
+
];
|
|
91
|
+
const lines = [
|
|
92
|
+
`=== VIABLE QUESTION ${inquiry.id} ===`,
|
|
93
|
+
`kind: ${inquiry.kind}${traits.length > 0 ? ` · ${traits.join(' · ')}` : ''}`,
|
|
94
|
+
...(inquiry.expiresAt != null ? [`expires: ${inquiry.expiresAt}`] : []),
|
|
95
|
+
'',
|
|
96
|
+
'HOW TO ANSWER THIS (do not answer it yourself):',
|
|
97
|
+
'Put this question to the person you are working for, in your own words. It is a decision about',
|
|
98
|
+
'THEIR project, and a guess here is a whole application built on the wrong assumption. If they',
|
|
99
|
+
'are not available, say so — do not invent an answer.',
|
|
100
|
+
'',
|
|
101
|
+
'WHAT TO SEND BACK — call exactly:',
|
|
102
|
+
...answerCalls(inquiry),
|
|
103
|
+
'',
|
|
104
|
+
'--- THE QUESTION ---',
|
|
105
|
+
inquiry.question,
|
|
106
|
+
];
|
|
107
|
+
if (inquiry.context != null && inquiry.context !== '') {
|
|
108
|
+
lines.push('--- BACKGROUND ---', inquiry.context);
|
|
109
|
+
}
|
|
110
|
+
if (inquiry.options != null && inquiry.options.length > 0) {
|
|
111
|
+
lines.push('--- OPTIONS ---');
|
|
112
|
+
for (const option of inquiry.options) {
|
|
113
|
+
lines.push(` ${option.value} — ${option.label}`);
|
|
114
|
+
if (option.description != null && option.description !== '') {
|
|
115
|
+
lines.push(` ${option.description}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (inquiry.default != null) {
|
|
120
|
+
lines.push('--- IF NOBODY ANSWERS ---', `The platform will assume: ${Array.isArray(inquiry.default) ? inquiry.default.join(', ') : inquiry.default}`);
|
|
121
|
+
}
|
|
122
|
+
lines.push(`=== END QUESTION ${inquiry.id} ===`);
|
|
123
|
+
return lines.join('\n');
|
|
124
|
+
};
|
|
125
|
+
/** The offered values, listed so a refusal is actionable without re-reading the envelope. */
|
|
126
|
+
const offered = (inquiry) => (inquiry.options ?? []).map(option => option.value).join(', ');
|
|
127
|
+
const asStrings = (value) => {
|
|
128
|
+
if (typeof value === 'string')
|
|
129
|
+
return [value];
|
|
130
|
+
if (Array.isArray(value) && value.every(entry => typeof entry === 'string')) {
|
|
131
|
+
return value;
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Check what the parent sent against the question that asked for it, before the platform sees it.
|
|
137
|
+
*
|
|
138
|
+
* The same rule the model-task parser follows, for the same reason: a refusal caught here is a
|
|
139
|
+
* sentence the parent can act on immediately, with the person still in front of it, while one the
|
|
140
|
+
* platform catches costs a round trip on a question a human already answered. So a mismatch comes
|
|
141
|
+
* back as a `problem` rather than a throw, and every problem names what WOULD be accepted.
|
|
142
|
+
*
|
|
143
|
+
* `declined` short-circuits everything. It is a real answer — somebody saw the question and chose
|
|
144
|
+
* not to decide — and reading anything else beside it would let a parent both decline and answer.
|
|
145
|
+
*/
|
|
146
|
+
export const parseAnswer = (inquiry, raw) => {
|
|
147
|
+
if (raw.declined === true) {
|
|
148
|
+
return { answer: { inquiryId: inquiry.id, declined: true } };
|
|
149
|
+
}
|
|
150
|
+
const text = typeof raw.text === 'string' ? raw.text.trim() : '';
|
|
151
|
+
const values = asStrings(raw.answer);
|
|
152
|
+
const hasAnswer = raw.answer != null;
|
|
153
|
+
if (!hasAnswer && text === '') {
|
|
154
|
+
return { problem: 'Send an answer, a text, or declined: true.' };
|
|
155
|
+
}
|
|
156
|
+
if (inquiry.kind === ConnectInquiryKind.Confirm) {
|
|
157
|
+
// A boolean is accepted as readily as a word: the tool's own schema offers `answer` as a
|
|
158
|
+
// string, and a model that sent `true` anyway has said exactly what was asked for.
|
|
159
|
+
const said = typeof raw.answer === 'boolean'
|
|
160
|
+
? String(raw.answer)
|
|
161
|
+
: values?.[0] ?? text;
|
|
162
|
+
const confirmed = CONFIRM_WORDS[said.trim().toLowerCase()];
|
|
163
|
+
if (confirmed == null) {
|
|
164
|
+
return { problem: `Answer this one with "${CONFIRM_YES}" or "${CONFIRM_NO}".` };
|
|
165
|
+
}
|
|
166
|
+
return { answer: { inquiryId: inquiry.id, value: confirmed } };
|
|
167
|
+
}
|
|
168
|
+
if (inquiry.kind === ConnectInquiryKind.Choice) {
|
|
169
|
+
const known = new Set((inquiry.options ?? []).map(option => option.value));
|
|
170
|
+
if (known.size < 1) {
|
|
171
|
+
// A choice question that arrived carrying no choices. Nothing on the wire refuses one —
|
|
172
|
+
// `options` is optional and only the free-flight `ask_user` tool enforces the 2..max rule —
|
|
173
|
+
// and the value check below used to skip an empty set, so ANY string was recorded as a
|
|
174
|
+
// chosen value the asker can match against nothing, while the refusal that did fire read
|
|
175
|
+
// "one of the choices ()". The envelope prints `text` as the call for this shape, so text
|
|
176
|
+
// is what is taken back; a value is refused by naming the field that works.
|
|
177
|
+
return text !== ''
|
|
178
|
+
? capText(inquiry, { inquiryId: inquiry.id, text })
|
|
179
|
+
: {
|
|
180
|
+
problem: 'This question offers no choices — send `text` with what they said,'
|
|
181
|
+
+ ' or declined: true.',
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
if (values == null || values.length < 1) {
|
|
185
|
+
// Text alone is an answer only where the question said so. Elsewhere it is a value the
|
|
186
|
+
// asker cannot match against anything it offered, and accepting it silently loses the
|
|
187
|
+
// decision the person actually made.
|
|
188
|
+
if (inquiry.allowText === true && text !== '') {
|
|
189
|
+
return capText(inquiry, { inquiryId: inquiry.id, text });
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
problem: `Answer with one of the choices (${offered(inquiry)})`
|
|
193
|
+
+ `${inquiry.allowText === true ? ', or send `text` with what they said' : ''}.`,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
if (values.length > 1 && inquiry.multiple !== true) {
|
|
197
|
+
return { problem: `This question takes ONE answer (${offered(inquiry)}).` };
|
|
198
|
+
}
|
|
199
|
+
for (const value of values) {
|
|
200
|
+
if (!known.has(value)) {
|
|
201
|
+
return { problem: `"${value}" is not one of the choices (${offered(inquiry)}).` };
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// Through the same ceiling as every other text: a chosen value may carry the person's own
|
|
205
|
+
// words beside it, and that rider is the one path a length the wire schema refuses could
|
|
206
|
+
// otherwise take — refused there, it costs a round trip on a question already answered.
|
|
207
|
+
return capText(inquiry, {
|
|
208
|
+
inquiryId: inquiry.id,
|
|
209
|
+
value: inquiry.multiple === true ? values : values[0],
|
|
210
|
+
...(text !== '' ? { text } : {}),
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
const said = text !== '' ? text : (values?.join('\n') ?? '').trim();
|
|
214
|
+
if (said === '') {
|
|
215
|
+
return { problem: 'Send what they said as `text`.' };
|
|
216
|
+
}
|
|
217
|
+
return capText(inquiry, { inquiryId: inquiry.id, text: said });
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* The ONE ceiling, refused rather than silently applied.
|
|
221
|
+
*
|
|
222
|
+
* Cutting the text here would hand the asker most of a decision and say nothing; the person is
|
|
223
|
+
* still in front of the parent, so the honest answer is to ask them to be shorter and to say where
|
|
224
|
+
* a longer answer belongs.
|
|
225
|
+
*/
|
|
226
|
+
const capText = (inquiry, answer) => (answer.text?.length ?? 0) > CONNECT_INQUIRY_MAX_TEXT
|
|
227
|
+
? {
|
|
228
|
+
problem: `Too long — send at most ${CONNECT_INQUIRY_MAX_TEXT} characters; put anything`
|
|
229
|
+
+ ' longer in the project instead.',
|
|
230
|
+
}
|
|
231
|
+
: { answer: { ...answer, inquiryId: inquiry.id } };
|
|
232
|
+
//# sourceMappingURL=inquiry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inquiry.js","sourceRoot":"","sources":["../../src/task/inquiry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AAGtF;;;;;;;;GAQG;AACH,MAAM,CA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E,CAAC,CAAC,CAAC,EAAE,CAAC;SACjC,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IACnE,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QAChB,OAAO,EAAE,OAAO,EAAE,gCAAgC,EAAE,CAAA;IACtD,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;AAChE,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,OAAO,GAAG,CAAC,OAAuB,EAAE,MAA4B,EAAgB,EAAE,CACtF,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,wBAAwB;IACnD,CAAC,CAAC;QACA,OAAO,EAAE,2BAA2B,wBAAwB,2BAA2B;cACnF,iCAAiC;KACtC;IACD,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ToolDefinition, ToolHost } from './types.js';
|
|
2
|
+
import { ToolHostKind } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Everything a parent agent can ask the platform to do.
|
|
5
|
+
*
|
|
6
|
+
* Two rules shape the whole list. Every tool answers inside the strictest host's per-tool ceiling,
|
|
7
|
+
* so anything that takes minutes returns a JOB at once and is polled — a coding agent that blocks
|
|
8
|
+
* for twenty minutes is reported to its user as a hung server. And every tool that cannot work in
|
|
9
|
+
* a given mode is HIDDEN rather than failing, so the catalogue a parent reads is exactly the set
|
|
10
|
+
* of things that work for it.
|
|
11
|
+
*/
|
|
12
|
+
export declare const catalogue: ToolDefinition[];
|
|
13
|
+
/** The tools a given host actually offers. */
|
|
14
|
+
export declare const visibleTools: (host: ToolHost) => ToolDefinition[];
|
|
15
|
+
export declare const toolByName: (name: string) => ToolDefinition | undefined;
|
|
16
|
+
export { ToolHostKind };
|
|
17
|
+
//# sourceMappingURL=catalogue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogue.d.ts","sourceRoot":"","sources":["../../src/tools/catalogue.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAY,cAAc,EAAE,QAAQ,EAAc,MAAM,YAAY,CAAA;AAChF,OAAO,EACkE,YAAY,EACpF,MAAM,YAAY,CAAA;AA2SnB;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,EAAE,cAAc,EAqhCrC,CAAA;AAaD,8CAA8C;AAC9C,eAAO,MAAM,YAAY,SAAU,QAAQ,KAAG,cAAc,EACT,CAAA;AAEnD,eAAO,MAAM,UAAU,SAAU,MAAM,KAAG,cAAc,GAAG,SACf,CAAA;AAE5C,OAAO,EAAE,YAAY,EAAE,CAAA"}
|