@cydm/happy-elves 0.1.0-beta.31 → 0.1.0-beta.310
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/apps/cli/dist/commands/app.js +10 -0
- package/apps/cli/dist/commands/daemon.js +92 -4
- package/apps/cli/dist/commands/gateway.d.ts +2 -0
- package/apps/cli/dist/commands/gateway.js +429 -0
- package/apps/cli/dist/commands/lib/args.js +49 -0
- package/apps/cli/dist/commands/lib/bootstrap-daemon.d.ts +2 -2
- package/apps/cli/dist/commands/lib/bootstrap-daemon.js +2 -2
- package/apps/cli/dist/commands/lib/doctor.d.ts +11 -0
- package/apps/cli/dist/commands/lib/doctor.js +276 -11
- package/apps/cli/dist/commands/lib/gateway-store.d.ts +38 -0
- package/apps/cli/dist/commands/lib/gateway-store.js +33 -0
- package/apps/cli/dist/commands/lib/index.d.ts +4 -2
- package/apps/cli/dist/commands/lib/index.js +2 -0
- package/apps/cli/dist/commands/lib/json.d.ts +2 -2
- package/apps/cli/dist/commands/lib/json.js +5 -2
- package/apps/cli/dist/commands/lib/local-daemon.d.ts +1 -0
- package/apps/cli/dist/commands/lib/local-daemon.js +14 -0
- package/apps/cli/dist/commands/lib/paths.d.ts +2 -0
- package/apps/cli/dist/commands/lib/paths.js +2 -0
- package/apps/cli/dist/commands/lib/relay-db-audit.d.ts +37 -0
- package/apps/cli/dist/commands/lib/relay-db-audit.js +300 -0
- package/apps/cli/dist/commands/lib/relay-http.d.ts +1 -1
- package/apps/cli/dist/commands/lib/scope.d.ts +1 -1
- package/apps/cli/dist/commands/lib/session-output.d.ts +15 -1
- package/apps/cli/dist/commands/lib/session-output.js +214 -6
- package/apps/cli/dist/commands/lib/session-view.d.ts +2 -2
- package/apps/cli/dist/commands/lib/status.js +5 -1
- package/apps/cli/dist/commands/lib/types.d.ts +4 -2
- package/apps/cli/dist/commands/lib/usage.js +123 -10
- package/apps/cli/dist/commands/lib/workspace.d.ts +2 -2
- package/apps/cli/dist/commands/lib/workspace.js +63 -10
- package/apps/cli/dist/commands/machine.js +50 -9
- package/apps/cli/dist/commands/memory.d.ts +2 -0
- package/apps/cli/dist/commands/memory.js +179 -0
- package/apps/cli/dist/commands/relay.js +29 -2
- package/apps/cli/dist/commands/release.d.ts +2 -0
- package/apps/cli/dist/commands/release.js +197 -0
- package/apps/cli/dist/commands/remote.js +10 -2
- package/apps/cli/dist/commands/schedule.d.ts +2 -0
- package/apps/cli/dist/commands/schedule.js +273 -0
- package/apps/cli/dist/commands/session.js +517 -5
- package/apps/cli/dist/commands/turn.js +225 -9
- package/apps/cli/dist/commands/workspace.d.ts +2 -0
- package/apps/cli/dist/commands/workspace.js +68 -0
- package/apps/cli/package.json +6 -0
- package/apps/daemon/dist/gateway/adapters.d.ts +38 -0
- package/apps/daemon/dist/gateway/adapters.js +2 -0
- package/apps/daemon/dist/gateway/feishu.d.ts +65 -0
- package/apps/daemon/dist/gateway/feishu.js +493 -0
- package/apps/daemon/dist/gateway/format.d.ts +2 -0
- package/apps/daemon/dist/gateway/format.js +19 -0
- package/apps/daemon/dist/gateway/handler.d.ts +7 -0
- package/apps/daemon/dist/gateway/handler.js +151 -0
- package/apps/daemon/dist/gateway/runtime.d.ts +33 -0
- package/apps/daemon/dist/gateway/runtime.js +850 -0
- package/apps/daemon/dist/gateway/store.d.ts +92 -0
- package/apps/daemon/dist/gateway/store.js +268 -0
- package/apps/daemon/dist/memory/handler.d.ts +7 -0
- package/apps/daemon/dist/memory/handler.js +105 -0
- package/apps/daemon/dist/memory/manager.d.ts +44 -0
- package/apps/daemon/dist/memory/manager.js +359 -0
- package/apps/daemon/dist/paths.d.ts +3 -0
- package/apps/daemon/dist/paths.js +3 -0
- package/apps/daemon/dist/relay/admission.d.ts +30 -0
- package/apps/daemon/dist/relay/admission.js +31 -0
- package/apps/daemon/dist/relay/connection.js +37 -1
- package/apps/daemon/dist/relay/devtools.d.ts +1 -1
- package/apps/daemon/dist/relay/register.js +2 -0
- package/apps/daemon/dist/relay/send.d.ts +2 -2
- package/apps/daemon/dist/relay/send.js +2 -0
- package/apps/daemon/dist/relay-http.d.ts +1 -1
- package/apps/daemon/dist/runtime/external-provider.d.ts +1 -1
- package/apps/daemon/dist/runtime/external-provider.js +187 -17
- package/apps/daemon/dist/runtime.d.ts +1 -2
- package/apps/daemon/dist/runtime.js +0 -3
- package/apps/daemon/dist/schedule/handler.d.ts +9 -0
- package/apps/daemon/dist/schedule/handler.js +148 -0
- package/apps/daemon/dist/schedule/runner.d.ts +21 -0
- package/apps/daemon/dist/schedule/runner.js +547 -0
- package/apps/daemon/dist/schedule/store.d.ts +9 -0
- package/apps/daemon/dist/schedule/store.js +143 -0
- package/apps/daemon/dist/session/create-session.d.ts +1 -1
- package/apps/daemon/dist/session/directory.d.ts +1 -1
- package/apps/daemon/dist/session/events.d.ts +15 -2
- package/apps/daemon/dist/session/events.js +76 -24
- package/apps/daemon/dist/session/file-preview.d.ts +1 -1
- package/apps/daemon/dist/session/lifecycle.d.ts +26 -3
- package/apps/daemon/dist/session/lifecycle.js +161 -22
- package/apps/daemon/dist/session/metadata.d.ts +2 -2
- package/apps/daemon/dist/session/metadata.js +42 -1
- package/apps/daemon/dist/session/primitives.d.ts +1 -1
- package/apps/daemon/dist/session/primitives.js +37 -6
- package/apps/daemon/dist/session/prompt.d.ts +28 -1
- package/apps/daemon/dist/session/prompt.js +340 -5
- package/apps/daemon/dist/session/reconcile.d.ts +3 -0
- package/apps/daemon/dist/session/reconcile.js +235 -0
- package/apps/daemon/dist/session/runtime-handle.d.ts +1 -1
- package/apps/daemon/dist/start.js +5 -1
- package/apps/daemon/dist/state.d.ts +2 -2
- package/apps/daemon/dist/turn-coordinator.d.ts +1 -0
- package/apps/daemon/dist/turn-coordinator.js +4 -0
- package/apps/daemon/dist/types.d.ts +16 -1
- package/apps/daemon/package.json +3 -25
- package/apps/relay/dist/connections.d.ts +2 -0
- package/apps/relay/dist/controller-handlers.d.ts +42 -2
- package/apps/relay/dist/controller-handlers.js +349 -37
- package/apps/relay/dist/db.js +296 -2
- package/apps/relay/dist/errors.d.ts +2 -1
- package/apps/relay/dist/errors.js +3 -1
- package/apps/relay/dist/http-routes.js +659 -33
- package/apps/relay/dist/http-schemas.d.ts +156 -0
- package/apps/relay/dist/http-schemas.js +85 -0
- package/apps/relay/dist/index.js +31 -1
- package/apps/relay/dist/machine-handlers.d.ts +15 -7
- package/apps/relay/dist/machine-handlers.js +567 -27
- package/apps/relay/dist/projections.d.ts +1 -1
- package/apps/relay/dist/projections.js +13 -0
- package/apps/relay/dist/relay-context.d.ts +41 -3
- package/apps/relay/dist/relay-context.js +244 -19
- package/apps/relay/dist/repositories.d.ts +2 -2
- package/apps/relay/dist/repositories.js +28 -1
- package/apps/relay/dist/runtime-bindings.d.ts +25 -0
- package/apps/relay/dist/runtime-bindings.js +49 -0
- package/apps/relay/dist/scope.d.ts +1 -1
- package/apps/relay/dist/types.d.ts +71 -1
- package/apps/relay/dist/websocket.js +2 -0
- package/package.json +5 -11
- package/packages/agent-sdk/dist/index.d.ts +80 -0
- package/packages/agent-sdk/dist/index.js +16 -0
- package/packages/client/dist/account.d.ts +35 -2
- package/packages/client/dist/account.js +98 -1
- package/packages/client/dist/client.d.ts +59 -6
- package/packages/client/dist/client.js +312 -58
- package/packages/client/dist/index.d.ts +1 -1
- package/packages/client/dist/parsers.d.ts +28 -2
- package/packages/client/dist/parsers.js +167 -0
- package/packages/client/dist/transport.d.ts +21 -1
- package/packages/client/dist/transport.js +69 -6
- package/packages/client/dist/types.d.ts +177 -1
- package/packages/client/dist/validation.d.ts +1 -1
- package/packages/runtime/dist/index.d.ts +66 -0
- package/packages/runtime-acpx/dist/index.d.ts +1 -1
- package/packages/runtime-acpx/dist/index.js +8 -0
- package/packages/runtime-cli/dist/claude-history.d.ts +1 -2
- package/packages/runtime-cli/dist/claude-history.js +0 -3
- package/packages/runtime-cli/dist/claude-session-store.d.ts +0 -1
- package/packages/runtime-cli/dist/claude-session-store.js +1 -1
- package/packages/runtime-cli/dist/claude-turn.d.ts +2 -1
- package/packages/runtime-cli/dist/claude-turn.js +29 -9
- package/packages/runtime-cli/dist/codex-app-server.d.ts +8 -3
- package/packages/runtime-cli/dist/codex-app-server.js +122 -25
- package/packages/runtime-cli/dist/codex-history.d.ts +1 -2
- package/packages/runtime-cli/dist/codex-history.js +11 -5
- package/packages/runtime-cli/dist/codex-protocol.d.ts +2 -2
- package/packages/runtime-cli/dist/codex-protocol.js +4 -4
- package/packages/runtime-cli/dist/history-merge.d.ts +1 -1
- package/packages/runtime-cli/dist/index.d.ts +1 -1
- package/packages/runtime-cli/dist/index.js +108 -2
- package/packages/runtime-cli/dist/permissions.d.ts +1 -1
- package/packages/runtime-cli/dist/session-store.d.ts +2 -1
- package/packages/runtime-cli/dist/session-store.js +9 -8
- package/packages/shared/dist/index.d.ts +2 -0
- package/packages/shared/dist/index.js +2 -0
- package/packages/shared/dist/protocol-schemas.d.ts +1077 -0
- package/packages/shared/dist/protocol-schemas.js +273 -0
- package/packages/shared/dist/protocol-types.d.ts +371 -3
- package/packages/shared/dist/protocol.d.ts +181 -2
- package/packages/shared/dist/protocol.js +197 -1
- package/packages/shared/dist/session-tags.d.ts +12 -0
- package/packages/shared/dist/session-tags.js +50 -0
- package/apps/cli/dist/commands/account.js.map +0 -1
- package/apps/cli/dist/commands/app.js.map +0 -1
- package/apps/cli/dist/commands/collect.js.map +0 -1
- package/apps/cli/dist/commands/command.js.map +0 -1
- package/apps/cli/dist/commands/config.js.map +0 -1
- package/apps/cli/dist/commands/daemon.js.map +0 -1
- package/apps/cli/dist/commands/lib/args.js.map +0 -1
- package/apps/cli/dist/commands/lib/audit.js.map +0 -1
- package/apps/cli/dist/commands/lib/bootstrap-config.js.map +0 -1
- package/apps/cli/dist/commands/lib/bootstrap-daemon.js.map +0 -1
- package/apps/cli/dist/commands/lib/bootstrap-output.js.map +0 -1
- package/apps/cli/dist/commands/lib/bootstrap.js.map +0 -1
- package/apps/cli/dist/commands/lib/config.js.map +0 -1
- package/apps/cli/dist/commands/lib/doctor.js.map +0 -1
- package/apps/cli/dist/commands/lib/exit.js.map +0 -1
- package/apps/cli/dist/commands/lib/index.js.map +0 -1
- package/apps/cli/dist/commands/lib/json.js.map +0 -1
- package/apps/cli/dist/commands/lib/local-daemon.js.map +0 -1
- package/apps/cli/dist/commands/lib/loop-store.js.map +0 -1
- package/apps/cli/dist/commands/lib/paths.js.map +0 -1
- package/apps/cli/dist/commands/lib/relay-http.js.map +0 -1
- package/apps/cli/dist/commands/lib/scope.js.map +0 -1
- package/apps/cli/dist/commands/lib/session-output.js.map +0 -1
- package/apps/cli/dist/commands/lib/session-view.js.map +0 -1
- package/apps/cli/dist/commands/lib/status.js.map +0 -1
- package/apps/cli/dist/commands/lib/types.js.map +0 -1
- package/apps/cli/dist/commands/lib/usage.js.map +0 -1
- package/apps/cli/dist/commands/lib/workspace.js.map +0 -1
- package/apps/cli/dist/commands/loop.js.map +0 -1
- package/apps/cli/dist/commands/machine.js.map +0 -1
- package/apps/cli/dist/commands/relay.js.map +0 -1
- package/apps/cli/dist/commands/remote.js.map +0 -1
- package/apps/cli/dist/commands/session.js.map +0 -1
- package/apps/cli/dist/commands/token.js.map +0 -1
- package/apps/cli/dist/commands/turn.js.map +0 -1
- package/apps/cli/dist/errors.js.map +0 -1
- package/apps/cli/dist/index.js.map +0 -1
- package/apps/daemon/dist/app.js.map +0 -1
- package/apps/daemon/dist/args.js.map +0 -1
- package/apps/daemon/dist/audit.js.map +0 -1
- package/apps/daemon/dist/cli.js.map +0 -1
- package/apps/daemon/dist/config.js.map +0 -1
- package/apps/daemon/dist/errors.js.map +0 -1
- package/apps/daemon/dist/loop/runner.js.map +0 -1
- package/apps/daemon/dist/loop/store.js.map +0 -1
- package/apps/daemon/dist/pair.js.map +0 -1
- package/apps/daemon/dist/paths.js.map +0 -1
- package/apps/daemon/dist/process.js.map +0 -1
- package/apps/daemon/dist/relay/connection.js.map +0 -1
- package/apps/daemon/dist/relay/devtools.js.map +0 -1
- package/apps/daemon/dist/relay/register.js.map +0 -1
- package/apps/daemon/dist/relay/send.js.map +0 -1
- package/apps/daemon/dist/relay-http.js.map +0 -1
- package/apps/daemon/dist/runtime/external-provider.js.map +0 -1
- package/apps/daemon/dist/runtime.js.map +0 -1
- package/apps/daemon/dist/session/create-session.js.map +0 -1
- package/apps/daemon/dist/session/directory.js.map +0 -1
- package/apps/daemon/dist/session/events.js.map +0 -1
- package/apps/daemon/dist/session/file-preview.js.map +0 -1
- package/apps/daemon/dist/session/lifecycle.js.map +0 -1
- package/apps/daemon/dist/session/metadata.js.map +0 -1
- package/apps/daemon/dist/session/primitives.js.map +0 -1
- package/apps/daemon/dist/session/prompt.js.map +0 -1
- package/apps/daemon/dist/session/runtime-handle.js.map +0 -1
- package/apps/daemon/dist/start.js.map +0 -1
- package/apps/daemon/dist/state.js.map +0 -1
- package/apps/daemon/dist/turn-coordinator.js.map +0 -1
- package/apps/daemon/dist/types.js.map +0 -1
- package/apps/daemon/dist/utils.js.map +0 -1
- package/apps/relay/dist/auth.js.map +0 -1
- package/apps/relay/dist/connections.js.map +0 -1
- package/apps/relay/dist/controller-handlers.js.map +0 -1
- package/apps/relay/dist/db.js.map +0 -1
- package/apps/relay/dist/errors.js.map +0 -1
- package/apps/relay/dist/http-routes.js.map +0 -1
- package/apps/relay/dist/http-schemas.js.map +0 -1
- package/apps/relay/dist/index.js.map +0 -1
- package/apps/relay/dist/machine-handlers.js.map +0 -1
- package/apps/relay/dist/projections.js.map +0 -1
- package/apps/relay/dist/relay-context.js.map +0 -1
- package/apps/relay/dist/repositories.js.map +0 -1
- package/apps/relay/dist/retention.js.map +0 -1
- package/apps/relay/dist/scope.js.map +0 -1
- package/apps/relay/dist/security.js.map +0 -1
- package/apps/relay/dist/types.js.map +0 -1
- package/apps/relay/dist/websocket.js.map +0 -1
- package/apps/relay/package.json +0 -29
- package/packages/agent-sdk/dist/index.d.ts.map +0 -1
- package/packages/agent-sdk/dist/index.js.map +0 -1
- package/packages/agent-sdk/package.json +0 -20
- package/packages/client/dist/account.d.ts.map +0 -1
- package/packages/client/dist/account.js.map +0 -1
- package/packages/client/dist/client.d.ts.map +0 -1
- package/packages/client/dist/client.js.map +0 -1
- package/packages/client/dist/errors.d.ts.map +0 -1
- package/packages/client/dist/errors.js.map +0 -1
- package/packages/client/dist/http.d.ts.map +0 -1
- package/packages/client/dist/http.js.map +0 -1
- package/packages/client/dist/index.d.ts.map +0 -1
- package/packages/client/dist/index.js.map +0 -1
- package/packages/client/dist/parsers.d.ts.map +0 -1
- package/packages/client/dist/parsers.js.map +0 -1
- package/packages/client/dist/transport.d.ts.map +0 -1
- package/packages/client/dist/transport.js.map +0 -1
- package/packages/client/dist/types.d.ts.map +0 -1
- package/packages/client/dist/types.js.map +0 -1
- package/packages/client/dist/validation.d.ts.map +0 -1
- package/packages/client/dist/validation.js.map +0 -1
- package/packages/client/package.json +0 -22
- package/packages/pie-provider/dist/index.d.ts.map +0 -1
- package/packages/pie-provider/dist/index.js.map +0 -1
- package/packages/pie-provider/package.json +0 -26
- package/packages/runtime/dist/index.d.ts.map +0 -1
- package/packages/runtime/dist/index.js.map +0 -1
- package/packages/runtime/package.json +0 -19
- package/packages/runtime-acpx/dist/index.d.ts.map +0 -1
- package/packages/runtime-acpx/dist/index.js.map +0 -1
- package/packages/runtime-acpx/package.json +0 -23
- package/packages/runtime-cli/dist/async-queue.d.ts.map +0 -1
- package/packages/runtime-cli/dist/async-queue.js.map +0 -1
- package/packages/runtime-cli/dist/claude-history.d.ts.map +0 -1
- package/packages/runtime-cli/dist/claude-history.js.map +0 -1
- package/packages/runtime-cli/dist/claude-json.d.ts.map +0 -1
- package/packages/runtime-cli/dist/claude-json.js.map +0 -1
- package/packages/runtime-cli/dist/claude-rename.d.ts.map +0 -1
- package/packages/runtime-cli/dist/claude-rename.js.map +0 -1
- package/packages/runtime-cli/dist/claude-session-store.d.ts.map +0 -1
- package/packages/runtime-cli/dist/claude-session-store.js.map +0 -1
- package/packages/runtime-cli/dist/claude-turn.d.ts.map +0 -1
- package/packages/runtime-cli/dist/claude-turn.js.map +0 -1
- package/packages/runtime-cli/dist/codex-app-server.d.ts.map +0 -1
- package/packages/runtime-cli/dist/codex-app-server.js.map +0 -1
- package/packages/runtime-cli/dist/codex-approvals.d.ts.map +0 -1
- package/packages/runtime-cli/dist/codex-approvals.js.map +0 -1
- package/packages/runtime-cli/dist/codex-history.d.ts.map +0 -1
- package/packages/runtime-cli/dist/codex-history.js.map +0 -1
- package/packages/runtime-cli/dist/codex-json-rpc.d.ts.map +0 -1
- package/packages/runtime-cli/dist/codex-json-rpc.js.map +0 -1
- package/packages/runtime-cli/dist/codex-lifecycle.d.ts.map +0 -1
- package/packages/runtime-cli/dist/codex-lifecycle.js.map +0 -1
- package/packages/runtime-cli/dist/codex-protocol.d.ts.map +0 -1
- package/packages/runtime-cli/dist/codex-protocol.js.map +0 -1
- package/packages/runtime-cli/dist/command-resolver.d.ts.map +0 -1
- package/packages/runtime-cli/dist/command-resolver.js.map +0 -1
- package/packages/runtime-cli/dist/history-merge.d.ts.map +0 -1
- package/packages/runtime-cli/dist/history-merge.js.map +0 -1
- package/packages/runtime-cli/dist/index.d.ts.map +0 -1
- package/packages/runtime-cli/dist/index.js.map +0 -1
- package/packages/runtime-cli/dist/permissions.d.ts.map +0 -1
- package/packages/runtime-cli/dist/permissions.js.map +0 -1
- package/packages/runtime-cli/dist/session-store.d.ts.map +0 -1
- package/packages/runtime-cli/dist/session-store.js.map +0 -1
- package/packages/runtime-cli/package.json +0 -22
- package/packages/shared/dist/args.d.ts.map +0 -1
- package/packages/shared/dist/args.js.map +0 -1
- package/packages/shared/dist/crypto.d.ts.map +0 -1
- package/packages/shared/dist/crypto.js.map +0 -1
- package/packages/shared/dist/ids.d.ts.map +0 -1
- package/packages/shared/dist/ids.js.map +0 -1
- package/packages/shared/dist/index.d.ts.map +0 -1
- package/packages/shared/dist/index.js.map +0 -1
- package/packages/shared/dist/protocol-schemas.d.ts.map +0 -1
- package/packages/shared/dist/protocol-schemas.js.map +0 -1
- package/packages/shared/dist/protocol-types.d.ts.map +0 -1
- package/packages/shared/dist/protocol-types.js.map +0 -1
- package/packages/shared/dist/protocol.d.ts.map +0 -1
- package/packages/shared/dist/protocol.js.map +0 -1
- package/packages/shared/dist/session-name.d.ts.map +0 -1
- package/packages/shared/dist/session-name.js.map +0 -1
- package/packages/shared/dist/session-state.d.ts.map +0 -1
- package/packages/shared/dist/session-state.js.map +0 -1
- package/packages/shared/package.json +0 -24
|
@@ -7,6 +7,7 @@ export type RuntimeHandle = {
|
|
|
7
7
|
sessionKey: string;
|
|
8
8
|
backend: string;
|
|
9
9
|
runtimeSessionName: string;
|
|
10
|
+
model?: string;
|
|
10
11
|
cwd?: string;
|
|
11
12
|
acpxRecordId?: string;
|
|
12
13
|
backendSessionId?: string;
|
|
@@ -15,9 +16,22 @@ export type RuntimeHandle = {
|
|
|
15
16
|
externalHandle?: Record<string, unknown>;
|
|
16
17
|
};
|
|
17
18
|
export type RuntimeTurnAttachment = {
|
|
19
|
+
name?: string;
|
|
18
20
|
mediaType: string;
|
|
21
|
+
sizeBytes?: number;
|
|
19
22
|
data: string;
|
|
20
23
|
};
|
|
24
|
+
export type RuntimeModelOption = {
|
|
25
|
+
id: string;
|
|
26
|
+
label?: string;
|
|
27
|
+
unavailable?: boolean;
|
|
28
|
+
reason?: string;
|
|
29
|
+
};
|
|
30
|
+
export type RuntimeOptionChoice = {
|
|
31
|
+
id: string;
|
|
32
|
+
label: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
};
|
|
21
35
|
export type RuntimeEvent = {
|
|
22
36
|
type: "text_delta";
|
|
23
37
|
text: string;
|
|
@@ -29,6 +43,16 @@ export type RuntimeEvent = {
|
|
|
29
43
|
tag?: string;
|
|
30
44
|
used?: number;
|
|
31
45
|
size?: number;
|
|
46
|
+
} | {
|
|
47
|
+
type: "session_usage";
|
|
48
|
+
source: "provider" | "estimated";
|
|
49
|
+
usedTokens: number;
|
|
50
|
+
contextWindowTokens?: number;
|
|
51
|
+
inputTokens?: number;
|
|
52
|
+
outputTokens?: number;
|
|
53
|
+
cachedInputTokens?: number;
|
|
54
|
+
reasoningOutputTokens?: number;
|
|
55
|
+
totalTokens?: number;
|
|
32
56
|
} | {
|
|
33
57
|
type: "tool_call";
|
|
34
58
|
text: string;
|
|
@@ -36,6 +60,13 @@ export type RuntimeEvent = {
|
|
|
36
60
|
toolCallId?: string;
|
|
37
61
|
status?: string;
|
|
38
62
|
title?: string;
|
|
63
|
+
} | {
|
|
64
|
+
type: "option_request";
|
|
65
|
+
optionRequestId: string;
|
|
66
|
+
title?: string;
|
|
67
|
+
message: string;
|
|
68
|
+
options: RuntimeOptionChoice[];
|
|
69
|
+
allowFreeText?: boolean;
|
|
39
70
|
} | {
|
|
40
71
|
type: "done";
|
|
41
72
|
stopReason?: string;
|
|
@@ -74,6 +105,11 @@ export interface RuntimeTurn {
|
|
|
74
105
|
cancel(input?: {
|
|
75
106
|
reason?: string;
|
|
76
107
|
}): Promise<void>;
|
|
108
|
+
respondOption?(input: {
|
|
109
|
+
optionRequestId: string;
|
|
110
|
+
selectedOptionId?: string;
|
|
111
|
+
text?: string;
|
|
112
|
+
}): Promise<void>;
|
|
77
113
|
closeStream(input?: {
|
|
78
114
|
reason?: string;
|
|
79
115
|
}): Promise<void>;
|
|
@@ -99,6 +135,8 @@ export type RuntimeAgentProfile = {
|
|
|
99
135
|
label: string;
|
|
100
136
|
command?: string;
|
|
101
137
|
historyModel?: RuntimeHistoryModel;
|
|
138
|
+
defaultModel?: string;
|
|
139
|
+
models?: RuntimeModelOption[];
|
|
102
140
|
sessionPrimitives?: RuntimeCapabilities["sessionPrimitives"];
|
|
103
141
|
};
|
|
104
142
|
export type RuntimeHistoricalSession = {
|
|
@@ -153,6 +191,26 @@ export type RuntimeHistoricalEventPage = {
|
|
|
153
191
|
currentHead?: string;
|
|
154
192
|
lastTurnId?: string;
|
|
155
193
|
};
|
|
194
|
+
export type RuntimeTurnInspection = {
|
|
195
|
+
status: "active";
|
|
196
|
+
currentHead?: string;
|
|
197
|
+
lastTurnId?: string;
|
|
198
|
+
providerTurnId?: string;
|
|
199
|
+
evidence?: string;
|
|
200
|
+
} | {
|
|
201
|
+
status: "terminal";
|
|
202
|
+
terminalStatus: "completed" | "cancelled" | "failed";
|
|
203
|
+
currentHead?: string;
|
|
204
|
+
lastTurnId?: string;
|
|
205
|
+
providerTurnId?: string;
|
|
206
|
+
error?: string;
|
|
207
|
+
evidence?: string;
|
|
208
|
+
} | {
|
|
209
|
+
status: "unknown" | "not_found" | "uninspectable";
|
|
210
|
+
providerTurnId?: string;
|
|
211
|
+
reason?: string;
|
|
212
|
+
evidence?: string;
|
|
213
|
+
};
|
|
156
214
|
export interface HappyElvesRuntime {
|
|
157
215
|
getCapabilities(): RuntimeCapabilities;
|
|
158
216
|
listAgents(): RuntimeAgentProfile[];
|
|
@@ -164,6 +222,7 @@ export interface HappyElvesRuntime {
|
|
|
164
222
|
resumeHandle?: RuntimeHandle;
|
|
165
223
|
cwd?: string;
|
|
166
224
|
permissionMode?: RuntimePermissionMode;
|
|
225
|
+
model?: string;
|
|
167
226
|
restartableEmptySession?: boolean;
|
|
168
227
|
}): Promise<RuntimeHandle>;
|
|
169
228
|
listHistoricalSessions?(input: {
|
|
@@ -196,12 +255,19 @@ export interface HappyElvesRuntime {
|
|
|
196
255
|
before?: string;
|
|
197
256
|
limit?: number;
|
|
198
257
|
}): Promise<RuntimeHistoricalEventPage>;
|
|
258
|
+
inspectTurn?(input: {
|
|
259
|
+
handle: RuntimeHandle;
|
|
260
|
+
turnId?: string;
|
|
261
|
+
providerTurnId?: string;
|
|
262
|
+
requestId?: string;
|
|
263
|
+
}): Promise<RuntimeTurnInspection>;
|
|
199
264
|
startTurn(input: {
|
|
200
265
|
handle: RuntimeHandle;
|
|
201
266
|
text: string;
|
|
202
267
|
attachments?: RuntimeTurnAttachment[];
|
|
203
268
|
mode: RuntimePromptMode;
|
|
204
269
|
permissionMode?: RuntimePermissionMode;
|
|
270
|
+
model?: string;
|
|
205
271
|
requestId: string;
|
|
206
272
|
timeoutMs?: number;
|
|
207
273
|
signal?: AbortSignal;
|
|
@@ -101,6 +101,14 @@ export function createAcpxRuntimeProvider(options) {
|
|
|
101
101
|
startTurn(input) {
|
|
102
102
|
return runtime.startTurn(input);
|
|
103
103
|
},
|
|
104
|
+
async inspectTurn(input) {
|
|
105
|
+
return {
|
|
106
|
+
status: "uninspectable",
|
|
107
|
+
providerTurnId: input.providerTurnId ?? input.handle.backendSessionId ?? input.handle.acpxRecordId,
|
|
108
|
+
reason: "ACP runtime does not expose an authoritative inspectTurn primitive",
|
|
109
|
+
evidence: "unsupported",
|
|
110
|
+
};
|
|
111
|
+
},
|
|
104
112
|
cancel(input) {
|
|
105
113
|
return runtime.cancel({ ...input, handle: input.handle });
|
|
106
114
|
},
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { RuntimeHistoricalEvent,
|
|
1
|
+
import type { RuntimeHistoricalEvent, RuntimeHistoricalSessionPage } from "../../runtime/dist/index.js";
|
|
2
2
|
import { type ClaudeContentBlock } from "./claude-json.js";
|
|
3
|
-
export declare function readClaudeHistoricalSessions(cwd: string | undefined, limit: number): Promise<RuntimeHistoricalSession[]>;
|
|
4
3
|
export declare function readClaudeHistoricalSessionPage(cwd: string | undefined, limit: number, cursor?: string): Promise<RuntimeHistoricalSessionPage>;
|
|
5
4
|
export declare function readClaudeSessionName(filePath: string): Promise<string | undefined>;
|
|
6
5
|
export declare function contentBlocks(value: unknown): ClaudeContentBlock[];
|
|
@@ -3,9 +3,6 @@ import { readFile, readdir, stat } from "node:fs/promises";
|
|
|
3
3
|
import { basename, join } from "node:path";
|
|
4
4
|
import { parseClaudeJsonLine, record } from "./claude-json.js";
|
|
5
5
|
import { canonicalClaudeCwd, claudeProjectDirsForCwd, claudeProjectsDir, claudeSessionPath } from "./claude-session-store.js";
|
|
6
|
-
export async function readClaudeHistoricalSessions(cwd, limit) {
|
|
7
|
-
return (await readClaudeHistoricalSessionPage(cwd, limit)).sessions;
|
|
8
|
-
}
|
|
9
6
|
export async function readClaudeHistoricalSessionPage(cwd, limit, cursor) {
|
|
10
7
|
const offset = claudeHistoryOffset(cursor);
|
|
11
8
|
if (cwd?.trim()) {
|
|
@@ -5,7 +5,7 @@ import { homedir } from "node:os";
|
|
|
5
5
|
import { join, resolve } from "node:path";
|
|
6
6
|
import { createInterface } from "node:readline";
|
|
7
7
|
import { parseClaudeJsonLine } from "./claude-json.js";
|
|
8
|
-
|
|
8
|
+
function claudeProjectDir(cwd) {
|
|
9
9
|
const projectId = canonicalClaudeCwd(cwd).replace(/[^a-zA-Z0-9-]/g, "-");
|
|
10
10
|
return join(claudeProjectsDir(), projectId);
|
|
11
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RuntimeHandle, RuntimeTurn } from "
|
|
1
|
+
import type { RuntimeHandle, RuntimeTurn } from "../../runtime/dist/index.js";
|
|
2
2
|
import { type RuntimePermissionMode } from "./permissions.js";
|
|
3
3
|
export declare function startClaudeTurn(input: {
|
|
4
4
|
command: string;
|
|
@@ -7,6 +7,7 @@ export declare function startClaudeTurn(input: {
|
|
|
7
7
|
requestId: string;
|
|
8
8
|
timeoutMs?: number;
|
|
9
9
|
permissionMode?: RuntimePermissionMode;
|
|
10
|
+
model?: string;
|
|
10
11
|
resume: boolean;
|
|
11
12
|
name?: string;
|
|
12
13
|
}): RuntimeTurn;
|
|
@@ -17,6 +17,7 @@ export function startClaudeTurn(input) {
|
|
|
17
17
|
"--verbose",
|
|
18
18
|
...sessionArgs,
|
|
19
19
|
...(input.name ? ["--name", input.name] : []),
|
|
20
|
+
...(input.model ? ["--model", input.model] : []),
|
|
20
21
|
"--permission-mode",
|
|
21
22
|
claudePermissionMode(input.permissionMode),
|
|
22
23
|
input.text,
|
|
@@ -35,18 +36,35 @@ export function startClaudeTurn(input) {
|
|
|
35
36
|
if (settled)
|
|
36
37
|
return;
|
|
37
38
|
settled = true;
|
|
39
|
+
clearInactivityTimer();
|
|
38
40
|
queue.close();
|
|
39
41
|
resolveResult(value);
|
|
40
42
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
let inactivityTimer = null;
|
|
44
|
+
const clearInactivityTimer = () => {
|
|
45
|
+
if (!inactivityTimer)
|
|
46
|
+
return;
|
|
47
|
+
clearTimeout(inactivityTimer);
|
|
48
|
+
inactivityTimer = null;
|
|
49
|
+
};
|
|
50
|
+
const refreshInactivityTimer = () => {
|
|
51
|
+
if (!input.timeoutMs || settled)
|
|
52
|
+
return;
|
|
53
|
+
clearInactivityTimer();
|
|
54
|
+
inactivityTimer = setTimeout(() => {
|
|
55
|
+
inactivityTimer = null;
|
|
56
|
+
queue.push({
|
|
57
|
+
type: "status",
|
|
58
|
+
text: `No Claude runtime activity for ${input.timeoutMs}ms; still waiting for provider completion.`,
|
|
59
|
+
tag: "inactivity",
|
|
60
|
+
});
|
|
61
|
+
}, input.timeoutMs);
|
|
62
|
+
};
|
|
63
|
+
refreshInactivityTimer();
|
|
47
64
|
createInterface({ input: proc.stdout }).on("line", (line) => {
|
|
48
65
|
if (!line.trim())
|
|
49
66
|
return;
|
|
67
|
+
refreshInactivityTimer();
|
|
50
68
|
const message = parseClaudeJsonLine(line);
|
|
51
69
|
if (!message) {
|
|
52
70
|
queue.push({ type: "text_delta", text: line, stream: "output" });
|
|
@@ -79,10 +97,12 @@ export function startClaudeTurn(input) {
|
|
|
79
97
|
queue.push({ type: "status", text: "Claude session resumed", tag: typeof message.session_id === "string" ? message.session_id : undefined });
|
|
80
98
|
}
|
|
81
99
|
});
|
|
82
|
-
proc.stderr.on("data", (chunk) =>
|
|
100
|
+
proc.stderr.on("data", (chunk) => {
|
|
101
|
+
refreshInactivityTimer();
|
|
102
|
+
queue.push({ type: "status", text: chunk.toString(), tag: "stderr" });
|
|
103
|
+
});
|
|
83
104
|
proc.on("exit", (code, signal) => {
|
|
84
|
-
|
|
85
|
-
clearTimeout(timer);
|
|
105
|
+
clearInactivityTimer();
|
|
86
106
|
if (!settled && code === 0)
|
|
87
107
|
finish({ status: "completed" });
|
|
88
108
|
if (!settled)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { RuntimePromptMode, RuntimeTurn } from "
|
|
1
|
+
import type { RuntimePromptMode, RuntimeTurn } from "../../runtime/dist/index.js";
|
|
2
2
|
import type { RuntimePermissionMode } from "./permissions.js";
|
|
3
3
|
export declare class CodexAppServerSession {
|
|
4
4
|
private readonly command;
|
|
5
5
|
private readonly cwd;
|
|
6
6
|
private readonly onThreadIdChanged?;
|
|
7
|
+
private readonly initialModel?;
|
|
7
8
|
private rpc;
|
|
8
9
|
private turnQueue;
|
|
9
10
|
private turnResolve;
|
|
@@ -11,12 +12,14 @@ export declare class CodexAppServerSession {
|
|
|
11
12
|
private activeTurnId;
|
|
12
13
|
private activeTurnOutputCount;
|
|
13
14
|
private activeTurnStderr;
|
|
15
|
+
private activeTurnActivity;
|
|
14
16
|
private completedTurnIds;
|
|
15
17
|
private appliedPermissionMode;
|
|
18
|
+
private appliedModel;
|
|
16
19
|
private restartableEmptyThread;
|
|
17
20
|
threadId: string | null;
|
|
18
|
-
constructor(command: string, cwd: string, threadId?: string, onThreadIdChanged?: ((threadId: string) => void) | undefined, restartableEmptyThread?: boolean);
|
|
19
|
-
ensure(permissionMode?: RuntimePermissionMode): Promise<string>;
|
|
21
|
+
constructor(command: string, cwd: string, threadId?: string, onThreadIdChanged?: ((threadId: string) => void) | undefined, restartableEmptyThread?: boolean, initialModel?: string | undefined);
|
|
22
|
+
ensure(permissionMode?: RuntimePermissionMode, model?: string): Promise<string>;
|
|
20
23
|
private ensureCurrentPermission;
|
|
21
24
|
private ensurePermission;
|
|
22
25
|
private startNewThread;
|
|
@@ -28,6 +31,7 @@ export declare class CodexAppServerSession {
|
|
|
28
31
|
timeoutMs?: number;
|
|
29
32
|
mode: RuntimePromptMode;
|
|
30
33
|
permissionMode?: RuntimePermissionMode;
|
|
34
|
+
model?: string;
|
|
31
35
|
}): RuntimeTurn;
|
|
32
36
|
close(): Promise<void>;
|
|
33
37
|
cancel(): Promise<void>;
|
|
@@ -49,6 +53,7 @@ export declare class CodexAppServerSession {
|
|
|
49
53
|
private handleNotification;
|
|
50
54
|
private extractTurnId;
|
|
51
55
|
private recordStderr;
|
|
56
|
+
private noteTurnActivity;
|
|
52
57
|
private emptyCompletionFailure;
|
|
53
58
|
}
|
|
54
59
|
//# sourceMappingURL=codex-app-server.d.ts.map
|
|
@@ -8,6 +8,7 @@ export class CodexAppServerSession {
|
|
|
8
8
|
command;
|
|
9
9
|
cwd;
|
|
10
10
|
onThreadIdChanged;
|
|
11
|
+
initialModel;
|
|
11
12
|
rpc = null;
|
|
12
13
|
turnQueue = null;
|
|
13
14
|
turnResolve = null;
|
|
@@ -15,51 +16,56 @@ export class CodexAppServerSession {
|
|
|
15
16
|
activeTurnId = null;
|
|
16
17
|
activeTurnOutputCount = 0;
|
|
17
18
|
activeTurnStderr = [];
|
|
19
|
+
activeTurnActivity = null;
|
|
18
20
|
completedTurnIds = [];
|
|
19
21
|
appliedPermissionMode;
|
|
22
|
+
appliedModel;
|
|
20
23
|
restartableEmptyThread = false;
|
|
21
24
|
threadId;
|
|
22
|
-
constructor(command, cwd, threadId, onThreadIdChanged, restartableEmptyThread = false) {
|
|
25
|
+
constructor(command, cwd, threadId, onThreadIdChanged, restartableEmptyThread = false, initialModel) {
|
|
23
26
|
this.command = command;
|
|
24
27
|
this.cwd = cwd;
|
|
25
28
|
this.onThreadIdChanged = onThreadIdChanged;
|
|
29
|
+
this.initialModel = initialModel;
|
|
26
30
|
this.threadId = threadId ?? null;
|
|
27
31
|
this.restartableEmptyThread = Boolean(threadId) && restartableEmptyThread;
|
|
28
32
|
}
|
|
29
|
-
async ensure(permissionMode) {
|
|
30
|
-
return await this.ensurePermission(normalizeCodexPermissionMode(permissionMode));
|
|
33
|
+
async ensure(permissionMode, model) {
|
|
34
|
+
return await this.ensurePermission(normalizeCodexPermissionMode(permissionMode), normalizeModel(model ?? this.initialModel));
|
|
31
35
|
}
|
|
32
36
|
async ensureCurrentPermission() {
|
|
33
|
-
return await this.ensurePermission(normalizeCodexPermissionMode(this.appliedPermissionMode));
|
|
37
|
+
return await this.ensurePermission(normalizeCodexPermissionMode(this.appliedPermissionMode), this.appliedModel ?? normalizeModel(this.initialModel));
|
|
34
38
|
}
|
|
35
|
-
async ensurePermission(permissionMode) {
|
|
39
|
+
async ensurePermission(permissionMode, model) {
|
|
36
40
|
const hadProcess = Boolean(this.rpc);
|
|
37
41
|
if (!this.rpc)
|
|
38
42
|
await this.connect();
|
|
39
43
|
if (this.threadId) {
|
|
40
|
-
if (!hadProcess || permissionMode !== this.appliedPermissionMode) {
|
|
44
|
+
if (!hadProcess || permissionMode !== this.appliedPermissionMode || model !== this.appliedModel) {
|
|
41
45
|
try {
|
|
42
|
-
await this.request("thread/resume", codexThreadResumeParams(this.threadId, this.cwd, permissionMode));
|
|
46
|
+
await this.request("thread/resume", codexThreadResumeParams(this.threadId, this.cwd, permissionMode, model));
|
|
43
47
|
}
|
|
44
48
|
catch (error) {
|
|
45
49
|
if (!this.canRestartEmptyThread(error))
|
|
46
50
|
throw error;
|
|
47
|
-
return await this.restartEmptyThread(permissionMode);
|
|
51
|
+
return await this.restartEmptyThread(permissionMode, model);
|
|
48
52
|
}
|
|
49
53
|
this.appliedPermissionMode = permissionMode;
|
|
54
|
+
this.appliedModel = model;
|
|
50
55
|
}
|
|
51
56
|
return this.threadId;
|
|
52
57
|
}
|
|
53
|
-
return await this.startNewThread(permissionMode, true);
|
|
58
|
+
return await this.startNewThread(permissionMode, true, model);
|
|
54
59
|
}
|
|
55
|
-
async startNewThread(permissionMode, restartableEmptyThread) {
|
|
56
|
-
const result = (await this.request("thread/start", codexThreadStartParams(this.cwd, permissionMode)));
|
|
60
|
+
async startNewThread(permissionMode, restartableEmptyThread, model) {
|
|
61
|
+
const result = (await this.request("thread/start", codexThreadStartParams(this.cwd, permissionMode, model)));
|
|
57
62
|
const threadId = result.thread?.id;
|
|
58
63
|
if (!threadId)
|
|
59
64
|
throw new Error("Codex app-server did not return a thread id");
|
|
60
65
|
this.threadId = threadId;
|
|
61
66
|
this.restartableEmptyThread = restartableEmptyThread;
|
|
62
67
|
this.appliedPermissionMode = permissionMode;
|
|
68
|
+
this.appliedModel = model;
|
|
63
69
|
this.onThreadIdChanged?.(threadId);
|
|
64
70
|
return threadId;
|
|
65
71
|
}
|
|
@@ -69,20 +75,21 @@ export class CodexAppServerSession {
|
|
|
69
75
|
!this.activeTurnId &&
|
|
70
76
|
/no rollout found|failed to load thread history|invalid thread-store request/iu.test(error instanceof Error ? error.message : String(error)));
|
|
71
77
|
}
|
|
72
|
-
async restartEmptyThread(permissionMode) {
|
|
78
|
+
async restartEmptyThread(permissionMode, model) {
|
|
73
79
|
const previousThreadId = this.threadId;
|
|
74
80
|
if (previousThreadId) {
|
|
75
81
|
await this.request("thread/archive", { threadId: previousThreadId }).catch(() => undefined);
|
|
76
82
|
}
|
|
77
83
|
this.threadId = null;
|
|
78
84
|
this.appliedPermissionMode = undefined;
|
|
85
|
+
this.appliedModel = undefined;
|
|
79
86
|
this.restartableEmptyThread = false;
|
|
80
87
|
this.turnQueue?.push({
|
|
81
88
|
type: "status",
|
|
82
89
|
text: "Codex empty thread could not be resumed; starting a fresh empty thread with the requested permission mode.",
|
|
83
90
|
tag: "runtime",
|
|
84
91
|
});
|
|
85
|
-
return await this.startNewThread(permissionMode, true);
|
|
92
|
+
return await this.startNewThread(permissionMode, true, model);
|
|
86
93
|
}
|
|
87
94
|
startTurn(input) {
|
|
88
95
|
const queue = new AsyncQueue();
|
|
@@ -101,7 +108,7 @@ export class CodexAppServerSession {
|
|
|
101
108
|
queue.close();
|
|
102
109
|
resolveResult(value);
|
|
103
110
|
};
|
|
104
|
-
this.sendTurn(input.text, input.timeoutMs, input.permissionMode).catch((error) => {
|
|
111
|
+
this.sendTurn(input.text, input.timeoutMs, input.permissionMode, input.model).catch((error) => {
|
|
105
112
|
queue.push({ type: "error", message: error instanceof Error ? error.message : String(error) });
|
|
106
113
|
this.turnResolve?.({ status: "failed", error: { message: error instanceof Error ? error.message : String(error) } });
|
|
107
114
|
});
|
|
@@ -198,20 +205,44 @@ export class CodexAppServerSession {
|
|
|
198
205
|
throw error;
|
|
199
206
|
}
|
|
200
207
|
}
|
|
201
|
-
async sendTurn(text,
|
|
202
|
-
const threadId = await this.ensure(permissionMode);
|
|
208
|
+
async sendTurn(text, inactivityTimeoutMs, permissionMode, model) {
|
|
209
|
+
const threadId = await this.ensure(permissionMode, model);
|
|
203
210
|
const completion = new Promise((resolve) => {
|
|
204
211
|
this.activeCompletionResolve = resolve;
|
|
205
212
|
});
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
let inactivityTimer = null;
|
|
214
|
+
const clearInactivityTimer = () => {
|
|
215
|
+
if (!inactivityTimer)
|
|
216
|
+
return;
|
|
217
|
+
clearTimeout(inactivityTimer);
|
|
218
|
+
inactivityTimer = null;
|
|
219
|
+
};
|
|
220
|
+
const refreshInactivityTimer = () => {
|
|
221
|
+
if (!inactivityTimeoutMs)
|
|
222
|
+
return;
|
|
223
|
+
clearInactivityTimer();
|
|
224
|
+
inactivityTimer = setTimeout(() => {
|
|
225
|
+
inactivityTimer = null;
|
|
226
|
+
this.turnQueue?.push({
|
|
227
|
+
type: "status",
|
|
228
|
+
text: `No Codex runtime activity for ${inactivityTimeoutMs}ms; still waiting for provider completion.`,
|
|
229
|
+
tag: "inactivity",
|
|
230
|
+
});
|
|
231
|
+
}, inactivityTimeoutMs);
|
|
232
|
+
};
|
|
233
|
+
this.activeTurnActivity = refreshInactivityTimer;
|
|
234
|
+
refreshInactivityTimer();
|
|
235
|
+
try {
|
|
236
|
+
const result = (await this.request("turn/start", codexTurnStartParams(threadId, this.cwd, text, normalizeCodexPermissionMode(permissionMode))));
|
|
237
|
+
this.activeTurnId = result.turn?.id ?? null;
|
|
238
|
+
const finalResult = await completion;
|
|
239
|
+
this.turnResolve?.(finalResult);
|
|
240
|
+
}
|
|
241
|
+
finally {
|
|
242
|
+
clearInactivityTimer();
|
|
243
|
+
this.activeTurnActivity = null;
|
|
244
|
+
this.activeCompletionResolve = null;
|
|
245
|
+
}
|
|
215
246
|
}
|
|
216
247
|
async interrupt() {
|
|
217
248
|
if (!this.threadId || !this.activeTurnId)
|
|
@@ -225,6 +256,7 @@ export class CodexAppServerSession {
|
|
|
225
256
|
const decision = codexServerRequestResponse(method, params, this.appliedPermissionMode);
|
|
226
257
|
if (!decision)
|
|
227
258
|
throw new Error(`Unsupported Codex app-server request: ${method}`);
|
|
259
|
+
this.noteTurnActivity();
|
|
228
260
|
this.turnQueue?.push({ type: "status", text: decision.summary, tag: "approval" });
|
|
229
261
|
return decision.response;
|
|
230
262
|
}
|
|
@@ -232,7 +264,13 @@ export class CodexAppServerSession {
|
|
|
232
264
|
const queue = this.turnQueue;
|
|
233
265
|
if (!method || !queue)
|
|
234
266
|
return;
|
|
267
|
+
this.noteTurnActivity();
|
|
235
268
|
const payload = recordFrom(params);
|
|
269
|
+
const usage = codexUsageEventFromNotification(method, payload);
|
|
270
|
+
if (usage) {
|
|
271
|
+
queue.push(usage);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
236
274
|
if (method === "turn/started") {
|
|
237
275
|
this.activeTurnId = stringField(recordFrom(payload.turn), "id") ?? stringField(payload, "turnId") ?? this.activeTurnId;
|
|
238
276
|
queue.push({ type: "status", text: "Codex turn started", tag: "turn" });
|
|
@@ -283,12 +321,16 @@ export class CodexAppServerSession {
|
|
|
283
321
|
}
|
|
284
322
|
recordStderr(text) {
|
|
285
323
|
if (this.turnQueue) {
|
|
324
|
+
this.noteTurnActivity();
|
|
286
325
|
this.activeTurnStderr.push(text);
|
|
287
326
|
if (this.activeTurnStderr.length > 25)
|
|
288
327
|
this.activeTurnStderr.shift();
|
|
289
328
|
this.turnQueue.push({ type: "status", text, tag: "stderr" });
|
|
290
329
|
}
|
|
291
330
|
}
|
|
331
|
+
noteTurnActivity() {
|
|
332
|
+
this.activeTurnActivity?.();
|
|
333
|
+
}
|
|
292
334
|
emptyCompletionFailure() {
|
|
293
335
|
if (this.activeTurnOutputCount > 0)
|
|
294
336
|
return undefined;
|
|
@@ -318,4 +360,59 @@ function codexStderrMessage(text) {
|
|
|
318
360
|
}
|
|
319
361
|
return text.trim();
|
|
320
362
|
}
|
|
363
|
+
function codexUsageEventFromNotification(method, payload) {
|
|
364
|
+
const candidates = [
|
|
365
|
+
payload,
|
|
366
|
+
recordFrom(payload.payload),
|
|
367
|
+
recordFrom(payload.event),
|
|
368
|
+
recordFrom(payload.message),
|
|
369
|
+
];
|
|
370
|
+
for (const candidate of candidates) {
|
|
371
|
+
const type = stringField(candidate, "type");
|
|
372
|
+
const info = recordFrom(candidate.info);
|
|
373
|
+
const total = recordFrom(info.total_token_usage ?? candidate.total_token_usage ?? candidate.totalTokenUsage);
|
|
374
|
+
const last = recordFrom(info.last_token_usage ?? candidate.last_token_usage ?? candidate.lastTokenUsage);
|
|
375
|
+
const contextWindow = numberField(info, "model_context_window", "modelContextWindow") ?? numberField(candidate, "model_context_window", "modelContextWindow");
|
|
376
|
+
const totalTokens = numberField(total, "total_tokens", "totalTokens") ??
|
|
377
|
+
numberField(candidate, "total_tokens", "totalTokens");
|
|
378
|
+
const inputTokens = numberField(total, "input_tokens", "inputTokens") ??
|
|
379
|
+
numberField(last, "input_tokens", "inputTokens") ??
|
|
380
|
+
numberField(candidate, "input_tokens", "inputTokens");
|
|
381
|
+
const outputTokens = numberField(total, "output_tokens", "outputTokens") ??
|
|
382
|
+
numberField(last, "output_tokens", "outputTokens") ??
|
|
383
|
+
numberField(candidate, "output_tokens", "outputTokens");
|
|
384
|
+
const cachedInputTokens = numberField(total, "cached_input_tokens", "cachedInputTokens") ??
|
|
385
|
+
numberField(last, "cached_input_tokens", "cachedInputTokens") ??
|
|
386
|
+
numberField(candidate, "cached_input_tokens", "cachedInputTokens");
|
|
387
|
+
const reasoningOutputTokens = numberField(total, "reasoning_output_tokens", "reasoningOutputTokens") ??
|
|
388
|
+
numberField(last, "reasoning_output_tokens", "reasoningOutputTokens") ??
|
|
389
|
+
numberField(candidate, "reasoning_output_tokens", "reasoningOutputTokens");
|
|
390
|
+
const usedTokens = totalTokens ?? inputTokens;
|
|
391
|
+
if (usedTokens === undefined || (type !== "token_count" && !/token|usage/i.test(method) && contextWindow === undefined))
|
|
392
|
+
continue;
|
|
393
|
+
return {
|
|
394
|
+
type: "session_usage",
|
|
395
|
+
source: "provider",
|
|
396
|
+
usedTokens,
|
|
397
|
+
...(contextWindow !== undefined ? { contextWindowTokens: contextWindow } : {}),
|
|
398
|
+
...(inputTokens !== undefined ? { inputTokens } : {}),
|
|
399
|
+
...(outputTokens !== undefined ? { outputTokens } : {}),
|
|
400
|
+
...(cachedInputTokens !== undefined ? { cachedInputTokens } : {}),
|
|
401
|
+
...(reasoningOutputTokens !== undefined ? { reasoningOutputTokens } : {}),
|
|
402
|
+
...(totalTokens !== undefined ? { totalTokens } : {}),
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
return undefined;
|
|
406
|
+
}
|
|
407
|
+
function numberField(record, ...keys) {
|
|
408
|
+
for (const key of keys) {
|
|
409
|
+
const value = record[key];
|
|
410
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
411
|
+
return Math.max(0, Math.round(value));
|
|
412
|
+
}
|
|
413
|
+
return undefined;
|
|
414
|
+
}
|
|
415
|
+
function normalizeModel(value) {
|
|
416
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
417
|
+
}
|
|
321
418
|
//# sourceMappingURL=codex-app-server.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RuntimeHistoricalEvent, RuntimeHistoricalSession, RuntimeHistoricalSessionPage } from "
|
|
1
|
+
import type { RuntimeHistoricalEvent, RuntimeHistoricalSession, RuntimeHistoricalSessionPage } from "../../runtime/dist/index.js";
|
|
2
2
|
export declare function readCodexCanonicalHistoricalSessionPage(input: {
|
|
3
3
|
command: string;
|
|
4
4
|
cwd?: string;
|
|
@@ -9,7 +9,6 @@ export declare function readCodexCanonicalHistoricalSessionPage(input: {
|
|
|
9
9
|
snapshotDir?: string;
|
|
10
10
|
}): Promise<RuntimeHistoricalSessionPage>;
|
|
11
11
|
export declare function readCodexFilesystemHistoricalSessionPage(cwd: string | undefined, limit: number, runtimeCwd?: string, includeArchived?: boolean, cursor?: string): Promise<RuntimeHistoricalSessionPage>;
|
|
12
|
-
export declare function readCodexHistoricalSessions(command: string, cwd: string | undefined, limit: number, runtimeCwd?: string, includeArchived?: boolean): Promise<RuntimeHistoricalSession[]>;
|
|
13
12
|
export declare function readCodexHistoricalSessionPage(command: string, cwd: string | undefined, limit: number, runtimeCwd?: string, includeArchived?: boolean, cursor?: string): Promise<RuntimeHistoricalSessionPage>;
|
|
14
13
|
export declare function codexThreadRecordToHistoricalSession(item: unknown, cwd: string | undefined, runtimeCwd?: string): RuntimeHistoricalSession | undefined;
|
|
15
14
|
export declare function codexToolEventFromItem(item: unknown, fallbackStatus?: "started" | "completed"): RuntimeHistoricalEvent["payload"] | undefined;
|
|
@@ -111,9 +111,6 @@ export async function readCodexFilesystemHistoricalSessionPage(cwd, limit, runti
|
|
|
111
111
|
...(hasMore ? { nextCursor: encodeFilesystemCursor({ phase, indexOffset, directoryIndex, fileIndex, legacySkip }) } : {}),
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
|
-
export async function readCodexHistoricalSessions(command, cwd, limit, runtimeCwd = process.cwd(), includeArchived = false) {
|
|
115
|
-
return (await readCodexHistoricalSessionPage(command, cwd, limit, runtimeCwd, includeArchived)).sessions;
|
|
116
|
-
}
|
|
117
114
|
export async function readCodexHistoricalSessionPage(command, cwd, limit, runtimeCwd = process.cwd(), includeArchived = false, cursor) {
|
|
118
115
|
const rpc = probeClient(command, cwd ? canonicalPath(cwd) : runtimeCwd);
|
|
119
116
|
try {
|
|
@@ -209,6 +206,15 @@ function timestampMs(value) {
|
|
|
209
206
|
}
|
|
210
207
|
return undefined;
|
|
211
208
|
}
|
|
209
|
+
function uuidV7TimestampMs(value) {
|
|
210
|
+
if (!value)
|
|
211
|
+
return undefined;
|
|
212
|
+
const match = /^([0-9a-f]{8})-([0-9a-f]{4})-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.exec(value);
|
|
213
|
+
if (!match)
|
|
214
|
+
return undefined;
|
|
215
|
+
const timestamp = Number.parseInt(`${match[1]}${match[2]}`, 16);
|
|
216
|
+
return Number.isSafeInteger(timestamp) ? timestamp : undefined;
|
|
217
|
+
}
|
|
212
218
|
function stringifyToolText(value) {
|
|
213
219
|
if (typeof value === "string")
|
|
214
220
|
return value.trim();
|
|
@@ -269,7 +275,7 @@ export function codexToolEventFromItem(item, fallbackStatus = "completed") {
|
|
|
269
275
|
export function codexTurnToHistoricalEvents(turn) {
|
|
270
276
|
const record = recordFrom(turn);
|
|
271
277
|
const turnId = typeof record.id === "string" ? record.id : randomUUID();
|
|
272
|
-
const turnTimestamp = timestampMs(recordFrom(turn).createdAt ?? recordFrom(turn).timestamp ?? recordFrom(turn).updatedAt);
|
|
278
|
+
const turnTimestamp = timestampMs(recordFrom(turn).createdAt ?? recordFrom(turn).timestamp ?? recordFrom(turn).updatedAt) ?? uuidV7TimestampMs(turnId);
|
|
273
279
|
const events = [];
|
|
274
280
|
for (const item of Array.isArray(record.items) ? record.items : []) {
|
|
275
281
|
const itemRecord = recordFrom(item);
|
|
@@ -594,7 +600,7 @@ function parseCodexRolloutEvents(records) {
|
|
|
594
600
|
turnIndex += 1;
|
|
595
601
|
stableTurnId = `turn_${turnIndex}`;
|
|
596
602
|
}
|
|
597
|
-
const occurredAt = timestampMs(record.timestamp ?? payload.createdAt ?? payload.updatedAt);
|
|
603
|
+
const occurredAt = timestampMs(record.timestamp ?? payload.createdAt ?? payload.updatedAt) ?? uuidV7TimestampMs(stableTurnId);
|
|
598
604
|
if (record.type === "event_msg" && payloadType === "user_message") {
|
|
599
605
|
const text = stringField(payload, "message")?.trim();
|
|
600
606
|
if (text)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RuntimePermissionMode } from "./permissions.js";
|
|
2
2
|
export declare function normalizeCodexPermissionMode(mode?: RuntimePermissionMode): RuntimePermissionMode;
|
|
3
|
-
export declare function codexThreadStartParams(cwd: string, permissionMode: RuntimePermissionMode): Record<string, unknown>;
|
|
4
|
-
export declare function codexThreadResumeParams(threadId: string, cwd: string, permissionMode: RuntimePermissionMode): Record<string, unknown>;
|
|
3
|
+
export declare function codexThreadStartParams(cwd: string, permissionMode: RuntimePermissionMode, model?: string): Record<string, unknown>;
|
|
4
|
+
export declare function codexThreadResumeParams(threadId: string, cwd: string, permissionMode: RuntimePermissionMode, model?: string): Record<string, unknown>;
|
|
5
5
|
export declare function codexTurnStartParams(threadId: string, cwd: string, text: string, permissionMode: RuntimePermissionMode): Record<string, unknown>;
|
|
6
6
|
//# sourceMappingURL=codex-protocol.d.ts.map
|