@spunto/build 0.32.0 → 0.34.0
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/package.json +1 -1
- package/src/agent-contract/agent-contract.v1.schema.json +180 -0
- package/src/agent-contract/conformance.ts +25 -2
- package/src/agent-contract/examples/fake-agent.mjs +11 -0
- package/src/agent-contract/index.ts +3 -2
- package/src/agent-contract/runner.ts +7 -0
- package/src/agent-contract/vocabulary.ts +42 -4
- package/src/agent-stream/agent-stream.ts +8 -2
- package/src/agent-stream/index.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spunto/build",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "Spunto's shared Build engine — the devcontainer image protocol and VS Code extension registry clients, with no database, no HTTP framework and no UI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -607,6 +607,9 @@
|
|
|
607
607
|
"type": "null"
|
|
608
608
|
}
|
|
609
609
|
]
|
|
610
|
+
},
|
|
611
|
+
"holds": {
|
|
612
|
+
"type": "boolean"
|
|
610
613
|
}
|
|
611
614
|
},
|
|
612
615
|
"additionalProperties": false
|
|
@@ -850,6 +853,131 @@
|
|
|
850
853
|
],
|
|
851
854
|
"additionalProperties": false
|
|
852
855
|
},
|
|
856
|
+
{
|
|
857
|
+
"type": "object",
|
|
858
|
+
"properties": {
|
|
859
|
+
"type": {
|
|
860
|
+
"const": "question"
|
|
861
|
+
},
|
|
862
|
+
"source": {
|
|
863
|
+
"description": "The harness's own message this event was read from, verbatim — kept so the projection can be replayed."
|
|
864
|
+
},
|
|
865
|
+
"callId": {
|
|
866
|
+
"type": "string"
|
|
867
|
+
},
|
|
868
|
+
"status": {
|
|
869
|
+
"type": "string",
|
|
870
|
+
"enum": [
|
|
871
|
+
"pending",
|
|
872
|
+
"answered",
|
|
873
|
+
"dismissed"
|
|
874
|
+
]
|
|
875
|
+
},
|
|
876
|
+
"questions": {
|
|
877
|
+
"type": "array",
|
|
878
|
+
"items": {
|
|
879
|
+
"type": "object",
|
|
880
|
+
"properties": {
|
|
881
|
+
"question": {
|
|
882
|
+
"type": "string"
|
|
883
|
+
},
|
|
884
|
+
"header": {
|
|
885
|
+
"anyOf": [
|
|
886
|
+
{
|
|
887
|
+
"type": "string"
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
"type": "null"
|
|
891
|
+
}
|
|
892
|
+
]
|
|
893
|
+
},
|
|
894
|
+
"multiSelect": {
|
|
895
|
+
"type": "boolean"
|
|
896
|
+
},
|
|
897
|
+
"options": {
|
|
898
|
+
"type": "array",
|
|
899
|
+
"items": {
|
|
900
|
+
"type": "object",
|
|
901
|
+
"properties": {
|
|
902
|
+
"label": {
|
|
903
|
+
"type": "string"
|
|
904
|
+
},
|
|
905
|
+
"description": {
|
|
906
|
+
"anyOf": [
|
|
907
|
+
{
|
|
908
|
+
"type": "string"
|
|
909
|
+
},
|
|
910
|
+
{
|
|
911
|
+
"type": "null"
|
|
912
|
+
}
|
|
913
|
+
]
|
|
914
|
+
},
|
|
915
|
+
"preview": {
|
|
916
|
+
"anyOf": [
|
|
917
|
+
{
|
|
918
|
+
"type": "string"
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
"type": "null"
|
|
922
|
+
}
|
|
923
|
+
]
|
|
924
|
+
}
|
|
925
|
+
},
|
|
926
|
+
"required": [
|
|
927
|
+
"label"
|
|
928
|
+
],
|
|
929
|
+
"additionalProperties": false
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
},
|
|
933
|
+
"required": [
|
|
934
|
+
"question",
|
|
935
|
+
"options"
|
|
936
|
+
],
|
|
937
|
+
"additionalProperties": false
|
|
938
|
+
}
|
|
939
|
+
},
|
|
940
|
+
"answers": {
|
|
941
|
+
"type": "array",
|
|
942
|
+
"items": {
|
|
943
|
+
"type": "object",
|
|
944
|
+
"properties": {
|
|
945
|
+
"question": {
|
|
946
|
+
"type": "string"
|
|
947
|
+
},
|
|
948
|
+
"selected": {
|
|
949
|
+
"type": "array",
|
|
950
|
+
"items": {
|
|
951
|
+
"type": "string"
|
|
952
|
+
}
|
|
953
|
+
},
|
|
954
|
+
"text": {
|
|
955
|
+
"anyOf": [
|
|
956
|
+
{
|
|
957
|
+
"type": "string"
|
|
958
|
+
},
|
|
959
|
+
{
|
|
960
|
+
"type": "null"
|
|
961
|
+
}
|
|
962
|
+
]
|
|
963
|
+
}
|
|
964
|
+
},
|
|
965
|
+
"required": [
|
|
966
|
+
"question",
|
|
967
|
+
"selected"
|
|
968
|
+
],
|
|
969
|
+
"additionalProperties": false
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
},
|
|
973
|
+
"required": [
|
|
974
|
+
"type",
|
|
975
|
+
"callId",
|
|
976
|
+
"status",
|
|
977
|
+
"questions"
|
|
978
|
+
],
|
|
979
|
+
"additionalProperties": false
|
|
980
|
+
},
|
|
853
981
|
{
|
|
854
982
|
"type": "object",
|
|
855
983
|
"properties": {
|
|
@@ -955,6 +1083,58 @@
|
|
|
955
1083
|
"description"
|
|
956
1084
|
],
|
|
957
1085
|
"additionalProperties": false
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
"type": "object",
|
|
1089
|
+
"properties": {
|
|
1090
|
+
"type": {
|
|
1091
|
+
"type": "string",
|
|
1092
|
+
"enum": [
|
|
1093
|
+
"answer"
|
|
1094
|
+
]
|
|
1095
|
+
},
|
|
1096
|
+
"callId": {
|
|
1097
|
+
"type": "string"
|
|
1098
|
+
},
|
|
1099
|
+
"answers": {
|
|
1100
|
+
"type": "array",
|
|
1101
|
+
"items": {
|
|
1102
|
+
"type": "object",
|
|
1103
|
+
"properties": {
|
|
1104
|
+
"question": {
|
|
1105
|
+
"type": "string"
|
|
1106
|
+
},
|
|
1107
|
+
"selected": {
|
|
1108
|
+
"type": "array",
|
|
1109
|
+
"items": {
|
|
1110
|
+
"type": "string"
|
|
1111
|
+
}
|
|
1112
|
+
},
|
|
1113
|
+
"text": {
|
|
1114
|
+
"anyOf": [
|
|
1115
|
+
{
|
|
1116
|
+
"type": "string"
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
"type": "null"
|
|
1120
|
+
}
|
|
1121
|
+
]
|
|
1122
|
+
}
|
|
1123
|
+
},
|
|
1124
|
+
"required": [
|
|
1125
|
+
"question",
|
|
1126
|
+
"selected"
|
|
1127
|
+
],
|
|
1128
|
+
"additionalProperties": false
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
},
|
|
1132
|
+
"required": [
|
|
1133
|
+
"type",
|
|
1134
|
+
"callId",
|
|
1135
|
+
"answers"
|
|
1136
|
+
],
|
|
1137
|
+
"additionalProperties": false
|
|
958
1138
|
}
|
|
959
1139
|
]
|
|
960
1140
|
}
|
|
@@ -35,7 +35,7 @@ export type RunnerProcess = {
|
|
|
35
35
|
/** Start the runner: `run`, plus `--resume <id>` when asked. */
|
|
36
36
|
export type StartRunner = (opts: { resume?: string }) => RunnerProcess
|
|
37
37
|
|
|
38
|
-
export const CONFORMANCE_SCENARIOS = ["simple", "tool", "interrupt", "resume", "limit", "title", "files"] as const
|
|
38
|
+
export const CONFORMANCE_SCENARIOS = ["simple", "tool", "interrupt", "resume", "limit", "title", "files", "question"] as const
|
|
39
39
|
export type ConformanceScenario = (typeof CONFORMANCE_SCENARIOS)[number]
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -45,7 +45,9 @@ export type ConformanceScenario = (typeof CONFORMANCE_SCENARIOS)[number]
|
|
|
45
45
|
* - `tool`: call one tool, get its result, answer, end the turn;
|
|
46
46
|
* - `long`: keep the turn going (a long tool call, say) until interrupted;
|
|
47
47
|
* - `limit`: end the turn on the account's usage limit, with the time it lifts;
|
|
48
|
-
* - `screenshot`: call a tool whose result is a PNG, inline (base64), and end the turn
|
|
48
|
+
* - `screenshot`: call a tool whose result is a PNG, inline (base64), and end the turn;
|
|
49
|
+
* - `question`: ask the human to choose between at least two options, wait for the answer, then
|
|
50
|
+
* say in prose what was picked and end the turn.
|
|
49
51
|
*/
|
|
50
52
|
export const CONFORMANCE_PROMPTS = {
|
|
51
53
|
reply: "spunto-conformance: reply",
|
|
@@ -53,6 +55,7 @@ export const CONFORMANCE_PROMPTS = {
|
|
|
53
55
|
long: "spunto-conformance: long",
|
|
54
56
|
limit: "spunto-conformance: limit",
|
|
55
57
|
screenshot: "spunto-conformance: screenshot",
|
|
58
|
+
question: "spunto-conformance: question",
|
|
56
59
|
} as const
|
|
57
60
|
|
|
58
61
|
export type ConformanceResult = {
|
|
@@ -288,6 +291,26 @@ const SCENARIOS: Record<ConformanceScenario, (launch: Launch, problems: string[]
|
|
|
288
291
|
if (result) expect(problems, !String(result.output).includes(fileData(result) ?? "\u0000"), "the file's bytes are in the result's `output` text")
|
|
289
292
|
await s.close()
|
|
290
293
|
},
|
|
294
|
+
|
|
295
|
+
// A question of the agent's: printed `pending`, answered by the `answer` verb, restated `answered`
|
|
296
|
+
// with what was picked — and the turn waited for it, then carried on.
|
|
297
|
+
async question(launch, problems) {
|
|
298
|
+
const s = launch()
|
|
299
|
+
s.send({ type: "user", text: CONFORMANCE_PROMPTS.question })
|
|
300
|
+
const asked = await s.next("a `question` `pending`", (l) => l.type === "question" && l.status === "pending")
|
|
301
|
+
const first = (asked.questions as Line[] | undefined)?.[0]
|
|
302
|
+
const options = (first?.options as Line[] | undefined) ?? []
|
|
303
|
+
expect(problems, options.length >= 2, "the question offers fewer than two options")
|
|
304
|
+
expect(problems, !s.all().some((l) => l.type === "session.ended"), "the turn ended before the question was answered — it must wait")
|
|
305
|
+
const pick = String(options[0]?.label ?? "")
|
|
306
|
+
s.send({ type: "answer", callId: String(asked.callId), answers: [{ question: String(first?.question ?? ""), selected: [pick] }] })
|
|
307
|
+
const answered = await s.next("the question restated `answered`", (l) => l.type === "question" && l.callId === asked.callId && l.status === "answered")
|
|
308
|
+
const answers = (answered.answers as Line[] | undefined) ?? []
|
|
309
|
+
expect(problems, answers.some((a) => Array.isArray(a.selected) && a.selected.includes(pick)), "the answered question does not carry the option picked")
|
|
310
|
+
const { ended } = await s.turn()
|
|
311
|
+
expect(problems, ended.status === "succeeded", `the turn ended ${String(ended.status)} after the answer (expected succeeded)`)
|
|
312
|
+
await s.close()
|
|
313
|
+
},
|
|
291
314
|
}
|
|
292
315
|
|
|
293
316
|
/** The first base64 file block's data in a line, if any. */
|
|
@@ -13,6 +13,7 @@ const resume = argv[argv.indexOf("--resume") + 1]
|
|
|
13
13
|
const sessionId = argv.includes("--resume") && resume ? resume : `fake-${process.pid}`
|
|
14
14
|
let started = false
|
|
15
15
|
let pending = null // the turn waiting to be interrupted
|
|
16
|
+
let asked = null // the turn waiting on the human's answer
|
|
16
17
|
|
|
17
18
|
function turn(text) {
|
|
18
19
|
if (!started) out({ type: "session.started", harness: "fake", model: null, sessionId }), (started = true)
|
|
@@ -31,6 +32,15 @@ function turn(text) {
|
|
|
31
32
|
const limit = { kind: "usage", status: 429, message: "Usage limit reached", resetsAt }
|
|
32
33
|
return out({ type: "session.ended", status: "failed", summary: limit.message, limit })
|
|
33
34
|
}
|
|
35
|
+
if (text.endsWith("question")) {
|
|
36
|
+
const questions = [{ question: "Which color?", options: [{ label: "Red" }, { label: "Blue" }] }]
|
|
37
|
+
out({ type: "question", callId: "q1", status: "pending", questions })
|
|
38
|
+
return (asked = (answers) => {
|
|
39
|
+
out({ type: "question", callId: "q1", status: "answered", questions, answers })
|
|
40
|
+
out({ type: "message", role: "assistant", text: `You picked ${answers[0]?.selected.join(", ")}` })
|
|
41
|
+
done("ok")
|
|
42
|
+
})
|
|
43
|
+
}
|
|
34
44
|
if (text.endsWith("long")) return (pending = () => out({ type: "session.ended", status: "failed", summary: "Interrupted." }))
|
|
35
45
|
out({ type: "message", role: "assistant", text: `You said: ${text}` })
|
|
36
46
|
done("ok")
|
|
@@ -41,6 +51,7 @@ createInterface({ input: process.stdin })
|
|
|
41
51
|
const msg = JSON.parse(line)
|
|
42
52
|
if (msg.type === "user") turn(msg.text)
|
|
43
53
|
if (msg.type === "interrupt") pending?.(), (pending = null)
|
|
54
|
+
if (msg.type === "answer") asked?.(msg.answers), (asked = null)
|
|
44
55
|
if (msg.type === "title") out({ type: "session.title", title: msg.description.slice(0, 60) })
|
|
45
56
|
})
|
|
46
57
|
.on("close", () => process.exit(0))
|
|
@@ -10,6 +10,7 @@ export {
|
|
|
10
10
|
contractLineProblem,
|
|
11
11
|
isTransient,
|
|
12
12
|
MAX_TEXT,
|
|
13
|
+
QUESTION_STATUSES,
|
|
13
14
|
readContractLine,
|
|
14
15
|
readContractObject,
|
|
15
16
|
SUBAGENT_STATUSES,
|
|
@@ -17,10 +18,10 @@ export {
|
|
|
17
18
|
TRANSIENT_TYPES,
|
|
18
19
|
TURN_LIMIT_KINDS,
|
|
19
20
|
} from "./vocabulary"
|
|
20
|
-
export type { NormalizedEvent, RunnerInput, SourcedEvent, TaskEventType, TransientType, TurnLimit, TurnLimitKind } from "./vocabulary"
|
|
21
|
+
export type { NormalizedEvent, QuestionAnswer, RunnerInput, SourcedEvent, TaskEventType, TransientType, TurnLimit, TurnLimitKind } from "./vocabulary"
|
|
21
22
|
|
|
22
23
|
// The runner's side of it: how the platform starts one, what reaches it, what an app lets a task choose.
|
|
23
|
-
export { AGENT_HOME, AGENT_NODE, MCP_ENV, OPTIONS_ENV, RUNNER_ENV, STREAM_ENV, agentOptionsError, runnerCommand } from "./runner"
|
|
24
|
+
export { AGENT_HOME, AGENT_NODE, MCP_ENV, OPTIONS_ENV, QUESTIONS_ENV, RUNNER_ENV, STREAM_ENV, agentOptionsError, runnerCommand } from "./runner"
|
|
24
25
|
export type { AgentCatalog, AgentMcpServer, AgentModel, AgentParam, AgentParamValue } from "./runner"
|
|
25
26
|
|
|
26
27
|
export { CONFORMANCE_PROMPTS, CONFORMANCE_SCENARIOS, runConformance } from "./conformance"
|
|
@@ -43,6 +43,13 @@ export const STREAM_ENV = "SPUNTO_AGENT_STREAM"
|
|
|
43
43
|
*/
|
|
44
44
|
export const MCP_ENV = "SPUNTO_AGENT_MCP"
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* `"1"` when a human is at the other end of the session to answer the agent's questions (`question`
|
|
48
|
+
* events, the `answer` verb): a task someone delegated, not a sub-task another agent drives. Absent,
|
|
49
|
+
* a runner does not let its harness ask — the turn would wait on someone who is not coming.
|
|
50
|
+
*/
|
|
51
|
+
export const QUESTIONS_ENV = "SPUNTO_AGENT_QUESTIONS"
|
|
52
|
+
|
|
46
53
|
export type AgentMcpServer = { name: string; path: string }
|
|
47
54
|
|
|
48
55
|
/**
|
|
@@ -74,6 +74,7 @@ export const TASK_EVENT_TYPES = [
|
|
|
74
74
|
"subagent",
|
|
75
75
|
"context.compacted",
|
|
76
76
|
"skill.loaded",
|
|
77
|
+
"question",
|
|
77
78
|
"raw",
|
|
78
79
|
] as const
|
|
79
80
|
export type TaskEventType = (typeof TASK_EVENT_TYPES)[number]
|
|
@@ -94,8 +95,11 @@ export type NormalizedEvent = {
|
|
|
94
95
|
/** An event and the harness line it came from. One line can yield several. */
|
|
95
96
|
export type SourcedEvent = NormalizedEvent & { source: string }
|
|
96
97
|
|
|
98
|
+
/** The human's answer to one question of a `question` event: the options picked, and/or their own words. */
|
|
99
|
+
export type QuestionAnswer = { question: string; selected: string[]; text?: string | null }
|
|
100
|
+
|
|
97
101
|
/**
|
|
98
|
-
* One line of a runner's stdin. The whole input side of the contract —
|
|
102
|
+
* One line of a runner's stdin. The whole input side of the contract — four verbs, the same for
|
|
99
103
|
* every harness, so the platform never writes a harness's own shape into a runner. Closing stdin
|
|
100
104
|
* ends the session once its turn is over.
|
|
101
105
|
*/
|
|
@@ -103,6 +107,7 @@ export type RunnerInput =
|
|
|
103
107
|
| { type: "user"; text: string }
|
|
104
108
|
| { type: "interrupt"; id: string }
|
|
105
109
|
| { type: "title"; id: string; description: string }
|
|
110
|
+
| { type: "answer"; callId: string; answers: QuestionAnswer[] }
|
|
106
111
|
|
|
107
112
|
// ── The table ─────────────────────────────────────────────────────────────────
|
|
108
113
|
|
|
@@ -182,6 +187,16 @@ const PARENT = nullable(str())
|
|
|
182
187
|
/** How a subagent stands. `stopped`: killed before it ended (an interrupt, a dead process). */
|
|
183
188
|
export const SUBAGENT_STATUSES = ["running", "completed", "failed", "stopped"] as const
|
|
184
189
|
|
|
190
|
+
/**
|
|
191
|
+
* How a question of the agent's stands. `pending`: the turn is waiting on the human's choice.
|
|
192
|
+
* `answered`: they chose (`answer` verb). `dismissed`: it will never be answered as asked — the
|
|
193
|
+
* human wrote a message instead (which the runner hands the harness as the answer), or the turn
|
|
194
|
+
* was interrupted.
|
|
195
|
+
*/
|
|
196
|
+
export const QUESTION_STATUSES = ["pending", "answered", "dismissed"] as const
|
|
197
|
+
|
|
198
|
+
const ANSWERS = array(object({ question: req(str()), selected: req(array(str())), text: nullable(str()) }))
|
|
199
|
+
|
|
185
200
|
/**
|
|
186
201
|
* Every line type, and its fields. `type` and `source` are on every line and not repeated here.
|
|
187
202
|
* A field absent from a line is "unknown", which is not the same as `null` only for the reader of
|
|
@@ -243,10 +258,12 @@ const FIELDS: Record<TaskEventType | TransientType, Record<string, Field>> = {
|
|
|
243
258
|
summary: str(),
|
|
244
259
|
limit: nullable(LIMIT),
|
|
245
260
|
},
|
|
246
|
-
// What the harness still runs in the background, restated whole
|
|
247
|
-
// running has not handed
|
|
261
|
+
// What the harness still runs in the background, restated whole. `holds`: the agent will come
|
|
262
|
+
// back for it (a backgrounded subagent) — a turn that leaves such work running has not handed
|
|
263
|
+
// back. `false` is work it may never wait for (a shell: as often a dev server as a test run).
|
|
264
|
+
// Absent reads as `true`, which is what every task meant before the field existed.
|
|
248
265
|
"session.background": {
|
|
249
|
-
tasks: req(array(object({ id: nullable(str()), kind: nullable(str()), description: nullable(str()) }))),
|
|
266
|
+
tasks: req(array(object({ id: nullable(str()), kind: nullable(str()), description: nullable(str()), holds: bool() }))),
|
|
250
267
|
},
|
|
251
268
|
// A subagent the session started (`callId`: the tool call that did), restated whole on every
|
|
252
269
|
// change — the latest line of a `callId` is where it stands. What it does inside is on lines of
|
|
@@ -290,6 +307,26 @@ const FIELDS: Record<TaskEventType | TransientType, Record<string, Field>> = {
|
|
|
290
307
|
truncated: bool(),
|
|
291
308
|
parentCallId: PARENT,
|
|
292
309
|
},
|
|
310
|
+
// The agent asks the human to choose, and its turn waits for the answer (Claude Code's
|
|
311
|
+
// `AskUserQuestion`): restated whole on every change, the latest line of a `callId` is where it
|
|
312
|
+
// stands. `callId` is the tool call that asked, when the harness asks through one. `answers` once
|
|
313
|
+
// `answered`, one per question: the options' labels picked, and `text`, the human's own words.
|
|
314
|
+
question: {
|
|
315
|
+
callId: req(str()),
|
|
316
|
+
status: req(oneOf(QUESTION_STATUSES)),
|
|
317
|
+
questions: req(
|
|
318
|
+
array(
|
|
319
|
+
object({
|
|
320
|
+
question: req(str()),
|
|
321
|
+
// A very short label for the question (« Library », « Approach »).
|
|
322
|
+
header: nullable(str()),
|
|
323
|
+
multiSelect: bool(),
|
|
324
|
+
options: req(array(object({ label: req(str()), description: nullable(str()), preview: nullable(str()) }))),
|
|
325
|
+
}),
|
|
326
|
+
),
|
|
327
|
+
),
|
|
328
|
+
answers: ANSWERS,
|
|
329
|
+
},
|
|
293
330
|
raw: { json: any(), text: str() },
|
|
294
331
|
// Not stored. `start` opens a fresh draft (one draft is one text block), else `text` is appended.
|
|
295
332
|
"message.delta": { text: req(str()), start: bool() },
|
|
@@ -306,6 +343,7 @@ export function agentContractSchema(): Record<string, unknown> {
|
|
|
306
343
|
{ type: req(oneOf(["user"])), text: req(str()) },
|
|
307
344
|
{ type: req(oneOf(["interrupt"])), id: req(str()) },
|
|
308
345
|
{ type: req(oneOf(["title"])), id: req(str()), description: req(str()) },
|
|
346
|
+
{ type: req(oneOf(["answer"])), callId: req(str()), answers: req(ANSWERS) },
|
|
309
347
|
]
|
|
310
348
|
return {
|
|
311
349
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
* ingestion loop lives in task-events.service.ts.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import { readContractLine, type NormalizedEvent, type RunnerInput, type SourcedEvent } from "../agent-contract/vocabulary"
|
|
24
|
+
import { readContractLine, type NormalizedEvent, type QuestionAnswer, type RunnerInput, type SourcedEvent } from "../agent-contract/vocabulary"
|
|
25
25
|
|
|
26
26
|
export { TASK_EVENT_TYPES } from "../agent-contract/vocabulary"
|
|
27
|
-
export type { NormalizedEvent, RunnerInput, SourcedEvent, TaskEventType } from "../agent-contract/vocabulary"
|
|
27
|
+
export type { NormalizedEvent, QuestionAnswer, RunnerInput, SourcedEvent, TaskEventType } from "../agent-contract/vocabulary"
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* How a session is read.
|
|
@@ -63,6 +63,12 @@ export function interruptLine(protocol: AgentProtocol, requestId: string): strin
|
|
|
63
63
|
return runnerLine({ type: "interrupt", id: requestId })
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/** The human's choice, for a question the agent asked (`question`) and waits on — or null for a session that cannot be told. */
|
|
67
|
+
export function answerLine(protocol: AgentProtocol, callId: string, answers: QuestionAnswer[]): string | null {
|
|
68
|
+
if (protocol !== "agent-v1") return null
|
|
69
|
+
return runnerLine({ type: "answer", callId, answers })
|
|
70
|
+
}
|
|
71
|
+
|
|
66
72
|
/**
|
|
67
73
|
* Ask the session to **name the conversation**, or null when it cannot be asked. The runner
|
|
68
74
|
* answers — if its harness can name a conversation at all — with a `session.title` line; the
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
export {
|
|
8
8
|
AGENT_PROTOCOLS,
|
|
9
|
+
answerLine,
|
|
9
10
|
interruptLine,
|
|
10
11
|
isInteractive,
|
|
11
12
|
parseLines,
|
|
@@ -28,6 +29,7 @@ export type { TurnLimit, TurnLimitKind } from "../agent-contract/vocabulary"
|
|
|
28
29
|
export type {
|
|
29
30
|
AgentProtocol,
|
|
30
31
|
NormalizedEvent,
|
|
32
|
+
QuestionAnswer,
|
|
31
33
|
RunnerInput,
|
|
32
34
|
SessionUsage,
|
|
33
35
|
SourcedEvent,
|