@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
|
@@ -176,7 +176,13 @@ export function createExternalAgentRuntimeProvider(options) {
|
|
|
176
176
|
}));
|
|
177
177
|
}
|
|
178
178
|
function clientForAgent(agent) {
|
|
179
|
-
|
|
179
|
+
const client = clientsByAgent.get(agent);
|
|
180
|
+
if (!client)
|
|
181
|
+
return undefined;
|
|
182
|
+
if (client.isAvailable() && client.listAgents().some((profile) => profile.id === agent))
|
|
183
|
+
return client;
|
|
184
|
+
clientsByAgent.delete(agent);
|
|
185
|
+
return undefined;
|
|
180
186
|
}
|
|
181
187
|
function clientForHandle(handle) {
|
|
182
188
|
return handle.externalProviderId ? clients.find((client) => client.id === handle.externalProviderId) : undefined;
|
|
@@ -220,6 +226,7 @@ export function createExternalAgentRuntimeProvider(options) {
|
|
|
220
226
|
agentSessionId: handle.sessionId,
|
|
221
227
|
externalProviderId: handle.provider,
|
|
222
228
|
externalHandle: handle,
|
|
229
|
+
...(handle.model ? { model: handle.model } : {}),
|
|
223
230
|
};
|
|
224
231
|
}
|
|
225
232
|
function sdkHandle(handle) {
|
|
@@ -248,7 +255,7 @@ export function createExternalAgentRuntimeProvider(options) {
|
|
|
248
255
|
id: "fallback",
|
|
249
256
|
load: (cursor, pageLimit) => filterHistoricalSessionPage(fallbackHistoricalSessionPage({ ...input, cursor, limit: pageLimit }), input.cwdMode),
|
|
250
257
|
},
|
|
251
|
-
...clients.map((client) => ({
|
|
258
|
+
...clients.filter((client) => client.isAvailable()).map((client) => ({
|
|
252
259
|
id: `external:${client.id}`,
|
|
253
260
|
load: (cursor, pageLimit) => filterHistoricalSessionPage(client.request("listHistoricalSessions", { ...input, cursor, limit: pageLimit }).catch(emptyPageUnlessCursorStale), input.cwdMode),
|
|
254
261
|
})),
|
|
@@ -276,20 +283,26 @@ export function createExternalAgentRuntimeProvider(options) {
|
|
|
276
283
|
return options.fallback.getCapabilities();
|
|
277
284
|
},
|
|
278
285
|
listAgents() {
|
|
279
|
-
const externalAgents = clients.flatMap((client) => client.listAgents()).map((agent) =>
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
286
|
+
const externalAgents = clients.flatMap((client) => client.listAgents()).map((agent) => {
|
|
287
|
+
const defaultModel = normalizedModelId(agent.defaultModel);
|
|
288
|
+
const models = normalizeModelOptions(agent.models);
|
|
289
|
+
return {
|
|
290
|
+
id: agent.id,
|
|
291
|
+
label: agent.label,
|
|
292
|
+
command: agent.command,
|
|
293
|
+
...(defaultModel ? { defaultModel } : {}),
|
|
294
|
+
...(models ? { models } : {}),
|
|
295
|
+
historyModel: normalizeHistoryModel(agent.historyModel),
|
|
296
|
+
sessionPrimitives: agent.capabilities?.sessionPrimitives
|
|
297
|
+
? {
|
|
298
|
+
resume: fromSdkPrimitive(agent.capabilities.sessionPrimitives.resume),
|
|
299
|
+
rewind: fromSdkPrimitive(agent.capabilities.sessionPrimitives.rewind),
|
|
300
|
+
fork: fromSdkPrimitive(agent.capabilities.sessionPrimitives.fork),
|
|
301
|
+
rename: agent.capabilities.sessionPrimitives.rename ? fromSdkPrimitive(agent.capabilities.sessionPrimitives.rename) : "unsupported",
|
|
302
|
+
}
|
|
303
|
+
: undefined,
|
|
304
|
+
};
|
|
305
|
+
});
|
|
293
306
|
const agentsById = new Map();
|
|
294
307
|
for (const agent of externalAgents)
|
|
295
308
|
agentsById.set(agent.id, agent);
|
|
@@ -312,6 +325,7 @@ export function createExternalAgentRuntimeProvider(options) {
|
|
|
312
325
|
...(input.resumeHandle ? { resumeHandle: sdkHandle(input.resumeHandle) } : {}),
|
|
313
326
|
cwd: input.cwd,
|
|
314
327
|
permissionMode: input.permissionMode,
|
|
328
|
+
model: input.model,
|
|
315
329
|
restartableEmptySession: input.restartableEmptySession,
|
|
316
330
|
});
|
|
317
331
|
return toRuntimeHandle(input.sessionKey, handle, input.cwd);
|
|
@@ -372,6 +386,83 @@ export function createExternalAgentRuntimeProvider(options) {
|
|
|
372
386
|
}
|
|
373
387
|
throw new Error(`External provider ${client.id} exceeded the historical event page safety limit`);
|
|
374
388
|
},
|
|
389
|
+
async inspectTurn(input) {
|
|
390
|
+
const client = requireClientForHandle(input.handle);
|
|
391
|
+
if (!client) {
|
|
392
|
+
if (options.fallback.inspectTurn)
|
|
393
|
+
return await options.fallback.inspectTurn(input);
|
|
394
|
+
return {
|
|
395
|
+
status: "uninspectable",
|
|
396
|
+
providerTurnId: input.providerTurnId ?? input.handle.backendSessionId,
|
|
397
|
+
reason: "Fallback runtime does not expose inspectTurn",
|
|
398
|
+
evidence: "unsupported",
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
const runtimeSessionId = input.handle.backendSessionId;
|
|
402
|
+
if (!runtimeSessionId) {
|
|
403
|
+
return {
|
|
404
|
+
status: "uninspectable",
|
|
405
|
+
providerTurnId: input.providerTurnId,
|
|
406
|
+
reason: "External provider handle is missing backendSessionId",
|
|
407
|
+
evidence: "missing-backend-session-id",
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
try {
|
|
411
|
+
return await client.request("inspectTurn", {
|
|
412
|
+
handle: sdkHandle(input.handle),
|
|
413
|
+
turnId: input.turnId,
|
|
414
|
+
providerTurnId: input.providerTurnId,
|
|
415
|
+
requestId: input.requestId,
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
catch (error) {
|
|
419
|
+
if (!isUnsupportedProviderError(error)) {
|
|
420
|
+
return {
|
|
421
|
+
status: "unknown",
|
|
422
|
+
providerTurnId: input.providerTurnId ?? runtimeSessionId,
|
|
423
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
424
|
+
evidence: "provider-inspect-error",
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
try {
|
|
429
|
+
const events = [];
|
|
430
|
+
let before;
|
|
431
|
+
const seenCursors = new Set();
|
|
432
|
+
for (let pageCount = 0; pageCount < historicalEventPageSafetyLimit; pageCount += 1) {
|
|
433
|
+
const page = await client.request("readHistoricalEvents", {
|
|
434
|
+
agent: input.handle.runtimeSessionName,
|
|
435
|
+
cwd: input.handle.cwd ?? "",
|
|
436
|
+
runtimeSessionId,
|
|
437
|
+
handle: sdkHandle(input.handle),
|
|
438
|
+
before,
|
|
439
|
+
limit: historicalEventPageLimit,
|
|
440
|
+
});
|
|
441
|
+
events.unshift(...page.events);
|
|
442
|
+
if (!page.hasMoreBefore)
|
|
443
|
+
break;
|
|
444
|
+
if (!page.nextBefore)
|
|
445
|
+
throw new Error(`External provider ${client.id} returned more history without a nextBefore cursor`);
|
|
446
|
+
if (seenCursors.has(page.nextBefore))
|
|
447
|
+
throw new Error(`External provider ${client.id} returned a repeated history cursor`);
|
|
448
|
+
seenCursors.add(page.nextBefore);
|
|
449
|
+
before = page.nextBefore;
|
|
450
|
+
}
|
|
451
|
+
return inspectHistoricalEvents(events ?? [], {
|
|
452
|
+
turnId: input.turnId,
|
|
453
|
+
providerTurnId: input.providerTurnId,
|
|
454
|
+
fallbackProviderTurnId: runtimeSessionId,
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
catch (error) {
|
|
458
|
+
return {
|
|
459
|
+
status: "unknown",
|
|
460
|
+
providerTurnId: input.providerTurnId ?? runtimeSessionId,
|
|
461
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
462
|
+
evidence: "provider-history-error",
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
},
|
|
375
466
|
startTurn(input) {
|
|
376
467
|
const client = requireClientForHandle(input.handle);
|
|
377
468
|
if (!client)
|
|
@@ -383,7 +474,7 @@ export function createExternalAgentRuntimeProvider(options) {
|
|
|
383
474
|
mode: input.mode,
|
|
384
475
|
permissionMode: input.permissionMode,
|
|
385
476
|
requestId: input.requestId,
|
|
386
|
-
|
|
477
|
+
model: input.model ?? input.handle.model,
|
|
387
478
|
});
|
|
388
479
|
},
|
|
389
480
|
cancel(input) {
|
|
@@ -441,6 +532,31 @@ function emptyPageUnlessCursorStale(error) {
|
|
|
441
532
|
throw error;
|
|
442
533
|
return { sessions: [] };
|
|
443
534
|
}
|
|
535
|
+
function normalizedModelId(value) {
|
|
536
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
537
|
+
}
|
|
538
|
+
function normalizeModelOptions(value) {
|
|
539
|
+
if (!Array.isArray(value))
|
|
540
|
+
return undefined;
|
|
541
|
+
const seen = new Set();
|
|
542
|
+
const models = value.flatMap((item) => {
|
|
543
|
+
if (!isRecord(item))
|
|
544
|
+
return [];
|
|
545
|
+
const id = normalizedModelId(item.id);
|
|
546
|
+
if (!id || seen.has(id))
|
|
547
|
+
return [];
|
|
548
|
+
seen.add(id);
|
|
549
|
+
const label = normalizedModelId(item.label);
|
|
550
|
+
const reason = normalizedModelId(item.reason);
|
|
551
|
+
return [{
|
|
552
|
+
id,
|
|
553
|
+
...(label ? { label } : {}),
|
|
554
|
+
...(item.unavailable === true ? { unavailable: true } : {}),
|
|
555
|
+
...(reason ? { reason } : {}),
|
|
556
|
+
}];
|
|
557
|
+
});
|
|
558
|
+
return models.length > 0 ? models : undefined;
|
|
559
|
+
}
|
|
444
560
|
class ExternalProviderClient {
|
|
445
561
|
config;
|
|
446
562
|
id;
|
|
@@ -470,6 +586,9 @@ class ExternalProviderClient {
|
|
|
470
586
|
listAgents() {
|
|
471
587
|
return this.agents;
|
|
472
588
|
}
|
|
589
|
+
isAvailable() {
|
|
590
|
+
return this.ready && !!this.child && !this.child.killed && !this.exited;
|
|
591
|
+
}
|
|
473
592
|
diagnostics() {
|
|
474
593
|
const processAvailable = !!this.child && !this.child.killed && !this.exited;
|
|
475
594
|
return {
|
|
@@ -568,6 +687,14 @@ class ExternalProviderClient {
|
|
|
568
687
|
cancel: async (input) => {
|
|
569
688
|
await this.request("cancel", { handle: params.handle, reason: input?.reason });
|
|
570
689
|
},
|
|
690
|
+
respondOption: async (input) => {
|
|
691
|
+
await this.request("respondOption", {
|
|
692
|
+
handle: params.handle,
|
|
693
|
+
optionRequestId: input.optionRequestId,
|
|
694
|
+
...(input.selectedOptionId ? { selectedOptionId: input.selectedOptionId } : {}),
|
|
695
|
+
...(input.text ? { text: input.text } : {}),
|
|
696
|
+
});
|
|
697
|
+
},
|
|
571
698
|
closeStream: async (input) => {
|
|
572
699
|
await this.request("cancel", { handle: params.handle, reason: input?.reason ?? "stream closed" });
|
|
573
700
|
},
|
|
@@ -648,6 +775,7 @@ class ExternalProviderClient {
|
|
|
648
775
|
this.ready = false;
|
|
649
776
|
this.exited = true;
|
|
650
777
|
this.lastError = error.message;
|
|
778
|
+
this.agents = [];
|
|
651
779
|
for (const [id, pending] of this.pending) {
|
|
652
780
|
clearTimeout(pending.timer);
|
|
653
781
|
pending.reject(error);
|
|
@@ -733,12 +861,54 @@ function fromSdkEvent(event) {
|
|
|
733
861
|
function fromSdkResult(result) {
|
|
734
862
|
return result;
|
|
735
863
|
}
|
|
864
|
+
function inspectHistoricalEvents(events, input) {
|
|
865
|
+
const candidates = new Set([input.turnId, input.providerTurnId].filter((value) => typeof value === "string" && value.length > 0));
|
|
866
|
+
const providerTurnId = input.providerTurnId ?? input.fallbackProviderTurnId;
|
|
867
|
+
const relevant = candidates.size === 0
|
|
868
|
+
? events
|
|
869
|
+
: events.filter((event) => {
|
|
870
|
+
if (candidates.has(event.turnId))
|
|
871
|
+
return true;
|
|
872
|
+
if (event.payload.type !== "done")
|
|
873
|
+
return false;
|
|
874
|
+
return Boolean((event.payload.currentHead && candidates.has(event.payload.currentHead)) ||
|
|
875
|
+
(event.payload.lastTurnId && candidates.has(event.payload.lastTurnId)));
|
|
876
|
+
});
|
|
877
|
+
if (relevant.length === 0) {
|
|
878
|
+
return {
|
|
879
|
+
status: "not_found",
|
|
880
|
+
providerTurnId,
|
|
881
|
+
reason: "No provider history event matched the requested turn",
|
|
882
|
+
evidence: "provider-history-empty",
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
const done = [...relevant].reverse().find((event) => event.payload.type === "done");
|
|
886
|
+
if (done?.payload.type === "done") {
|
|
887
|
+
return {
|
|
888
|
+
status: "terminal",
|
|
889
|
+
terminalStatus: done.payload.status,
|
|
890
|
+
currentHead: done.payload.currentHead,
|
|
891
|
+
lastTurnId: done.payload.lastTurnId ?? done.turnId,
|
|
892
|
+
providerTurnId: done.payload.lastTurnId ?? done.payload.currentHead ?? providerTurnId,
|
|
893
|
+
error: done.payload.error,
|
|
894
|
+
evidence: "provider-history-terminal",
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
return {
|
|
898
|
+
status: "active",
|
|
899
|
+
providerTurnId,
|
|
900
|
+
evidence: "provider-history-nonterminal-events",
|
|
901
|
+
};
|
|
902
|
+
}
|
|
736
903
|
function providerResponseError(message) {
|
|
737
904
|
const error = new Error(message.error.message);
|
|
738
905
|
error.name = message.error.code;
|
|
739
906
|
error.code = message.error.code;
|
|
740
907
|
return error;
|
|
741
908
|
}
|
|
909
|
+
function isUnsupportedProviderError(error) {
|
|
910
|
+
return error instanceof Error && (error.name === "UNSUPPORTED" || error.code === "UNSUPPORTED");
|
|
911
|
+
}
|
|
742
912
|
function requiredString(value, label) {
|
|
743
913
|
if (typeof value !== "string" || !value.trim())
|
|
744
914
|
throw new Error(`${label} must be a non-empty string.`);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { HappyElvesRuntime } from "
|
|
1
|
+
import type { HappyElvesRuntime } from "../../../packages/runtime/dist/index.js";
|
|
2
2
|
import type { PrimitiveSupport } from "./types.js";
|
|
3
3
|
export declare function getRuntime(defaultCwd: string): HappyElvesRuntime;
|
|
4
4
|
export declare function initializeRuntime(defaultCwd: string): Promise<void>;
|
|
5
|
-
export declare function runtimeDiagnostics(): Array<Record<string, unknown>>;
|
|
6
5
|
export declare function disposeRuntime(): void;
|
|
7
6
|
export declare function setRuntimeForTests(runtimeOverride: HappyElvesRuntime | null): void;
|
|
8
7
|
export declare function runtimePrimitiveSupport(runtimeInstance: HappyElvesRuntime): {
|
|
@@ -57,9 +57,6 @@ export async function initializeRuntime(defaultCwd) {
|
|
|
57
57
|
await runtimeInstance.initialize();
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
export function runtimeDiagnostics() {
|
|
61
|
-
return runtime?.diagnostics?.() ?? [];
|
|
62
|
-
}
|
|
63
60
|
export function disposeRuntime() {
|
|
64
61
|
runtime?.dispose?.();
|
|
65
62
|
runtime = null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type MachineCommand, type ScheduleRecord } from "../../../../packages/shared/dist/index.js";
|
|
2
|
+
import type { DaemonConfig } from "../types.js";
|
|
3
|
+
type ScheduleCommand = Extract<MachineCommand, {
|
|
4
|
+
type: "machine:schedule";
|
|
5
|
+
}>;
|
|
6
|
+
export declare function handleScheduleCommand(ws: WebSocket, config: DaemonConfig, command: ScheduleCommand): Promise<void>;
|
|
7
|
+
declare function withSchedulePreview(schedule: ScheduleRecord): ScheduleRecord;
|
|
8
|
+
export declare const __testWithSchedulePreview: typeof withSchedulePreview;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { randomId } from "../../../../packages/shared/dist/index.js";
|
|
2
|
+
import { claimCommandRequest, sendCommandResponse } from "../relay/send.js";
|
|
3
|
+
import { nextRunAtForSchedule, nextRunPreviewForSchedule, occurrenceIdFor, runDueSchedulesNow, runMissedScheduleOccurrence, runScheduleNow } from "./runner.js";
|
|
4
|
+
import { compactSchedules, normalizeScheduleRecord, readScheduleStore, updateScheduleStore } from "./store.js";
|
|
5
|
+
export async function handleScheduleCommand(ws, config, command) {
|
|
6
|
+
if (!claimCommandRequest(ws, command.requestId))
|
|
7
|
+
return;
|
|
8
|
+
const result = await executeScheduleCommand(config, command);
|
|
9
|
+
await sendCommandResponse(ws, {
|
|
10
|
+
type: "machine:scheduleResult",
|
|
11
|
+
requestId: command.requestId,
|
|
12
|
+
machineId: config.machineId,
|
|
13
|
+
result,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
async function executeScheduleCommand(config, command) {
|
|
17
|
+
if (command.action === "list") {
|
|
18
|
+
const store = await readScheduleStore();
|
|
19
|
+
return { action: "list", schedules: compactSchedules(store).map(withSchedulePreview) };
|
|
20
|
+
}
|
|
21
|
+
if (command.action === "show") {
|
|
22
|
+
const store = await readScheduleStore();
|
|
23
|
+
return { action: "show", schedule: withSchedulePreview(requireSchedule(store, command.scheduleId)) };
|
|
24
|
+
}
|
|
25
|
+
if (command.action === "create") {
|
|
26
|
+
if (!command.schedule)
|
|
27
|
+
throw new Error("schedule create requires schedule input");
|
|
28
|
+
const scheduleInput = normalizeCreateInput(command.schedule);
|
|
29
|
+
const now = new Date().toISOString();
|
|
30
|
+
const schedule = normalizeScheduleRecord({
|
|
31
|
+
id: scheduleInput.id ?? randomId("sched"),
|
|
32
|
+
...(scheduleInput.name ? { name: scheduleInput.name } : {}),
|
|
33
|
+
...(scheduleInput.sessionId ? { sessionId: scheduleInput.sessionId } : {}),
|
|
34
|
+
...(scheduleInput.sourceSessionId ? { sourceSessionId: scheduleInput.sourceSessionId } : {}),
|
|
35
|
+
target: scheduleInput.target,
|
|
36
|
+
prompt: scheduleInput.prompt,
|
|
37
|
+
dueAt: scheduleInput.dueAt,
|
|
38
|
+
schedule: scheduleInput.schedule,
|
|
39
|
+
execution: scheduleInput.execution ?? "continue",
|
|
40
|
+
memoryMode: scheduleInput.memoryMode ?? "inherit",
|
|
41
|
+
stopOn: scheduleInput.stopOn ?? ["blocked", "failed", "permission"],
|
|
42
|
+
status: "active",
|
|
43
|
+
createdAt: now,
|
|
44
|
+
updatedAt: now,
|
|
45
|
+
runs: [],
|
|
46
|
+
});
|
|
47
|
+
if (!schedule)
|
|
48
|
+
throw new Error("schedule create input is invalid");
|
|
49
|
+
schedule.nextRunAt = nextRunAtForSchedule(schedule, Date.now());
|
|
50
|
+
const store = await updateScheduleStore((current) => ({
|
|
51
|
+
...current,
|
|
52
|
+
schedules: [schedule, ...current.schedules.filter((item) => item.id !== schedule.id)],
|
|
53
|
+
}));
|
|
54
|
+
return { action: "create", schedule: withSchedulePreview(requireSchedule(store, schedule.id)) };
|
|
55
|
+
}
|
|
56
|
+
if (command.action === "pause" || command.action === "resume" || command.action === "delete") {
|
|
57
|
+
const nextStatus = command.action === "pause" ? "paused" : command.action === "resume" ? "active" : "deleted";
|
|
58
|
+
const nowMs = Date.now();
|
|
59
|
+
const store = await updateScheduleStore((current) => ({
|
|
60
|
+
...current,
|
|
61
|
+
schedules: current.schedules.map((schedule) => schedule.id === command.scheduleId
|
|
62
|
+
? {
|
|
63
|
+
...schedule,
|
|
64
|
+
status: nextStatus,
|
|
65
|
+
...(nextStatus === "active" ? { nextRunAt: nextRunAtForSchedule(schedule, nowMs) } : { nextRunAt: undefined }),
|
|
66
|
+
updatedAt: new Date(nowMs).toISOString(),
|
|
67
|
+
}
|
|
68
|
+
: schedule),
|
|
69
|
+
}));
|
|
70
|
+
return {
|
|
71
|
+
action: command.action,
|
|
72
|
+
schedule: command.action === "delete" ? undefined : withSchedulePreview(requireSchedule(store, command.scheduleId)),
|
|
73
|
+
scheduleId: command.scheduleId,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (command.action === "history") {
|
|
77
|
+
const store = await readScheduleStore();
|
|
78
|
+
const schedule = requireSchedule(store, command.scheduleId);
|
|
79
|
+
return { action: "history", scheduleId: schedule.id, history: schedule.runs };
|
|
80
|
+
}
|
|
81
|
+
if (command.action === "run") {
|
|
82
|
+
const store = await readScheduleStore();
|
|
83
|
+
const schedule = requireSchedule(store, command.scheduleId);
|
|
84
|
+
const run = await runScheduleNow(config, schedule);
|
|
85
|
+
return { action: "run", scheduleId: schedule.id, run };
|
|
86
|
+
}
|
|
87
|
+
if (command.action === "runDue") {
|
|
88
|
+
const runs = await runDueSchedulesNow(config);
|
|
89
|
+
return { action: "runDue", runs };
|
|
90
|
+
}
|
|
91
|
+
if (command.action === "runMissed") {
|
|
92
|
+
const store = await readScheduleStore();
|
|
93
|
+
const schedule = requireSchedule(store, command.scheduleId);
|
|
94
|
+
const occurrenceId = command.occurrenceId ?? occurrenceIdFor(schedule);
|
|
95
|
+
const run = await runMissedScheduleOccurrence(config, schedule, occurrenceId);
|
|
96
|
+
return { action: "runMissed", scheduleId: schedule.id, run };
|
|
97
|
+
}
|
|
98
|
+
throw new Error(`Unsupported schedule action: ${command.action}`);
|
|
99
|
+
}
|
|
100
|
+
function requireSchedule(store, scheduleId) {
|
|
101
|
+
if (!scheduleId)
|
|
102
|
+
throw new Error("scheduleId is required");
|
|
103
|
+
const schedule = store.schedules.find((item) => item.id === scheduleId && item.status !== "deleted");
|
|
104
|
+
if (!schedule)
|
|
105
|
+
throw new Error("Schedule not found");
|
|
106
|
+
return schedule;
|
|
107
|
+
}
|
|
108
|
+
function withSchedulePreview(schedule) {
|
|
109
|
+
if (schedule.status !== "active") {
|
|
110
|
+
return {
|
|
111
|
+
...schedule,
|
|
112
|
+
nextRunAt: undefined,
|
|
113
|
+
previewRunAt: [],
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
...schedule,
|
|
118
|
+
nextRunAt: schedule.nextRunAt ?? nextRunAtForSchedule(schedule, Date.now()),
|
|
119
|
+
previewRunAt: nextRunPreviewForSchedule(schedule, 3, Date.now()),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
export const __testWithSchedulePreview = withSchedulePreview;
|
|
123
|
+
function normalizeCreateInput(input) {
|
|
124
|
+
const prompt = input.prompt?.trim();
|
|
125
|
+
if (!prompt)
|
|
126
|
+
throw new Error("schedule prompt is required");
|
|
127
|
+
const schedule = input.schedule ?? (input.dueAt ? { type: "oneshot", runAt: parseScheduleDate(input.dueAt) } : { type: "manual" });
|
|
128
|
+
const dueAt = schedule.type === "oneshot" ? parseScheduleDate(schedule.runAt) : input.dueAt ? parseScheduleDate(input.dueAt) : undefined;
|
|
129
|
+
const sourceSessionId = input.sourceSessionId ?? input.sessionId ?? (input.target?.type === "sourceSession" ? input.target.sourceSessionId : undefined);
|
|
130
|
+
const target = input.target ?? (sourceSessionId ? { type: "sourceSession", sourceSessionId } : undefined);
|
|
131
|
+
if (!target)
|
|
132
|
+
throw new Error("schedule target is required");
|
|
133
|
+
return {
|
|
134
|
+
...input,
|
|
135
|
+
prompt,
|
|
136
|
+
...(sourceSessionId ? { sourceSessionId, sessionId: input.sessionId ?? sourceSessionId } : {}),
|
|
137
|
+
target,
|
|
138
|
+
schedule,
|
|
139
|
+
...(dueAt ? { dueAt } : {}),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function parseScheduleDate(value) {
|
|
143
|
+
const date = new Date(value);
|
|
144
|
+
if (!Number.isFinite(date.getTime()))
|
|
145
|
+
throw new Error("Invalid schedule date");
|
|
146
|
+
return date.toISOString();
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ScheduleRecord, type ScheduleRunRecord } from "../../../../packages/shared/dist/index.js";
|
|
2
|
+
import type { DaemonConfig } from "../types.js";
|
|
3
|
+
export declare function tickSchedules(config: DaemonConfig, onlineSinceMs: number): Promise<void>;
|
|
4
|
+
export declare function runMissedScheduleOccurrence(config: DaemonConfig, schedule: ScheduleRecord, occurrenceId: string): Promise<ScheduleRunRecord>;
|
|
5
|
+
export declare function runScheduleNow(config: DaemonConfig, schedule: ScheduleRecord): Promise<ScheduleRunRecord>;
|
|
6
|
+
export declare function runDueSchedulesNow(config: DaemonConfig): Promise<Array<{
|
|
7
|
+
scheduleId: string;
|
|
8
|
+
run: ScheduleRunRecord;
|
|
9
|
+
}>>;
|
|
10
|
+
export declare function occurrenceIdFor(schedule: Pick<ScheduleRecord, "id" | "dueAt" | "nextRunAt">, dueAt?: string): string;
|
|
11
|
+
export declare function __testWithActiveScheduleOccurrence<T>(scheduleId: string, occurrenceId: string, action: () => Promise<T> | T): Promise<T>;
|
|
12
|
+
export declare function nextRunAtForSchedule(schedule: Pick<ScheduleRecord, "schedule" | "dueAt" | "runs">, afterMs?: number): string | undefined;
|
|
13
|
+
export declare function nextRunPreviewForSchedule(schedule: Pick<ScheduleRecord, "id" | "schedule" | "dueAt" | "runs">, count?: number, afterMs?: number): string[];
|
|
14
|
+
export declare function settleScheduleTurnTerminal(input: {
|
|
15
|
+
requestId: string;
|
|
16
|
+
turnId: string;
|
|
17
|
+
status: "completed" | "failed" | "cancelled";
|
|
18
|
+
outputPreview?: string;
|
|
19
|
+
error?: string;
|
|
20
|
+
finishedAt?: string;
|
|
21
|
+
}): Promise<ScheduleRunRecord | undefined>;
|