@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
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal decoders for the `codex app-server` messages the adapter reads, checked against bindings
|
|
3
|
+
* generated by `codex app-server generate-ts` (0.160.1). Lenient: only the fields used are declared,
|
|
4
|
+
* unknown fields are ignored, and a field the adapter can do without is optional and nullable.
|
|
5
|
+
*/
|
|
6
|
+
import { Option, Schema } from 'effect';
|
|
7
|
+
/** Optional and nullable: absent, `null` and `undefined` all mean "not known". */
|
|
8
|
+
const maybe = (schema) => Schema.optionalKey(Schema.NullOr(schema));
|
|
9
|
+
/**
|
|
10
|
+
* One `ThreadItem`, of any `type`, as one flat struct: the fields of every item kind the adapter
|
|
11
|
+
* maps, all optional. Fields whose type differs between kinds (`content`, `result`) are decoded
|
|
12
|
+
* loosely and read according to the item's `type`. Decode items with `itemOf`, never directly.
|
|
13
|
+
*/
|
|
14
|
+
export const Item = Schema.Struct({
|
|
15
|
+
type: Schema.String,
|
|
16
|
+
id: Schema.String,
|
|
17
|
+
// userMessage
|
|
18
|
+
clientId: maybe(Schema.String),
|
|
19
|
+
// userMessage: input parts (`{type, text}`); reasoning: strings. Read only for userMessage.
|
|
20
|
+
content: maybe(Schema.Array(Schema.Unknown)),
|
|
21
|
+
// agentMessage, plan
|
|
22
|
+
text: maybe(Schema.String),
|
|
23
|
+
// commandExecution
|
|
24
|
+
command: maybe(Schema.String),
|
|
25
|
+
cwd: maybe(Schema.String),
|
|
26
|
+
aggregatedOutput: maybe(Schema.String),
|
|
27
|
+
exitCode: maybe(Schema.Number),
|
|
28
|
+
// every tool item
|
|
29
|
+
status: maybe(Schema.String),
|
|
30
|
+
// fileChange
|
|
31
|
+
changes: maybe(Schema.Array(Schema.Struct({
|
|
32
|
+
path: Schema.String,
|
|
33
|
+
kind: maybe(Schema.Struct({ type: Schema.String })),
|
|
34
|
+
diff: maybe(Schema.String),
|
|
35
|
+
}))),
|
|
36
|
+
// mcpToolCall, dynamicToolCall, collabAgentToolCall
|
|
37
|
+
server: maybe(Schema.String),
|
|
38
|
+
tool: maybe(Schema.String),
|
|
39
|
+
namespace: maybe(Schema.String),
|
|
40
|
+
arguments: Schema.optionalKey(Schema.Unknown),
|
|
41
|
+
result: Schema.optionalKey(Schema.Unknown),
|
|
42
|
+
error: maybe(Schema.Struct({ message: Schema.String })),
|
|
43
|
+
contentItems: maybe(Schema.Array(Schema.Struct({ type: Schema.String, text: maybe(Schema.String) }))),
|
|
44
|
+
success: maybe(Schema.Boolean),
|
|
45
|
+
// webSearch
|
|
46
|
+
query: maybe(Schema.String),
|
|
47
|
+
action: Schema.optionalKey(Schema.Unknown),
|
|
48
|
+
// imageView, imageGeneration
|
|
49
|
+
path: maybe(Schema.String),
|
|
50
|
+
revisedPrompt: maybe(Schema.String),
|
|
51
|
+
savedPath: maybe(Schema.String),
|
|
52
|
+
failure: Schema.optionalKey(Schema.Unknown),
|
|
53
|
+
// collabAgentToolCall
|
|
54
|
+
receiverThreadIds: maybe(Schema.Array(Schema.String)),
|
|
55
|
+
prompt: maybe(Schema.String),
|
|
56
|
+
model: maybe(Schema.String),
|
|
57
|
+
reasoningEffort: maybe(Schema.String),
|
|
58
|
+
agentsStates: maybe(Schema.Record(Schema.String, Schema.Struct({ status: Schema.String, message: maybe(Schema.String) }))),
|
|
59
|
+
// subAgentActivity
|
|
60
|
+
kind: maybe(Schema.String),
|
|
61
|
+
agentThreadId: maybe(Schema.String),
|
|
62
|
+
agentPath: maybe(Schema.String),
|
|
63
|
+
});
|
|
64
|
+
/** Every item's identity: what remains of an item whose other fields do not decode. */
|
|
65
|
+
const ItemIdentity = Schema.Struct({ type: Schema.String, id: Schema.String });
|
|
66
|
+
const decodeFullItem = Schema.decodeUnknownOption(Item);
|
|
67
|
+
const decodeItemIdentity = Schema.decodeUnknownOption(ItemIdentity);
|
|
68
|
+
/**
|
|
69
|
+
* One item, decoded on its own so that it can never make a notification or a page of history
|
|
70
|
+
* unreadable: when a field has a shape the adapter does not expect, only the item's `type` and
|
|
71
|
+
* `id` are kept (its content is then shown empty or left out). `undefined`: not an item at all.
|
|
72
|
+
*/
|
|
73
|
+
export const itemOf = (value) => Option.getOrUndefined(Option.orElse(decodeFullItem(value), () => decodeItemIdentity(value)));
|
|
74
|
+
const ThreadScoped = { threadId: Schema.String };
|
|
75
|
+
const TurnNotification = Schema.Struct({
|
|
76
|
+
...ThreadScoped,
|
|
77
|
+
turn: Schema.Struct({
|
|
78
|
+
status: Schema.String,
|
|
79
|
+
error: maybe(Schema.Struct({ codexErrorInfo: Schema.optionalKey(Schema.Unknown) })),
|
|
80
|
+
}),
|
|
81
|
+
});
|
|
82
|
+
const ItemNotification = Schema.Struct({ ...ThreadScoped, item: Schema.Unknown });
|
|
83
|
+
const StatusNotification = Schema.Struct({
|
|
84
|
+
...ThreadScoped,
|
|
85
|
+
status: Schema.Struct({ type: Schema.String }),
|
|
86
|
+
});
|
|
87
|
+
const PlanNotification = Schema.Struct({
|
|
88
|
+
...ThreadScoped,
|
|
89
|
+
explanation: maybe(Schema.String),
|
|
90
|
+
plan: Schema.Array(Schema.Struct({ step: Schema.String, status: Schema.String })),
|
|
91
|
+
});
|
|
92
|
+
const Window = Schema.Struct({ usedPercent: Schema.Number, resetsAt: maybe(Schema.Number) });
|
|
93
|
+
const RateLimitsNotification = Schema.Struct({
|
|
94
|
+
rateLimits: Schema.Struct({ primary: maybe(Window), secondary: maybe(Window) }),
|
|
95
|
+
});
|
|
96
|
+
const decode = (schema) => (params) => Option.getOrUndefined(Schema.decodeUnknownOption(schema)(params));
|
|
97
|
+
const decodeTurn = decode(TurnNotification);
|
|
98
|
+
const decodeItem = decode(ItemNotification);
|
|
99
|
+
const decodeStatus = decode(StatusNotification);
|
|
100
|
+
const decodePlan = decode(PlanNotification);
|
|
101
|
+
const decodeRateLimits = decode(RateLimitsNotification);
|
|
102
|
+
const fullResetsAt = (windows) => {
|
|
103
|
+
const resets = windows.flatMap((window) => window !== null &&
|
|
104
|
+
window !== undefined &&
|
|
105
|
+
window.usedPercent >= 100 &&
|
|
106
|
+
typeof window.resetsAt === 'number'
|
|
107
|
+
? [window.resetsAt]
|
|
108
|
+
: []);
|
|
109
|
+
return resets.length === 0 ? undefined : Math.max(...resets);
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* The frame of one server notification, or `undefined` for a notification the tracker ignores
|
|
113
|
+
* (or one whose parameters do not decode).
|
|
114
|
+
*/
|
|
115
|
+
export const frameOf = (method, params) => {
|
|
116
|
+
switch (method) {
|
|
117
|
+
case 'turn/started': {
|
|
118
|
+
const turn = decodeTurn(params);
|
|
119
|
+
return turn && { _tag: 'TurnStarted', threadId: turn.threadId };
|
|
120
|
+
}
|
|
121
|
+
case 'turn/completed': {
|
|
122
|
+
const turn = decodeTurn(params);
|
|
123
|
+
return (turn && {
|
|
124
|
+
_tag: 'TurnCompleted',
|
|
125
|
+
threadId: turn.threadId,
|
|
126
|
+
status: turn.turn.status,
|
|
127
|
+
errorInfo: turn.turn.error?.codexErrorInfo,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
case 'item/started':
|
|
131
|
+
case 'item/completed': {
|
|
132
|
+
const notification = decodeItem(params);
|
|
133
|
+
const item = notification && itemOf(notification.item);
|
|
134
|
+
return (notification &&
|
|
135
|
+
item && {
|
|
136
|
+
_tag: method === 'item/started' ? 'ItemStarted' : 'ItemCompleted',
|
|
137
|
+
threadId: notification.threadId,
|
|
138
|
+
item,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
case 'thread/status/changed': {
|
|
142
|
+
const status = decodeStatus(params);
|
|
143
|
+
return (status && { _tag: 'ThreadStatus', threadId: status.threadId, status: status.status.type });
|
|
144
|
+
}
|
|
145
|
+
case 'turn/plan/updated': {
|
|
146
|
+
const plan = decodePlan(params);
|
|
147
|
+
return (plan && {
|
|
148
|
+
_tag: 'PlanUpdated',
|
|
149
|
+
threadId: plan.threadId,
|
|
150
|
+
explanation: plan.explanation ?? undefined,
|
|
151
|
+
plan: plan.plan,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
case 'account/rateLimits/updated': {
|
|
155
|
+
const limits = decodeRateLimits(params);
|
|
156
|
+
return (limits && {
|
|
157
|
+
_tag: 'RateLimits',
|
|
158
|
+
fullResetsAt: fullResetsAt([limits.rateLimits.primary, limits.rateLimits.secondary]),
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
default:
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
/** The name of a `codexErrorInfo`: the string itself, or the single key of its object form. */
|
|
166
|
+
export const errorInfoName = (info) => {
|
|
167
|
+
if (typeof info === 'string')
|
|
168
|
+
return info;
|
|
169
|
+
if (typeof info !== 'object' || info === null)
|
|
170
|
+
return undefined;
|
|
171
|
+
const [name] = Object.keys(info);
|
|
172
|
+
return name;
|
|
173
|
+
};
|
|
174
|
+
/** `thread/start` and `thread/resume` responses: the thread's ID. */
|
|
175
|
+
export const ThreadResponse = Schema.Struct({ thread: Schema.Struct({ id: Schema.String }) });
|
|
176
|
+
/** `thread/read` response: what Continue and preload need of a stored thread. */
|
|
177
|
+
export const ThreadReadResponse = Schema.Struct({
|
|
178
|
+
thread: Schema.Struct({
|
|
179
|
+
cwd: Schema.String,
|
|
180
|
+
model: maybe(Schema.String),
|
|
181
|
+
reasoningEffort: maybe(Schema.String),
|
|
182
|
+
}),
|
|
183
|
+
});
|
|
184
|
+
/** `thread/turns/list` response: one page of turns, oldest first when asked `asc`. Items: `itemOf`. */
|
|
185
|
+
export const TurnsPage = Schema.Struct({
|
|
186
|
+
data: Schema.Array(Schema.Struct({ items: Schema.Array(Schema.Unknown) })),
|
|
187
|
+
nextCursor: maybe(Schema.String),
|
|
188
|
+
});
|
|
189
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/codex/protocol.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,kFAAkF;AAClF,MAAM,KAAK,GAAG,CAAuB,MAAS,EAAE,EAAE,CAAC,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AM,CAAC,MAAM,CAAC;CACjC,CAAC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-RPC over an app-server transport: requests with IDs, notifications, and the server's own
|
|
3
|
+
* requests, each answered at once with a decline or cancel so nothing waits on a human. The
|
|
4
|
+
* app-server's framing has no `jsonrpc` field. Internal.
|
|
5
|
+
*/
|
|
6
|
+
import { Cause, Effect, Stream, type Scope } from 'effect';
|
|
7
|
+
import type { Transport } from './process.ts';
|
|
8
|
+
import type { Notification } from './protocol.ts';
|
|
9
|
+
declare const RpcFailure_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
10
|
+
readonly _tag: "RpcFailure";
|
|
11
|
+
} & Readonly<A>;
|
|
12
|
+
/** The server answered a request with an error; `message` is Codex's own text, or empty. */
|
|
13
|
+
export declare class RpcFailure extends RpcFailure_base<{
|
|
14
|
+
readonly method: string;
|
|
15
|
+
readonly code: number | undefined;
|
|
16
|
+
readonly message: string;
|
|
17
|
+
readonly data: unknown;
|
|
18
|
+
}> {
|
|
19
|
+
}
|
|
20
|
+
declare const RpcClosed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
21
|
+
readonly _tag: "RpcClosed";
|
|
22
|
+
} & Readonly<A>;
|
|
23
|
+
/** The process ended before answering. */
|
|
24
|
+
export declare class RpcClosed extends RpcClosed_base {
|
|
25
|
+
}
|
|
26
|
+
export interface Rpc {
|
|
27
|
+
readonly request: (method: string, params: unknown) => Effect.Effect<unknown, RpcFailure | RpcClosed>;
|
|
28
|
+
readonly notify: (method: string) => Effect.Effect<void>;
|
|
29
|
+
/** Every server notification in order; ends when the process ends. One consumer. */
|
|
30
|
+
readonly notifications: Stream.Stream<Notification>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The reply to a server request: the decline or cancel each request type expects, or an error
|
|
34
|
+
* where its type has none. Every request is answered, so nothing waits on a human.
|
|
35
|
+
*/
|
|
36
|
+
export declare const declineReply: (method: string) => {
|
|
37
|
+
readonly result: unknown;
|
|
38
|
+
} | {
|
|
39
|
+
readonly error: {
|
|
40
|
+
readonly code: number;
|
|
41
|
+
readonly message: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
/** A JSON-RPC client over `transport` for the scope: its reader runs until the transport ends. */
|
|
45
|
+
export declare const makeRpc: (transport: Transport) => Effect.Effect<Rpc, never, Scope.Scope>;
|
|
46
|
+
/** A `turn/start` refused because the running turn (a review or compaction) cannot be steered. */
|
|
47
|
+
export declare const isNotSteerable: (error: RpcFailure | RpcClosed) => boolean;
|
|
48
|
+
/** Opens the conversation: `initialize`, then `initialized`. */
|
|
49
|
+
export declare const initialize: (rpc: Rpc) => Effect.Effect<void, RpcClosed | RpcFailure, never>;
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=rpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../../src/codex/rpc.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,EAAkB,MAAM,EAAS,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAElF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;;;;AAElD,4FAA4F;AAC5F,qBAAa,UAAW,SAAQ,gBAA+B;IAC7D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB,CAAC;CAAG;;;;AAEL,0CAA0C;AAC1C,qBAAa,SAAU,SAAQ,cAA6B;CAAG;AAE/D,MAAM,WAAW,GAAG;IAClB,QAAQ,CAAC,OAAO,EAAE,CAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,KACZ,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAAC,CAAC;IACpD,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACzD,oFAAoF;IACpF,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;CACrD;AAKD;;;GAGG;AACH,eAAO,MAAM,YAAY,WACf,MAAM,KAEZ;IAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC5B;IAAE,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAoBxE,CAAC;AAeF,kGAAkG;AAClG,eAAO,MAAM,OAAO,cAAe,SAAS,KAAG,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CA6EhF,CAAC;AAaL,kGAAkG;AAClG,eAAO,MAAM,cAAc,UAAW,UAAU,GAAG,SAAS,KAAG,OAI9D,CAAC;AAEF,gEAAgE;AAChE,eAAO,MAAM,UAAU,QAAS,GAAG,uDAMiB,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-RPC over an app-server transport: requests with IDs, notifications, and the server's own
|
|
3
|
+
* requests, each answered at once with a decline or cancel so nothing waits on a human. The
|
|
4
|
+
* app-server's framing has no `jsonrpc` field. Internal.
|
|
5
|
+
*/
|
|
6
|
+
import { Cause, Data, Deferred, Effect, Queue, Stream } from 'effect';
|
|
7
|
+
/** The server answered a request with an error; `message` is Codex's own text, or empty. */
|
|
8
|
+
export class RpcFailure extends Data.TaggedError('RpcFailure') {
|
|
9
|
+
}
|
|
10
|
+
/** The process ended before answering. */
|
|
11
|
+
export class RpcClosed extends Data.TaggedError('RpcClosed') {
|
|
12
|
+
}
|
|
13
|
+
/** Why Fluidcast declines: it runs unattended, so no human can answer. */
|
|
14
|
+
const unattended = 'Fluidcast runs Codex unattended: no one can answer this request.';
|
|
15
|
+
/**
|
|
16
|
+
* The reply to a server request: the decline or cancel each request type expects, or an error
|
|
17
|
+
* where its type has none. Every request is answered, so nothing waits on a human.
|
|
18
|
+
*/
|
|
19
|
+
export const declineReply = (method) => {
|
|
20
|
+
switch (method) {
|
|
21
|
+
case 'item/commandExecution/requestApproval':
|
|
22
|
+
case 'item/fileChange/requestApproval':
|
|
23
|
+
return { result: { decision: 'decline' } };
|
|
24
|
+
case 'item/tool/requestUserInput':
|
|
25
|
+
return { result: { answers: {} } };
|
|
26
|
+
case 'mcpServer/elicitation/request':
|
|
27
|
+
return { result: { action: 'decline', content: null, ['_meta']: null } };
|
|
28
|
+
case 'item/tool/call':
|
|
29
|
+
return {
|
|
30
|
+
result: { contentItems: [{ type: 'inputText', text: unattended }], success: false },
|
|
31
|
+
};
|
|
32
|
+
case 'applyPatchApproval':
|
|
33
|
+
case 'execCommandApproval':
|
|
34
|
+
return { result: { decision: { denied: { rejection: unattended } } } };
|
|
35
|
+
default:
|
|
36
|
+
// Permission grants, auth refresh, attestation and anything newer: no decline exists.
|
|
37
|
+
return { error: { code: -32603, message: unattended } };
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const parse = (line) => {
|
|
41
|
+
try {
|
|
42
|
+
const value = JSON.parse(line);
|
|
43
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
44
|
+
? value
|
|
45
|
+
: undefined;
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
/** A JSON-RPC client over `transport` for the scope: its reader runs until the transport ends. */
|
|
52
|
+
export const makeRpc = (transport) => Effect.gen(function* () {
|
|
53
|
+
const pending = new Map();
|
|
54
|
+
let nextId = 0;
|
|
55
|
+
let closed = false;
|
|
56
|
+
const notifications = yield* Queue.unbounded();
|
|
57
|
+
const send = (message) => transport.write(JSON.stringify(message));
|
|
58
|
+
const onMessage = (message) => {
|
|
59
|
+
const method = message['method'];
|
|
60
|
+
const id = message['id'];
|
|
61
|
+
if (typeof method === 'string') {
|
|
62
|
+
if (id === undefined)
|
|
63
|
+
return Queue.offer(notifications, { method, params: message['params'] }).pipe(Effect.asVoid);
|
|
64
|
+
return send({ id, ...declineReply(method) }).pipe(Effect.andThen(Effect.logWarning('codex server request declined')), Effect.annotateLogs({ method }));
|
|
65
|
+
}
|
|
66
|
+
const waiting = typeof id === 'number' ? pending.get(id) : undefined;
|
|
67
|
+
if (waiting === undefined)
|
|
68
|
+
return Effect.void;
|
|
69
|
+
pending.delete(id);
|
|
70
|
+
const error = message['error'];
|
|
71
|
+
if (typeof error === 'object' && error !== null) {
|
|
72
|
+
const { code, message: text, data } = error;
|
|
73
|
+
return Deferred.fail(waiting.reply, new RpcFailure({
|
|
74
|
+
method: waiting.method,
|
|
75
|
+
code: typeof code === 'number' ? code : undefined,
|
|
76
|
+
message: typeof text === 'string' ? text : '',
|
|
77
|
+
data,
|
|
78
|
+
})).pipe(Effect.asVoid);
|
|
79
|
+
}
|
|
80
|
+
return Deferred.succeed(waiting.reply, message['result']).pipe(Effect.asVoid);
|
|
81
|
+
};
|
|
82
|
+
yield* transport.lines.pipe(Stream.runForEach((line) => {
|
|
83
|
+
const message = parse(line);
|
|
84
|
+
return message === undefined ? Effect.void : onMessage(message);
|
|
85
|
+
}), Effect.ensuring(Effect.gen(function* () {
|
|
86
|
+
closed = true;
|
|
87
|
+
for (const { reply } of pending.values())
|
|
88
|
+
yield* Deferred.fail(reply, new RpcClosed());
|
|
89
|
+
pending.clear();
|
|
90
|
+
yield* Queue.end(notifications);
|
|
91
|
+
})), Effect.forkScoped);
|
|
92
|
+
const request = (method, params) => Effect.gen(function* () {
|
|
93
|
+
if (closed)
|
|
94
|
+
return yield* new RpcClosed();
|
|
95
|
+
const id = ++nextId;
|
|
96
|
+
const reply = yield* Deferred.make();
|
|
97
|
+
pending.set(id, { method, reply });
|
|
98
|
+
yield* send({ id, method, params });
|
|
99
|
+
return yield* Deferred.await(reply);
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
request,
|
|
103
|
+
notify: (method) => send({ method }),
|
|
104
|
+
notifications: Stream.fromQueue(notifications),
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
/** The `codexErrorInfo` an error response carries in its `data`, if any. */
|
|
108
|
+
const errorInfoOf = (data) => {
|
|
109
|
+
if (typeof data !== 'object' || data === null)
|
|
110
|
+
return undefined;
|
|
111
|
+
const record = data;
|
|
112
|
+
if ('codexErrorInfo' in record)
|
|
113
|
+
return record['codexErrorInfo'];
|
|
114
|
+
const error = record['error'];
|
|
115
|
+
return typeof error === 'object' && error !== null
|
|
116
|
+
? error['codexErrorInfo']
|
|
117
|
+
: undefined;
|
|
118
|
+
};
|
|
119
|
+
/** A `turn/start` refused because the running turn (a review or compaction) cannot be steered. */
|
|
120
|
+
export const isNotSteerable = (error) => {
|
|
121
|
+
if (error._tag !== 'RpcFailure')
|
|
122
|
+
return false;
|
|
123
|
+
const info = errorInfoOf(error.data);
|
|
124
|
+
return typeof info === 'object' && info !== null && 'activeTurnNotSteerable' in info;
|
|
125
|
+
};
|
|
126
|
+
/** Opens the conversation: `initialize`, then `initialized`. */
|
|
127
|
+
export const initialize = (rpc) => rpc
|
|
128
|
+
.request('initialize', {
|
|
129
|
+
clientInfo: { name: 'fluidcast', title: 'Fluidcast', version: '0.0.0' },
|
|
130
|
+
capabilities: null,
|
|
131
|
+
})
|
|
132
|
+
.pipe(Effect.andThen(r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AAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,wBAAwB,IAAI,IAAI,CAAC;AACvF,CAAC,CAAC;AAEF,gEAAgE;AAChE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAE,EAAE,CACrC,GAAG;KACA,OAAO,CAAC,YAAY,EAAE;IACrB,UAAU,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE;IACvE,YAAY,EAAE,IAAI;CACnB,CAAC;KACD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { TranscriptEntry } from '../schema.ts';
|
|
2
|
+
import { type Item } from './protocol.ts';
|
|
3
|
+
export declare const isToolItem: (item: Item) => boolean;
|
|
4
|
+
/**
|
|
5
|
+
* The subagent threads an item starts: a `spawnAgent` call's receivers, or a started
|
|
6
|
+
* `subAgentActivity`'s thread (the form Codex 0.160.1 emits with current models). Empty for every
|
|
7
|
+
* other item.
|
|
8
|
+
*/
|
|
9
|
+
export declare const spawnedThreads: (item: Item) => ReadonlyArray<string>;
|
|
10
|
+
export declare const toolCall: (item: Item, parentToolUseId: string | null) => TranscriptEntry;
|
|
11
|
+
export declare const toolResult: (item: Item, parentToolUseId: string | null) => TranscriptEntry;
|
|
12
|
+
/**
|
|
13
|
+
* The entries of a finished item other than a tool call (those take a call and a result):
|
|
14
|
+
* text, plan and compaction status, and, for stored history only (`prompts`), user prompts.
|
|
15
|
+
*/
|
|
16
|
+
export declare const completedEntries: (item: Item, parentToolUseId: string | null, prompts: boolean) => ReadonlyArray<TranscriptEntry>;
|
|
17
|
+
/** A `turn/plan/updated` as one status line per step, after its explanation. */
|
|
18
|
+
export declare const planStatus: (explanation: string | undefined, plan: ReadonlyArray<{
|
|
19
|
+
readonly step: string;
|
|
20
|
+
readonly status: string;
|
|
21
|
+
}>) => string;
|
|
22
|
+
/**
|
|
23
|
+
* How a main-thread turn ended: `success`, `interrupted`, else Codex's own error name (falling back
|
|
24
|
+
* to `failed`), uninterpreted. `resetsAt` is attached to `usageLimitExceeded` when known.
|
|
25
|
+
*/
|
|
26
|
+
export declare const turnEnd: (status: string, errorInfo: unknown, resetsAt: number | undefined) => TranscriptEntry;
|
|
27
|
+
/**
|
|
28
|
+
* A stored thread and its subagents as entries. `threads` holds every thread's items in order,
|
|
29
|
+
* by thread ID. Each subagent's entries come right after the item that started it
|
|
30
|
+
* (before that call's result), nested under it. No `turnEnd` is invented, as for Claude Code.
|
|
31
|
+
*/
|
|
32
|
+
export declare const historyEntries: (mainThreadId: string, threads: ReadonlyMap<string, ReadonlyArray<Item>>) => ReadonlyArray<TranscriptEntry>;
|
|
33
|
+
/**
|
|
34
|
+
* A stored main thread's last answer: every agent message after its last user message, joined by
|
|
35
|
+
* blank lines (the same rule as for Claude Code), or `undefined` when there is none.
|
|
36
|
+
*/
|
|
37
|
+
export declare const lastAnswer: (items: ReadonlyArray<Item>) => string | undefined;
|
|
38
|
+
//# sourceMappingURL=transcript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../src/codex/transcript.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAiB,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AAoBzD,eAAO,MAAM,UAAU,SAAU,IAAI,KAAG,OACW,CAAC;AAEpD;;;;GAIG;AACH,eAAO,MAAM,cAAc,SAAU,IAAI,KAAG,aAAa,CAAC,MAAM,CAK/D,CAAC;AA+GF,eAAO,MAAM,QAAQ,SAAU,IAAI,mBAAmB,MAAM,GAAG,IAAI,KAAG,eAWrE,CAAC;AAEF,eAAO,MAAM,UAAU,SAAU,IAAI,mBAAmB,MAAM,GAAG,IAAI,KAAG,eAWvE,CAAC;AAYF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,SACrB,IAAI,mBACO,MAAM,GAAG,IAAI,WACrB,OAAO,KACf,aAAa,CAAC,eAAe,CAiB/B,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,UAAU,gBACR,MAAM,GAAG,SAAS,QACzB,aAAa,CAAC;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,KACtE,MAIW,CAAC;AAEf;;;GAGG;AACH,eAAO,MAAM,OAAO,WACV,MAAM,aACH,OAAO,YACR,MAAM,GAAG,SAAS,KAC3B,eASF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,iBACX,MAAM,WACX,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,KAChD,aAAa,CAAC,eAAe,CAoB/B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,UAAW,aAAa,CAAC,IAAI,CAAC,KAAG,MAAM,GAAG,SAOhE,CAAC"}
|