@yourtechbudstudio/fluidcast-tool-agent 0.0.0-stage → 0.0.2

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.
Files changed (91) hide show
  1. package/LICENSE +201 -0
  2. package/dist/claude/attach.d.ts +24 -0
  3. package/dist/claude/attach.d.ts.map +1 -0
  4. package/dist/claude/attach.js +25 -0
  5. package/dist/claude/attach.js.map +1 -0
  6. package/dist/claude/connect.d.ts +52 -0
  7. package/dist/claude/connect.d.ts.map +1 -0
  8. package/dist/claude/connect.js +93 -0
  9. package/dist/claude/connect.js.map +1 -0
  10. package/dist/claude/failure.d.ts +35 -0
  11. package/dist/claude/failure.d.ts.map +1 -0
  12. package/dist/claude/failure.js +42 -0
  13. package/dist/claude/failure.js.map +1 -0
  14. package/dist/claude/index.d.ts +30 -0
  15. package/dist/claude/index.d.ts.map +1 -0
  16. package/dist/claude/index.js +41 -0
  17. package/dist/claude/index.js.map +1 -0
  18. package/dist/claude/transcript.d.ts +33 -0
  19. package/dist/claude/transcript.d.ts.map +1 -0
  20. package/dist/claude/transcript.js +217 -0
  21. package/dist/claude/transcript.js.map +1 -0
  22. package/dist/claude/turn.d.ts +57 -0
  23. package/dist/claude/turn.d.ts.map +1 -0
  24. package/dist/claude/turn.js +96 -0
  25. package/dist/claude/turn.js.map +1 -0
  26. package/dist/codex/attach.d.ts +29 -0
  27. package/dist/codex/attach.d.ts.map +1 -0
  28. package/dist/codex/attach.js +78 -0
  29. package/dist/codex/attach.js.map +1 -0
  30. package/dist/codex/connect.d.ts +71 -0
  31. package/dist/codex/connect.d.ts.map +1 -0
  32. package/dist/codex/connect.js +93 -0
  33. package/dist/codex/connect.js.map +1 -0
  34. package/dist/codex/index.d.ts +60 -0
  35. package/dist/codex/index.d.ts.map +1 -0
  36. package/dist/codex/index.js +53 -0
  37. package/dist/codex/index.js.map +1 -0
  38. package/dist/codex/process.d.ts +41 -0
  39. package/dist/codex/process.d.ts.map +1 -0
  40. package/dist/codex/process.js +66 -0
  41. package/dist/codex/process.js.map +1 -0
  42. package/dist/codex/protocol.d.ts +133 -0
  43. package/dist/codex/protocol.d.ts.map +1 -0
  44. package/dist/codex/protocol.js +189 -0
  45. package/dist/codex/protocol.js.map +1 -0
  46. package/dist/codex/rpc.d.ts +51 -0
  47. package/dist/codex/rpc.d.ts.map +1 -0
  48. package/dist/codex/rpc.js +133 -0
  49. package/dist/codex/rpc.js.map +1 -0
  50. package/dist/codex/transcript.d.ts +38 -0
  51. package/dist/codex/transcript.d.ts.map +1 -0
  52. package/dist/codex/transcript.js +246 -0
  53. package/dist/codex/transcript.js.map +1 -0
  54. package/dist/codex/turn.d.ts +35 -0
  55. package/dist/codex/turn.d.ts.map +1 -0
  56. package/dist/codex/turn.js +132 -0
  57. package/dist/codex/turn.js.map +1 -0
  58. package/dist/content.d.ts +9 -0
  59. package/dist/content.d.ts.map +1 -0
  60. package/dist/content.js +8 -0
  61. package/dist/content.js.map +1 -0
  62. package/dist/forward-tool.d.ts +68 -0
  63. package/dist/forward-tool.d.ts.map +1 -0
  64. package/dist/forward-tool.js +57 -0
  65. package/dist/forward-tool.js.map +1 -0
  66. package/dist/handoff.d.ts +70 -0
  67. package/dist/handoff.d.ts.map +1 -0
  68. package/dist/handoff.js +241 -0
  69. package/dist/handoff.js.map +1 -0
  70. package/dist/index.d.ts +6 -0
  71. package/dist/index.d.ts.map +1 -0
  72. package/dist/index.js +6 -0
  73. package/dist/index.js.map +1 -0
  74. package/dist/progress.d.ts +42 -0
  75. package/dist/progress.d.ts.map +1 -0
  76. package/dist/progress.js +88 -0
  77. package/dist/progress.js.map +1 -0
  78. package/dist/schema.d.ts +267 -0
  79. package/dist/schema.d.ts.map +1 -0
  80. package/dist/schema.js +112 -0
  81. package/dist/schema.js.map +1 -0
  82. package/dist/session.d.ts +100 -0
  83. package/dist/session.d.ts.map +1 -0
  84. package/dist/session.js +316 -0
  85. package/dist/session.js.map +1 -0
  86. package/dist/worker.d.ts +69 -0
  87. package/dist/worker.d.ts.map +1 -0
  88. package/dist/worker.js +9 -0
  89. package/dist/worker.js.map +1 -0
  90. package/package.json +74 -3
  91. package/README.md +0 -3
