@ai0x0/codex-ts 0.6.4 → 0.7.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/README.md +22 -3
- package/dist/core/src/codex_thread.d.ts +6 -0
- package/dist/core/src/codex_thread.d.ts.map +1 -1
- package/dist/core/src/codex_thread.js +62 -7
- package/dist/core/src/codex_thread.js.map +1 -1
- package/dist/core/src/compact.d.ts +12 -2
- package/dist/core/src/compact.d.ts.map +1 -1
- package/dist/core/src/compact.js +28 -11
- package/dist/core/src/compact.js.map +1 -1
- package/dist/core/src/index.d.ts +4 -4
- package/dist/core/src/index.d.ts.map +1 -1
- package/dist/core/src/index.js +3 -3
- package/dist/core/src/index.js.map +1 -1
- package/dist/core/src/session/retry.d.ts +47 -5
- package/dist/core/src/session/retry.d.ts.map +1 -1
- package/dist/core/src/session/retry.js +143 -6
- package/dist/core/src/session/retry.js.map +1 -1
- package/dist/core/src/session/turn.d.ts +6 -0
- package/dist/core/src/session/turn.d.ts.map +1 -1
- package/dist/core/src/session/turn.js +103 -42
- package/dist/core/src/session/turn.js.map +1 -1
- package/dist/core/src/skills.d.ts +35 -2
- package/dist/core/src/skills.d.ts.map +1 -1
- package/dist/core/src/skills.js +146 -41
- package/dist/core/src/skills.js.map +1 -1
- package/dist/core/src/state/auto_compact_window.d.ts +58 -4
- package/dist/core/src/state/auto_compact_window.d.ts.map +1 -1
- package/dist/core/src/state/auto_compact_window.js +89 -5
- package/dist/core/src/state/auto_compact_window.js.map +1 -1
- package/dist/core/src/tools/handlers/request_user_input_spec.d.ts +10 -1
- package/dist/core/src/tools/handlers/request_user_input_spec.d.ts.map +1 -1
- package/dist/core/src/tools/handlers/request_user_input_spec.js +30 -2
- package/dist/core/src/tools/handlers/request_user_input_spec.js.map +1 -1
- package/dist/core/src/tools/router.d.ts.map +1 -1
- package/dist/core/src/tools/router.js +12 -2
- package/dist/core/src/tools/router.js.map +1 -1
- package/dist/core/tests/suite/compact.test.js +64 -7
- package/dist/core/tests/suite/compact.test.js.map +1 -1
- package/dist/core/tests/suite/goal.test.js +18 -2
- package/dist/core/tests/suite/goal.test.js.map +1 -1
- package/dist/core/tests/suite/image_input.test.js +23 -0
- package/dist/core/tests/suite/image_input.test.js.map +1 -1
- package/dist/core/tests/suite/reasoning_delta.test.d.ts +11 -0
- package/dist/core/tests/suite/reasoning_delta.test.d.ts.map +1 -0
- package/dist/core/tests/suite/reasoning_delta.test.js +85 -0
- package/dist/core/tests/suite/reasoning_delta.test.js.map +1 -0
- package/dist/core/tests/suite/request_user_input.test.js +78 -1
- package/dist/core/tests/suite/request_user_input.test.js.map +1 -1
- package/dist/core/tests/suite/skills.test.js +30 -2
- package/dist/core/tests/suite/skills.test.js.map +1 -1
- package/dist/core/tests/suite/stream_failure.test.d.ts +11 -0
- package/dist/core/tests/suite/stream_failure.test.d.ts.map +1 -0
- package/dist/core/tests/suite/stream_failure.test.js +162 -0
- package/dist/core/tests/suite/stream_failure.test.js.map +1 -0
- package/dist/core/tests/suite/token_count.test.js +8 -1
- package/dist/core/tests/suite/token_count.test.js.map +1 -1
- package/dist/core/tests/suite/tool_arg_parse_error.test.d.ts +14 -0
- package/dist/core/tests/suite/tool_arg_parse_error.test.d.ts.map +1 -0
- package/dist/core/tests/suite/tool_arg_parse_error.test.js +100 -0
- package/dist/core/tests/suite/tool_arg_parse_error.test.js.map +1 -0
- package/dist/ext/goal/src/spec.d.ts.map +1 -1
- package/dist/ext/goal/src/spec.js +14 -9
- package/dist/ext/goal/src/spec.js.map +1 -1
- package/dist/ext/goal/src/tool.d.ts.map +1 -1
- package/dist/ext/goal/src/tool.js +39 -15
- package/dist/ext/goal/src/tool.js.map +1 -1
- package/dist/protocol/src/index.d.ts +2 -1
- package/dist/protocol/src/index.d.ts.map +1 -1
- package/dist/protocol/src/index.js +1 -1
- package/dist/protocol/src/index.js.map +1 -1
- package/dist/protocol/src/protocol.d.ts +114 -5
- package/dist/protocol/src/protocol.d.ts.map +1 -1
- package/dist/protocol/src/protocol.js +13 -1
- package/dist/protocol/src/protocol.js.map +1 -1
- package/dist/protocol/src/request_user_input.d.ts +15 -0
- package/dist/protocol/src/request_user_input.d.ts.map +1 -1
- package/dist/protocol/src/user_input.d.ts +11 -0
- package/dist/protocol/src/user_input.d.ts.map +1 -1
- package/dist/state/src/runtime/goals.d.ts +15 -1
- package/dist/state/src/runtime/goals.d.ts.map +1 -1
- package/dist/state/src/runtime/goals.js +36 -3
- package/dist/state/src/runtime/goals.js.map +1 -1
- package/dist/thread-store/src/types.d.ts +5 -0
- package/dist/thread-store/src/types.d.ts.map +1 -1
- package/dist/tools/src/json_schema.d.ts +2 -0
- package/dist/tools/src/json_schema.d.ts.map +1 -1
- package/dist/tools/src/json_schema.js +4 -0
- package/dist/tools/src/json_schema.js.map +1 -1
- package/package.json +1 -1
|
@@ -25,13 +25,12 @@ export function createCreateGoalTool() {
|
|
|
25
25
|
name: CREATE_GOAL_TOOL_NAME,
|
|
26
26
|
description: [
|
|
27
27
|
"Create a goal only when explicitly requested by the user or system/developer instructions; do not infer goals from ordinary tasks.",
|
|
28
|
-
`Set token_budget only when an explicit token budget is requested. Fails if
|
|
28
|
+
`Set token_budget only when an explicit token budget is requested. Fails if an unfinished goal exists; use ${UPDATE_GOAL_TOOL_NAME} only for status.`,
|
|
29
29
|
].join("\n"),
|
|
30
30
|
parameters: S.object({
|
|
31
31
|
objective: S.string("Required. The concrete objective to start pursuing. " +
|
|
32
|
-
"This starts a new active goal
|
|
33
|
-
|
|
34
|
-
token_budget: S.integer("Optional positive token budget for the new active goal."),
|
|
32
|
+
"This starts a new active goal when no goal exists or replaces the current goal when it is complete."),
|
|
33
|
+
token_budget: S.integer("Positive token budget for the new goal. Omit unless explicitly requested."),
|
|
35
34
|
}, ["objective"], false),
|
|
36
35
|
strict: false,
|
|
37
36
|
},
|
|
@@ -44,15 +43,21 @@ export function createUpdateGoalTool() {
|
|
|
44
43
|
name: UPDATE_GOAL_TOOL_NAME,
|
|
45
44
|
description: [
|
|
46
45
|
"Update the existing goal.",
|
|
47
|
-
"Use this tool only to mark the goal achieved or blocked.",
|
|
46
|
+
"Use this tool only to mark the goal achieved or genuinely blocked.",
|
|
48
47
|
"Set status to `complete` only when the objective has actually been achieved and no required work remains.",
|
|
49
|
-
"Set status to `blocked` only when the goal cannot
|
|
48
|
+
"Set status to `blocked` only when the same blocking condition has repeated for at least three consecutive goal turns, counting the original/user-triggered turn and any automatic continuations, and the agent cannot make meaningful progress without user input or an external-state change.",
|
|
49
|
+
"If the user resumes a goal that was previously marked `blocked`, treat the resumed run as a fresh blocked audit. If the same blocking condition then repeats for at least three consecutive resumed goal turns, set status to `blocked` again.",
|
|
50
|
+
"Once the blocked threshold is satisfied, do not keep reporting that you are still blocked while leaving the goal active; set status to `blocked`.",
|
|
51
|
+
"Do not use `blocked` merely because the work is hard, slow, uncertain, incomplete, or would benefit from clarification.",
|
|
50
52
|
"Do not mark a goal complete merely because its budget is nearly exhausted or because you are stopping work.",
|
|
53
|
+
"You cannot use this tool to pause, resume, budget-limit, or usage-limit a goal; those status changes are controlled by the user or system.",
|
|
54
|
+
"When marking a budgeted goal achieved with status `complete`, report the final token usage from the tool result to the user.",
|
|
51
55
|
].join("\n"),
|
|
52
56
|
parameters: S.object({
|
|
53
|
-
status: S.stringEnum(["complete", "blocked"], "Required. Set to complete only when the objective is achieved and no required work remains. " +
|
|
54
|
-
"Set to blocked only
|
|
55
|
-
"
|
|
57
|
+
status: S.stringEnum(["complete", "blocked"], "Required. Set to `complete` only when the objective is achieved and no required work remains. " +
|
|
58
|
+
"Set to `blocked` only after the same blocking condition has recurred for at least three consecutive " +
|
|
59
|
+
"goal turns and the agent is at an impasse. After a previously blocked goal is resumed, the resumed " +
|
|
60
|
+
"run starts a fresh blocked audit."),
|
|
56
61
|
}, ["status"], false),
|
|
57
62
|
strict: false,
|
|
58
63
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../../ext/goal/src/spec.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,CAAC,MAAM,mCAAmC,CAAC;AAEvD,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC;AACnD,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC;AAEnD,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE;YACJ,IAAI,EAAE,kBAAkB;YACxB,WAAW,EACT,4HAA4H;YAC9H,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC;YACnC,MAAM,EAAE,KAAK;SACd;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE;YACJ,IAAI,EAAE,qBAAqB;YAC3B,WAAW,EAAE;gBACX,oIAAoI;gBACpI,
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../../ext/goal/src/spec.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,CAAC,MAAM,mCAAmC,CAAC;AAEvD,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC;AACnD,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC;AAEnD,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE;YACJ,IAAI,EAAE,kBAAkB;YACxB,WAAW,EACT,4HAA4H;YAC9H,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC;YACnC,MAAM,EAAE,KAAK;SACd;KACF,CAAC;AACJ,CAAC;AAED,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V,sBAAsB,EACvB,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../../ext/goal/src/tool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,UAAU,EAEV,sBAAsB,EACvB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAYrE,qBAAa,gBAAgB;IAC3B,iFAAiF;IACjF,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAwB;gBAEnC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS;IAOzC,MAAM,CACV,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAAA;KAAE,CAAC;IAiD9D,GAAG,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,IAAI,CAAA;KAAE,CAAC;IAS/C,MAAM,CACV,MAAM,EAAE,UAAU,GAAG,SAAS,GAC7B,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAAA;KAAE,CAAC;IA0B9D,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,SAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBpE,eAAe,IAAI,UAAU,GAAG,IAAI;IAMpC,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,gBAAgB;CAKzB"}
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
* Accepts an optional GoalStore for durable persistence (SQLite, IndexedDB…).
|
|
7
7
|
* Falls back to in-memory state when no store is supplied.
|
|
8
8
|
*/
|
|
9
|
+
import { validateThreadGoalObjective } from "../../../protocol/src/protocol.js";
|
|
10
|
+
/** verbatim from handle_create's ok_or_else (tool.rs:201-205) */
|
|
11
|
+
const CREATE_BLOCKED_ERROR = "cannot create a new goal because this thread has an unfinished goal; complete the existing goal first";
|
|
9
12
|
export class GoalToolExecutor {
|
|
10
13
|
/** In-memory snapshot — always current, written through to store when present */
|
|
11
14
|
snapshot = null;
|
|
@@ -17,29 +20,43 @@ export class GoalToolExecutor {
|
|
|
17
20
|
}
|
|
18
21
|
// ─── create_goal ────────────────────────────────────────────────────────────
|
|
19
22
|
async create(objective, token_budget) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
23
|
+
// mirrors handle_create (tool.rs:200) on top of create_thread_goal
|
|
24
|
+
// (goals.rs:225): an UNFINISHED goal blocks creation, but a COMPLETE one is
|
|
25
|
+
// replaced (counters reset), so a thread can start its next goal.
|
|
26
|
+
if (this.snapshot !== null && this.snapshot.status !== "Complete") {
|
|
27
|
+
return { output: JSON.stringify({ error: CREATE_BLOCKED_ERROR }), event: null };
|
|
25
28
|
}
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
// mirrors handle_create (tool.rs:185-187): trim, then
|
|
30
|
+
// validate_thread_goal_objective (protocol.rs:4055).
|
|
31
|
+
const trimmedObjective = (objective ?? "").trim();
|
|
32
|
+
const objectiveError = validateThreadGoalObjective(trimmedObjective);
|
|
33
|
+
if (objectiveError !== null) {
|
|
34
|
+
return { output: JSON.stringify({ error: objectiveError }), event: null };
|
|
28
35
|
}
|
|
29
36
|
if (token_budget !== undefined && (token_budget <= 0 || !Number.isInteger(token_budget))) {
|
|
30
37
|
return { output: JSON.stringify({ error: "token_budget must be a positive integer." }), event: null };
|
|
31
38
|
}
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
// mirrors handle_create (tool.rs:190-206): the store's create is
|
|
40
|
+
// authoritative — a null result means it found an unfinished goal.
|
|
41
|
+
if (this.store) {
|
|
42
|
+
const created = await this.store.createThreadGoal(this.threadId, trimmedObjective, token_budget);
|
|
43
|
+
if (created === null) {
|
|
44
|
+
return { output: JSON.stringify({ error: CREATE_BLOCKED_ERROR }), event: null };
|
|
45
|
+
}
|
|
46
|
+
this.snapshot = created;
|
|
47
|
+
return { output: this.formatResponse(), event: this.goalUpdatedEvent() };
|
|
48
|
+
}
|
|
49
|
+
const now = Date.now();
|
|
50
|
+
this.snapshot = {
|
|
51
|
+
thread_id: this.threadId,
|
|
52
|
+
objective: trimmedObjective,
|
|
34
53
|
status: "Active",
|
|
35
54
|
...(token_budget !== undefined ? { token_budget } : {}),
|
|
36
55
|
tokens_used: 0,
|
|
37
56
|
time_used_seconds: 0,
|
|
57
|
+
created_at: now,
|
|
58
|
+
updated_at: now,
|
|
38
59
|
};
|
|
39
|
-
if (this.store) {
|
|
40
|
-
await this.store.replaceThreadGoal(this.threadId, objective, "Active", token_budget);
|
|
41
|
-
}
|
|
42
|
-
this.snapshot = goal;
|
|
43
60
|
return { output: this.formatResponse(), event: this.goalUpdatedEvent() };
|
|
44
61
|
}
|
|
45
62
|
// ─── get_goal ───────────────────────────────────────────────────────────────
|
|
@@ -64,7 +81,11 @@ export class GoalToolExecutor {
|
|
|
64
81
|
if (this.store) {
|
|
65
82
|
await this.store.updateThreadGoal(this.threadId, { status: goalStatus });
|
|
66
83
|
}
|
|
67
|
-
this.snapshot = {
|
|
84
|
+
this.snapshot = {
|
|
85
|
+
...this.snapshot,
|
|
86
|
+
status: goalStatus,
|
|
87
|
+
updated_at: Date.now(),
|
|
88
|
+
};
|
|
68
89
|
return { output: this.formatResponse(), event: this.goalUpdatedEvent() };
|
|
69
90
|
}
|
|
70
91
|
// ─── Token accounting ───────────────────────────────────────────────────────
|
|
@@ -82,6 +103,7 @@ export class GoalToolExecutor {
|
|
|
82
103
|
...this.snapshot,
|
|
83
104
|
tokens_used: this.snapshot.tokens_used + count,
|
|
84
105
|
time_used_seconds: this.snapshot.time_used_seconds + elapsedSeconds,
|
|
106
|
+
updated_at: Date.now(),
|
|
85
107
|
};
|
|
86
108
|
}
|
|
87
109
|
currentSnapshot() {
|
|
@@ -98,7 +120,9 @@ export class GoalToolExecutor {
|
|
|
98
120
|
return JSON.stringify({ goal: this.snapshot, remaining_tokens });
|
|
99
121
|
}
|
|
100
122
|
goalUpdatedEvent() {
|
|
101
|
-
return this.snapshot
|
|
123
|
+
return this.snapshot
|
|
124
|
+
? { thread_id: this.threadId, goal: { ...this.snapshot } }
|
|
125
|
+
: null;
|
|
102
126
|
}
|
|
103
127
|
}
|
|
104
128
|
//# sourceMappingURL=tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../../ext/goal/src/tool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../../ext/goal/src/tool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAGhF,iEAAiE;AACjE,MAAM,oBAAoB,GACxB,uGAAuG,CAAC;AAQ1G,MAAM,OAAO,gBAAgB;IAC3B,iFAAiF;IACzE,QAAQ,GAAsB,IAAI,CAAC;IAC1B,QAAQ,CAAS;IACjB,KAAK,CAAyB;IAE/C,YAAY,QAAgB,EAAE,KAAiB;QAC7C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,+EAA+E;IAE/E,KAAK,CAAC,MAAM,CACV,SAAiB,EACjB,YAAqB;QAErB,mEAAmE;QACnE,4EAA4E;QAC5E,kEAAkE;QAClE,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YAClE,OAAO,EAAE,MAAM,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Q,CAAC,iBAAiB,GAAG,cAAc;YACnE,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;SACvB,CAAC;IACJ,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACrD,CAAC;IAED,gFAAgF;IAExE,cAAc;QACpB,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAA6B,CAAC,CAAC;QAC3F,CAAC;QACD,MAAM,gBAAgB,GACpB,IAAI,CAAC,QAAQ,CAAC,YAAY,KAAK,SAAS;YACtC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW;YACxD,CAAC,CAAC,IAAI,CAAC;QACX,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,gBAAgB,EAA6B,CAAC,CAAC;IAC9F,CAAC;IAEO,gBAAgB;QACtB,OAAO,IAAI,CAAC,QAAQ;YAClB,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,EAAE;YAC1D,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;CACF"}
|
|
@@ -2,5 +2,6 @@ export type { UserInput } from "./user_input.js";
|
|
|
2
2
|
export type { RequestUserInputQuestionOption, RequestUserInputQuestion, RequestUserInputArgs, RequestUserInputAnswer, RequestUserInputResponse, RequestUserInputEvent, } from "./request_user_input.js";
|
|
3
3
|
export type { StepStatus, PlanItemArg, UpdatePlanArgs } from "./plan_tool.js";
|
|
4
4
|
export type { ContextCompactedEvent, WarningEvent } from "./protocol.js";
|
|
5
|
-
export
|
|
5
|
+
export { MAX_THREAD_GOAL_OBJECTIVE_CHARS, validateThreadGoalObjective, } from "./protocol.js";
|
|
6
|
+
export type { ThreadGoalStatus, ThreadGoal, TurnStartedEvent, TurnCompleteEvent, TurnAbortedEvent, TurnAbortReason, AgentMessageEvent, AgentMessageContentDeltaEvent, ReasoningContentDeltaEvent, ThreadGoalUpdatedEvent, CodexErrorInfo, ErrorEvent, TokenUsage, TokenUsageInfo, TokenCountEvent, EventMsg, Event, Op, } from "./protocol.js";
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../protocol/src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,YAAY,EACV,8BAA8B,EAC9B,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC9E,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACzE,YAAY,EACV,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,6BAA6B,EAC7B,sBAAsB,EACtB,UAAU,EACV,QAAQ,EACR,KAAK,EACL,EAAE,GACH,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../protocol/src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,YAAY,EACV,8BAA8B,EAC9B,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC9E,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EACL,+BAA+B,EAC/B,2BAA2B,GAC5B,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,6BAA6B,EAC7B,0BAA0B,EAC1B,sBAAsB,EACtB,cAAc,EACd,UAAU,EACV,UAAU,EACV,cAAc,EACd,eAAe,EACf,QAAQ,EACR,KAAK,EACL,EAAE,GACH,MAAM,eAAe,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { MAX_THREAD_GOAL_OBJECTIVE_CHARS, validateThreadGoalObjective, } from "./protocol.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../protocol/src/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../protocol/src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,+BAA+B,EAC/B,2BAA2B,GAC5B,MAAM,eAAe,CAAC"}
|
|
@@ -9,18 +9,58 @@ import type { RequestUserInputEvent, RequestUserInputResponse } from "./request_
|
|
|
9
9
|
import type { UpdatePlanArgs } from "./plan_tool.js";
|
|
10
10
|
export type ThreadGoalStatus = "Active" | "Paused" | "Blocked" | "UsageLimited" | "BudgetLimited" | "Complete";
|
|
11
11
|
export interface ThreadGoal {
|
|
12
|
+
/** mirrors ThreadGoal.thread_id (protocol.rs:4071) — the owning thread. */
|
|
13
|
+
thread_id: string;
|
|
12
14
|
objective: string;
|
|
13
15
|
status: ThreadGoalStatus;
|
|
14
16
|
token_budget?: number | undefined;
|
|
15
17
|
tokens_used: number;
|
|
16
18
|
time_used_seconds: number;
|
|
19
|
+
/** Unix epoch milliseconds — mirrors created_at/updated_at (protocol.rs:4079). */
|
|
20
|
+
created_at: number;
|
|
21
|
+
updated_at: number;
|
|
17
22
|
}
|
|
23
|
+
/** mirrors MAX_THREAD_GOAL_OBJECTIVE_CHARS (protocol.rs:4053) */
|
|
24
|
+
export declare const MAX_THREAD_GOAL_OBJECTIVE_CHARS = 4000;
|
|
25
|
+
/** mirrors validate_thread_goal_objective (protocol.rs:4055) — returns the
|
|
26
|
+
* error message, or null when the objective is acceptable. */
|
|
27
|
+
export declare function validateThreadGoalObjective(value: string): string | null;
|
|
18
28
|
export interface TurnStartedEvent {
|
|
19
29
|
turn_id: string;
|
|
20
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* mirrors TurnCompleteEvent (protocol.rs:1986). codex-rs emits this at the END
|
|
33
|
+
* of EVERY turn — successful or not — carrying the terminal error when the turn
|
|
34
|
+
* failed (tasks/mod.rs:803). codex-ts mirrors that: a failing turn now emits
|
|
35
|
+
* BOTH `Error` (unchanged, for hosts that key off it) and a final
|
|
36
|
+
* `TurnComplete` with `error` set, so a host looping until TurnComplete no
|
|
37
|
+
* longer hangs on failure.
|
|
38
|
+
*/
|
|
21
39
|
export interface TurnCompleteEvent {
|
|
22
40
|
turn_id: string;
|
|
23
41
|
last_agent_message?: string | undefined;
|
|
42
|
+
/** Terminal error details when the turn completed unsuccessfully. */
|
|
43
|
+
error?: ErrorEvent | undefined;
|
|
44
|
+
/** Unix timestamp (seconds) when the turn started / completed. */
|
|
45
|
+
started_at?: number | undefined;
|
|
46
|
+
completed_at?: number | undefined;
|
|
47
|
+
/** Turn wall-clock duration in milliseconds, when known. */
|
|
48
|
+
duration_ms?: number | undefined;
|
|
49
|
+
}
|
|
50
|
+
/** mirrors TurnAbortReason (protocol.rs:4209). codex-ts only ever produces
|
|
51
|
+
* `interrupted` (Op.Interrupt); the rest exist for shape parity. */
|
|
52
|
+
export type TurnAbortReason = "interrupted" | "replaced" | "review_ended" | "budget_limited";
|
|
53
|
+
/**
|
|
54
|
+
* mirrors TurnAbortedEvent (protocol.rs:4190). codex-rs ends an aborted turn with
|
|
55
|
+
* THIS event instead of TurnComplete (tasks/mod.rs:785-794), so an interrupted
|
|
56
|
+
* turn has its own terminal event rather than a success-shaped one.
|
|
57
|
+
*/
|
|
58
|
+
export interface TurnAbortedEvent {
|
|
59
|
+
turn_id?: string | undefined;
|
|
60
|
+
reason: TurnAbortReason;
|
|
61
|
+
started_at?: number | undefined;
|
|
62
|
+
completed_at?: number | undefined;
|
|
63
|
+
duration_ms?: number | undefined;
|
|
24
64
|
}
|
|
25
65
|
/** Full assistant text for a completed message */
|
|
26
66
|
export interface AgentMessageEvent {
|
|
@@ -32,19 +72,79 @@ export interface AgentMessageContentDeltaEvent {
|
|
|
32
72
|
item_id: string;
|
|
33
73
|
delta: string;
|
|
34
74
|
}
|
|
35
|
-
/** Streaming reasoning (thinking) chunk — mirrors codex-rs
|
|
36
|
-
* Emitted while the model streams
|
|
37
|
-
* output_text. Lets hosts show a
|
|
75
|
+
/** Streaming reasoning (thinking) chunk — mirrors codex-rs
|
|
76
|
+
* ReasoningContentDeltaEvent (protocol.rs:1873). Emitted while the model streams
|
|
77
|
+
* its reasoning/thinking, before any final output_text. Lets hosts show a
|
|
78
|
+
* "thinking" state only while truly reasoning. */
|
|
38
79
|
export interface ReasoningContentDeltaEvent {
|
|
39
80
|
turn_id: string;
|
|
81
|
+
/** Reasoning item this delta belongs to — mirrors item_id (protocol.rs:1876). */
|
|
82
|
+
item_id: string;
|
|
40
83
|
delta: string;
|
|
84
|
+
/**
|
|
85
|
+
* Which reasoning block the delta belongs to — mirrors summary_index
|
|
86
|
+
* (protocol.rs:1880). Sourced from the SSE `summary_index` for
|
|
87
|
+
* `response.reasoning_summary_text.delta` and from `content_index` for
|
|
88
|
+
* `response.reasoning_text.delta` (codex-api/src/sse/responses.rs), so hosts
|
|
89
|
+
* can keep separate reasoning blocks apart. Defaults to 0, like rs's
|
|
90
|
+
* `#[serde(default)]`.
|
|
91
|
+
*/
|
|
92
|
+
summary_index: number;
|
|
41
93
|
}
|
|
42
94
|
export interface ThreadGoalUpdatedEvent {
|
|
95
|
+
/** mirrors ThreadGoalUpdatedEvent.thread_id (protocol.rs:4087) */
|
|
96
|
+
thread_id: string;
|
|
43
97
|
turn_id?: string | undefined;
|
|
44
98
|
goal: ThreadGoal;
|
|
45
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* mirrors codex-rs/protocol/src/protocol.rs CodexErrorInfo (protocol.rs:1758) —
|
|
102
|
+
* the client-facing error classification. codex-ts produces the subset it can
|
|
103
|
+
* actually observe over HTTP/SSE (see codexErrorInfoFor in session/retry.ts);
|
|
104
|
+
* the remaining variants are kept for shape parity with rs.
|
|
105
|
+
*/
|
|
106
|
+
export type CodexErrorInfo = {
|
|
107
|
+
type: "context_window_exceeded";
|
|
108
|
+
} | {
|
|
109
|
+
type: "session_budget_exceeded";
|
|
110
|
+
} | {
|
|
111
|
+
type: "usage_limit_exceeded";
|
|
112
|
+
} | {
|
|
113
|
+
type: "server_overloaded";
|
|
114
|
+
} | {
|
|
115
|
+
type: "cyber_policy";
|
|
116
|
+
} | {
|
|
117
|
+
type: "http_connection_failed";
|
|
118
|
+
http_status_code?: number | undefined;
|
|
119
|
+
} | {
|
|
120
|
+
type: "response_stream_connection_failed";
|
|
121
|
+
http_status_code?: number | undefined;
|
|
122
|
+
} | {
|
|
123
|
+
type: "internal_server_error";
|
|
124
|
+
} | {
|
|
125
|
+
type: "unauthorized";
|
|
126
|
+
} | {
|
|
127
|
+
type: "bad_request";
|
|
128
|
+
} | {
|
|
129
|
+
type: "sandbox_error";
|
|
130
|
+
} | {
|
|
131
|
+
type: "response_stream_disconnected";
|
|
132
|
+
http_status_code?: number | undefined;
|
|
133
|
+
} | {
|
|
134
|
+
type: "response_too_many_failed_attempts";
|
|
135
|
+
http_status_code?: number | undefined;
|
|
136
|
+
} | {
|
|
137
|
+
type: "thread_rollback_failed";
|
|
138
|
+
} | {
|
|
139
|
+
type: "other";
|
|
140
|
+
};
|
|
46
141
|
export interface ErrorEvent {
|
|
47
142
|
message: string;
|
|
143
|
+
/**
|
|
144
|
+
* mirrors ErrorEvent.codex_error_info (protocol.rs:1925) — lets hosts branch
|
|
145
|
+
* on the error class instead of matching message text.
|
|
146
|
+
*/
|
|
147
|
+
codex_error_info?: CodexErrorInfo | undefined;
|
|
48
148
|
/**
|
|
49
149
|
* Browser-specific extension — no equivalent in codex-rs/protocol ErrorEvent.
|
|
50
150
|
* Lets hosts correlate an error with the turn that produced it (e.g. to
|
|
@@ -58,15 +158,19 @@ export type ContextCompactedEvent = Record<never, never>;
|
|
|
58
158
|
export interface WarningEvent {
|
|
59
159
|
message: string;
|
|
60
160
|
}
|
|
61
|
-
/** mirrors TokenUsage (protocol.rs:
|
|
161
|
+
/** mirrors TokenUsage (protocol.rs:2056) */
|
|
62
162
|
export interface TokenUsage {
|
|
63
163
|
input_tokens: number;
|
|
64
164
|
cached_input_tokens: number;
|
|
165
|
+
/** Prompt-cache WRITE tokens — mirrors cache_write_input_tokens
|
|
166
|
+
* (protocol.rs:2063), read from `usage.input_tokens_details.cache_write_tokens`
|
|
167
|
+
* (codex-api/src/sse/responses.rs:137). 0 when the provider omits it. */
|
|
168
|
+
cache_write_input_tokens: number;
|
|
65
169
|
output_tokens: number;
|
|
66
170
|
reasoning_output_tokens: number;
|
|
67
171
|
total_tokens: number;
|
|
68
172
|
}
|
|
69
|
-
/** mirrors TokenUsageInfo (protocol.rs:
|
|
173
|
+
/** mirrors TokenUsageInfo (protocol.rs:2073) */
|
|
70
174
|
export interface TokenUsageInfo {
|
|
71
175
|
total_token_usage: TokenUsage;
|
|
72
176
|
last_token_usage: TokenUsage;
|
|
@@ -85,6 +189,11 @@ export type EventMsg = {
|
|
|
85
189
|
} | {
|
|
86
190
|
type: "TurnComplete";
|
|
87
191
|
event: TurnCompleteEvent;
|
|
192
|
+
}
|
|
193
|
+
/** mirrors EventMsg::TurnAborted — terminal event for an interrupted turn */
|
|
194
|
+
| {
|
|
195
|
+
type: "TurnAborted";
|
|
196
|
+
event: TurnAbortedEvent;
|
|
88
197
|
} | {
|
|
89
198
|
type: "AgentMessage";
|
|
90
199
|
event: AgentMessageEvent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../protocol/src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIrD,MAAM,MAAM,gBAAgB,GACxB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,cAAc,GACd,eAAe,GACf,UAAU,CAAC;AAEf,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,gBAAgB,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../protocol/src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIrD,MAAM,MAAM,gBAAgB,GACxB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,cAAc,GACd,eAAe,GACf,UAAU,CAAC;AAEf,MAAM,WAAW,UAAU;IACzB,2EAA2E;IAC3E,SAA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AC9C;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,GACD;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,uEAAuE;IACvE,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,wBAAwB,CAAC;CACpC,GACD;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC;AAE1B,YAAY,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,CAAC;AAChE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -4,5 +4,17 @@
|
|
|
4
4
|
* Subset: Op + EventMsg variants needed for goal, request_user_input,
|
|
5
5
|
* and conversation (turn lifecycle + streaming text).
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
/** mirrors MAX_THREAD_GOAL_OBJECTIVE_CHARS (protocol.rs:4053) */
|
|
8
|
+
export const MAX_THREAD_GOAL_OBJECTIVE_CHARS = 4_000;
|
|
9
|
+
/** mirrors validate_thread_goal_objective (protocol.rs:4055) — returns the
|
|
10
|
+
* error message, or null when the objective is acceptable. */
|
|
11
|
+
export function validateThreadGoalObjective(value) {
|
|
12
|
+
if (value.length === 0) {
|
|
13
|
+
return "goal objective must not be empty";
|
|
14
|
+
}
|
|
15
|
+
if (Array.from(value).length > MAX_THREAD_GOAL_OBJECTIVE_CHARS) {
|
|
16
|
+
return `goal objective must be at most ${MAX_THREAD_GOAL_OBJECTIVE_CHARS} characters`;
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
8
20
|
//# sourceMappingURL=protocol.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../protocol/src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../protocol/src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgCH,iEAAiE;AACjE,MAAM,CAAC,MAAM,+BAA+B,GAAG,KAAK,CAAC;AAErD;+DAC+D;AAC/D,MAAM,UAAU,2BAA2B,CAAC,KAAa;IACvD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,kCAAkC,CAAC;IAC5C,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,+BAA+B,EAAE,CAAC;QAC/D,OAAO,kCAAkC,+BAA+B,aAAa,CAAC;IACxF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -14,6 +14,15 @@ export interface RequestUserInputQuestion {
|
|
|
14
14
|
}
|
|
15
15
|
export interface RequestUserInputArgs {
|
|
16
16
|
questions: RequestUserInputQuestion[];
|
|
17
|
+
/**
|
|
18
|
+
* Optional auto-resolution window in milliseconds — mirrors
|
|
19
|
+
* `auto_resolution_ms` (request_user_input.rs:34). Present only when the
|
|
20
|
+
* question is useful but NON-blocking: the host may proceed with the agent's
|
|
21
|
+
* best judgment if the user does not answer within the window. Clamped to
|
|
22
|
+
* [MIN_AUTO_RESOLUTION_MS, MAX_AUTO_RESOLUTION_MS] by
|
|
23
|
+
* normalizeRequestUserInputArgs.
|
|
24
|
+
*/
|
|
25
|
+
autoResolutionMs?: number | undefined;
|
|
17
26
|
}
|
|
18
27
|
/** Per-question answers: key = question id */
|
|
19
28
|
export interface RequestUserInputAnswer {
|
|
@@ -27,5 +36,11 @@ export interface RequestUserInputEvent {
|
|
|
27
36
|
call_id: string;
|
|
28
37
|
turn_id: string;
|
|
29
38
|
questions: RequestUserInputQuestion[];
|
|
39
|
+
/**
|
|
40
|
+
* Auto-resolution window forwarded from the tool call — mirrors
|
|
41
|
+
* `RequestUserInputEvent.auto_resolution_ms` (request_user_input.rs:58).
|
|
42
|
+
* Absent means the agent needs an explicit answer before continuing.
|
|
43
|
+
*/
|
|
44
|
+
autoResolutionMs?: number | undefined;
|
|
30
45
|
}
|
|
31
46
|
//# sourceMappingURL=request_user_input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request_user_input.d.ts","sourceRoot":"","sources":["../../../protocol/src/request_user_input.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,MAAM,WAAW,8BAA8B;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,8BAA8B,EAAE,GAAG,SAAS,CAAC;CACxD;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,wBAAwB,EAAE,CAAC;CACvC;AAED,8CAA8C;AAC9C,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;CACjD;AAED,4DAA4D;AAC5D,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,wBAAwB,EAAE,CAAC;CACvC"}
|
|
1
|
+
{"version":3,"file":"request_user_input.d.ts","sourceRoot":"","sources":["../../../protocol/src/request_user_input.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,MAAM,WAAW,8BAA8B;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,8BAA8B,EAAE,GAAG,SAAS,CAAC;CACxD;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,wBAAwB,EAAE,CAAC;IACtC;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAED,8CAA8C;AAC9C,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;CACjD;AAED,4DAA4D;AAC5D,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,wBAAwB,EAAE,CAAC;IACtC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC"}
|
|
@@ -5,5 +5,16 @@ export type UserInput = {
|
|
|
5
5
|
} | {
|
|
6
6
|
type: "image";
|
|
7
7
|
image_url: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Pre-encoded audio data URI forwarded to the Responses API — mirrors
|
|
11
|
+
* `UserInput::Audio { audio_url }` (user_input.rs:41), serialized as
|
|
12
|
+
* `ContentItem::InputAudio { audio_url }` (models.rs:1778). The rs
|
|
13
|
+
* `LocalAudio`/`LocalImage` variants read from disk, so they have no browser
|
|
14
|
+
* equivalent: a host records audio and passes the data URI here directly.
|
|
15
|
+
*/
|
|
16
|
+
| {
|
|
17
|
+
type: "audio";
|
|
18
|
+
audio_url: string;
|
|
8
19
|
};
|
|
9
20
|
//# sourceMappingURL=user_input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user_input.d.ts","sourceRoot":"","sources":["../../../protocol/src/user_input.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAElD,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"user_input.d.ts","sourceRoot":"","sources":["../../../protocol/src/user_input.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAElD,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;AACtC;;;;;;GAMG;GACD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -35,10 +35,24 @@ export declare class GoalStore {
|
|
|
35
35
|
private readonly backend;
|
|
36
36
|
constructor(backend?: GoalBackend);
|
|
37
37
|
getThreadGoal(threadId: string): Promise<ThreadGoal | null>;
|
|
38
|
-
/** Create or replace a thread goal */
|
|
38
|
+
/** Create or replace a thread goal (mirrors replace_thread_goal, goals.rs:158) */
|
|
39
39
|
replaceThreadGoal(threadId: string, objective: string, status: ThreadGoalStatus, token_budget?: number): Promise<ThreadGoal>;
|
|
40
|
+
/**
|
|
41
|
+
* Create a goal only when the thread has no goal, or its goal is already
|
|
42
|
+
* complete. mirrors create_thread_goal (goals.rs:225): upstream changed the
|
|
43
|
+
* `ON CONFLICT(thread_id) DO NOTHING` to `DO UPDATE … WHERE status =
|
|
44
|
+
* 'complete'`, so a finished goal is replaced (usage counters reset to 0)
|
|
45
|
+
* while an UNFINISHED goal still blocks creation. Returns null when blocked.
|
|
46
|
+
*/
|
|
47
|
+
createThreadGoal(threadId: string, objective: string, token_budget?: number): Promise<ThreadGoal | null>;
|
|
40
48
|
/** Apply a partial update to an existing goal */
|
|
41
49
|
updateThreadGoal(threadId: string, update: GoalUpdate): Promise<GoalAccountingOutcome>;
|
|
50
|
+
/**
|
|
51
|
+
* Delete the thread's goal and return what was removed (null when there was
|
|
52
|
+
* none). mirrors delete_thread_goal (goals.rs:472), which upstream changed
|
|
53
|
+
* from `bool` to the deleted row so callers can report/emit it.
|
|
54
|
+
*/
|
|
55
|
+
deleteThreadGoal(threadId: string): Promise<ThreadGoal | null>;
|
|
42
56
|
/**
|
|
43
57
|
* Record token and time usage against the active goal budget.
|
|
44
58
|
* Mirrors the accounting path in GoalStore::account_tokens().
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goals.d.ts","sourceRoot":"","sources":["../../../../state/src/runtime/goals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAItF,MAAM,WAAW,WAAW;IAC1B,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAC5D,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD;AAID,qBAAa,mBAAoB,YAAW,WAAW;IACrD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiC;IAEjD,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAI3D,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,C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CACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,qBAAqB,CAAC;CA8BlC"}
|
|
@@ -30,21 +30,39 @@ export class GoalStore {
|
|
|
30
30
|
async getThreadGoal(threadId) {
|
|
31
31
|
return this.backend.getThreadGoal(threadId);
|
|
32
32
|
}
|
|
33
|
-
/** Create or replace a thread goal */
|
|
33
|
+
/** Create or replace a thread goal (mirrors replace_thread_goal, goals.rs:158) */
|
|
34
34
|
async replaceThreadGoal(threadId, objective, status, token_budget) {
|
|
35
|
+
const now = Date.now();
|
|
35
36
|
const goal = {
|
|
37
|
+
thread_id: threadId,
|
|
36
38
|
objective,
|
|
37
39
|
status,
|
|
38
40
|
...(token_budget !== undefined ? { token_budget } : {}),
|
|
39
41
|
tokens_used: 0,
|
|
40
42
|
time_used_seconds: 0,
|
|
43
|
+
created_at: now,
|
|
44
|
+
updated_at: now,
|
|
41
45
|
};
|
|
42
46
|
await this.backend.saveThreadGoal(threadId, goal);
|
|
43
47
|
return goal;
|
|
44
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Create a goal only when the thread has no goal, or its goal is already
|
|
51
|
+
* complete. mirrors create_thread_goal (goals.rs:225): upstream changed the
|
|
52
|
+
* `ON CONFLICT(thread_id) DO NOTHING` to `DO UPDATE … WHERE status =
|
|
53
|
+
* 'complete'`, so a finished goal is replaced (usage counters reset to 0)
|
|
54
|
+
* while an UNFINISHED goal still blocks creation. Returns null when blocked.
|
|
55
|
+
*/
|
|
56
|
+
async createThreadGoal(threadId, objective, token_budget) {
|
|
57
|
+
const existing = await this.getThreadGoal(threadId);
|
|
58
|
+
if (existing !== null && existing.status !== "Complete") {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
return this.replaceThreadGoal(threadId, objective, "Active", token_budget);
|
|
62
|
+
}
|
|
45
63
|
/** Apply a partial update to an existing goal */
|
|
46
64
|
async updateThreadGoal(threadId, update) {
|
|
47
|
-
const existing = await this.
|
|
65
|
+
const existing = await this.getThreadGoal(threadId);
|
|
48
66
|
if (existing === null) {
|
|
49
67
|
return { kind: "Unchanged", goal: null };
|
|
50
68
|
}
|
|
@@ -56,16 +74,30 @@ export class GoalStore {
|
|
|
56
74
|
? {}
|
|
57
75
|
: { token_budget: update.token_budget }
|
|
58
76
|
: {}),
|
|
77
|
+
updated_at: Date.now(),
|
|
59
78
|
};
|
|
60
79
|
await this.backend.saveThreadGoal(threadId, updated);
|
|
61
80
|
return { kind: "Updated", goal: updated };
|
|
62
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Delete the thread's goal and return what was removed (null when there was
|
|
84
|
+
* none). mirrors delete_thread_goal (goals.rs:472), which upstream changed
|
|
85
|
+
* from `bool` to the deleted row so callers can report/emit it.
|
|
86
|
+
*/
|
|
87
|
+
async deleteThreadGoal(threadId) {
|
|
88
|
+
const existing = await this.getThreadGoal(threadId);
|
|
89
|
+
if (existing === null) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
await this.backend.deleteThreadGoal(threadId);
|
|
93
|
+
return existing;
|
|
94
|
+
}
|
|
63
95
|
/**
|
|
64
96
|
* Record token and time usage against the active goal budget.
|
|
65
97
|
* Mirrors the accounting path in GoalStore::account_tokens().
|
|
66
98
|
*/
|
|
67
99
|
async accountTokens(threadId, tokens, elapsedSeconds) {
|
|
68
|
-
const existing = await this.
|
|
100
|
+
const existing = await this.getThreadGoal(threadId);
|
|
69
101
|
if (existing === null || existing.status !== "Active") {
|
|
70
102
|
return { kind: "Unchanged", goal: existing };
|
|
71
103
|
}
|
|
@@ -82,6 +114,7 @@ export class GoalStore {
|
|
|
82
114
|
tokens_used,
|
|
83
115
|
time_used_seconds,
|
|
84
116
|
status,
|
|
117
|
+
updated_at: Date.now(),
|
|
85
118
|
};
|
|
86
119
|
await this.backend.saveThreadGoal(threadId, updated);
|
|
87
120
|
const changed = status !== existing.status || tokens_used !== existing.tokens_used;
|