@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.
- package/LICENSE +201 -0
- package/dist/claude/attach.d.ts +24 -0
- package/dist/claude/attach.d.ts.map +1 -0
- package/dist/claude/attach.js +25 -0
- package/dist/claude/attach.js.map +1 -0
- package/dist/claude/connect.d.ts +52 -0
- package/dist/claude/connect.d.ts.map +1 -0
- package/dist/claude/connect.js +93 -0
- package/dist/claude/connect.js.map +1 -0
- package/dist/claude/failure.d.ts +35 -0
- package/dist/claude/failure.d.ts.map +1 -0
- package/dist/claude/failure.js +42 -0
- package/dist/claude/failure.js.map +1 -0
- package/dist/claude/index.d.ts +30 -0
- package/dist/claude/index.d.ts.map +1 -0
- package/dist/claude/index.js +41 -0
- package/dist/claude/index.js.map +1 -0
- package/dist/claude/transcript.d.ts +33 -0
- package/dist/claude/transcript.d.ts.map +1 -0
- package/dist/claude/transcript.js +217 -0
- package/dist/claude/transcript.js.map +1 -0
- package/dist/claude/turn.d.ts +57 -0
- package/dist/claude/turn.d.ts.map +1 -0
- package/dist/claude/turn.js +96 -0
- package/dist/claude/turn.js.map +1 -0
- package/dist/codex/attach.d.ts +29 -0
- package/dist/codex/attach.d.ts.map +1 -0
- package/dist/codex/attach.js +78 -0
- package/dist/codex/attach.js.map +1 -0
- package/dist/codex/connect.d.ts +71 -0
- package/dist/codex/connect.d.ts.map +1 -0
- package/dist/codex/connect.js +93 -0
- package/dist/codex/connect.js.map +1 -0
- package/dist/codex/index.d.ts +60 -0
- package/dist/codex/index.d.ts.map +1 -0
- package/dist/codex/index.js +53 -0
- package/dist/codex/index.js.map +1 -0
- package/dist/codex/process.d.ts +41 -0
- package/dist/codex/process.d.ts.map +1 -0
- package/dist/codex/process.js +66 -0
- package/dist/codex/process.js.map +1 -0
- package/dist/codex/protocol.d.ts +133 -0
- package/dist/codex/protocol.d.ts.map +1 -0
- package/dist/codex/protocol.js +189 -0
- package/dist/codex/protocol.js.map +1 -0
- package/dist/codex/rpc.d.ts +51 -0
- package/dist/codex/rpc.d.ts.map +1 -0
- package/dist/codex/rpc.js +133 -0
- package/dist/codex/rpc.js.map +1 -0
- package/dist/codex/transcript.d.ts +38 -0
- package/dist/codex/transcript.d.ts.map +1 -0
- package/dist/codex/transcript.js +246 -0
- package/dist/codex/transcript.js.map +1 -0
- package/dist/codex/turn.d.ts +35 -0
- package/dist/codex/turn.d.ts.map +1 -0
- package/dist/codex/turn.js +132 -0
- package/dist/codex/turn.js.map +1 -0
- package/dist/content.d.ts +9 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/content.js +8 -0
- package/dist/content.js.map +1 -0
- package/dist/forward-tool.d.ts +68 -0
- package/dist/forward-tool.d.ts.map +1 -0
- package/dist/forward-tool.js +57 -0
- package/dist/forward-tool.js.map +1 -0
- package/dist/handoff.d.ts +70 -0
- package/dist/handoff.d.ts.map +1 -0
- package/dist/handoff.js +238 -0
- package/dist/handoff.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/progress.d.ts +42 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +88 -0
- package/dist/progress.js.map +1 -0
- package/dist/schema.d.ts +267 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +112 -0
- package/dist/schema.js.map +1 -0
- package/dist/session.d.ts +100 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +316 -0
- package/dist/session.js.map +1 -0
- package/dist/worker.d.ts +69 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +9 -0
- package/dist/worker.js.map +1 -0
- package/package.json +74 -3
- package/README.md +0 -3
package/dist/session.js
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The worker session: the one worker's state, busy periods (one Harness execution each), its reader
|
|
3
|
+
* fiber, faults, and the Worker streams.
|
|
4
|
+
*
|
|
5
|
+
* All state, including the worker's transcript, is one `SubscriptionRef`. Every decision is one
|
|
6
|
+
* atomic `modify` that records its transcript entries and returns the effects it implies (complete
|
|
7
|
+
* a `Deferred`, report a fault), which run right after it. That linearises `assign` (under the
|
|
8
|
+
* Harness lock), reader events, context sampling, progress snapshots and the Worker streams without
|
|
9
|
+
* a second lock, and the transcript's order is the order of the decisions.
|
|
10
|
+
*/
|
|
11
|
+
import { Deferred, Effect, FiberHandle, Option, Queue, Stream, SubscriptionRef, } from 'effect';
|
|
12
|
+
import { uuidv7 } from '@yourtechbudstudio/fluidcast-core/actions';
|
|
13
|
+
import { ToolError, ToolFault, } from '@yourtechbudstudio/fluidcast-harness';
|
|
14
|
+
import { conversationSince, renderHandoff } from './handoff.js';
|
|
15
|
+
import { progressLoop } from './progress.js';
|
|
16
|
+
import { forwardErrorMessage, } from './schema.js';
|
|
17
|
+
export const statusOf = (worker) => worker.period !== undefined || worker.activity === 'running'
|
|
18
|
+
? 'working'
|
|
19
|
+
: worker.failed
|
|
20
|
+
? 'failed'
|
|
21
|
+
: 'idle';
|
|
22
|
+
const summaryOf = (worker) => ({
|
|
23
|
+
_tag: 'WorkerSummary',
|
|
24
|
+
status: statusOf(worker),
|
|
25
|
+
sessionId: worker.sessionId ?? null,
|
|
26
|
+
});
|
|
27
|
+
/** The per-iteration context: the worker's state, or nothing while it is idle. */
|
|
28
|
+
export const renderContext = (status) => {
|
|
29
|
+
switch (status) {
|
|
30
|
+
case 'idle':
|
|
31
|
+
return undefined;
|
|
32
|
+
case 'working':
|
|
33
|
+
return 'The agent is working.';
|
|
34
|
+
case 'failed':
|
|
35
|
+
return "The agent's last turn stopped with an error.";
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const withOpening = (state, executionId, opening) => ({
|
|
39
|
+
...state,
|
|
40
|
+
openings: new Map(state.openings).set(executionId, opening),
|
|
41
|
+
});
|
|
42
|
+
/** Builds the worker session in the current scope, attaching a preloaded session. Nothing connects. */
|
|
43
|
+
export const makeWorkerSession = (options) => Effect.gen(function* () {
|
|
44
|
+
const { type } = options;
|
|
45
|
+
const reader = yield* FiberHandle.make();
|
|
46
|
+
const faultQueue = yield* Queue.unbounded();
|
|
47
|
+
const inbox = yield* Queue.unbounded();
|
|
48
|
+
const attached = options.sessionId === undefined ? undefined : yield* type.attach(options.sessionId);
|
|
49
|
+
const state = yield* SubscriptionRef.make({
|
|
50
|
+
sessionId: options.sessionId,
|
|
51
|
+
cwd: attached?.cwd ?? type.cwd,
|
|
52
|
+
connected: false,
|
|
53
|
+
lastHandle: undefined,
|
|
54
|
+
activity: 'settled',
|
|
55
|
+
failed: false,
|
|
56
|
+
fault: undefined,
|
|
57
|
+
period: undefined,
|
|
58
|
+
undelivered: [],
|
|
59
|
+
transcript: attached?.history ?? [],
|
|
60
|
+
openings: new Map(),
|
|
61
|
+
});
|
|
62
|
+
/** Applies one decision atomically; the caller runs the effects it planned. */
|
|
63
|
+
const decide = (decision) => SubscriptionRef.modify(state, decision);
|
|
64
|
+
// The reader: one fiber for the worker's connection, in the session's scope.
|
|
65
|
+
const onEvent = (event) => Effect.flatten(decide((current) => applyEvent(current, event)));
|
|
66
|
+
/** A connection failure: fails the open period's `run`, else goes to `faults`. Exactly once. */
|
|
67
|
+
const onFault = (fault) => Effect.flatten(decide((current) => {
|
|
68
|
+
const report = current.period === undefined
|
|
69
|
+
? Queue.offer(faultQueue, fault)
|
|
70
|
+
: Deferred.fail(current.period.outcome, fault);
|
|
71
|
+
return [
|
|
72
|
+
Effect.asVoid(report).pipe(Effect.andThen(Effect.logWarning('worker faulted').pipe(Effect.annotateLogs({ reason: fault.reason })))),
|
|
73
|
+
{
|
|
74
|
+
...current,
|
|
75
|
+
activity: 'settled',
|
|
76
|
+
failed: true,
|
|
77
|
+
fault,
|
|
78
|
+
period: undefined,
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
}));
|
|
82
|
+
// Interruption (the session's scope closing) runs no handler: `catch` and `catchDefect` do not
|
|
83
|
+
// catch it. A worker connects exactly once (`connected`), so an ID known at connect time is a
|
|
84
|
+
// preloaded session to resume, and an unknown one is a new session: its `SessionStarted` can
|
|
85
|
+
// only arrive after this.
|
|
86
|
+
const connect = (worker) => type.connect({ cwd: worker.cwd, resume: worker.sessionId }, Stream.fromQueue(inbox)).pipe(Stream.runForEach(onEvent),
|
|
87
|
+
// An adapter must not end on its own.
|
|
88
|
+
Effect.andThen(Effect.fail(new ToolFault({ reason: 'WorkerEnded' }))), Effect.catch(onFault), Effect.catchDefect(() => onFault(new ToolFault({ reason: 'WorkerDefect' }))));
|
|
89
|
+
/**
|
|
90
|
+
* Places a reached forward call: a new busy period (`call.executionId`) or the open one. Runs
|
|
91
|
+
* under the Harness lock and never waits. Throws from the hook or `composeMessage` escape as
|
|
92
|
+
* defects, which the Harness turns into a halt.
|
|
93
|
+
*
|
|
94
|
+
* Joining is safe: the Harness reads its state and calls `assign` in one locked step, and an
|
|
95
|
+
* execution only finishes under that lock. The session removes a period in its `modify` before
|
|
96
|
+
* it completes the period's outcome. So a period it still sees as open is an open Harness
|
|
97
|
+
* execution of this tool.
|
|
98
|
+
*/
|
|
99
|
+
const assign = (_input, call) => Effect.gen(function* () {
|
|
100
|
+
// `lastHandle` changes only here, which the Harness lock serialises, so the hand-off built
|
|
101
|
+
// from this read stays valid.
|
|
102
|
+
const known = yield* SubscriptionRef.get(state);
|
|
103
|
+
if (known.fault !== undefined) {
|
|
104
|
+
const failure = known.fault;
|
|
105
|
+
yield* SubscriptionRef.update(state, (current) => withOpening(current, call.executionId, { _tag: 'Refused', failure }));
|
|
106
|
+
return call.executionId;
|
|
107
|
+
}
|
|
108
|
+
const conversation = conversationSince(call.state, known.lastHandle, call.handle);
|
|
109
|
+
const isFirstMessage = known.lastHandle === undefined;
|
|
110
|
+
const prompt = options.hook({
|
|
111
|
+
conversation,
|
|
112
|
+
isFirstMessage,
|
|
113
|
+
rendered: renderHandoff({ conversation, isFirstMessage }),
|
|
114
|
+
});
|
|
115
|
+
const text = type.composeMessage(prompt.prompt, prompt.modifiers ?? []);
|
|
116
|
+
const outcome = yield* Deferred.make();
|
|
117
|
+
const id = uuidv7();
|
|
118
|
+
// Recorded in the same decision that sends it, so it always precedes the reply.
|
|
119
|
+
const sentEntry = {
|
|
120
|
+
_tag: 'prompt',
|
|
121
|
+
parentToolUseId: null,
|
|
122
|
+
source: 'fluidcast',
|
|
123
|
+
text,
|
|
124
|
+
};
|
|
125
|
+
const decision = yield* decide((current) => {
|
|
126
|
+
// The worker faulted since the first read.
|
|
127
|
+
if (current.fault !== undefined) {
|
|
128
|
+
return [
|
|
129
|
+
{ _tag: 'Refused' },
|
|
130
|
+
withOpening(current, call.executionId, {
|
|
131
|
+
_tag: 'Refused',
|
|
132
|
+
failure: current.fault,
|
|
133
|
+
}),
|
|
134
|
+
];
|
|
135
|
+
}
|
|
136
|
+
if (current.period !== undefined) {
|
|
137
|
+
const period = { ...current.period, sent: new Set(current.period.sent).add(id) };
|
|
138
|
+
return [
|
|
139
|
+
{
|
|
140
|
+
_tag: 'Sent',
|
|
141
|
+
executionId: period.executionId,
|
|
142
|
+
joined: true,
|
|
143
|
+
connect: undefined,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
...current,
|
|
147
|
+
lastHandle: call.handle,
|
|
148
|
+
period,
|
|
149
|
+
transcript: [...current.transcript, sentEntry],
|
|
150
|
+
},
|
|
151
|
+
];
|
|
152
|
+
}
|
|
153
|
+
const opened = {
|
|
154
|
+
...current,
|
|
155
|
+
connected: true,
|
|
156
|
+
lastHandle: call.handle,
|
|
157
|
+
transcript: [...current.transcript, sentEntry],
|
|
158
|
+
undelivered: [],
|
|
159
|
+
period: {
|
|
160
|
+
executionId: call.executionId,
|
|
161
|
+
sent: new Set([id]),
|
|
162
|
+
consumed: new Set(),
|
|
163
|
+
texts: current.undelivered,
|
|
164
|
+
lastTurnEnd: undefined,
|
|
165
|
+
outcome,
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
return [
|
|
169
|
+
{
|
|
170
|
+
_tag: 'Sent',
|
|
171
|
+
executionId: call.executionId,
|
|
172
|
+
joined: false,
|
|
173
|
+
connect: current.connected ? undefined : opened,
|
|
174
|
+
},
|
|
175
|
+
withOpening(opened, call.executionId, {
|
|
176
|
+
_tag: 'Period',
|
|
177
|
+
outcome,
|
|
178
|
+
transcriptStart: current.transcript.length,
|
|
179
|
+
}),
|
|
180
|
+
];
|
|
181
|
+
});
|
|
182
|
+
if (decision._tag === 'Refused')
|
|
183
|
+
return call.executionId;
|
|
184
|
+
yield* Queue.offer(inbox, { id, text });
|
|
185
|
+
// Only the decision that set `connected` forks, so the worker has exactly one reader.
|
|
186
|
+
if (decision.connect !== undefined) {
|
|
187
|
+
yield* FiberHandle.run(reader, connect(decision.connect));
|
|
188
|
+
}
|
|
189
|
+
yield* Effect.logInfo('forward sent').pipe(Effect.annotateLogs({ handle: call.handle, joined: decision.joined }));
|
|
190
|
+
return decision.executionId;
|
|
191
|
+
});
|
|
192
|
+
/** Awaits the period `assign` opened for this execution, with progress while it runs. */
|
|
193
|
+
const run = (_input, context) => Effect.gen(function* () {
|
|
194
|
+
const opening = yield* decide((current) => {
|
|
195
|
+
const openings = new Map(current.openings);
|
|
196
|
+
const found = openings.get(context.executionId);
|
|
197
|
+
openings.delete(context.executionId);
|
|
198
|
+
return [found, { ...current, openings }];
|
|
199
|
+
});
|
|
200
|
+
if (opening === undefined) {
|
|
201
|
+
return yield* Effect.die(new Error('the forward execution has no opening from assign'));
|
|
202
|
+
}
|
|
203
|
+
if (opening._tag === 'Refused')
|
|
204
|
+
return yield* Effect.fail(opening.failure);
|
|
205
|
+
return yield* Effect.scoped(Effect.gen(function* () {
|
|
206
|
+
yield* Effect.forkScoped(progressLoop({
|
|
207
|
+
schedule: options.schedule,
|
|
208
|
+
prompt: options.progressPrompt,
|
|
209
|
+
model: options.model,
|
|
210
|
+
transcript: transcriptNow,
|
|
211
|
+
start: opening.transcriptStart,
|
|
212
|
+
offer: context.progress,
|
|
213
|
+
}));
|
|
214
|
+
return yield* Deferred.await(opening.outcome);
|
|
215
|
+
}));
|
|
216
|
+
});
|
|
217
|
+
const transcriptNow = SubscriptionRef.get(state).pipe(Effect.map((current) => current.transcript));
|
|
218
|
+
const status = SubscriptionRef.changes(state).pipe(Stream.map(summaryOf), Stream.changesWith((a, b) => a.status === b.status && a.sessionId === b.sessionId));
|
|
219
|
+
// Every emission is the whole append-only array, so a skipped value loses no entries.
|
|
220
|
+
const transcript = SubscriptionRef.changes(state).pipe(Stream.map((current) => current.transcript), Stream.mapAccum(() => undefined, (seen, entries) => {
|
|
221
|
+
if (seen === undefined) {
|
|
222
|
+
return [entries.length, [{ _tag: 'TranscriptSnapshot', entries }]];
|
|
223
|
+
}
|
|
224
|
+
const added = entries.slice(seen);
|
|
225
|
+
return [
|
|
226
|
+
entries.length,
|
|
227
|
+
added.length === 0 ? [] : [{ _tag: 'TranscriptAppended', entries: added }],
|
|
228
|
+
];
|
|
229
|
+
}));
|
|
230
|
+
// Every fault is recorded in the state, whether or not a period was open (`onFault`), so this
|
|
231
|
+
// sees the ones `faults` does not carry. A failed turn sets `failed` without a `fault`.
|
|
232
|
+
const fault = SubscriptionRef.changes(state).pipe(Stream.map((current) => current.fault), Stream.filter((recorded) => recorded !== undefined), Stream.runHead, Effect.flatMap(Option.match({ onNone: () => Effect.never, onSome: Effect.succeed })));
|
|
233
|
+
// A plain read, not a subscription: it still works after the scope closed, when the reader
|
|
234
|
+
// fiber is gone and the value can no longer change.
|
|
235
|
+
const sessionId = SubscriptionRef.get(state).pipe(Effect.map((current) => current.sessionId ?? null));
|
|
236
|
+
return {
|
|
237
|
+
assign,
|
|
238
|
+
run,
|
|
239
|
+
context: SubscriptionRef.get(state).pipe(Effect.map((current) => renderContext(statusOf(current)))),
|
|
240
|
+
faults: Stream.fromQueue(faultQueue),
|
|
241
|
+
status,
|
|
242
|
+
transcript,
|
|
243
|
+
fault,
|
|
244
|
+
sessionId,
|
|
245
|
+
};
|
|
246
|
+
});
|
|
247
|
+
/** One reader event as a decision: the next state, and the effect that completes a period. */
|
|
248
|
+
const applyEvent = (current, event) => {
|
|
249
|
+
const period = current.period;
|
|
250
|
+
switch (event._tag) {
|
|
251
|
+
// Identity only: neither activity nor the transcript.
|
|
252
|
+
case 'SessionStarted':
|
|
253
|
+
return [Effect.void, { ...current, sessionId: event.sessionId }];
|
|
254
|
+
case 'Entry': {
|
|
255
|
+
const { entry } = event;
|
|
256
|
+
const topLevel = entry.parentToolUseId === null;
|
|
257
|
+
const next = period === undefined || !topLevel
|
|
258
|
+
? period
|
|
259
|
+
: entry._tag === 'text'
|
|
260
|
+
? { ...period, texts: [...period.texts, entry.text] }
|
|
261
|
+
: entry._tag === 'turnEnd'
|
|
262
|
+
? { ...period, lastTurnEnd: entry }
|
|
263
|
+
: period;
|
|
264
|
+
// Text with no period to join waits for the next one.
|
|
265
|
+
const undelivered = period === undefined && topLevel && entry._tag === 'text'
|
|
266
|
+
? [...current.undelivered, entry.text]
|
|
267
|
+
: current.undelivered;
|
|
268
|
+
return [
|
|
269
|
+
Effect.void,
|
|
270
|
+
{
|
|
271
|
+
...current,
|
|
272
|
+
activity: 'running',
|
|
273
|
+
period: next,
|
|
274
|
+
undelivered,
|
|
275
|
+
transcript: [...current.transcript, entry],
|
|
276
|
+
},
|
|
277
|
+
];
|
|
278
|
+
}
|
|
279
|
+
case 'Consumed': {
|
|
280
|
+
if (period === undefined)
|
|
281
|
+
return [Effect.void, current];
|
|
282
|
+
const consumed = new Set(period.consumed);
|
|
283
|
+
for (const id of event.ids)
|
|
284
|
+
if (period.sent.has(id))
|
|
285
|
+
consumed.add(id);
|
|
286
|
+
return [Effect.void, { ...current, period: { ...period, consumed } }];
|
|
287
|
+
}
|
|
288
|
+
case 'Settled': {
|
|
289
|
+
const settled = { ...current, activity: 'settled' };
|
|
290
|
+
if (period === undefined)
|
|
291
|
+
return [Effect.void, settled];
|
|
292
|
+
const unconsumed = [...period.sent].filter((id) => !period.consumed.has(id)).length;
|
|
293
|
+
if (unconsumed > 0) {
|
|
294
|
+
// Superseded: a later message is still to be taken in, so the period continues.
|
|
295
|
+
return [
|
|
296
|
+
Effect.logInfo('worker result superseded').pipe(Effect.annotateLogs({ unconsumed })),
|
|
297
|
+
settled,
|
|
298
|
+
];
|
|
299
|
+
}
|
|
300
|
+
const turnEnd = period.lastTurnEnd;
|
|
301
|
+
const failed = turnEnd !== undefined && turnEnd.outcome !== 'success';
|
|
302
|
+
const complete = failed
|
|
303
|
+
? Deferred.fail(period.outcome, new ToolError({
|
|
304
|
+
message: forwardErrorMessage({
|
|
305
|
+
outcome: turnEnd.outcome,
|
|
306
|
+
resetsAt: turnEnd.resetsAt,
|
|
307
|
+
messages: period.texts,
|
|
308
|
+
}),
|
|
309
|
+
}))
|
|
310
|
+
: Deferred.succeed(period.outcome, { messages: period.texts });
|
|
311
|
+
// The period leaves the state before its outcome completes (see `assign`).
|
|
312
|
+
return [Effect.asVoid(complete), { ...settled, failed, period: undefined }];
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,QAAQ,EACR,MAAM,EACN,WAAW,EACX,MAAM,EACN,KAAK,EACL,MAAM,EACN,eAAe,GAGhB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EACL,SAAS,EACT,SAAS,GAGV,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAoC,MAAM,cAAc,CAAC;AAClG,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,mBAAmB,GAOpB,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,OAAO,EAAE,mBAAmB,CAAC;wBAC3B,OAAO,EAAE,OAAO,CAAC,OAAO;wBACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;wBAC1B,QAAQ,EAAE,MAAM,CAAC,KAAK;qBACvB,CAAC;iBACH,CAAC,CACH;gBACH,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;YACjE,2EAA2E;YAC3E,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC;AACH,CAAC,CAAC"}
|
package/dist/worker.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** The adapter contract between the SDK-neutral Forward tool and one kind of worker (an agent SDK). */
|
|
2
|
+
import { Schema, type Effect, type Stream } from 'effect';
|
|
3
|
+
import type { ToolFault } from '@yourtechbudstudio/fluidcast-harness';
|
|
4
|
+
import type { Modifier } from './handoff.ts';
|
|
5
|
+
import type { TranscriptEntry } from './schema.ts';
|
|
6
|
+
/** One message for the worker. `id` is a UUID the worker reports back in `Consumed`. */
|
|
7
|
+
export interface WorkerMessage {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly text: string;
|
|
10
|
+
}
|
|
11
|
+
/** What a worker reports while its connection runs. */
|
|
12
|
+
export type WorkerEvent =
|
|
13
|
+
/** A normalised transcript item. A turn's end is a `turnEnd` entry. */
|
|
14
|
+
{
|
|
15
|
+
readonly _tag: 'Entry';
|
|
16
|
+
readonly entry: TranscriptEntry;
|
|
17
|
+
}
|
|
18
|
+
/** Messages a turn has taken in. */
|
|
19
|
+
| {
|
|
20
|
+
readonly _tag: 'Consumed';
|
|
21
|
+
readonly ids: ReadonlyArray<string>;
|
|
22
|
+
}
|
|
23
|
+
/** Idle, with no live background work, and a turn's result seen. */
|
|
24
|
+
| {
|
|
25
|
+
readonly _tag: 'Settled';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The agent's ID for a new session, once, before or with the connection's first entry. The agent
|
|
29
|
+
* owns the ID: a new worker has none until this arrives. Optional on resume, where it must equal
|
|
30
|
+
* the resumed ID.
|
|
31
|
+
*/
|
|
32
|
+
| {
|
|
33
|
+
readonly _tag: 'SessionStarted';
|
|
34
|
+
readonly sessionId: string;
|
|
35
|
+
};
|
|
36
|
+
/** One kind of worker, such as Claude Code. */
|
|
37
|
+
export interface WorkerType {
|
|
38
|
+
/** Where a new worker runs. */
|
|
39
|
+
readonly cwd: string;
|
|
40
|
+
/**
|
|
41
|
+
* The exact message text for a prompt and the hook's modifiers, in this worker type's syntax.
|
|
42
|
+
* Throws when the type cannot express the modifiers (a hook defect, which halts).
|
|
43
|
+
*/
|
|
44
|
+
readonly composeMessage: (prompt: string, modifiers: ReadonlyArray<Modifier>) => string;
|
|
45
|
+
/** Preload: checks an existing session and reads its directory and history. Starts no turn. */
|
|
46
|
+
readonly attach: (sessionId: string) => Effect.Effect<{
|
|
47
|
+
readonly cwd: string;
|
|
48
|
+
readonly history: ReadonlyArray<TranscriptEntry>;
|
|
49
|
+
}, WorkerSetupError>;
|
|
50
|
+
/**
|
|
51
|
+
* Runs one worker process for as long as the stream is consumed: it reads `input`, and its
|
|
52
|
+
* finalizer closes the process. An end or failure of the process fails the stream with a
|
|
53
|
+
* `ToolFault`; interruption is teardown and records nothing. `resume` is the session to continue,
|
|
54
|
+
* or `undefined` for a new session, whose ID the agent reports with `SessionStarted`.
|
|
55
|
+
*/
|
|
56
|
+
readonly connect: (worker: {
|
|
57
|
+
readonly cwd: string;
|
|
58
|
+
readonly resume: string | undefined;
|
|
59
|
+
}, input: Stream.Stream<WorkerMessage>) => Stream.Stream<WorkerEvent, ToolFault>;
|
|
60
|
+
}
|
|
61
|
+
declare const WorkerSetupError_base: Schema.Class<WorkerSetupError, Schema.TaggedStruct<"WorkerSetupError", {
|
|
62
|
+
readonly sessionId: Schema.String;
|
|
63
|
+
readonly reason: Schema.Literals<readonly ["SessionNotFound", "SessionUnreadable"]>;
|
|
64
|
+
}>, import("effect/Cause").YieldableError>;
|
|
65
|
+
/** The worker could not be set up: the session to preload cannot be attached. */
|
|
66
|
+
export declare class WorkerSetupError extends WorkerSetupError_base {
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA,uGAAuG;AACvG,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAEtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,wFAAwF;AACxF,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,uDAAuD;AACvD,MAAM,MAAM,WAAW;AACrB,uEAAuE;AACrE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAA;CAAE;AAC7D,oCAAoC;GAClC;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAAE;AACpE,oEAAoE;GAClE;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE;AAC9B;;;;GAIG;GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpE,+CAA+C;AAC/C,MAAM,WAAW,UAAU;IACzB,+BAA+B;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,KAAK,MAAM,CAAC;IACxF,+FAA+F;IAC/F,QAAQ,CAAC,MAAM,EAAE,CACf,SAAS,EAAE,MAAM,KACd,MAAM,CAAC,MAAM,CAChB;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,eAAe,CAAC,CAAA;KAAE,EAC1E,gBAAgB,CACjB,CAAC;IACF;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,CAChB,MAAM,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,EACrE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,KAChC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;CAC5C;;;;;AAED,iFAAiF;AACjF,qBAAa,gBAAiB,SAAQ,qBAGpC;CAAG"}
|
package/dist/worker.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The adapter contract between the SDK-neutral Forward tool and one kind of worker (an agent SDK). */
|
|
2
|
+
import { Schema } from 'effect';
|
|
3
|
+
/** The worker could not be set up: the session to preload cannot be attached. */
|
|
4
|
+
export class WorkerSetupError extends Schema.TaggedError()('WorkerSetupError', {
|
|
5
|
+
sessionId: Schema.String,
|
|
6
|
+
reason: Schema.Literals(['SessionNotFound', 'SessionUnreadable']),
|
|
7
|
+
}) {
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA,uGAAuG;AACvG,OAAO,EAAE,MAAM,EAA4B,MAAM,QAAQ,CAAC;AAwD1D,iFAAiF;AACjF,MAAM,OAAO,gBAAiB,SAAQ,MAAM,CAAC,WAAW,EAAoB,CAAC,kBAAkB,EAAE;IAC/F,SAAS,EAAE,MAAM,CAAC,MAAM;IACxB,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;CAClE,CAAC;CAAG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,77 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yourtechbudstudio/fluidcast-tool-agent",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"author": "YourTechBud",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/YourTechBudStudio/Fluidcast.git",
|
|
9
|
+
"directory": "packages/tool-agent"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./schema": {
|
|
23
|
+
"types": "./dist/schema.d.ts",
|
|
24
|
+
"default": "./dist/schema.js"
|
|
25
|
+
},
|
|
26
|
+
"./claude": {
|
|
27
|
+
"types": "./dist/claude/index.d.ts",
|
|
28
|
+
"default": "./dist/claude/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./codex": {
|
|
31
|
+
"types": "./dist/codex/index.d.ts",
|
|
32
|
+
"default": "./dist/codex/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@anthropic-ai/claude-agent-sdk": "^0.3.283",
|
|
40
|
+
"@anthropic-ai/sdk": "0.127.0",
|
|
41
|
+
"@modelcontextprotocol/sdk": "1.30.0",
|
|
42
|
+
"@types/node": "26.4.1",
|
|
43
|
+
"@yourtechbudstudio/fluidcast-core": "0.0.1",
|
|
44
|
+
"@yourtechbudstudio/fluidcast-harness": "0.0.1",
|
|
45
|
+
"@yourtechbudstudio/fluidcast-tool-ask": "0.0.1",
|
|
46
|
+
"@yourtechbudstudio/fluidcast-tool-show": "0.0.1",
|
|
47
|
+
"@yourtechbudstudio/fluidcast-typescript-config": "0.0.1",
|
|
48
|
+
"effect": "^4.0.2",
|
|
49
|
+
"oxfmt": "0.66.0",
|
|
50
|
+
"oxlint": "1.81.0",
|
|
51
|
+
"typescript": "7.0.2",
|
|
52
|
+
"zod": "4.6.5"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@anthropic-ai/claude-agent-sdk": "^0.3.283",
|
|
56
|
+
"@yourtechbudstudio/fluidcast-core": "0.0.1",
|
|
57
|
+
"@yourtechbudstudio/fluidcast-harness": "0.0.1",
|
|
58
|
+
"@yourtechbudstudio/fluidcast-tool-ask": "0.0.1",
|
|
59
|
+
"@yourtechbudstudio/fluidcast-tool-show": "0.0.1",
|
|
60
|
+
"effect": "^4.0.2"
|
|
61
|
+
},
|
|
62
|
+
"peerDependenciesMeta": {
|
|
63
|
+
"@anthropic-ai/claude-agent-sdk": {
|
|
64
|
+
"optional": true
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"scripts": {
|
|
68
|
+
"build": "tsc --project tsconfig.build.json",
|
|
69
|
+
"check": "pnpm lint && pnpm build && pnpm typecheck && pnpm test && pnpm format:check",
|
|
70
|
+
"dev": "tsc --watch --preserveWatchOutput --project tsconfig.build.json",
|
|
71
|
+
"fix": "oxlint . --fix && oxfmt --write .",
|
|
72
|
+
"format:check": "oxfmt --check .",
|
|
73
|
+
"lint": "oxlint . --deny-warnings",
|
|
74
|
+
"test": "node --test \"src/**/*.test.ts\"",
|
|
75
|
+
"typecheck": "tsc --project tsconfig.json"
|
|
76
|
+
}
|
|
6
77
|
}
|
package/README.md
DELETED