@@ -0,0 +1,246 @@
1
+ /**
2
+ * Codex thread items and stored threads as `TranscriptEntry`s. Pure.
3
+ *
4
+ * Agent text becomes `text`; reasoning is left out; commands, file changes, MCP, dynamic tool,
5
+ * web search, image and subagent calls, and subagent starts, become a `toolCall` and its
6
+ * `toolResult`, sharing the item `id`; plans and compaction become `status`. Live user messages are not echoed (the pool
7
+ * records what it sends); stored ones are `prompt`s.
8
+ */
9
+ import { capped } from '../content.js';
10
+ import { errorInfoName } from './protocol.js';
11
+ /** Items that are a tool call with a result. */
12
+ const toolItems = new Set([
13
+ 'commandExecution',
14
+ 'fileChange',
15
+ 'mcpToolCall',
16
+ 'dynamicToolCall',
17
+ 'webSearch',
18
+ 'imageView',
19
+ 'imageGeneration',
20
+ 'collabAgentToolCall',
21
+ ]);
22
+ /**
23
+ * A subagent's start, as Codex reports it in multi-agent mode: shown as a call, so the subagent's
24
+ * entries have a call to nest under.
25
+ */
26
+ const isSubagentStart = (item) => item.type === 'subAgentActivity' && item.kind === 'started';
27
+ export const isToolItem = (item) => toolItems.has(item.type) || isSubagentStart(item);
28
+ /**
29
+ * The subagent threads an item starts: a `spawnAgent` call's receivers, or a started
30
+ * `subAgentActivity`'s thread (the form Codex 0.160.1 emits with current models). Empty for every
31
+ * other item.
32
+ */
33
+ export const spawnedThreads = (item) => {
34
+ if (item.type === 'collabAgentToolCall' && item.tool === 'spawnAgent') {
35
+ return item.receiverThreadIds ?? [];
36
+ }
37
+ return isSubagentStart(item) && item.agentThreadId ? [item.agentThreadId] : [];
38
+ };
39
+ const isRecord = (value) => typeof value === 'object' && value !== null;
40
+ /** A tool item's name and input as the transcript shows them. */
41
+ const callOf = (item) => {
42
+ switch (item.type) {
43
+ case 'commandExecution':
44
+ return { name: item.type, input: { command: item.command, cwd: item.cwd } };
45
+ case 'fileChange':
46
+ return {
47
+ name: item.type,
48
+ input: {
49
+ changes: (item.changes ?? []).map((change) => ({
50
+ path: change.path,
51
+ kind: change.kind?.type,
52
+ })),
53
+ },
54
+ };
55
+ case 'mcpToolCall':
56
+ return { name: `mcp:${item.server ?? ''}/${item.tool ?? ''}`, input: item.arguments ?? {} };
57
+ case 'dynamicToolCall':
58
+ return {
59
+ name: item.type,
60
+ input: { namespace: item.namespace, tool: item.tool, arguments: item.arguments },
61
+ };
62
+ case 'webSearch':
63
+ return { name: item.type, input: { query: item.query, action: item.action } };
64
+ case 'imageView':
65
+ return { name: item.type, input: { path: item.path } };
66
+ case 'imageGeneration':
67
+ return { name: item.type, input: { revisedPrompt: item.revisedPrompt } };
68
+ case 'subAgentActivity':
69
+ return {
70
+ name: item.type,
71
+ input: { kind: item.kind, agentThreadId: item.agentThreadId, agentPath: item.agentPath },
72
+ };
73
+ default:
74
+ return {
75
+ name: item.type,
76
+ input: {
77
+ tool: item.tool,
78
+ receiverThreadIds: item.receiverThreadIds,
79
+ prompt: item.prompt,
80
+ model: item.model,
81
+ reasoningEffort: item.reasoningEffort,
82
+ },
83
+ };
84
+ }
85
+ };
86
+ /** The text parts of MCP content blocks, else the blocks as JSON. */
87
+ const mcpText = (result) => {
88
+ if (!isRecord(result))
89
+ return '';
90
+ const content = result['content'];
91
+ if (!Array.isArray(content))
92
+ return JSON.stringify(result);
93
+ const texts = content.flatMap((block) => isRecord(block) && block['type'] === 'text' && typeof block['text'] === 'string'
94
+ ? [block['text']]
95
+ : []);
96
+ return texts.length === content.length ? texts.join('\n') : JSON.stringify(content);
97
+ };
98
+ const failedStatus = (item) => item.status === 'failed' || item.status === 'declined';
99
+ /** A tool item's result text and whether it failed. */
100
+ const resultOf = (item) => {
101
+ switch (item.type) {
102
+ case 'commandExecution':
103
+ return {
104
+ content: item.aggregatedOutput ?? '',
105
+ isError: failedStatus(item) || (typeof item.exitCode === 'number' && item.exitCode !== 0),
106
+ };
107
+ case 'fileChange':
108
+ return {
109
+ content: (item.changes ?? []).map((change) => change.diff ?? '').join('\n'),
110
+ isError: failedStatus(item),
111
+ };
112
+ case 'mcpToolCall':
113
+ return {
114
+ content: item.error?.message ?? mcpText(item.result),
115
+ isError: failedStatus(item) || (item.error !== undefined && item.error !== null),
116
+ };
117
+ case 'dynamicToolCall':
118
+ return {
119
+ content: (item.contentItems ?? []).flatMap((part) => part.text ?? []).join('\n'),
120
+ isError: failedStatus(item) || item.success === false,
121
+ };
122
+ case 'imageGeneration':
123
+ return {
124
+ content: item.savedPath ?? '',
125
+ isError: failedStatus(item) || (item.failure !== undefined && item.failure !== null),
126
+ };
127
+ case 'collabAgentToolCall':
128
+ return {
129
+ content: Object.entries(item.agentsStates ?? {})
130
+ .flatMap(([thread, state]) => state === undefined
131
+ ? []
132
+ : [`${thread}: ${state.status}${state.message ? `\n${state.message}` : ''}`])
133
+ .join('\n\n'),
134
+ isError: failedStatus(item),
135
+ };
136
+ default:
137
+ return { content: '', isError: failedStatus(item) };
138
+ }
139
+ };
140
+ export const toolCall = (item, parentToolUseId) => {
141
+ const { name, input } = callOf(item);
142
+ const text = capped(JSON.stringify(input ?? {}));
143
+ return {
144
+ _tag: 'toolCall',
145
+ parentToolUseId,
146
+ toolUseId: item.id,
147
+ name,
148
+ input: text.text,
149
+ truncated: text.truncated,
150
+ };
151
+ };
152
+ export const toolResult = (item, parentToolUseId) => {
153
+ const { content, isError } = resultOf(item);
154
+ const text = capped(content);
155
+ return {
156
+ _tag: 'toolResult',
157
+ parentToolUseId,
158
+ toolUseId: item.id,
159
+ content: text.text,
160
+ truncated: text.truncated,
161
+ isError,
162
+ };
163
+ };
164
+ /** A user message's text parts, joined by blank lines. */
165
+ const promptText = (item) => (item.content ?? [])
166
+ .flatMap((part) => isRecord(part) && part['type'] === 'text' && typeof part['text'] === 'string'
167
+ ? [part['text']]
168
+ : [])
169
+ .join('\n\n');
170
+ /**
171
+ * The entries of a finished item other than a tool call (those take a call and a result):
172
+ * text, plan and compaction status, and, for stored history only (`prompts`), user prompts.
173
+ */
174
+ export const completedEntries = (item, parentToolUseId, prompts) => {
175
+ switch (item.type) {
176
+ case 'agentMessage':
177
+ return item.text ? [{ _tag: 'text', parentToolUseId, text: item.text }] : [];
178
+ case 'plan':
179
+ return item.text ? [{ _tag: 'status', parentToolUseId, text: item.text }] : [];
180
+ case 'contextCompaction':
181
+ return [{ _tag: 'status', parentToolUseId, text: 'Context compacted.' }];
182
+ case 'userMessage': {
183
+ const text = promptText(item);
184
+ return prompts && text !== ''
185
+ ? [{ _tag: 'prompt', parentToolUseId, source: 'earlier', text }]
186
+ : [];
187
+ }
188
+ default:
189
+ return [];
190
+ }
191
+ };
192
+ /** A `turn/plan/updated` as one status line per step, after its explanation. */
193
+ export const planStatus = (explanation, plan) => [
194
+ ...(explanation ? [explanation] : []),
195
+ ...plan.map(({ step, status }) => `[${status}] ${step}`),
196
+ ].join('\n');
197
+ /**
198
+ * How a main-thread turn ended: `success`, `interrupted`, else Codex's own error name (falling back
199
+ * to `failed`), uninterpreted. `resetsAt` is attached to `usageLimitExceeded` when known.
200
+ */
201
+ export const turnEnd = (status, errorInfo, resetsAt) => {
202
+ if (status === 'completed')
203
+ return { _tag: 'turnEnd', parentToolUseId: null, outcome: 'success' };
204
+ if (status === 'interrupted') {
205
+ return { _tag: 'turnEnd', parentToolUseId: null, outcome: 'interrupted' };
206
+ }
207
+ const outcome = errorInfoName(errorInfo) ?? 'failed';
208
+ return outcome === 'usageLimitExceeded' && resetsAt !== undefined
209
+ ? { _tag: 'turnEnd', parentToolUseId: null, outcome, resetsAt }
210
+ : { _tag: 'turnEnd', parentToolUseId: null, outcome };
211
+ };
212
+ /**
213
+ * A stored thread and its subagents as entries. `threads` holds every thread's items in order,
214
+ * by thread ID. Each subagent's entries come right after the item that started it
215
+ * (before that call's result), nested under it. No `turnEnd` is invented, as for Claude Code.
216
+ */
217
+ export const historyEntries = (mainThreadId, threads) => {
218
+ const rendered = new Set();
219
+ const render = (threadId, parentToolUseId) => {
220
+ // A thread is shown once, even if several calls name it.
221
+ if (rendered.has(threadId))
222
+ return [];
223
+ rendered.add(threadId);
224
+ return (threads.get(threadId) ?? []).flatMap((item) => isToolItem(item)
225
+ ? [
226
+ toolCall(item, parentToolUseId),
227
+ ...spawnedThreads(item).flatMap((child) => render(child, item.id)),
228
+ toolResult(item, parentToolUseId),
229
+ ]
230
+ : completedEntries(item, parentToolUseId, true));
231
+ };
232
+ return render(mainThreadId, null);
233
+ };
234
+ /**
235
+ * A stored main thread's last answer: every agent message after its last user message, joined by
236
+ * blank lines (the same rule as for Claude Code), or `undefined` when there is none.
237
+ */
238
+ export const lastAnswer = (items) => {
239
+ const start = items.findLastIndex((item) => item.type === 'userMessage');
240
+ const answer = items
241
+ .slice(start + 1)
242
+ .flatMap((item) => (item.type === 'agentMessage' && item.text ? [item.text] : []))
243
+ .join('\n\n');
244
+ return answer === '' ? undefined : answer;
245
+ };
246
+ //# sourceMappingURL=transcript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transcript.js","sourceRoot":"","sources":["../../src/codex/transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAa,MAAM,eAAe,CAAC;AAEzD,gDAAgD;AAChD,MAAM,SAAS,GAAwB,IAAI,GAAG,CAAC;IAC7C,kBAAkB;IAClB,YAAY;IACZ,aAAa;IACb,iBAAiB;IACjB,WAAW;IACX,WAAW;IACX,iBAAiB;IACjB,qBAAqB;CACtB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,eAAe,GAAG,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,kBAAkB,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;AAEpG,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAU,EAAW,EAAE,CAChD,SAAS,CAAC,GAAG,CAAC,IAAI,C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,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;SAChB,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,cAAc,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SACjF,IAAI,CAAC,MAAM,CAAC,CAAC;IAChB,OAAO,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;AAC5C,CAAC,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { WorkerEvent } from '../worker.ts';
2
+ import { type Notification } from './protocol.ts';
3
+ export interface TurnState {
4
+ readonly mainThreadId: string;
5
+ /** The main thread's last status, `systemError` counting as `idle`. */
6
+ readonly mainIdle: boolean;
7
+ /** A main-thread `turn/completed` arrived since the latest main-thread `turn/started`. */
8
+ readonly turnCompleted: boolean;
9
+ /** `Settled` was the last activity reported. */
10
+ readonly settled: boolean;
11
+ /** Subagent threads by ID: busy or not. Present once any of its turn frames or its spawn is seen. */
12
+ readonly subagents: ReadonlyMap<string, boolean>;
13
+ /** Each known subagent thread's starting item (shown as a call). */
14
+ readonly spawnedBy: ReadonlyMap<string, string>;
15
+ /** Tool items whose call was shown on `item/started` and whose result is pending. */
16
+ readonly openCalls: ReadonlySet<string>;
17
+ /** Message IDs already reported consumed. */
18
+ readonly consumed: ReadonlySet<string>;
19
+ /** The reset time of the latest rate-limit snapshot's full window, if any. */
20
+ readonly resetsAt: number | undefined;
21
+ }
22
+ export declare const initialTurnState: (mainThreadId: string) => TurnState;
23
+ export type TrackerOutput = WorkerEvent
24
+ /** A main-thread turn completed: a held message may be sent again. */
25
+ | {
26
+ readonly _tag: 'MainTurnCompleted';
27
+ };
28
+ type Step = readonly [TurnState, ReadonlyArray<TrackerOutput>];
29
+ /**
30
+ * One notification: its entries and consumed messages, then `Settled` when it settles the worker,
31
+ * or again when it brought entries to an already settled worker.
32
+ */
33
+ export declare const step: (state: TurnState, notification: Notification) => Step;
34
+ export {};
35
+ //# sourceMappingURL=turn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn.d.ts","sourceRoot":"","sources":["../../src/codex/turn.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAkC,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAWlF,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,0FAA0F;IAC1F,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,gDAAgD;IAChD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,qGAAqG;IACrG,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjD,oEAAoE;IACpE,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChD,qFAAqF;IACrF,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACxC,6CAA6C;IAC7C,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAED,eAAO,MAAM,gBAAgB,iBAAkB,MAAM,KAAG,SAUtD,CAAC;AAEH,MAAM,MAAM,aAAa,GACrB,WAAW;AACb,sEAAsE;GACpE;IAAE,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAE3C,KAAK,IAAI,GAAG,SAAS,CAAC,SAAS,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC;AA+G/D;;;GAGG;AACH,eAAO,MAAM,IAAI,UAAW,SAAS,gBAAgB,YAAY,KAAG,IAUnE,CAAC"}
@@ -0,0 +1,132 @@
1
+ import { frameOf } from './protocol.js';
2
+ import { completedEntries, isToolItem, planStatus, spawnedThreads, toolCall, toolResult, turnEnd, } from './transcript.js';
3
+ export const initialTurnState = (mainThreadId) => ({
4
+ mainThreadId,
5
+ mainIdle: true,
6
+ turnCompleted: false,
7
+ settled: false,
8
+ subagents: new Map(),
9
+ spawnedBy: new Map(),
10
+ openCalls: new Set(),
11
+ consumed: new Set(),
12
+ resetsAt: undefined,
13
+ });
14
+ const entry = (value) => ({ _tag: 'Entry', entry: value });
15
+ /**
16
+ * Where a thread's entries nest: the main thread at the top level; a subagent under the item that
17
+ * started it, or, before that item is known, under its own thread ID. Never `null` for a
18
+ * subagent: top-level text becomes the forward result, which a subagent must never write.
19
+ */
20
+ const parentOf = (state, threadId) => threadId === state.mainThreadId ? null : (state.spawnedBy.get(threadId) ?? threadId);
21
+ /** Records the subagents an item starts: nesting, and busy while their turns are unseen. */
22
+ const noteSpawn = (state, item) => {
23
+ const children = spawnedThreads(item);
24
+ if (children.length === 0)
25
+ return state;
26
+ const spawnedBy = new Map(state.spawnedBy);
27
+ const subagents = new Map(state.subagents);
28
+ for (const child of children) {
29
+ spawnedBy.set(child, item.id);
30
+ if (!subagents.has(child))
31
+ subagents.set(child, true);
32
+ }
33
+ return { ...state, spawnedBy, subagents };
34
+ };
35
+ const consumedOf = (state, threadId, item) => {
36
+ const id = item.clientId;
37
+ if (threadId !== state.mainThreadId ||
38
+ id === undefined ||
39
+ id === null ||
40
+ state.consumed.has(id)) {
41
+ return [state, []];
42
+ }
43
+ return [
44
+ { ...state, consumed: new Set([...state.consumed, id]) },
45
+ [{ _tag: 'Consumed', ids: [id] }],
46
+ ];
47
+ };
48
+ const onItem = (state, threadId, item, completed) => {
49
+ if (item.type === 'userMessage')
50
+ return consumedOf(state, threadId, item);
51
+ const next = noteSpawn(state, item);
52
+ const parent = parentOf(next, threadId);
53
+ if (!isToolItem(item)) {
54
+ return [next, completed ? completedEntries(item, parent, false).map(entry) : []];
55
+ }
56
+ if (!completed) {
57
+ return next.openCalls.has(item.id)
58
+ ? [next, []]
59
+ : [
60
+ { ...next, openCalls: new Set([...next.openCalls, item.id]) },
61
+ [entry(toolCall(item, parent))],
62
+ ];
63
+ }
64
+ const openCalls = new Set(next.openCalls);
65
+ const shown = openCalls.delete(item.id);
66
+ return [
67
+ { ...next, openCalls },
68
+ [...(shown ? [] : [entry(toolCall(item, parent))]), entry(toolResult(item, parent))],
69
+ ];
70
+ };
71
+ const setSubagent = (state, threadId, busy) => ({
72
+ ...state,
73
+ subagents: new Map(state.subagents).set(threadId, busy),
74
+ });
75
+ const onFrame = (state, frame) => {
76
+ const main = 'threadId' in frame && frame.threadId === state.mainThreadId;
77
+ switch (frame._tag) {
78
+ case 'TurnStarted':
79
+ return main
80
+ ? [{ ...state, turnCompleted: false, settled: false }, []]
81
+ : [{ ...setSubagent(state, frame.threadId, true), settled: false }, []];
82
+ case 'TurnCompleted':
83
+ return main
84
+ ? [
85
+ { ...state, turnCompleted: true },
86
+ [
87
+ entry(turnEnd(frame.status, frame.errorInfo, state.resetsAt)),
88
+ { _tag: 'MainTurnCompleted' },
89
+ ],
90
+ ]
91
+ : [setSubagent(state, frame.threadId, false), []];
92
+ case 'ThreadStatus':
93
+ return main
94
+ ? [{ ...state, mainIdle: frame.status === 'idle' || frame.status === 'systemError' }, []]
95
+ : [state, []];
96
+ case 'ItemStarted':
97
+ case 'ItemCompleted':
98
+ return onItem(state, frame.threadId, frame.item, frame._tag === 'ItemCompleted');
99
+ case 'PlanUpdated':
100
+ return [
101
+ state,
102
+ [
103
+ entry({
104
+ _tag: 'status',
105
+ parentToolUseId: parentOf(state, frame.threadId),
106
+ text: planStatus(frame.explanation, frame.plan),
107
+ }),
108
+ ],
109
+ ];
110
+ case 'RateLimits':
111
+ return [{ ...state, resetsAt: frame.fullResetsAt }, []];
112
+ }
113
+ };
114
+ const busySubagent = (state) => [...state.subagents.values()].some((busy) => busy);
115
+ /**
116
+ * One notification: its entries and consumed messages, then `Settled` when it settles the worker,
117
+ * or again when it brought entries to an already settled worker.
118
+ */
119
+ export const step = (state, notification) => {
120
+ const frame = frameOf(notification.method, notification.params);
121
+ if (frame === undefined)
122
+ return [state, []];
123
+ const [next, outputs] = onFrame(state, frame);
124
+ const entries = outputs.some((output) => output._tag === 'Entry');
125
+ if (next.settled)
126
+ return [next, entries ? [...outputs, { _tag: 'Settled' }] : outputs];
127
+ if (next.turnCompleted && next.mainIdle && !busySubagent(next)) {
128
+ return [{ ...next, settled: true }, [...outputs, { _tag: 'Settled' }]];
129
+ }
130
+ return [next, outputs];
131
+ };
132
+ //# sourceMappingURL=turn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn.js","sourceRoot":"","sources":["../../src/codex/turn.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAA4C,MAAM,eAAe,CAAC;AAClF,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,cAAc,EACd,QAAQ,EACR,UAAU,EACV,OAAO,GACR,MAAM,iBAAiB,CAAC;AAsBzB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,YAAoB,EAAa,EAAE,CAAC,CAAC;IACpE,YAAY;IACZ,QAAQ,EAAE,IAAI;IACd,aAAa,EAAE,KAAK;IACpB,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI,GAAG,EAAE;IACpB,SAAS,EAAE,IAAI,GAAG,EAAE;IACpB,SAAS,EAAE,IAAI,GAAG,EAAE;IACpB,QAAQ,EAAE,IAAI,GAAG,EAAE;IACnB,QAAQ,EAAE,SAAS;CACpB,CAAC,CAAC;AASH,MAAM,KAAK,GAAG,CAAC,KAAsB,EAAiB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAE3F;;;;GAIG;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AC,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;AAE9F;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAgB,EAAE,YAA0B,EAAQ,EAAE;IACzE,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAChE,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC5C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;IAClE,IAAI,IAAI,CAAC,OAAO;QAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACvF,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/D,OAAO,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACzB,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /** Capping of transcript content, shared by every worker type's transcript mapping. Pure. */
2
+ /** The cap on a tool call's input JSON and a tool result's text, in characters. */
3
+ export declare const maxContentLength = 4000;
4
+ /** `text` cut to `maxContentLength`, with `truncated` saying whether the cap applied. */
5
+ export declare const capped: (text: string) => {
6
+ text: string;
7
+ truncated: boolean;
8
+ };
9
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAE7F,mFAAmF;AACnF,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC,yFAAyF;AACzF,eAAO,MAAM,MAAM,SAAU,MAAM;;;CAGH,CAAC"}
@@ -0,0 +1,8 @@
1
+ /** Capping of transcript content, shared by every worker type's transcript mapping. Pure. */
2
+ /** The cap on a tool call's input JSON and a tool result's text, in characters. */
3
+ export const maxContentLength = 4000;
4
+ /** `text` cut to `maxContentLength`, with `truncated` saying whether the cap applied. */
5
+ export const capped = (text) => text.length > maxContentLength
6
+ ? { text: text.slice(0, maxContentLength), truncated: true }
7
+ : { text, truncated: false };
8
+ //# sourceMappingURL=content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAE7F,mFAAmF;AACnF,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAErC,yFAAyF;AACzF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE,CACrC,IAAI,CAAC,MAAM,GAAG,gBAAgB;IAC5B,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE;IAC5D,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { Effect, type Schedule, type Scope, type Stream } from 'effect';
2
+ import { LanguageModel } from 'effect/ai';
3
+ import type { ToolDefinition } from '@yourtechbudstudio/fluidcast-core/generation';
4
+ import type { Tool, ToolFault } from '@yourtechbudstudio/fluidcast-harness';
5
+ import type { Handoff, HandoffPrompt } from './handoff.ts';
6
+ import { ForwardInput, ForwardResult, type TranscriptMessage, type WorkerSummary } from './schema.ts';
7
+ import type { WorkerSetupError, WorkerType } from './worker.ts';
8
+ export interface ForwardAgentToolOptions {
9
+ /** The worker that does the thinking and the work, such as `claudeWorker(…)`. */
10
+ readonly worker: WorkerType;
11
+ /**
12
+ * An existing session to resume as the worker, such as a fork of a recorded Claude Code session:
13
+ * its history opens the transcript, and its first forward resumes it in its recorded directory.
14
+ * No worker connects until then. Absent: a new session.
15
+ */
16
+ readonly session?: {
17
+ readonly sessionId: string;
18
+ };
19
+ /**
20
+ * Progress snapshots while the worker is busy: when to write one (default
21
+ * `defaultProgressSchedule`) and the writer's system prompt (default `defaultProgressPrompt`; a
22
+ * preset may supply its own).
23
+ */
24
+ readonly progress?: {
25
+ readonly schedule?: Schedule.Schedule<unknown>;
26
+ readonly prompt?: string;
27
+ };
28
+ /** Reshapes each hand-off. Synchronous and pure; a throw halts the conversation. Default: `{ prompt: handoff.rendered }`. */
29
+ readonly hook?: (handoff: Handoff) => HandoffPrompt;
30
+ }
31
+ /** A read-only view of the worker for applications (the reference apps' Worker view). */
32
+ export interface WorkerHandle {
33
+ /** The worker's summary now, then again whenever its status or session ID changes. */
34
+ readonly status: Stream.Stream<WorkerSummary>;
35
+ /** The worker's transcript: a snapshot, then appended entries. */
36
+ readonly transcript: Stream.Stream<TranscriptMessage>;
37
+ /**
38
+ * Completes once, with the fault, when the worker's single connection ends; never otherwise. A
39
+ * turn that fails without ending the connection is not a fault. Unlike the tool's `faults`, it
40
+ * also reports a fault that ended an open forward, so a host (e.g. one that instruments its
41
+ * worker per invocation) can tell when the worker is gone.
42
+ */
43
+ readonly fault: Effect.Effect<ToolFault>;
44
+ /**
45
+ * The native session ID the worker knows now: the resumed one, or the one `SessionStarted`
46
+ * reported; `null` before either. A plain read, so a host can read the final ID after the worker's
47
+ * scope has closed, which `status` cannot give.
48
+ */
49
+ readonly sessionId: Effect.Effect<string | null>;
50
+ }
51
+ export interface ForwardAgentTool {
52
+ /** Accepts no client commands (it has no `command`), so the Harness rejects every one. */
53
+ readonly tool: Tool<ForwardInput, ForwardResult>;
54
+ readonly worker: WorkerHandle;
55
+ }
56
+ /**
57
+ * The half of the Forward Agent tool the model sees, without a worker: its mechanics only. When to
58
+ * forward, what to say while waiting and how to present the agent's replies are the
59
+ * configuration's (a preset's). For rendering prompts without starting a worker.
60
+ */
61
+ export declare const forwardAgentDefinition: ToolDefinition<ForwardInput, ForwardResult>;
62
+ /**
63
+ * The Forward Agent tool: one worker (the agent) behind one model-facing `forward_agent` action
64
+ * with no fields. Its resources live in the current scope, which must outlive the Harness session
65
+ * (acquire it first). The `LanguageModel` writes progress snapshots.
66
+ */
67
+ export declare const forwardAgentTool: (options: ForwardAgentToolOptions) => Effect.Effect<ForwardAgentTool, WorkerSetupError, LanguageModel.LanguageModel | Scope.Scope>;
68
+ //# sourceMappingURL=forward-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forward-tool.d.ts","sourceRoot":"","sources":["../src/forward-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,QAAQ,EAAE,KAAK,KAAK,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAE5E,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EACL,YAAY,EACZ,aAAa,EAEb,KAAK,iBAAiB,EACtB,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,M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B,KAC/B,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,CAAC,aAAa,GAAG,KAAK,CAAC,KAAK,CA2B1F,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { Effect } from 'effect';
2
+ import { LanguageModel } from 'effect/ai';
3
+ import { defaultProgressPrompt, defaultProgressSchedule } from './progress.js';
4
+ import { ForwardInput, ForwardResult, forwardToolName, } from './schema.js';
5
+ import { makeWorkerSession } from './session.js';
6
+ /** What the model reads for a result: the agent's messages as it wrote them, never split or summarised. */
7
+ const renderForwardResult = ({ messages }) => messages.length === 0 ? '(No reply was written.)' : messages.join('\n\n');
8
+ /**
9
+ * The half of the Forward Agent tool the model sees, without a worker: its mechanics only. When to
10
+ * forward, what to say while waiting and how to present the agent's replies are the
11
+ * configuration's (a preset's). For rendering prompts without starting a worker.
12
+ */
13
+ export const forwardAgentDefinition = {
14
+ name: forwardToolName,
15
+ input: ForwardInput,
16
+ guidelines: [
17
+ `\`${forwardToolName}\` (just \`{"type":"${forwardToolName}"}\`, no fields) hands the agent your conversation since the last \`${forwardToolName}\`, including the listener's answers.`,
18
+ ],
19
+ result: ForwardResult,
20
+ renderResult: renderForwardResult,
21
+ // Every earlier call reads back with no fields, so a field the model added once never
22
+ // becomes the precedent for the next.
23
+ renderCall: () => ({}),
24
+ };
25
+ /**
26
+ * The Forward Agent tool: one worker (the agent) behind one model-facing `forward_agent` action
27
+ * with no fields. Its resources live in the current scope, which must outlive the Harness session
28
+ * (acquire it first). The `LanguageModel` writes progress snapshots.
29
+ */
30
+ export const forwardAgentTool = (options) => Effect.gen(function* () {
31
+ const session = yield* makeWorkerSession({
32
+ type: options.worker,
33
+ sessionId: options.session?.sessionId,
34
+ hook: options.hook ?? ((handoff) => ({ prompt: handoff.rendered })),
35
+ schedule: options.progress?.schedule ?? defaultProgressSchedule,
36
+ progressPrompt: options.progress?.prompt ?? defaultProgressPrompt,
37
+ model: yield* LanguageModel.LanguageModel,
38
+ });
39
+ const tool = {
40
+ ...forwardAgentDefinition,
41
+ policy: { blocking: false, response: 'all', replay: false },
42
+ assign: session.assign,
43
+ context: session.context,
44
+ faults: session.faults,
45
+ run: session.run,
46
+ };
47
+ return {
48
+ tool,
49
+ worker: {
50
+ status: session.status,
51
+ transcript: session.transcript,
52
+ fault: session.fault,
53
+ sessionId: session.sessionId,
54
+ },
55
+ };
56
+ });
57
+ //# sourceMappingURL=forward-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forward-tool.js","sourceRoot":"","sources":["../src/forward-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA0C,MAAM,QAAQ,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EACL,YAAY,EACZ,aAAa,EACb,eAAe,GAGhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAoDjD,2GAA2G;AAC3G,MAAM,mBAAmB,GAAG,CAAC,EAAE,QAAQ,EAAiB,EAAU,EAAE,CAClE,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAE5E;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAgD;IACjF,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,YAAY;IACnB,UAAU,EAAE;QACV,KAAK,eAAe,uBAAuB,eAAe,uEAAuE,eAAe,uCAAuC;KACxL;IACD,MAAM,EAAE,aAAa;IACrB,YAAY,EAAE,mBAAmB;IACjC,sFAAsF;IACtF,sCAAsC;IACtC,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAA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