@kortix/sdk 0.13.46 → 0.13.47
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/README.md +18 -13
- package/dist/browser/session-sync/server-transcript-mirror.d.ts +1 -1
- package/dist/browser/session-sync/server-transcript-mirror.d.ts.map +1 -1
- package/dist/browser/session-sync/session-sync-registry.d.ts +1 -1
- package/dist/browser/session-sync/session-sync-registry.d.ts.map +1 -1
- package/dist/browser/stores/opencode-pending-store.d.ts +1 -1
- package/dist/browser/stores/opencode-pending-store.d.ts.map +1 -1
- package/dist/browser/stores/sync-store/reconcile-parts.d.ts +1 -1
- package/dist/browser/stores/sync-store/reconcile-parts.d.ts.map +1 -1
- package/dist/browser/stores/sync-store/types.d.ts +1 -1
- package/dist/browser/stores/sync-store/types.d.ts.map +1 -1
- package/dist/browser/stores/sync-store.d.ts +1 -1
- package/dist/browser/stores/sync-store.d.ts.map +1 -1
- package/dist/core/agents/composer-agents.d.ts +1 -1
- package/dist/core/agents/composer-agents.d.ts.map +1 -1
- package/dist/core/client/kortix.d.ts +117 -59
- package/dist/core/client/kortix.d.ts.map +1 -1
- package/dist/core/client/kortix.js +59 -14
- package/dist/core/client/kortix.js.map +1 -1
- package/dist/core/models/composer-model.d.ts +1 -1
- package/dist/core/models/composer-model.d.ts.map +1 -1
- package/dist/core/models/model-flatten.d.ts +8 -1
- package/dist/core/models/model-flatten.d.ts.map +1 -1
- package/dist/core/models/model-flatten.js +2 -0
- package/dist/core/models/model-flatten.js.map +1 -1
- package/dist/core/models/model-key.d.ts +11 -0
- package/dist/core/models/model-key.d.ts.map +1 -1
- package/dist/core/models/model-key.js +20 -0
- package/dist/core/models/model-key.js.map +1 -1
- package/dist/core/models/provider-selection.d.ts +1 -1
- package/dist/core/models/provider-selection.d.ts.map +1 -1
- package/dist/core/rest/platform-client/host-boundary.d.ts +14 -19
- package/dist/core/rest/platform-client/host-boundary.d.ts.map +1 -1
- package/dist/core/rest/platform-client/host-boundary.js +7 -38
- package/dist/core/rest/platform-client/host-boundary.js.map +1 -1
- package/dist/core/rest/projects-client/agent-config.d.ts +8 -0
- package/dist/core/rest/projects-client/agent-config.d.ts.map +1 -1
- package/dist/core/rest/projects-client/agent-config.js.map +1 -1
- package/dist/core/rest/projects-client/audit-filter.d.ts +6 -0
- package/dist/core/rest/projects-client/audit-filter.d.ts.map +1 -0
- package/dist/core/rest/projects-client/audit-filter.js +11 -0
- package/dist/core/rest/projects-client/audit-filter.js.map +1 -0
- package/dist/core/rest/projects-client/audit.d.ts +2 -18
- package/dist/core/rest/projects-client/audit.d.ts.map +1 -1
- package/dist/core/rest/projects-client/audit.js +30 -108
- package/dist/core/rest/projects-client/audit.js.map +1 -1
- package/dist/core/rest/projects-client/connectors.d.ts +4 -3
- package/dist/core/rest/projects-client/connectors.d.ts.map +1 -1
- package/dist/core/rest/projects-client/connectors.js.map +1 -1
- package/dist/core/rest/projects-client/iam-roles.d.ts +5 -0
- package/dist/core/rest/projects-client/iam-roles.d.ts.map +1 -1
- package/dist/core/rest/projects-client/iam-roles.js +9 -0
- package/dist/core/rest/projects-client/iam-roles.js.map +1 -1
- package/dist/core/rest/projects-client/projects.d.ts +8 -5
- package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
- package/dist/core/rest/projects-client/projects.js +0 -1
- package/dist/core/rest/projects-client/projects.js.map +1 -1
- package/dist/core/rest/projects-client/secrets.d.ts +17 -8
- package/dist/core/rest/projects-client/secrets.d.ts.map +1 -1
- package/dist/core/rest/projects-client/secrets.js.map +1 -1
- package/dist/core/rest/projects-client/sessions.d.ts +4 -1
- package/dist/core/rest/projects-client/sessions.d.ts.map +1 -1
- package/dist/core/rest/projects-client/sessions.js.map +1 -1
- package/dist/core/rest/projects-client/triggers.d.ts +12 -0
- package/dist/core/rest/projects-client/triggers.d.ts.map +1 -1
- package/dist/core/rest/projects-client/triggers.js.map +1 -1
- package/dist/core/runtime/client.d.ts +12 -11
- package/dist/core/runtime/client.d.ts.map +1 -1
- package/dist/core/runtime/client.js +9 -4
- package/dist/core/runtime/client.js.map +1 -1
- package/dist/core/runtime/runtime-rest-client.d.ts +436 -0
- package/dist/core/runtime/runtime-rest-client.d.ts.map +1 -0
- package/dist/core/runtime/runtime-rest-client.js +291 -0
- package/dist/core/runtime/runtime-rest-client.js.map +1 -0
- package/dist/core/runtime/runtime-types.d.ts +1174 -0
- package/dist/core/runtime/runtime-types.d.ts.map +1 -0
- package/dist/core/runtime/runtime-types.js +2 -0
- package/dist/core/runtime/runtime-types.js.map +1 -0
- package/dist/core/runtime/transcript-types.d.ts +564 -0
- package/dist/core/runtime/transcript-types.d.ts.map +1 -0
- package/dist/core/runtime/transcript-types.js +57 -0
- package/dist/core/runtime/transcript-types.js.map +1 -0
- package/dist/core/session/health.d.ts +2 -1
- package/dist/core/session/health.d.ts.map +1 -1
- package/dist/core/session/health.js.map +1 -1
- package/dist/core/session/index.d.ts +2 -0
- package/dist/core/session/index.d.ts.map +1 -1
- package/dist/core/session/index.js +1 -0
- package/dist/core/session/index.js.map +1 -1
- package/dist/core/session/runtime-sessions.d.ts +26 -0
- package/dist/core/session/runtime-sessions.d.ts.map +1 -0
- package/dist/core/session/runtime-sessions.js +39 -0
- package/dist/core/session/runtime-sessions.js.map +1 -0
- package/dist/core/session/runtime-verbs.d.ts +55 -0
- package/dist/core/session/runtime-verbs.d.ts.map +1 -0
- package/dist/core/session/runtime-verbs.js +124 -0
- package/dist/core/session/runtime-verbs.js.map +1 -0
- package/dist/core/session/wire-message-id.d.ts +55 -12
- package/dist/core/session/wire-message-id.d.ts.map +1 -1
- package/dist/core/session/wire-message-id.js +62 -12
- package/dist/core/session/wire-message-id.js.map +1 -1
- package/dist/core/session-sync/session-sync-controller.d.ts +1 -1
- package/dist/core/session-sync/session-sync-controller.d.ts.map +1 -1
- package/dist/core/stream/event-stream.d.ts +10 -5
- package/dist/core/stream/event-stream.d.ts.map +1 -1
- package/dist/core/stream/event-stream.js +5 -1
- package/dist/core/stream/event-stream.js.map +1 -1
- package/dist/core/turns/classify.d.ts +31 -2
- package/dist/core/turns/classify.d.ts.map +1 -1
- package/dist/core/turns/classify.js +94 -0
- package/dist/core/turns/classify.js.map +1 -1
- package/dist/core/turns/index.d.ts +1 -0
- package/dist/core/turns/index.d.ts.map +1 -1
- package/dist/core/turns/index.js +1 -0
- package/dist/core/turns/index.js.map +1 -1
- package/dist/core/turns/parts.d.ts +2 -1
- package/dist/core/turns/parts.d.ts.map +1 -1
- package/dist/core/turns/parts.js +53 -49
- package/dist/core/turns/parts.js.map +1 -1
- package/dist/core/turns/segments/narration.d.ts.map +1 -1
- package/dist/core/turns/segments/narration.js +40 -130
- package/dist/core/turns/segments/narration.js.map +1 -1
- package/dist/core/turns/tool-kind.d.ts +15 -0
- package/dist/core/turns/tool-kind.d.ts.map +1 -0
- package/dist/core/turns/tool-kind.js +115 -0
- package/dist/core/turns/tool-kind.js.map +1 -0
- package/dist/core/turns/tool-registry.d.ts +6 -7
- package/dist/core/turns/tool-registry.d.ts.map +1 -1
- package/dist/core/turns/tool-registry.js +78 -73
- package/dist/core/turns/tool-registry.js.map +1 -1
- package/dist/core/turns/tools/tool-meta.d.ts +1 -0
- package/dist/core/turns/tools/tool-meta.d.ts.map +1 -1
- package/dist/core/turns/tools/tool-meta.js +7 -6
- package/dist/core/turns/tools/tool-meta.js.map +1 -1
- package/dist/core/turns/view-model.d.ts.map +1 -1
- package/dist/core/turns/view-model.js +19 -12
- package/dist/core/turns/view-model.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/kortix.esm.min.js +42 -41
- package/dist/kortix.global.js +42 -41
- package/dist/node/app-viewer.js +1 -1
- package/dist/node/app-viewer.js.map +1 -1
- package/dist/node/auth.js +1 -1
- package/dist/node/auth.js.map +1 -1
- package/dist/node/scoped-client.d.ts +20 -0
- package/dist/node/scoped-client.d.ts.map +1 -0
- package/dist/node/scoped-client.js +170 -0
- package/dist/node/scoped-client.js.map +1 -0
- package/dist/node/server.d.ts +2 -21
- package/dist/node/server.d.ts.map +1 -1
- package/dist/node/server.js +2 -170
- package/dist/node/server.js.map +1 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/sign-in-with-kortix.d.ts +8 -8
- package/dist/react/use-feature-flag.d.ts +2 -2
- package/dist/react/use-feature-flag.d.ts.map +1 -1
- package/dist/react/use-feature-flag.js +3 -2
- package/dist/react/use-feature-flag.js.map +1 -1
- package/dist/react/use-kortix-master.d.ts +1 -1
- package/dist/react/use-opencode-config.d.ts +7 -1
- package/dist/react/use-opencode-config.d.ts.map +1 -1
- package/dist/react/use-opencode-config.js +9 -1
- package/dist/react/use-opencode-config.js.map +1 -1
- package/dist/react/use-opencode-events/diagnostics.d.ts +1 -1
- package/dist/react/use-opencode-events/diagnostics.d.ts.map +1 -1
- package/dist/react/use-opencode-events/handle-event.d.ts +4 -6
- package/dist/react/use-opencode-events/handle-event.d.ts.map +1 -1
- package/dist/react/use-opencode-events/handle-event.js +43 -594
- package/dist/react/use-opencode-events/handle-event.js.map +1 -1
- package/dist/react/use-opencode-events/handle-interaction-event.d.ts +4 -0
- package/dist/react/use-opencode-events/handle-interaction-event.d.ts.map +1 -0
- package/dist/react/use-opencode-events/handle-interaction-event.js +42 -0
- package/dist/react/use-opencode-events/handle-interaction-event.js.map +1 -0
- package/dist/react/use-opencode-events/handle-message-event.d.ts +4 -0
- package/dist/react/use-opencode-events/handle-message-event.d.ts.map +1 -0
- package/dist/react/use-opencode-events/handle-message-event.js +33 -0
- package/dist/react/use-opencode-events/handle-message-event.js.map +1 -0
- package/dist/react/use-opencode-events/handle-session-event.d.ts +5 -0
- package/dist/react/use-opencode-events/handle-session-event.d.ts.map +1 -0
- package/dist/react/use-opencode-events/handle-session-event.js +243 -0
- package/dist/react/use-opencode-events/handle-session-event.js.map +1 -0
- package/dist/react/use-opencode-events/handle-workspace-event.d.ts +4 -0
- package/dist/react/use-opencode-events/handle-workspace-event.d.ts.map +1 -0
- package/dist/react/use-opencode-events/handle-workspace-event.js +113 -0
- package/dist/react/use-opencode-events/handle-workspace-event.js.map +1 -0
- package/dist/react/use-opencode-events/handler-context.d.ts +29 -0
- package/dist/react/use-opencode-events/handler-context.d.ts.map +1 -0
- package/dist/react/use-opencode-events/handler-context.js +2 -0
- package/dist/react/use-opencode-events/handler-context.js.map +1 -0
- package/dist/react/use-opencode-events/hydrate-core.d.ts +23 -0
- package/dist/react/use-opencode-events/hydrate-core.d.ts.map +1 -0
- package/dist/react/use-opencode-events/hydrate-core.js +126 -0
- package/dist/react/use-opencode-events/hydrate-core.js.map +1 -0
- package/dist/react/use-opencode-events/index.d.ts.map +1 -1
- package/dist/react/use-opencode-events/index.js +25 -143
- package/dist/react/use-opencode-events/index.js.map +1 -1
- package/dist/react/use-opencode-events/use-event-stream-refs.d.ts +1 -1
- package/dist/react/use-opencode-events/use-event-stream-refs.d.ts.map +1 -1
- package/dist/react/use-opencode-local.d.ts +1 -1
- package/dist/react/use-opencode-local.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/agents.d.ts +1 -1
- package/dist/react/use-opencode-sessions/agents.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/commands.d.ts +4 -1
- package/dist/react/use-opencode-sessions/commands.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/commands.js +6 -1
- package/dist/react/use-opencode-sessions/commands.js.map +1 -1
- package/dist/react/use-opencode-sessions/keys.d.ts +1 -1
- package/dist/react/use-opencode-sessions/keys.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/mcp.d.ts +1 -1
- package/dist/react/use-opencode-sessions/mcp.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/messages.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/messages.js +8 -2
- package/dist/react/use-opencode-sessions/messages.js.map +1 -1
- package/dist/react/use-opencode-sessions/parts.d.ts +2 -2
- package/dist/react/use-opencode-sessions/parts.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/projects.d.ts +1 -1
- package/dist/react/use-opencode-sessions/projects.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/providers.d.ts +1 -1
- package/dist/react/use-opencode-sessions/sessions.d.ts +3 -3
- package/dist/react/use-opencode-sessions/sessions.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/sharing.d.ts +1 -1
- package/dist/react/use-opencode-sessions/sharing.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/vcs.d.ts +1 -1
- package/dist/react/use-opencode-sessions/vcs.d.ts.map +1 -1
- package/dist/react/use-project-gateway.d.ts +28 -0
- package/dist/react/use-project-gateway.d.ts.map +1 -0
- package/dist/react/use-project-gateway.js +120 -0
- package/dist/react/use-project-gateway.js.map +1 -0
- package/dist/react/use-project-secrets.d.ts +6 -6
- package/dist/react/use-session-sync.d.ts +4 -5
- package/dist/react/use-session-sync.d.ts.map +1 -1
- package/dist/react/use-session-working.d.ts +1 -1
- package/dist/react/use-session-working.d.ts.map +1 -1
- package/dist/react/use-session.d.ts +18 -8
- package/dist/react/use-session.d.ts.map +1 -1
- package/dist/react/use-session.js +56 -11
- package/dist/react/use-session.js.map +1 -1
- package/dist/react/use-teams-installations.d.ts +14 -0
- package/dist/react/use-teams-installations.d.ts.map +1 -1
- package/dist/react/use-teams-installations.js.map +1 -1
- package/dist/react/use-visible-agents.d.ts +1 -1
- package/dist/react/use-visible-agents.d.ts.map +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/transcript.d.ts.map +1 -1
- package/dist/workspace-search/client.d.ts +20 -0
- package/dist/workspace-search/client.d.ts.map +1 -0
- package/dist/workspace-search/client.js +235 -0
- package/dist/workspace-search/client.js.map +1 -0
- package/dist/workspace-search/core.d.ts.map +1 -1
- package/dist/workspace-search/core.js +9 -2
- package/dist/workspace-search/core.js.map +1 -1
- package/dist/workspace-search/index.d.ts +3 -0
- package/dist/workspace-search/index.d.ts.map +1 -0
- package/dist/workspace-search/index.js +3 -0
- package/dist/workspace-search/index.js.map +1 -0
- package/package.json +7 -5
- package/dist/core/runtime/opencode-v2-event-aliases.d.ts +0 -184
- package/dist/core/runtime/opencode-v2-event-aliases.d.ts.map +0 -1
- package/dist/core/runtime/opencode-v2-event-aliases.js +0 -2
- package/dist/core/runtime/opencode-v2-event-aliases.js.map +0 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Kortix session transcript and event format, `kortix.transcript.v1`:
|
|
3
|
+
* a message is `{ info, parts }`, streamed as `{ type, properties }` events.
|
|
4
|
+
*
|
|
5
|
+
* A copy of `packages/api-contract/src/transcript.ts`, which kortixd and
|
|
6
|
+
* apps/api import. This package is published and cannot depend on that
|
|
7
|
+
* private one; `transcript-types.test.ts` fails when the two copies differ
|
|
8
|
+
* below this header.
|
|
9
|
+
*
|
|
10
|
+
* v1 keeps OpenCode 1.18's field names, so an OpenCode frame is a valid
|
|
11
|
+
* Kortix frame. The names this SDK published before v1 (`Message`, `Part`,
|
|
12
|
+
* `TextPart`, …) are aliases of these types in `runtime-types.ts`.
|
|
13
|
+
*/
|
|
14
|
+
export const KORTIX_TRANSCRIPT_SCHEMA = 'kortix.transcript.v1';
|
|
15
|
+
// ─── Turn errors ─────────────────────────────────────────────────────────────
|
|
16
|
+
/**
|
|
17
|
+
* Why a turn failed, as the daemon classifies it. Channels (Slack, Teams) pick
|
|
18
|
+
* the message a user sees from it. `unknown` covers every failure without a
|
|
19
|
+
* more specific code, including an abort nobody asked for.
|
|
20
|
+
*/
|
|
21
|
+
export const TURN_ERROR_CODES = [
|
|
22
|
+
'auth',
|
|
23
|
+
'rate_limit',
|
|
24
|
+
'credits',
|
|
25
|
+
'context_length',
|
|
26
|
+
'output_length',
|
|
27
|
+
'aborted',
|
|
28
|
+
'unknown',
|
|
29
|
+
];
|
|
30
|
+
export function isTurnErrorCode(value) {
|
|
31
|
+
return typeof value === 'string' && TURN_ERROR_CODES.includes(value);
|
|
32
|
+
}
|
|
33
|
+
/** `once` allows this call, `always` allows the capability for the session, `reject` denies it. */
|
|
34
|
+
export const RUNTIME_PERMISSION_REPLIES = ['once', 'always', 'reject'];
|
|
35
|
+
/**
|
|
36
|
+
* The capabilities a permission rule names. A harness maps each of its tool
|
|
37
|
+
* names onto one of these: pi's `write` is `edit`, OpenCode's `pty_*` tools
|
|
38
|
+
* are `bash`. They equal the manifest's permission keys.
|
|
39
|
+
*/
|
|
40
|
+
export const RUNTIME_PERMISSION_CAPABILITIES = [
|
|
41
|
+
'read',
|
|
42
|
+
'edit',
|
|
43
|
+
'glob',
|
|
44
|
+
'grep',
|
|
45
|
+
'list',
|
|
46
|
+
'bash',
|
|
47
|
+
'task',
|
|
48
|
+
'external_directory',
|
|
49
|
+
'todowrite',
|
|
50
|
+
'question',
|
|
51
|
+
'webfetch',
|
|
52
|
+
'websearch',
|
|
53
|
+
'lsp',
|
|
54
|
+
'doom_loop',
|
|
55
|
+
'skill',
|
|
56
|
+
];
|
|
57
|
+
//# sourceMappingURL=transcript-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript-types.js","sourceRoot":"","sources":["../../../src/core/runtime/transcript-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAA+B,CAAC;AAExE,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,MAAM;IACN,YAAY;IACZ,SAAS;IACT,gBAAgB;IAChB,eAAe;IACf,SAAS;IACT,SAAS;CACD,CAAC;AAGX,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,gBAAsC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC9F,CAAC;AAoXD,mGAAmG;AACnG,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAGhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,oBAAoB;IACpB,WAAW;IACX,UAAU;IACV,UAAU;IACV,WAAW;IACX,KAAK;IACL,WAAW;IACX,OAAO;CACC,CAAC"}
|
|
@@ -65,8 +65,9 @@ export type SessionHealthResponse = {
|
|
|
65
65
|
* - `session.todo` the runtime's todo list
|
|
66
66
|
* - `session.shell` a shell command run as a turn
|
|
67
67
|
* - `session.attach` attach the harness's own terminal client
|
|
68
|
+
* - `session.config` a runtime config document (`/global/config`)
|
|
68
69
|
*/
|
|
69
|
-
export type RuntimeCapability = 'session.rewind' | 'session.compact' | 'session.commands' | 'session.fork' | 'session.subagents' | 'session.mcp' | 'session.todo' | 'session.shell' | 'session.attach';
|
|
70
|
+
export type RuntimeCapability = 'session.rewind' | 'session.compact' | 'session.commands' | 'session.fork' | 'session.subagents' | 'session.mcp' | 'session.todo' | 'session.shell' | 'session.attach' | 'session.config';
|
|
70
71
|
/**
|
|
71
72
|
* Does the session's runtime serve `capability`? Pass the health
|
|
72
73
|
* `capabilities` list. A host hides the control of an absent feature instead
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../src/core/session/health.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE;QACR,0BAA0B;QAC1B,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,GAAG,IAAI,CAA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IACZ,iEAAiE;IACjE,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACrC,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,GAAG,EAAE,QAAQ,GAAG,IAAI,CAAC;IACrB,wEAAwE;IACxE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,qBAAqB,GAAG,IAAI,GAAG,OAAO,CAW5E;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,EAC1B,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,mBAAmB,CAAC,CAgC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../../src/core/session/health.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../../src/core/session/health.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AA8D5D;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,YAAkD,EAClD,UAA6B;IAE7B,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9E,OAAO,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC3C,CAAC;AAiBD,MAAM,UAAU,GAAsB;IACpC,eAA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G,EAAE,cAAc,EAAE,CAAC;AAC/E,CAAC"}
|
|
@@ -25,4 +25,6 @@ export * from './turn-end-cause.js';
|
|
|
25
25
|
export * from './compaction.js';
|
|
26
26
|
export * from './wake-escalation.js';
|
|
27
27
|
export * from './status-vocabulary.js';
|
|
28
|
+
export type { PendingInteractions, RuntimeVerbs, TranscriptPage } from './runtime-verbs.js';
|
|
29
|
+
export * from './runtime-sessions.js';
|
|
28
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,YAAY,EAAE,mBAAmB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACzF,cAAc,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A project session's conversation tree: its root conversation in the
|
|
3
|
+
* session runtime and the subagent children under it. The API serves the
|
|
4
|
+
* tree as `runtime_sessions` (read from the runtime projection); older API
|
|
5
|
+
* builds send only `opencode_sessions`, so every reader goes through these.
|
|
6
|
+
*/
|
|
7
|
+
import type { ProjectRuntimeSession, ProjectSession } from '../rest/projects-client/sessions.js';
|
|
8
|
+
type SessionTree = Pick<ProjectSession, 'runtime_sessions' | 'opencode_sessions' | 'runtime_session_id' | 'opencode_session_id'>;
|
|
9
|
+
/** Every conversation of a session's runtime: the root and its children. */
|
|
10
|
+
export declare function runtimeSessionsOf(session: SessionTree): ProjectRuntimeSession[];
|
|
11
|
+
/** The root conversation a session is pinned to, else (no pin yet) the first parentless one. */
|
|
12
|
+
export declare function rootRuntimeSession(session: SessionTree): ProjectRuntimeSession | null;
|
|
13
|
+
/**
|
|
14
|
+
* Direct, non-archived children of the root, newest `updated_at` first. A
|
|
15
|
+
* missing time counts as 0 and ties break on id, so the order never churns
|
|
16
|
+
* between refetches.
|
|
17
|
+
*/
|
|
18
|
+
export declare function directSubsessions(session: SessionTree): ProjectRuntimeSession[];
|
|
19
|
+
/**
|
|
20
|
+
* The project session that owns a runtime conversation id: a session id or
|
|
21
|
+
* root pin first, then any conversation of a row (a child runs in its
|
|
22
|
+
* parent's sandbox). Null for null or an unknown id.
|
|
23
|
+
*/
|
|
24
|
+
export declare function projectSessionForRuntimeId<S extends SessionTree & Pick<ProjectSession, 'session_id'>>(sessions: readonly S[], runtimeId: string | null): S | null;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=runtime-sessions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-sessions.d.ts","sourceRoot":"","sources":["../../../src/core/session/runtime-sessions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAE9F,KAAK,WAAW,GAAG,IAAI,CACrB,cAAc,EACd,kBAAkB,GAAG,mBAAmB,GAAG,oBAAoB,GAAG,qBAAqB,CACxF,CAAC;AAEF,4EAA4E;AAC5E,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,qBAAqB,EAAE,CAE/E;AAED,gGAAgG;AAChG,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,qBAAqB,GAAG,IAAI,CAKrF;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,qBAAqB,EAAE,CAM/E;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,WAAW,GAAG,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,EACnG,QAAQ,EAAE,SAAS,CAAC,EAAE,EACtB,SAAS,EAAE,MAAM,GAAG,IAAI,GACvB,CAAC,GAAG,IAAI,CAQV"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Every conversation of a session's runtime: the root and its children. */
|
|
2
|
+
export function runtimeSessionsOf(session) {
|
|
3
|
+
return session.runtime_sessions ?? session.opencode_sessions ?? [];
|
|
4
|
+
}
|
|
5
|
+
/** The root conversation a session is pinned to, else (no pin yet) the first parentless one. */
|
|
6
|
+
export function rootRuntimeSession(session) {
|
|
7
|
+
const conversations = runtimeSessionsOf(session);
|
|
8
|
+
const rootId = session.runtime_session_id ?? session.opencode_session_id;
|
|
9
|
+
if (rootId)
|
|
10
|
+
return conversations.find((item) => item.id === rootId) ?? null;
|
|
11
|
+
return conversations.find((item) => !item.parent_id) ?? null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Direct, non-archived children of the root, newest `updated_at` first. A
|
|
15
|
+
* missing time counts as 0 and ties break on id, so the order never churns
|
|
16
|
+
* between refetches.
|
|
17
|
+
*/
|
|
18
|
+
export function directSubsessions(session) {
|
|
19
|
+
const root = rootRuntimeSession(session);
|
|
20
|
+
if (!root)
|
|
21
|
+
return [];
|
|
22
|
+
return runtimeSessionsOf(session)
|
|
23
|
+
.filter((item) => item.parent_id === root.id && !item.archived_at)
|
|
24
|
+
.sort((a, b) => (b.updated_at ?? 0) - (a.updated_at ?? 0) || a.id.localeCompare(b.id));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The project session that owns a runtime conversation id: a session id or
|
|
28
|
+
* root pin first, then any conversation of a row (a child runs in its
|
|
29
|
+
* parent's sandbox). Null for null or an unknown id.
|
|
30
|
+
*/
|
|
31
|
+
export function projectSessionForRuntimeId(sessions, runtimeId) {
|
|
32
|
+
if (!runtimeId)
|
|
33
|
+
return null;
|
|
34
|
+
const direct = sessions.find((session) => session.session_id === runtimeId || (session.runtime_session_id ?? session.opencode_session_id) === runtimeId);
|
|
35
|
+
if (direct)
|
|
36
|
+
return direct;
|
|
37
|
+
return sessions.find((session) => runtimeSessionsOf(session).some((item) => item.id === runtimeId)) ?? null;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=runtime-sessions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-sessions.js","sourceRoot":"","sources":["../../../src/core/session/runtime-sessions.ts"],"names":[],"mappings":"AAaA,4EAA4E;AAC5E,MAAM,UAAU,iBAAiB,CAAC,OAAoB;IACpD,OAAO,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,iBAAiB,IAAI,EAAE,CAAC;AACrE,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,kBAAkB,CAAC,OAAoB;IACrD,MAAM,aAAa,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,OAAO,CAAC,kBAAkB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IACzE,IAAI,MAAM;QAAE,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC;IAC5E,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC;AAC/D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAoB;IACpD,MAAM,IAAI,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACzC,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,OAAO,iBAAiB,CAAC,OAAO,CAAC;SAC9B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;SACjE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC3F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,QAAsB,EACtB,SAAwB;IAExB,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAC5B,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAC1B,CAAC,OAAO,EAAE,EAAE,CACV,OAAO,CAAC,UAAU,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,kBAAkB,IAAI,OAAO,CAAC,mBAAmB,CAAC,KAAK,SAAS,CAChH,CAAC;IACF,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,IAAI,IAAI,CAAC;AAC9G,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { KortixMessage, KortixSessionStatus, RuntimePermissionReply, RuntimePermissionRequest, RuntimeQuestionAnswer, RuntimeQuestionRequest } from '../runtime/transcript-types.js';
|
|
2
|
+
export interface RuntimeVerbsInput {
|
|
3
|
+
/** The session's runtime base URL (`${backendUrl}/p/{externalId}/{port}`). */
|
|
4
|
+
runtimeUrl: string;
|
|
5
|
+
/** The session's root conversation in the runtime. */
|
|
6
|
+
rootId: string;
|
|
7
|
+
/** The fetch to send with (the SDK's authenticated fetch). */
|
|
8
|
+
fetch: typeof fetch;
|
|
9
|
+
}
|
|
10
|
+
/** One page of a conversation, oldest first. */
|
|
11
|
+
export interface TranscriptPage {
|
|
12
|
+
messages: KortixMessage[];
|
|
13
|
+
/** More messages exist before the first one. */
|
|
14
|
+
hasMore: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** What a session's runtime waits on. */
|
|
17
|
+
export interface PendingInteractions {
|
|
18
|
+
/** Status per conversation id (the root and its subagent children). */
|
|
19
|
+
statuses: Record<string, KortixSessionStatus>;
|
|
20
|
+
permissions: RuntimePermissionRequest[];
|
|
21
|
+
questions: RuntimeQuestionRequest[];
|
|
22
|
+
}
|
|
23
|
+
export declare function createRuntimeVerbs(input: RuntimeVerbsInput): {
|
|
24
|
+
/**
|
|
25
|
+
* A page of a conversation's messages, oldest first: the root by default,
|
|
26
|
+
* or `conversationId` (a subagent child). `before` pages backwards; a
|
|
27
|
+
* `limit` above the daemon's 200-message page is read in several pages.
|
|
28
|
+
*/
|
|
29
|
+
messages: (options?: {
|
|
30
|
+
conversationId?: string;
|
|
31
|
+
limit?: number;
|
|
32
|
+
before?: string;
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
}) => Promise<TranscriptPage>;
|
|
35
|
+
/** The conversations' statuses and the permission requests and questions waiting for an answer. */
|
|
36
|
+
pending: () => Promise<PendingInteractions>;
|
|
37
|
+
/** Answer a permission request: allow this call, allow the capability for the session, or deny. */
|
|
38
|
+
answerPermission: (requestId: string, reply: RuntimePermissionReply, message?: string) => Promise<void>;
|
|
39
|
+
/** Answer a question (one answer per question), or dismiss it with `null`. */
|
|
40
|
+
answerQuestion: (requestId: string, answers: RuntimeQuestionAnswer[] | null) => Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Summarize the conversation so far into a shorter context. Uses `model`,
|
|
43
|
+
* else the runtime's default model; throws an `ApiError` with code
|
|
44
|
+
* `MODEL_REQUIRED` when neither names one. Resolves with the model it used.
|
|
45
|
+
*/
|
|
46
|
+
compact: (model?: {
|
|
47
|
+
providerID: string;
|
|
48
|
+
modelID: string;
|
|
49
|
+
}) => Promise<{
|
|
50
|
+
providerID: string;
|
|
51
|
+
modelID: string;
|
|
52
|
+
}>;
|
|
53
|
+
};
|
|
54
|
+
export type RuntimeVerbs = ReturnType<typeof createRuntimeVerbs>;
|
|
55
|
+
//# sourceMappingURL=runtime-verbs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-verbs.d.ts","sourceRoot":"","sources":["../../../src/core/session/runtime-verbs.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,6BAA6B,CAAC;AAKrC,MAAM,WAAW,iBAAiB;IAChC,8EAA8E;IAC9E,UAAU,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,KAAK,EAAE,OAAO,KAAK,CAAC;CACrB;AAED,gDAAgD;AAChD,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,yCAAyC;AACzC,MAAM,WAAW,mBAAmB;IAClC,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC9C,WAAW,EAAE,wBAAwB,EAAE,CAAC;IACxC,SAAS,EAAE,sBAAsB,EAAE,CAAC;CACrC;AAuBD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB;IAKvD;;;;OAIG;yBAEQ;QAAE,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,KAC1F,OAAO,CAAC,cAAc,CAAC;IAqC1B,mGAAmG;mBAChF,OAAO,CAAC,mBAAmB,CAAC;IAS/C,mGAAmG;kCAC/D,MAAM,SAAS,sBAAsB,YAAY,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;IAO3G,8EAA8E;gCAC5C,MAAM,WAAW,qBAAqB,EAAE,GAAG,IAAI,KAAG,OAAO,CAAC,IAAI,CAAC;IAQjG;;;;OAIG;sBACqB;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,KAAG,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;EAmBrH;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The session verbs a host calls instead of the raw runtime client: read the
|
|
3
|
+
* transcript, read what the agent waits on, answer it, compact. Each verb is
|
|
4
|
+
* bound to one session's runtime URL and root conversation, and throws an
|
|
5
|
+
* `ApiError` when the runtime refuses.
|
|
6
|
+
*
|
|
7
|
+
* `messages()` reads the Kortix transcript route (`/kortix/runtime/messages`);
|
|
8
|
+
* the other verbs use the runtime's compatibility routes until the daemon
|
|
9
|
+
* serves Kortix ones. A host never needs to know which.
|
|
10
|
+
*/
|
|
11
|
+
import { ApiError } from '../http/api/errors.js';
|
|
12
|
+
import { createRuntimeRestClient } from '../runtime/runtime-rest-client.js';
|
|
13
|
+
/** The most messages kortixd answers in one transcript page (`MAX_MESSAGE_PAGE`). */
|
|
14
|
+
const MESSAGE_PAGE_MAX = 200;
|
|
15
|
+
async function errorMessage(response) {
|
|
16
|
+
const text = await response.text().catch(() => '');
|
|
17
|
+
try {
|
|
18
|
+
const body = JSON.parse(text);
|
|
19
|
+
return body.data?.message || body.error || body.message || text || `HTTP ${response.status}`;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return text || `HTTP ${response.status}`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** A compatibility-route result as data, or an `ApiError`. */
|
|
26
|
+
function unwrap(result, what) {
|
|
27
|
+
if (result.error === undefined)
|
|
28
|
+
return result.data;
|
|
29
|
+
const error = result.error;
|
|
30
|
+
const detail = typeof error === 'string' ? error : error?.data?.message || error?.message || error?.error || 'request failed';
|
|
31
|
+
throw new ApiError(`${what}: ${detail}`, {
|
|
32
|
+
...(result.response ? { status: result.response.status, response: result.response } : {}),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export function createRuntimeVerbs(input) {
|
|
36
|
+
const base = input.runtimeUrl.replace(/\/$/, '');
|
|
37
|
+
const client = createRuntimeRestClient({ baseUrl: base, fetch: input.fetch });
|
|
38
|
+
return {
|
|
39
|
+
/**
|
|
40
|
+
* A page of a conversation's messages, oldest first: the root by default,
|
|
41
|
+
* or `conversationId` (a subagent child). `before` pages backwards; a
|
|
42
|
+
* `limit` above the daemon's 200-message page is read in several pages.
|
|
43
|
+
*/
|
|
44
|
+
messages: async (options = {}) => {
|
|
45
|
+
const conversation = encodeURIComponent(options.conversationId ?? input.rootId);
|
|
46
|
+
const readPage = async (limit, before) => {
|
|
47
|
+
const query = new URLSearchParams();
|
|
48
|
+
if (limit !== undefined)
|
|
49
|
+
query.set('limit', String(limit));
|
|
50
|
+
if (before)
|
|
51
|
+
query.set('before', before);
|
|
52
|
+
const suffix = `/messages/${conversation}${query.size ? `?${query}` : ''}`;
|
|
53
|
+
const read = (mount) => input.fetch(new Request(`${base}${mount}${suffix}`, { method: 'GET', ...(options.signal ? { signal: options.signal } : {}) }));
|
|
54
|
+
let response = await read('/kortix/runtime');
|
|
55
|
+
// A daemon built before W3 serves the same route at its OpenCode name.
|
|
56
|
+
if (response.status === 404 || (response.headers.get('content-type') ?? '').startsWith('text/html')) {
|
|
57
|
+
response = await read('/kortix/opencode');
|
|
58
|
+
}
|
|
59
|
+
if (!response.ok) {
|
|
60
|
+
throw new ApiError(`Reading the session transcript failed: ${await errorMessage(response)}`, {
|
|
61
|
+
status: response.status,
|
|
62
|
+
response,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const body = (await response.json());
|
|
66
|
+
return { messages: body.messages ?? [], hasMore: body.has_more === true };
|
|
67
|
+
};
|
|
68
|
+
// The daemon serves at most MESSAGE_PAGE_MAX a page: a larger limit pages
|
|
69
|
+
// backwards from the newest, and the pages join oldest first.
|
|
70
|
+
let page = await readPage(options.limit === undefined ? undefined : Math.min(options.limit, MESSAGE_PAGE_MAX), options.before);
|
|
71
|
+
const messages = [...page.messages];
|
|
72
|
+
while (options.limit !== undefined && messages.length < options.limit && page.hasMore && messages.length > 0) {
|
|
73
|
+
page = await readPage(Math.min(options.limit - messages.length, MESSAGE_PAGE_MAX), messages[0].info.id);
|
|
74
|
+
if (!page.messages.length)
|
|
75
|
+
break;
|
|
76
|
+
messages.unshift(...page.messages);
|
|
77
|
+
}
|
|
78
|
+
return { messages, hasMore: page.hasMore };
|
|
79
|
+
},
|
|
80
|
+
/** The conversations' statuses and the permission requests and questions waiting for an answer. */
|
|
81
|
+
pending: async () => {
|
|
82
|
+
const [statuses, permissions, questions] = await Promise.all([
|
|
83
|
+
client.session.status().then((r) => unwrap(r, 'Reading the session status failed')),
|
|
84
|
+
client.permission.list().then((r) => unwrap(r, 'Reading permission requests failed')),
|
|
85
|
+
client.question.list().then((r) => unwrap(r, 'Reading questions failed')),
|
|
86
|
+
]);
|
|
87
|
+
return { statuses: statuses ?? {}, permissions: permissions ?? [], questions: questions ?? [] };
|
|
88
|
+
},
|
|
89
|
+
/** Answer a permission request: allow this call, allow the capability for the session, or deny. */
|
|
90
|
+
answerPermission: async (requestId, reply, message) => {
|
|
91
|
+
unwrap(await client.permission.reply({ requestID: requestId, reply, ...(message !== undefined ? { message } : {}) }), 'Answering the permission request failed');
|
|
92
|
+
},
|
|
93
|
+
/** Answer a question (one answer per question), or dismiss it with `null`. */
|
|
94
|
+
answerQuestion: async (requestId, answers) => {
|
|
95
|
+
if (answers === null) {
|
|
96
|
+
unwrap(await client.question.reject({ requestID: requestId }), 'Dismissing the question failed');
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
unwrap(await client.question.reply({ requestID: requestId, answers }), 'Answering the question failed');
|
|
100
|
+
},
|
|
101
|
+
/**
|
|
102
|
+
* Summarize the conversation so far into a shorter context. Uses `model`,
|
|
103
|
+
* else the runtime's default model; throws an `ApiError` with code
|
|
104
|
+
* `MODEL_REQUIRED` when neither names one. Resolves with the model it used.
|
|
105
|
+
*/
|
|
106
|
+
compact: async (model) => {
|
|
107
|
+
let chosen = model;
|
|
108
|
+
if (!chosen) {
|
|
109
|
+
// An unreadable config names no model: never guess one.
|
|
110
|
+
const config = await client.global.config.get().then((result) => (result.error === undefined ? result.data : null));
|
|
111
|
+
const reference = typeof config?.model === 'string' ? config.model : '';
|
|
112
|
+
const slash = reference.indexOf('/');
|
|
113
|
+
if (slash > 0 && slash < reference.length - 1) {
|
|
114
|
+
chosen = { providerID: reference.slice(0, slash), modelID: reference.slice(slash + 1) };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (!chosen)
|
|
118
|
+
throw new ApiError('Cannot compact: no model is set for this session', { code: 'MODEL_REQUIRED' });
|
|
119
|
+
unwrap(await client.session.summarize({ sessionID: input.rootId, providerID: chosen.providerID, modelID: chosen.modelID }), 'Compacting the session failed');
|
|
120
|
+
return chosen;
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=runtime-verbs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-verbs.js","sourceRoot":"","sources":["../../../src/core/session/runtime-verbs.ts"],"names":[],"mappings":"AAAA;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CAAC,EAAE,CAAC;gBACxE,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBACrC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC9C,MAAM,GAAG,EAAE,UAAU,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC1F,CAAC;YACH,CAAC;YACD,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,QAAQ,CAAC,kDAAkD,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC;YAChH,MAAM,CACJ,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,EACnH,+BAA+B,CAChC,CAAC;YACF,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Kortix message ids, format v1 — framework-free, with no imports. The format
|
|
3
|
+
* began as OpenCode's wire id; Kortix owns it now (the pi harness mints it
|
|
4
|
+
* natively). A client mints an id for a prompt (`mintWireMessageId`) and
|
|
5
|
+
* validates one (`WIRE_MESSAGE_ID`), and otherwise treats ids as opaque: the
|
|
6
|
+
* clock arithmetic below is `@deprecated` and stays only while the OpenCode
|
|
7
|
+
* runtime orders a transcript by id.
|
|
3
8
|
*
|
|
4
9
|
* FORMAT. `msg_` + the LOW 48 bits of `Date.now() * 0x1000` as 12 lowercase
|
|
5
10
|
* hex chars + 14 random base62 chars. OpenCode's own `Identifier.ascending`
|
|
@@ -22,11 +27,11 @@
|
|
|
22
27
|
* behavior.
|
|
23
28
|
*
|
|
24
29
|
* WHAT IS NOT HERE. Three other places touch the clock, each on purpose:
|
|
25
|
-
* - `apps/kortix-sandbox-agent-server/src/harness/pi/
|
|
30
|
+
* - `apps/kortix-sandbox-agent-server/src/harness/pi/message-id.ts` is the one
|
|
26
31
|
* remaining COPY: it mints the pi harness's reply ids. kortixd is a
|
|
27
32
|
* standalone compiled binary with no workspace dependencies. The copy
|
|
28
|
-
* orders on the ring through its own `
|
|
29
|
-
* `pi-
|
|
33
|
+
* orders on the ring through its own `messageIdClockDelta`, and
|
|
34
|
+
* `pi-message-id.test.ts` runs this file's regex and the golden mint and
|
|
30
35
|
* `delta` vectors against it. It mints with no backdate, at the box clock.
|
|
31
36
|
* - `./wire-id-unwrap` (internal, not exported) builds on the constants here:
|
|
32
37
|
* `core/turns/grouping.ts` orders messages for display on an UNWRAPPED
|
|
@@ -35,15 +40,25 @@
|
|
|
35
40
|
* ids from the HIGH bits. They key a bubble until the server's copy
|
|
36
41
|
* replaces it and are never sent as a prompt's wire `messageID`.
|
|
37
42
|
*/
|
|
38
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Sub-millisecond slots per millisecond in the id clock (`Date.now() * 0x1000`).
|
|
45
|
+
* @deprecated The message-id clock is an ordering detail of the OpenCode runtime;
|
|
46
|
+
* Kortix message ids are opaque to clients. Removed with OpenCode support.
|
|
47
|
+
*/
|
|
39
48
|
export declare const WIRE_ID_TIME_SCALE: bigint;
|
|
40
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* OpenCode keeps the low 6 bytes of its id clock.
|
|
51
|
+
* @deprecated The message-id clock is an ordering detail of the OpenCode runtime;
|
|
52
|
+
* Kortix message ids are opaque to clients. Removed with OpenCode support.
|
|
53
|
+
*/
|
|
41
54
|
export declare const WIRE_ID_TIME_MASK: bigint;
|
|
42
55
|
/**
|
|
43
56
|
* How far an id's clock may sit from the clock it is compared with and still
|
|
44
57
|
* count as placed by it: 1 hour. Every correct mint is within ~2 minutes of its
|
|
45
58
|
* own server timestamp (the backdate below); the high-bits bug put ids ~40 days
|
|
46
59
|
* out. `apps/api` re-exports it as `MAX_WIRE_ID_CLOCK_CORRECTION`.
|
|
60
|
+
* @deprecated The message-id clock is an ordering detail of the OpenCode runtime;
|
|
61
|
+
* Kortix message ids are opaque to clients. Removed with OpenCode support.
|
|
47
62
|
*/
|
|
48
63
|
export declare const WIRE_ID_CLOCK_TOLERANCE: bigint;
|
|
49
64
|
/**
|
|
@@ -51,13 +66,23 @@ export declare const WIRE_ID_CLOCK_TOLERANCE: bigint;
|
|
|
51
66
|
* is self-correcting (the lift raises it above what is on record); too LATE is
|
|
52
67
|
* undetectable downstream, because the next reply is minted from the box clock
|
|
53
68
|
* and would sort above its own prompt.
|
|
69
|
+
* @deprecated The message-id clock is an ordering detail of the OpenCode runtime;
|
|
70
|
+
* Kortix message ids are opaque to clients. Removed with OpenCode support.
|
|
54
71
|
*/
|
|
55
72
|
export declare const WIRE_ID_BACKDATE_MS: number;
|
|
56
73
|
/** `msg_` + 12 lowercase hex clock chars + 14 base62 chars. */
|
|
57
74
|
export declare const WIRE_MESSAGE_ID: RegExp;
|
|
58
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* The 48-bit clock encoded in a wire id, or null when `id` is not one.
|
|
77
|
+
* @deprecated The message-id clock is an ordering detail of the OpenCode runtime;
|
|
78
|
+
* Kortix message ids are opaque to clients. Removed with OpenCode support.
|
|
79
|
+
*/
|
|
59
80
|
export declare function wireIdClock(id: string | null | undefined): bigint | null;
|
|
60
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* The 48-bit id clock of wall-clock instant `ms`, as OpenCode writes it.
|
|
83
|
+
* @deprecated The message-id clock is an ordering detail of the OpenCode runtime;
|
|
84
|
+
* Kortix message ids are opaque to clients. Removed with OpenCode support.
|
|
85
|
+
*/
|
|
61
86
|
export declare function wireIdClockAt(ms: number): bigint;
|
|
62
87
|
/**
|
|
63
88
|
* Signed distance from `reference` to `clock` on the 48-bit ring, in clock
|
|
@@ -67,32 +92,48 @@ export declare function wireIdClockAt(ms: number): bigint;
|
|
|
67
92
|
* This is the ONE ordering primitive. Compare two clocks with
|
|
68
93
|
* `wireIdClockDelta(a, b) > 0`, never with `a > b`: a plain compare puts every
|
|
69
94
|
* id minted after a wrap BELOW every id minted before it.
|
|
95
|
+
* @deprecated The message-id clock is an ordering detail of the OpenCode runtime;
|
|
96
|
+
* Kortix message ids are opaque to clients. Removed with OpenCode support.
|
|
70
97
|
*/
|
|
71
98
|
export declare function wireIdClockDelta(clock: bigint, reference: bigint): bigint;
|
|
72
99
|
/**
|
|
73
100
|
* The newest of `clocks` on the ring, or null when none is given. `null` and
|
|
74
101
|
* `undefined` entries are skipped, so a caller can merge optional floors in one
|
|
75
102
|
* call: `maxWireIdClock([transcriptNewest, deliveredNewest, submitted])`.
|
|
103
|
+
* @deprecated The message-id clock is an ordering detail of the OpenCode runtime;
|
|
104
|
+
* Kortix message ids are opaque to clients. Removed with OpenCode support.
|
|
76
105
|
*/
|
|
77
106
|
export declare function maxWireIdClock(clocks: Iterable<bigint | null | undefined>): bigint | null;
|
|
78
107
|
/**
|
|
79
108
|
* Whether `id` claims a clock more than {@link WIRE_ID_CLOCK_TOLERANCE} ahead
|
|
80
109
|
* of `nowMs`. Such an id cannot have been placed against any real transcript;
|
|
81
110
|
* a floor or a lift must skip it rather than let it veto every later mint.
|
|
111
|
+
* @deprecated The message-id clock is an ordering detail of the OpenCode runtime;
|
|
112
|
+
* Kortix message ids are opaque to clients. Removed with OpenCode support.
|
|
82
113
|
*/
|
|
83
114
|
export declare function isWireIdAheadOf(id: string, nowMs: number): boolean;
|
|
84
115
|
/**
|
|
85
116
|
* The newest clock among `ids`, compared on the ring, or null when none is a
|
|
86
117
|
* wire id. With `nowMs`, an id {@link isWireIdAheadOf} it is skipped: it is not
|
|
87
118
|
* a position, and as a floor it would veto every lift.
|
|
119
|
+
* @deprecated The message-id clock is an ordering detail of the OpenCode runtime;
|
|
120
|
+
* Kortix message ids are opaque to clients. Removed with OpenCode support.
|
|
88
121
|
*/
|
|
89
122
|
export declare function newestWireIdClock(ids: Iterable<string | null | undefined>, nowMs?: number): bigint | null;
|
|
90
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* A minted id and the clock it encodes.
|
|
125
|
+
* @deprecated The message-id clock is an ordering detail of the OpenCode runtime;
|
|
126
|
+
* Kortix message ids are opaque to clients. Removed with OpenCode support.
|
|
127
|
+
*/
|
|
91
128
|
export interface MintedWireMessageId {
|
|
92
129
|
id: string;
|
|
93
130
|
time: bigint;
|
|
94
131
|
}
|
|
95
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* Input for {@link mintWireMessageIdAbove}.
|
|
134
|
+
* @deprecated The message-id clock is an ordering detail of the OpenCode runtime;
|
|
135
|
+
* Kortix message ids are opaque to clients. Removed with OpenCode support.
|
|
136
|
+
*/
|
|
96
137
|
export interface MintWireMessageIdAboveInput {
|
|
97
138
|
/** Wall clock to mint at, in ms since epoch. */
|
|
98
139
|
nowMs: number;
|
|
@@ -108,7 +149,7 @@ export interface MintWireMessageIdAboveInput {
|
|
|
108
149
|
* so the id lands where OpenCode itself would mint it.
|
|
109
150
|
*/
|
|
110
151
|
backdateMs?: number;
|
|
111
|
-
/** Source for the 14-char tail, in [0, 1). Default: `
|
|
152
|
+
/** Source for the 14-char tail, in [0, 1). Default: `crypto.getRandomValues`. */
|
|
112
153
|
random?: () => number;
|
|
113
154
|
}
|
|
114
155
|
/**
|
|
@@ -119,6 +160,8 @@ export interface MintWireMessageIdAboveInput {
|
|
|
119
160
|
* Dated `backdateMs` (default {@link WIRE_ID_BACKDATE_MS}) back, then lifted
|
|
120
161
|
* to `newestKnownTime + 1` when that floor is 0 to
|
|
121
162
|
* {@link WIRE_ID_CLOCK_TOLERANCE} ahead on the ring.
|
|
163
|
+
* @deprecated The message-id clock is an ordering detail of the OpenCode runtime;
|
|
164
|
+
* Kortix message ids are opaque to clients. Removed with OpenCode support.
|
|
122
165
|
*/
|
|
123
166
|
export declare function mintWireMessageIdAbove(input: MintWireMessageIdAboveInput): MintedWireMessageId;
|
|
124
167
|
/** Options for {@link mintWireMessageId}. */
|
|
@@ -133,7 +176,7 @@ export interface MintWireMessageIdOptions {
|
|
|
133
176
|
after?: Iterable<string | null | undefined>;
|
|
134
177
|
}
|
|
135
178
|
/**
|
|
136
|
-
* Mint
|
|
179
|
+
* Mint a Kortix message id for a prompt.
|
|
137
180
|
*
|
|
138
181
|
* Use this — never a hand-rolled `Date.now()` encoding — for the `messageId`
|
|
139
182
|
* of `session.prompts.create()`. It is dated {@link WIRE_ID_BACKDATE_MS} back
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire-message-id.d.ts","sourceRoot":"","sources":["../../../src/core/session/wire-message-id.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"wire-message-id.d.ts","sourceRoot":"","sources":["../../../src/core/session/wire-message-id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAIH;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAAiB,CAAC;AACjD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAyB,CAAC;AAIxD;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,QAA8C,CAAC;AAEnF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,QAAgB,CAAC;AAEjD,+DAA+D;AAC/D,eAAO,MAAM,eAAe,QAAsC,CAAC;AAKnE;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAGxE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MA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