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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +238 -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,70 @@
1
+ import { type SessionState } from '@yourtechbudstudio/fluidcast-harness/protocol';
2
+ import { AskInput, type AskCommand } from '@yourtechbudstudio/fluidcast-tool-ask/schema';
3
+ import { ShowInput } from '@yourtechbudstudio/fluidcast-tool-show/schema';
4
+ /** One item of the conversation the worker is handed, in log order. */
5
+ export type ConversationEntry = {
6
+ /** What the voice said, as the worker. */
7
+ readonly kind: 'voice';
8
+ /** The speaker's name, when several speakers are configured. */
9
+ readonly speaker: string | undefined;
10
+ readonly text: string;
11
+ } | {
12
+ readonly kind: 'show';
13
+ readonly input: ShowInput;
14
+ /** What session state proves: the client reported a render, has not reported yet, or reported a failure. */
15
+ readonly status: 'rendered' | 'awaiting' | 'failed';
16
+ readonly failure?: string;
17
+ } | {
18
+ readonly kind: 'question';
19
+ readonly input: AskInput;
20
+ readonly answer: AskCommand | undefined;
21
+ } | {
22
+ readonly kind: 'user';
23
+ readonly text: string;
24
+ } | {
25
+ readonly kind: 'interruption';
26
+ readonly during: 'speech' | 'wait';
27
+ } | {
28
+ /** Another tool's outcome (not Show, Ask or Forward). */
29
+ readonly kind: 'toolOutcome';
30
+ readonly tool: string;
31
+ readonly outcome: 'result' | 'error';
32
+ readonly text: string;
33
+ };
34
+ /**
35
+ * A skill or command token, such as `brainstorm`. The prompt itself is what it receives as arguments.
36
+ * A worker type decides how many one message takes; Claude Code takes one.
37
+ */
38
+ export interface Modifier {
39
+ readonly name: string;
40
+ }
41
+ /** Everything the hook receives about one message to the worker. */
42
+ export interface Handoff {
43
+ /**
44
+ * The conversation since the last forward, or all of it for the worker's first message: what the
45
+ * voice said and showed, and the listener's own words.
46
+ */
47
+ readonly conversation: ReadonlyArray<ConversationEntry>;
48
+ /** The default text (`renderHandoff`). */
49
+ readonly rendered: string;
50
+ /** No earlier message was sent to the worker in this session (a new or preloaded worker). */
51
+ readonly isFirstMessage: boolean;
52
+ }
53
+ /** What the hook returns: the prompt, and skill tokens the worker type composes with it. */
54
+ export interface HandoffPrompt {
55
+ readonly prompt: string;
56
+ readonly modifiers?: ReadonlyArray<Modifier>;
57
+ }
58
+ /**
59
+ * Pure: the entries after the forward call `since` (or the whole conversation when `undefined`) up
60
+ * to, not including, the forward call `handle`. Forward's own results are left out: the worker wrote
61
+ * them. So is the voice's speech in reply to a progress update: it retells the worker's progress.
62
+ */
63
+ export declare const conversationSince: (state: SessionState, since: string | undefined, handle: string) => ReadonlyArray<ConversationEntry>;
64
+ /** One entry as Markdown. An interruption renders standalone; `renderConversation` merges one into the line it cut. */
65
+ export declare const renderEntry: (entry: ConversationEntry) => string;
66
+ /** The entries as Markdown, one blank line apart; a speech interruption marks the line it cut. */
67
+ export declare const renderConversation: (entries: ReadonlyArray<ConversationEntry>) => string;
68
+ /** The default text the worker receives. Nothing is XML-escaped. */
69
+ export declare const renderHandoff: (handoff: Omit<Handoff, 'rendered'>) => string;
70
+ //# sourceMappingURL=handoff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handoff.d.ts","sourceRoot":"","sources":["../src/handoff.ts"],"names":[],"mappings":"AAOA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,QAAQ,EAGR,KAAK,UAAU,EAChB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,SAAS,EAAgB,MAAM,+CAA+C,CAAC;AAIxF,uEAAuE;AACvE,MAAM,MAAM,iBAAiB,GACzB;IACE,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,gEAAgE;IAChE,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,Q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AC,CAAC;CAC9C;AAWD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,UACrB,YAAY,SACZ,MAAM,GAAG,SAAS,UACjB,MAAM,KACb,aAAa,CAAC,iBAAiB,CA6GjC,CAAC;AA6CF,uHAAuH;AACvH,eAAO,MAAM,WAAW,UAAW,iBAAiB,KAAG,MA8BtD,CAAC;AAEF,kGAAkG;AAClG,eAAO,MAAM,kBAAkB,YAAa,aAAa,CAAC,iBAAiB,CAAC,KAAG,MAc9E,CAAC;AAEF,oEAAoE;AACpE,eAAO,MAAM,aAAa,YAAa,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,KAAG,MA6BlE,CAAC"}
@@ -0,0 +1,238 @@
1
+ /**
2
+ * The hand-off: which part of the conversation the worker has not seen yet, as ordered entries, and
3
+ * the default Markdown it receives. Built by code from session state, never summarised.
4
+ */
5
+ import { Schema } from 'effect';
6
+ import { effectiveActions, } from '@yourtechbudstudio/fluidcast-harness/protocol';
7
+ import { AskInput, AskResult, askToolName, } from '@yourtechbudstudio/fluidcast-tool-ask/schema';
8
+ import { ShowInput, showToolName } from '@yourtechbudstudio/fluidcast-tool-show/schema';
9
+ import { forwardToolName } from './schema.js';
10
+ const decodeShow = Schema.decodeUnknownOption(ShowInput);
11
+ const decodeAsk = Schema.decodeUnknownOption(AskInput);
12
+ const decodeAskResult = Schema.decodeUnknownOption(AskResult);
13
+ const isOutcome = (action) => action.type === 'tool_result' || action.type === 'tool_errored';
14
+ /**
15
+ * Pure: the entries after the forward call `since` (or the whole conversation when `undefined`) up
16
+ * to, not including, the forward call `handle`. Forward's own results are left out: the worker wrote
17
+ * them. So is the voice's speech in reply to a progress update: it retells the worker's progress.
18
+ */
19
+ export const conversationSince = (state, since, handle) => {
20
+ const actions = effectiveActions(state);
21
+ // Calls anywhere in the log: a result in the window may answer a call before it.
22
+ const calls = new Map();
23
+ const invalid = new Set();
24
+ for (const action of state.actions) {
25
+ if (action.type !== 'tool_call')
26
+ continue;
27
+ calls.set(action.handle, action);
28
+ const valid = action.tool === showToolName
29
+ ? decodeShow(action.input)._tag === 'Some'
30
+ : action.tool === askToolName
31
+ ? decodeAsk(action.input)._tag === 'Some'
32
+ : true;
33
+ if (!valid)
34
+ invalid.add(action.handle);
35
+ }
36
+ const outcomes = [...state.actions, ...state.pendingResults].filter(isOutcome);
37
+ const outcomeOf = (call) => outcomes.find((outcome) => outcome.handles.includes(call));
38
+ const start = since === undefined ? -1 : findCall(actions, since);
39
+ const end = findCall(actions, handle);
40
+ const window = actions.slice(start + 1, end === -1 ? actions.length : end);
41
+ const speakerName = (id) => state.speakers.length > 1
42
+ ? (state.speakers.find((speaker) => speaker.id === id)?.name ?? id)
43
+ : undefined;
44
+ const entries = [];
45
+ let paragraphSpeaker;
46
+ // Whether the actions are the reply to a progress update: until the next input, or through a retry.
47
+ let answeringProgress = false;
48
+ const push = (entry) => {
49
+ entries.push(entry);
50
+ paragraphSpeaker = undefined;
51
+ };
52
+ for (const action of window) {
53
+ switch (action.type) {
54
+ case 'tool_progress':
55
+ answeringProgress = true;
56
+ break;
57
+ case 'speak': {
58
+ if (answeringProgress)
59
+ break;
60
+ const last = entries.at(-1);
61
+ if (last?.kind === 'voice' && paragraphSpeaker === action.speaker) {
62
+ entries[entries.length - 1] = { ...last, text: `${last.text} ${action.text}` };
63
+ }
64
+ else {
65
+ push({ kind: 'voice', speaker: speakerName(action.speaker), text: action.text });
66
+ paragraphSpeaker = action.speaker;
67
+ }
68
+ break;
69
+ }
70
+ case 'user_message':
71
+ answeringProgress = false;
72
+ push({ kind: 'user', text: action.text });
73
+ break;
74
+ case 'interrupted':
75
+ answeringProgress = false;
76
+ push({ kind: 'interruption', during: action.during });
77
+ break;
78
+ case 'tool_call': {
79
+ if (invalid.has(action.handle))
80
+ break;
81
+ if (action.tool === showToolName) {
82
+ const input = decodeShow(action.input);
83
+ if (input._tag === 'None')
84
+ break;
85
+ const outcome = outcomeOf(action.handle);
86
+ if (outcome?.type === 'tool_errored') {
87
+ push({ kind: 'show', input: input.value, status: 'failed', failure: outcome.message });
88
+ }
89
+ else {
90
+ const open = state.executions.some((execution) => execution.handles.includes(action.handle));
91
+ push({ kind: 'show', input: input.value, status: open ? 'awaiting' : 'rendered' });
92
+ }
93
+ }
94
+ else if (action.tool === askToolName) {
95
+ const input = decodeAsk(action.input);
96
+ if (input._tag === 'None')
97
+ break;
98
+ const outcome = outcomeOf(action.handle);
99
+ const result = outcome?.type === 'tool_result' ? decodeAskResult(outcome.result) : undefined;
100
+ push({
101
+ kind: 'question',
102
+ input: input.value,
103
+ answer: result?._tag === 'Some' ? result.value.answer : undefined,
104
+ });
105
+ }
106
+ break;
107
+ }
108
+ case 'tool_result':
109
+ case 'tool_errored': {
110
+ answeringProgress = false;
111
+ const folded = action.handles.some((call) => invalid.has(call) ||
112
+ calls.get(call)?.tool === forwardToolName ||
113
+ calls.get(call)?.tool === showToolName ||
114
+ calls.get(call)?.tool === askToolName);
115
+ if (!folded)
116
+ push(toolOutcome(action));
117
+ break;
118
+ }
119
+ // Other calls, context and failures are not conversation.
120
+ default:
121
+ break;
122
+ }
123
+ }
124
+ return entries;
125
+ };
126
+ const findCall = (actions, handle) => actions.findIndex((action) => action.type === 'tool_call' && action.handle === handle);
127
+ const toolOutcome = (action) => action.type === 'tool_errored'
128
+ ? { kind: 'toolOutcome', tool: action.tool, outcome: 'error', text: action.message }
129
+ : {
130
+ kind: 'toolOutcome',
131
+ tool: action.tool,
132
+ outcome: 'result',
133
+ text: JSON.stringify(action.result),
134
+ };
135
+ /** A fence one backtick longer than the longest backtick run in `content`, and at least three. */
136
+ const fenceFor = (content) => {
137
+ const longest = Math.max(0, ...[...content.matchAll(/`+/g)].map((run) => run[0].length));
138
+ return '`'.repeat(Math.max(3, longest + 1));
139
+ };
140
+ const showLabel = {
141
+ rendered: 'Shown to the user',
142
+ awaiting: "Being put on the user's screen, not yet confirmed",
143
+ failed: 'Show failed to render',
144
+ };
145
+ const renderAnswer = (answer) => {
146
+ if (answer === undefined)
147
+ return '(not answered yet)';
148
+ switch (answer.kind) {
149
+ case 'text':
150
+ return answer.text;
151
+ case 'choice':
152
+ case 'multi': {
153
+ const chosen = answer.kind === 'choice' ? answer.choice : answer.choices.join('; ');
154
+ const added = answer.text?.trim() ?? '';
155
+ return added === '' ? chosen : `${chosen} — they added: ${added}`;
156
+ }
157
+ case 'continue':
158
+ return 'Continue';
159
+ }
160
+ };
161
+ /** One entry as Markdown. An interruption renders standalone; `renderConversation` merges one into the line it cut. */
162
+ export const renderEntry = (entry) => {
163
+ switch (entry.kind) {
164
+ case 'voice':
165
+ return entry.speaker === undefined
166
+ ? `**Voice:** ${entry.text}`
167
+ : `**Voice (${entry.speaker}):** ${entry.text}`;
168
+ case 'interruption':
169
+ return '*(The user interrupted to say something.)*';
170
+ case 'show': {
171
+ const { title, format, content } = entry.input;
172
+ const titled = title === undefined ? '' : ` — "${title}"`;
173
+ const failure = entry.status === 'failed' ? ` ${entry.failure ?? ''}` : '';
174
+ const fence = fenceFor(content);
175
+ return `**${showLabel[entry.status]}** (${format})${titled}:${failure}\n${fence}${format}\n${content}\n${fence}`;
176
+ }
177
+ case 'question': {
178
+ const lines = [`**Question:** ${entry.input.question}`];
179
+ if (entry.input.kind === 'choice' || entry.input.kind === 'multi') {
180
+ lines.push(`Options: ${entry.input.options.map((option) => option.label).join(' · ')}`);
181
+ }
182
+ lines.push(`**Answer:** ${renderAnswer(entry.answer)}`);
183
+ return lines.join('\n');
184
+ }
185
+ case 'user':
186
+ return `**User:** ${entry.text}`;
187
+ case 'toolOutcome': {
188
+ const kind = entry.outcome === 'result' ? 'Result' : 'Error';
189
+ return `**${kind} from \`${entry.tool}\`:**\n${entry.text}`;
190
+ }
191
+ }
192
+ };
193
+ /** The entries as Markdown, one blank line apart; a speech interruption marks the line it cut. */
194
+ export const renderConversation = (entries) => {
195
+ const blocks = [];
196
+ entries.forEach((entry, index) => {
197
+ if (entry.kind === 'interruption' &&
198
+ entry.during === 'speech' &&
199
+ entries[index - 1]?.kind === 'voice') {
200
+ blocks[blocks.length - 1] += ' *(interrupted by the user)*';
201
+ }
202
+ else {
203
+ blocks.push(renderEntry(entry));
204
+ }
205
+ });
206
+ return blocks.join('\n\n');
207
+ };
208
+ /** The default text the worker receives. Nothing is XML-escaped. */
209
+ export const renderHandoff = (handoff) => {
210
+ const [lead, tag] = handoff.isFirstMessage
211
+ ? [
212
+ 'The user is talking with you through a voice conversation. A voice speaks to them as you, in the first person: it presents your responses in short spoken pieces, with material shown on their screen, and passes everything they say back to you. Here is that conversation so far.',
213
+ 'conversation_so_far',
214
+ ]
215
+ : [
216
+ 'Here is the voice conversation since the last message you received from it.',
217
+ 'conversation_since_last_message',
218
+ ];
219
+ const conversation = handoff.conversation.length === 0
220
+ ? '(Nothing new was said.)'
221
+ : renderConversation(handoff.conversation);
222
+ return [
223
+ lead,
224
+ '',
225
+ `<${tag}>`,
226
+ conversation,
227
+ `</${tag}>`,
228
+ '',
229
+ "Respond to the user's latest words. They are the user's own, and take precedence over anything the voice said or showed.",
230
+ '',
231
+ '- You are working unattended. The user hears and sees your response only through the voice, in pieces, so include everything needed in it.',
232
+ '- The voice adds nothing of its own. When the user asks to slow down, repeat or re-explain something, do it in your response.',
233
+ '- If anything said or shown to the user misrepresents your work, correct it in your response.',
234
+ '- Do not use the AskUserQuestion tool.',
235
+ '- Run tasks and shell commands in the foreground, not in the background.',
236
+ ].join('\n');
237
+ };
238
+ //# sourceMappingURL=handoff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handoff.js","sourceRoot":"","sources":["../src/handoff.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EACL,gBAAgB,GAGjB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,QAAQ,EACR,SAAS,EACT,WAAW,GAEZ,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,+C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OAAO,EACpC,CAAC;YACD,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,8BAA8B,CAAC;QAC9D,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;QAClC,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC,CAAC;AAEF,oEAAoE;AACpE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAkC,EAAU,EAAE;IAC1E,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,cAAc;QACxC,CAAC,CAAC;YACE,sRAAsR;YACtR,qBAAqB;SACtB;QACH,CAAC,CAAC;YACE,6EAA6E;YAC7E,iCAAiC;SAClC,CAAC;IACN,MAAM,YAAY,GAChB,OAAO,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC;QAC/B,CAAC,CAAC,yBAAyB;QAC3B,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/C,OAAO;QACL,IAAI;QACJ,EAAE;QACF,IAAI,GAAG,GAAG;QACV,YAAY;QACZ,KAAK,GAAG,GAAG;QACX,EAAE;QACF,0HAA0H;QAC1H,EAAE;QACF,4IAA4I;QAC5I,+HAA+H;QAC/H,+FAA+F;QAC/F,wCAAwC;QACxC,0EAA0E;KAC3E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { forwardAgentDefinition, forwardAgentTool, type ForwardAgentTool, type ForwardAgentToolOptions, type WorkerHandle, } from './forward-tool.ts';
2
+ export { renderConversation, renderEntry, renderHandoff, type ConversationEntry, type Handoff, type HandoffPrompt, type Modifier, } from './handoff.ts';
3
+ export { defaultProgressPrompt, defaultProgressSchedule } from './progress.ts';
4
+ export { WorkerSetupError, type WorkerEvent, type WorkerMessage, type WorkerType, } from './worker.ts';
5
+ export * from './schema.ts';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,QAAQ,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EACL,gBAAgB,EAChB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,UAAU,GAChB,MAAM,aAAa,CAAC;AACrB,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { forwardAgentDefinition, forwardAgentTool, } from './forward-tool.js';
2
+ export { renderConversation, renderEntry, renderHandoff, } from './handoff.js';
3
+ export { defaultProgressPrompt, defaultProgressSchedule } from './progress.js';
4
+ export { WorkerSetupError, } from './worker.js';
5
+ export * from './schema.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,gBAAgB,GAIjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,aAAa,GAKd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EACL,gBAAgB,GAIjB,MAAM,aAAa,CAAC;AACrB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Progress snapshots: while a busy period runs, a schedule asks a language model for one sentence
3
+ * describing the worker's recent transcript and offers it to the Harness, which accepts (uses or keeps) or drops it.
4
+ */
5
+ import { Effect, Schedule } from 'effect';
6
+ import { LanguageModel } from 'effect/ai';
7
+ import type { TranscriptEntry } from './schema.ts';
8
+ /**
9
+ * Ticks at 10, 20, 30, 45 and 60 s, then 90, 150, 270 s and so on (exponential backoff, base 30 s,
10
+ * factor 2), with no cap.
11
+ */
12
+ export declare const defaultProgressSchedule: Schedule.Schedule<unknown>;
13
+ /**
14
+ * The progress writer's default system prompt: one neutral sentence about the agent's activity. A
15
+ * preset may supply its own.
16
+ */
17
+ export declare const defaultProgressPrompt = "Say what an agent is doing right now, for someone listening. Reply with one standalone sentence in the present tense, under 20 words, with no preamble, quotes or markdown. Describe the activity, not the tools.";
18
+ /**
19
+ * The reply as one standalone sentence, or `undefined` when it is not one: empty, a line break,
20
+ * fewer than three words, over 200 characters, or more text after a sentence end. Surrounding
21
+ * quotes are stripped and a final `.` added when missing. Nothing is truncated: a cut sentence is
22
+ * a fragment.
23
+ */
24
+ export declare const oneSentence: (reply: string) => string | undefined;
25
+ /**
26
+ * Runs for as long as its fiber lives (the execution's scope). Each tick skips unless the
27
+ * transcript gained activity since the last *accepted* snapshot, so a dropped or rejected snapshot is
28
+ * retried on the next tick. Model failures are logged by identifiers and skipped, never faults;
29
+ * neither the entries nor the text are logged.
30
+ */
31
+ export declare const progressLoop: (options: {
32
+ readonly schedule: Schedule.Schedule<unknown>;
33
+ /** The system prompt that asks for one sentence (`defaultProgressPrompt`, or a preset's). */
34
+ readonly prompt: string;
35
+ readonly model: LanguageModel.LanguageModel;
36
+ /** Reads the worker's transcript as it is now. */
37
+ readonly transcript: Effect.Effect<ReadonlyArray<TranscriptEntry>>;
38
+ /** The period's first transcript index. */
39
+ readonly start: number;
40
+ readonly offer: (text: string) => Effect.Effect<boolean>;
41
+ }) => Effect.Effect<void>;
42
+ //# sourceMappingURL=progress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAO,QAAQ,EAAU,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAM9D,CAAC;AAKF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,sNACmL,CAAC;AAmBtN;;;;;GAKG;AACH,eAAO,MAAM,WAAW,UAAW,MAAM,KAAG,MAAM,GAAG,SASpD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,YAAa;IACpC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9C,6FAA6F;IAC7F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC;IAC5C,kDAAkD;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC;IACnE,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;CAC1D,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CA0ClB,CAAC"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Progress snapshots: while a busy period runs, a schedule asks a language model for one sentence
3
+ * describing the worker's recent transcript and offers it to the Harness, which accepts (uses or keeps) or drops it.
4
+ */
5
+ import { Effect, Ref, Schedule, Stream } from 'effect';
6
+ import { LanguageModel } from 'effect/ai';
7
+ /**
8
+ * Ticks at 10, 20, 30, 45 and 60 s, then 90, 150, 270 s and so on (exponential backoff, base 30 s,
9
+ * factor 2), with no cap.
10
+ */
11
+ export const defaultProgressSchedule = Schedule.concat(Schedule.spaced('10 seconds').pipe(Schedule.upTo({ times: 3 })), Schedule.concat(Schedule.spaced('15 seconds').pipe(Schedule.upTo({ times: 2 })), Schedule.exponential('30 seconds', 2)));
12
+ /** How many recent entries a snapshot describes. */
13
+ const snapshotEntries = 20;
14
+ /**
15
+ * The progress writer's default system prompt: one neutral sentence about the agent's activity. A
16
+ * preset may supply its own.
17
+ */
18
+ export const defaultProgressPrompt = 'Say what an agent is doing right now, for someone listening. Reply with one standalone sentence in the present tense, under 20 words, with no preamble, quotes or markdown. Describe the activity, not the tools.';
19
+ /** Entries that say what the worker is doing. Prompts, results and turn ends do not. */
20
+ const isActivity = (entry) => entry._tag === 'text' || entry._tag === 'toolCall' || entry._tag === 'status';
21
+ const describe = (entry) => {
22
+ switch (entry._tag) {
23
+ case 'text':
24
+ return entry.text.slice(0, 300);
25
+ case 'toolCall':
26
+ return `${entry.name}(${entry.input.slice(0, 120)})`;
27
+ case 'status':
28
+ return entry.text;
29
+ default:
30
+ return '';
31
+ }
32
+ };
33
+ /**
34
+ * The reply as one standalone sentence, or `undefined` when it is not one: empty, a line break,
35
+ * fewer than three words, over 200 characters, or more text after a sentence end. Surrounding
36
+ * quotes are stripped and a final `.` added when missing. Nothing is truncated: a cut sentence is
37
+ * a fragment.
38
+ */
39
+ export const oneSentence = (reply) => {
40
+ const text = reply
41
+ .trim()
42
+ .replace(/^["'“‘]+|["'”’]+$/g, '')
43
+ .trim();
44
+ if (text === '' || /[\r\n]/.test(text) || text.length > 200)
45
+ return undefined;
46
+ if (text.split(/\s+/).length < 3)
47
+ return undefined;
48
+ if (/[.!?]\s+\S/.test(text))
49
+ return undefined;
50
+ return /[.!?]$/.test(text) ? text : `${text}.`;
51
+ };
52
+ /**
53
+ * Runs for as long as its fiber lives (the execution's scope). Each tick skips unless the
54
+ * transcript gained activity since the last *accepted* snapshot, so a dropped or rejected snapshot is
55
+ * retried on the next tick. Model failures are logged by identifiers and skipped, never faults;
56
+ * neither the entries nor the text are logged.
57
+ */
58
+ export const progressLoop = (options) => Effect.gen(function* () {
59
+ const acceptedUpTo = yield* Ref.make(options.start);
60
+ const failed = (error) => Effect.logWarning('worker progress failed').pipe(Effect.annotateLogs({ error }), Effect.as(undefined));
61
+ const tick = Effect.gen(function* () {
62
+ const entries = yield* options.transcript;
63
+ if (!entries.slice(yield* Ref.get(acceptedUpTo)).some(isActivity))
64
+ return;
65
+ const lines = entries
66
+ .slice(options.start)
67
+ .filter(isActivity)
68
+ .slice(-snapshotEntries)
69
+ .map(describe);
70
+ // Streamed, like the voice model's own generation: some OpenAI-compatible servers (vLLM)
71
+ // send non-streaming replies that the compatible client rejects (`service_tier: null`).
72
+ const reply = yield* options.model
73
+ .streamText({
74
+ prompt: [
75
+ { role: 'system', content: options.prompt },
76
+ { role: 'user', content: lines.join('\n') },
77
+ ],
78
+ })
79
+ .pipe(Stream.runFold(() => '', (text, part) => (part.type === 'text-delta' ? text + part.delta : text)), Effect.timeout('30 seconds'), Effect.map((text) => text), Effect.catch((error) => failed(error._tag === 'AiError' ? error.reason._tag : error._tag)), Effect.catchDefect(() => failed('Defect')));
80
+ const text = reply === undefined ? undefined : oneSentence(reply);
81
+ if (text === undefined)
82
+ return;
83
+ if (yield* options.offer(text))
84
+ yield* Ref.set(acceptedUpTo, entries.length);
85
+ });
86
+ yield* Effect.schedule(tick, options.schedule);
87
+ });
88
+ //# sourceMappingURL=progress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress.js","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACv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