@capybara-hq/kernel 0.1.0-rc.2 → 0.1.0-rc.4
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/dist/admin/admin.controller.d.ts +9 -4
- package/dist/admin/admin.controller.js +13 -4
- package/dist/admin/extensions.controller.d.ts +8 -1
- package/dist/admin/extensions.controller.js +22 -2
- package/dist/agents/agent-lookup.d.ts +3 -0
- package/dist/agents/agent-lookup.js +20 -2
- package/dist/agents/agent-profile.service.d.ts +29 -0
- package/dist/agents/agent-profile.service.js +117 -0
- package/dist/agents/agents.controller.d.ts +93 -3
- package/dist/agents/agents.controller.js +114 -4
- package/dist/agents/agents.module.js +6 -2
- package/dist/agents/agents.service.d.ts +13 -5
- package/dist/agents/agents.service.js +49 -13
- package/dist/agents/definition.d.ts +35 -8
- package/dist/agents/definition.js +203 -17
- package/dist/agents/instruction-files.d.ts +60 -0
- package/dist/agents/instruction-files.js +111 -0
- package/dist/agents/models.controller.d.ts +9 -3
- package/dist/agents/models.controller.js +19 -4
- package/dist/agents/profile.d.ts +96 -0
- package/dist/agents/profile.js +51 -0
- package/dist/agents/readiness.controller.d.ts +26 -0
- package/dist/agents/readiness.controller.js +56 -0
- package/dist/agents/templates.js +20 -5
- package/dist/background/background.controller.d.ts +38 -0
- package/dist/background/background.controller.js +87 -0
- package/dist/background/background.module.d.ts +10 -0
- package/dist/background/background.module.js +32 -0
- package/dist/background/finish.d.ts +43 -0
- package/dist/background/finish.js +94 -0
- package/dist/background/launch-lock.d.ts +14 -0
- package/dist/background/launch-lock.js +39 -0
- package/dist/background/launch.d.ts +36 -0
- package/dist/background/launch.js +70 -0
- package/dist/background/poll.job.d.ts +53 -0
- package/dist/background/poll.job.js +182 -0
- package/dist/background/render.d.ts +23 -0
- package/dist/background/render.js +48 -0
- package/dist/background/session.d.ts +37 -0
- package/dist/background/session.js +66 -0
- package/dist/background/status.d.ts +35 -0
- package/dist/background/status.js +57 -0
- package/dist/background/stop.d.ts +62 -0
- package/dist/background/stop.js +225 -0
- package/dist/background/store.d.ts +150 -0
- package/dist/background/store.js +351 -0
- package/dist/background/store.module.d.ts +6 -0
- package/dist/background/store.module.js +22 -0
- package/dist/background/tasks.service.d.ts +67 -0
- package/dist/background/tasks.service.js +186 -0
- package/dist/background/wake-rules.d.ts +57 -0
- package/dist/background/wake-rules.js +83 -0
- package/dist/background/wake.d.ts +28 -0
- package/dist/background/wake.js +57 -0
- package/dist/catalog/catalog-content.js +4 -1
- package/dist/catalog/claude/agents.js +15 -10
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/plugin-import.js +1 -1
- package/dist/catalog/plugin-upgrade.js +1 -1
- package/dist/channels/cards.d.ts +8 -2
- package/dist/channels/cards.js +17 -9
- package/dist/channels/connections.service.d.ts +16 -1
- package/dist/channels/connections.service.js +38 -4
- package/dist/channels/threads.d.ts +5 -0
- package/dist/channels/threads.js +8 -0
- package/dist/config/schema.d.ts +18 -0
- package/dist/config/schema.js +104 -2
- package/dist/conversations/access.js +2 -0
- package/dist/conversations/artifacts.d.ts +1 -1
- package/dist/conversations/artifacts.js +1 -1
- package/dist/conversations/attachments.service.d.ts +30 -0
- package/dist/conversations/attachments.service.js +130 -5
- package/dist/conversations/conversations.controller.d.ts +36 -5
- package/dist/conversations/conversations.controller.js +62 -12
- package/dist/conversations/conversations.module.js +3 -0
- package/dist/conversations/conversations.service.d.ts +44 -2
- package/dist/conversations/conversations.service.js +140 -12
- package/dist/conversations/event-log.d.ts +12 -1
- package/dist/conversations/event-log.js +29 -1
- package/dist/conversations/events.d.ts +81 -3
- package/dist/conversations/events.js +83 -16
- package/dist/conversations/queue.d.ts +3 -1
- package/dist/conversations/queue.js +13 -2
- package/dist/conversations/queue.service.js +3 -1
- package/dist/conversations/titles.d.ts +7 -0
- package/dist/conversations/titles.js +15 -0
- package/dist/db/kernel-schema.d.ts +60 -4
- package/dist/db/pool.d.ts +5 -0
- package/dist/db/pool.js +3 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +8 -0
- package/dist/evals/recorded-tools.d.ts +27 -1
- package/dist/evals/recorded-tools.js +85 -10
- package/dist/evals/run-replay.d.ts +10 -2
- package/dist/evals/run-replay.js +49 -12
- package/dist/evals/step-replay.js +12 -6
- package/dist/evals/trajectory.d.ts +2 -2
- package/dist/evals/trajectory.js +1 -1
- package/dist/extensions/admin-ops.js +2 -0
- package/dist/extensions/admin-view.d.ts +3 -1
- package/dist/extensions/admin-view.js +10 -2
- package/dist/extensions/blobs.js +1 -0
- package/dist/extensions/config-issues.d.ts +13 -1
- package/dist/extensions/config-issues.js +22 -5
- package/dist/extensions/config-json-schema.d.ts +43 -7
- package/dist/extensions/config-json-schema.js +124 -58
- package/dist/extensions/deployment-config-store.d.ts +6 -0
- package/dist/extensions/deployment-config.d.ts +50 -3
- package/dist/extensions/deployment-config.js +125 -28
- package/dist/extensions/display-name.d.ts +22 -0
- package/dist/extensions/display-name.js +77 -0
- package/dist/extensions/extensions.module.js +6 -0
- package/dist/extensions/host.d.ts +26 -1
- package/dist/extensions/host.js +82 -9
- package/dist/extensions/org-config.controller.d.ts +11 -3
- package/dist/extensions/org-config.controller.js +14 -6
- package/dist/extensions/org-config.d.ts +6 -0
- package/dist/extensions/org-config.js +12 -13
- package/dist/extensions/package.d.ts +14 -1
- package/dist/extensions/package.js +51 -2
- package/dist/extensions/permission-view.d.ts +3 -0
- package/dist/extensions/point-defaults.controller.d.ts +34 -0
- package/dist/extensions/point-defaults.controller.js +71 -0
- package/dist/extensions/point-defaults.d.ts +64 -0
- package/dist/extensions/point-defaults.js +206 -0
- package/dist/extensions/registry.d.ts +1 -1
- package/dist/extensions/registry.js +2 -0
- package/dist/http/api.module.js +8 -0
- package/dist/http/nest-logger.d.ts +6 -5
- package/dist/http/nest-logger.js +24 -10
- package/dist/identity/auth.controller.js +9 -5
- package/dist/identity/cookies.d.ts +20 -5
- package/dist/identity/cookies.js +44 -6
- package/dist/identity/me.controller.d.ts +5 -1
- package/dist/identity/me.controller.js +12 -3
- package/dist/identity/sessions.d.ts +12 -0
- package/dist/identity/sessions.js +45 -0
- package/dist/identity/settings.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/infra/config/kernel-config.service.js +6 -0
- package/dist/infra/database/database.module.js +1 -0
- package/dist/infra/events/kernel-events.d.ts +8 -0
- package/dist/infra/lifecycle/process-guards.js +4 -0
- package/dist/infra/logging/logging.module.d.ts +4 -2
- package/dist/infra/logging/logging.module.js +24 -6
- package/dist/infra/queue/redis-connection.d.ts +6 -0
- package/dist/infra/queue/redis-connection.js +7 -0
- package/dist/infra/redis/redis.module.js +6 -2
- package/dist/infra/tokens.d.ts +6 -1
- package/dist/infra/tokens.js +6 -1
- package/dist/lifecycle/kernel-lifecycle.js +5 -0
- package/dist/log.d.ts +13 -1
- package/dist/log.js +93 -17
- package/dist/models/purposes.d.ts +23 -0
- package/dist/models/purposes.js +31 -10
- package/dist/orgs/offboarding.d.ts +3 -1
- package/dist/orgs/offboarding.js +26 -16
- package/dist/orgs/settings.service.d.ts +7 -2
- package/dist/orgs/settings.service.js +15 -4
- package/dist/roles/worker.module.js +6 -0
- package/dist/runtime/context/build.d.ts +15 -13
- package/dist/runtime/context/build.js +45 -27
- package/dist/runtime/context/claude-tools.d.ts +3 -1
- package/dist/runtime/context/claude-tools.js +12 -12
- package/dist/runtime/context/compaction.js +4 -0
- package/dist/runtime/context/legacy-text.d.ts +22 -0
- package/dist/runtime/context/legacy-text.js +37 -0
- package/dist/runtime/context/skills.d.ts +29 -11
- package/dist/runtime/context/skills.js +37 -30
- package/dist/runtime/langgraph-loop.js +3 -2
- package/dist/runtime/loop.d.ts +5 -4
- package/dist/runtime/maintenance.d.ts +4 -2
- package/dist/runtime/maintenance.js +17 -5
- package/dist/runtime/model-call.d.ts +17 -1
- package/dist/runtime/model-call.js +4 -3
- package/dist/runtime/providers.d.ts +6 -0
- package/dist/runtime/providers.js +8 -0
- package/dist/runtime/run-finish.d.ts +1 -1
- package/dist/runtime/run-queue.d.ts +28 -5
- package/dist/runtime/run-queue.js +131 -35
- package/dist/runtime/run-worker.d.ts +2 -2
- package/dist/runtime/run-worker.js +20 -7
- package/dist/runtime/runtime.module.js +8 -3
- package/dist/runtime/step-log.d.ts +6 -0
- package/dist/runtime/step-log.js +16 -2
- package/dist/runtime/subagents/definition.d.ts +1 -6
- package/dist/runtime/subagents/definition.js +14 -13
- package/dist/runtime/subagents/dispatch.d.ts +2 -2
- package/dist/runtime/subagents/dispatch.js +2 -2
- package/dist/runtime/subagents/org-agents.js +2 -1
- package/dist/runtime/subagents/roster.d.ts +1 -1
- package/dist/runtime/subagents/roster.js +1 -1
- package/dist/runtime/subagents/skill-fork.d.ts +2 -2
- package/dist/runtime/subagents/skill-fork.js +2 -2
- package/dist/runtime/subagents/subagents.service.d.ts +3 -3
- package/dist/runtime/subagents/subagents.service.js +3 -3
- package/dist/runtime/usage-report.d.ts +2 -1
- package/dist/runtime/usage-report.js +2 -1
- package/dist/runtime/waits.d.ts +13 -7
- package/dist/runtime/waits.js +42 -16
- package/dist/sandbox/sandbox.module.js +6 -1
- package/dist/sandbox/sandbox.service.d.ts +61 -3
- package/dist/sandbox/sandbox.service.js +141 -7
- package/dist/skills/catalog.d.ts +4 -4
- package/dist/skills/catalog.js +4 -4
- package/dist/skills/changes.service.d.ts +2 -2
- package/dist/skills/changes.service.js +5 -4
- package/dist/skills/invocation-keys.d.ts +1 -1
- package/dist/skills/invocation-keys.js +1 -1
- package/dist/skills/invoke.d.ts +1 -1
- package/dist/skills/invoke.js +5 -4
- package/dist/tools/approvals.service.d.ts +6 -0
- package/dist/tools/approvals.service.js +21 -1
- package/dist/tools/builtin-names.d.ts +91 -0
- package/dist/tools/builtin-names.js +143 -0
- package/dist/tools/builtins/agent.d.ts +7 -7
- package/dist/tools/builtins/agent.js +7 -11
- package/dist/tools/builtins/ask-user.d.ts +1 -1
- package/dist/tools/builtins/ask-user.js +2 -2
- package/dist/tools/builtins/builtin-tools.d.ts +17 -3
- package/dist/tools/builtins/builtin-tools.js +36 -4
- package/dist/tools/builtins/read-tool-output.d.ts +1 -1
- package/dist/tools/builtins/read-tool-output.js +2 -2
- package/dist/tools/builtins/sandbox/bash.d.ts +4 -4
- package/dist/tools/builtins/sandbox/bash.js +259 -29
- package/dist/tools/builtins/sandbox/common.d.ts +30 -7
- package/dist/tools/builtins/sandbox/common.js +9 -5
- package/dist/tools/builtins/sandbox/deliver.d.ts +1 -1
- package/dist/tools/builtins/sandbox/deliver.js +12 -12
- package/dist/tools/builtins/sandbox/edit.d.ts +1 -1
- package/dist/tools/builtins/sandbox/edit.js +41 -30
- package/dist/tools/builtins/sandbox/file-state.d.ts +34 -0
- package/dist/tools/builtins/sandbox/file-state.js +34 -0
- package/dist/tools/builtins/sandbox/glob-match.d.ts +1 -1
- package/dist/tools/builtins/sandbox/glob-match.js +1 -1
- package/dist/tools/builtins/sandbox/glob.d.ts +1 -1
- package/dist/tools/builtins/sandbox/glob.js +4 -4
- package/dist/tools/builtins/sandbox/grep.d.ts +7 -4
- package/dist/tools/builtins/sandbox/grep.js +147 -30
- package/dist/tools/builtins/sandbox/index.d.ts +3 -1
- package/dist/tools/builtins/sandbox/index.js +7 -1
- package/dist/tools/builtins/sandbox/read.d.ts +2 -2
- package/dist/tools/builtins/sandbox/read.js +21 -14
- package/dist/tools/builtins/sandbox/task-output.d.ts +63 -0
- package/dist/tools/builtins/sandbox/task-output.js +304 -0
- package/dist/tools/builtins/sandbox/task-stop.d.ts +10 -0
- package/dist/tools/builtins/sandbox/task-stop.js +112 -0
- package/dist/tools/builtins/sandbox/write.d.ts +1 -1
- package/dist/tools/builtins/sandbox/write.js +37 -33
- package/dist/tools/builtins/skill-load.d.ts +3 -3
- package/dist/tools/builtins/skill-load.js +32 -16
- package/dist/tools/builtins/skill-write.d.ts +4 -4
- package/dist/tools/builtins/skill-write.js +10 -10
- package/dist/tools/builtins/tool-search.d.ts +13 -9
- package/dist/tools/builtins/tool-search.js +25 -14
- package/dist/tools/builtins/web/errors.d.ts +8 -0
- package/dist/tools/builtins/web/errors.js +53 -0
- package/dist/tools/builtins/web/extract.d.ts +62 -0
- package/dist/tools/builtins/web/extract.js +267 -0
- package/dist/tools/builtins/web/fetch.d.ts +55 -0
- package/dist/tools/builtins/web/fetch.js +174 -0
- package/dist/tools/builtins/web/index.d.ts +13 -0
- package/dist/tools/builtins/web/index.js +12 -0
- package/dist/tools/builtins/web/page-cache.d.ts +25 -0
- package/dist/tools/builtins/web/page-cache.js +77 -0
- package/dist/tools/builtins/web/search.d.ts +25 -0
- package/dist/tools/builtins/web/search.js +209 -0
- package/dist/tools/builtins/web/url.d.ts +17 -0
- package/dist/tools/builtins/web/url.js +43 -0
- package/dist/tools/connectors.service.js +4 -4
- package/dist/tools/display-names.d.ts +9 -0
- package/dist/tools/display-names.js +24 -0
- package/dist/tools/drift.js +5 -5
- package/dist/tools/elicitation.js +1 -1
- package/dist/tools/info.d.ts +20 -4
- package/dist/tools/info.js +55 -32
- package/dist/tools/legacy-data.d.ts +34 -0
- package/dist/tools/legacy-data.js +76 -0
- package/dist/tools/legacy-keys.d.ts +51 -0
- package/dist/tools/legacy-keys.js +115 -0
- package/dist/tools/naming.d.ts +1 -5
- package/dist/tools/naming.js +1 -7
- package/dist/tools/oauth/flow-paths.d.ts +1 -1
- package/dist/tools/oauth/flow-paths.js +1 -1
- package/dist/tools/outputs.js +1 -1
- package/dist/tools/pipeline.d.ts +13 -7
- package/dist/tools/pipeline.js +112 -39
- package/dist/tools/policy.d.ts +1 -14
- package/dist/tools/policy.js +13 -19
- package/dist/tools/questions.controller.d.ts +1 -1
- package/dist/tools/questions.controller.js +1 -1
- package/dist/tools/questions.service.d.ts +1 -1
- package/dist/tools/registry.d.ts +38 -24
- package/dist/tools/registry.js +54 -47
- package/dist/tools/resources.d.ts +1 -1
- package/dist/tools/resources.js +1 -1
- package/dist/tools/tools.module.js +13 -1
- package/dist/tools/validate.js +1 -1
- package/package.json +3 -3
- package/src/migrations/0063_tool_keys_claude_code.sql +220 -0
- package/src/migrations/0064_account_last_org.sql +7 -0
- package/src/migrations/0065_conversation_archive.sql +8 -0
- package/src/migrations/0066_extension_display_name.sql +4 -0
- package/src/migrations/0067_agent_profiles.sql +20 -0
- package/src/migrations/0068_agent_avatar_uploads.sql +7 -0
- package/src/migrations/0069_attachments_agent_idx.sql +3 -0
- package/src/migrations/0070_background_tasks.sql +37 -0
- package/src/migrations/0071_background_tasks_reserve.sql +6 -0
- package/src/migrations/0072_background_tasks_stopping.sql +5 -0
- package/src/migrations/0073_org_extension_point_defaults.sql +11 -0
- package/dist/tools/builtins/sandbox/names.d.ts +0 -7
- package/dist/tools/builtins/sandbox/names.js +0 -20
|
@@ -86,10 +86,10 @@ export type LogContentBlock = Exclude<ContentBlock, MediaBlock> | (MediaBlock ex
|
|
|
86
86
|
} : never : never);
|
|
87
87
|
/**
|
|
88
88
|
* Structured view of a builtin tool's result (UI refresh B, spec §5.5 / §5.9): display only, like
|
|
89
|
-
* `display`. `command`: `
|
|
89
|
+
* `display`. `command`: `Bash` (the model's `description`, the exit code, null when the
|
|
90
90
|
* command was stopped, and whether it timed out; the web shows "Failed" for a non-zero exit even
|
|
91
|
-
* though `isError` stays false); `edit`: `
|
|
92
|
-
* `read`: `
|
|
91
|
+
* though `isError` stays false); `edit`: `Edit` / `Write` (a capped line diff);
|
|
92
|
+
* `read`: `Read` (the line range shown).
|
|
93
93
|
*/
|
|
94
94
|
export declare const ToolViewSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
95
95
|
kind: z.ZodLiteral<"command">;
|
|
@@ -103,6 +103,11 @@ export declare const ToolViewSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
103
103
|
added: z.ZodNumber;
|
|
104
104
|
removed: z.ZodNumber;
|
|
105
105
|
truncated: z.ZodBoolean;
|
|
106
|
+
file: z.ZodOptional<z.ZodObject<{
|
|
107
|
+
path: z.ZodString;
|
|
108
|
+
size: z.ZodNumber;
|
|
109
|
+
sha256: z.ZodString;
|
|
110
|
+
}, z.core.$strip>>;
|
|
106
111
|
hunks: z.ZodArray<z.ZodObject<{
|
|
107
112
|
oldStart: z.ZodNumber;
|
|
108
113
|
newStart: z.ZodNumber;
|
|
@@ -120,6 +125,11 @@ export declare const ToolViewSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
120
125
|
path: z.ZodString;
|
|
121
126
|
fromLine: z.ZodOptional<z.ZodNumber>;
|
|
122
127
|
toLine: z.ZodOptional<z.ZodNumber>;
|
|
128
|
+
file: z.ZodOptional<z.ZodObject<{
|
|
129
|
+
path: z.ZodString;
|
|
130
|
+
size: z.ZodNumber;
|
|
131
|
+
sha256: z.ZodString;
|
|
132
|
+
}, z.core.$strip>>;
|
|
123
133
|
}, z.core.$strip>], "kind">;
|
|
124
134
|
export type ToolView = z.infer<typeof ToolViewSchema>;
|
|
125
135
|
/**
|
|
@@ -262,6 +272,11 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
262
272
|
model: z.ZodString;
|
|
263
273
|
}, z.core.$strip>;
|
|
264
274
|
triggerAccountId: z.ZodString;
|
|
275
|
+
trigger: z.ZodOptional<z.ZodEnum<{
|
|
276
|
+
background_task: "background_task";
|
|
277
|
+
message: "message";
|
|
278
|
+
}>>;
|
|
279
|
+
triggerSeq: z.ZodOptional<z.ZodNumber>;
|
|
265
280
|
}, z.core.$strip>;
|
|
266
281
|
}, z.core.$strip>, z.ZodObject<{
|
|
267
282
|
type: z.ZodLiteral<"model_call">;
|
|
@@ -396,7 +411,9 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
396
411
|
purpose: z.ZodOptional<z.ZodEnum<{
|
|
397
412
|
compaction: "compaction";
|
|
398
413
|
title: "title";
|
|
414
|
+
web_fetch: "web_fetch";
|
|
399
415
|
}>>;
|
|
416
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
400
417
|
}, z.core.$strip>;
|
|
401
418
|
}, z.core.$strip>, z.ZodObject<{
|
|
402
419
|
type: z.ZodLiteral<"reminder">;
|
|
@@ -441,6 +458,11 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
441
458
|
added: z.ZodNumber;
|
|
442
459
|
removed: z.ZodNumber;
|
|
443
460
|
truncated: z.ZodBoolean;
|
|
461
|
+
file: z.ZodOptional<z.ZodObject<{
|
|
462
|
+
path: z.ZodString;
|
|
463
|
+
size: z.ZodNumber;
|
|
464
|
+
sha256: z.ZodString;
|
|
465
|
+
}, z.core.$strip>>;
|
|
444
466
|
hunks: z.ZodArray<z.ZodObject<{
|
|
445
467
|
oldStart: z.ZodNumber;
|
|
446
468
|
newStart: z.ZodNumber;
|
|
@@ -458,6 +480,11 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
458
480
|
path: z.ZodString;
|
|
459
481
|
fromLine: z.ZodOptional<z.ZodNumber>;
|
|
460
482
|
toLine: z.ZodOptional<z.ZodNumber>;
|
|
483
|
+
file: z.ZodOptional<z.ZodObject<{
|
|
484
|
+
path: z.ZodString;
|
|
485
|
+
size: z.ZodNumber;
|
|
486
|
+
sha256: z.ZodString;
|
|
487
|
+
}, z.core.$strip>>;
|
|
461
488
|
}, z.core.$strip>], "kind">>;
|
|
462
489
|
card: z.ZodOptional<z.ZodObject<{
|
|
463
490
|
plugin: z.ZodString;
|
|
@@ -476,6 +503,13 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
476
503
|
}, z.core.$strip>, z.ZodObject<{
|
|
477
504
|
type: z.ZodLiteral<"approval_requested">;
|
|
478
505
|
payload: z.ZodObject<{
|
|
506
|
+
requestedFor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
507
|
+
approverRole: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
508
|
+
admin: "admin";
|
|
509
|
+
guest: "guest";
|
|
510
|
+
member: "member";
|
|
511
|
+
owner: "owner";
|
|
512
|
+
}>>>;
|
|
479
513
|
step: z.ZodNumber;
|
|
480
514
|
callId: z.ZodString;
|
|
481
515
|
approvalId: z.ZodString;
|
|
@@ -639,6 +673,10 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
639
673
|
name: z.ZodString;
|
|
640
674
|
avatarUrl: z.ZodDefault<z.ZodNullable<z.ZodURL>>;
|
|
641
675
|
instructions: z.ZodDefault<z.ZodString>;
|
|
676
|
+
instructionFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
677
|
+
name: z.ZodString;
|
|
678
|
+
content: z.ZodString;
|
|
679
|
+
}, z.core.$strict>>>;
|
|
642
680
|
model: z.ZodObject<{
|
|
643
681
|
provider: z.ZodString;
|
|
644
682
|
model: z.ZodString;
|
|
@@ -734,6 +772,13 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
734
772
|
}, z.core.$strip>, z.ZodObject<{
|
|
735
773
|
type: z.ZodLiteral<"subagent_waiting">;
|
|
736
774
|
payload: z.ZodObject<{
|
|
775
|
+
requestedFor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
776
|
+
approverRole: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
777
|
+
admin: "admin";
|
|
778
|
+
guest: "guest";
|
|
779
|
+
member: "member";
|
|
780
|
+
owner: "owner";
|
|
781
|
+
}>>>;
|
|
737
782
|
subagentId: z.ZodString;
|
|
738
783
|
childRunId: z.ZodString;
|
|
739
784
|
kind: z.ZodEnum<{
|
|
@@ -779,6 +824,29 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
779
824
|
childRunId: z.ZodOptional<z.ZodString>;
|
|
780
825
|
text: z.ZodString;
|
|
781
826
|
}, z.core.$strip>;
|
|
827
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
828
|
+
type: z.ZodLiteral<"background_task_finished">;
|
|
829
|
+
payload: z.ZodObject<{
|
|
830
|
+
taskId: z.ZodString;
|
|
831
|
+
description: z.ZodString;
|
|
832
|
+
status: z.ZodEnum<{
|
|
833
|
+
completed: "completed";
|
|
834
|
+
failed: "failed";
|
|
835
|
+
lost: "lost";
|
|
836
|
+
stopped: "stopped";
|
|
837
|
+
timed_out: "timed_out";
|
|
838
|
+
}>;
|
|
839
|
+
exitCode: z.ZodNullable<z.ZodNumber>;
|
|
840
|
+
elapsedMs: z.ZodNumber;
|
|
841
|
+
lastLines: z.ZodString;
|
|
842
|
+
outputPath: z.ZodString;
|
|
843
|
+
reported: z.ZodBoolean;
|
|
844
|
+
lostReason: z.ZodOptional<z.ZodString>;
|
|
845
|
+
stoppedBy: z.ZodOptional<z.ZodEnum<{
|
|
846
|
+
deletion: "deletion";
|
|
847
|
+
person: "person";
|
|
848
|
+
}>>;
|
|
849
|
+
}, z.core.$strip>;
|
|
782
850
|
}, z.core.$strip>, z.ZodObject<{
|
|
783
851
|
type: z.ZodLiteral<"compaction_summary">;
|
|
784
852
|
payload: z.ZodObject<{
|
|
@@ -839,6 +907,16 @@ export type ConversationEvent = ConversationEventBody & {
|
|
|
839
907
|
runId: string | null;
|
|
840
908
|
createdAt: Date;
|
|
841
909
|
};
|
|
910
|
+
/** An event a run absorbs at a step boundary: a person's message or a finished background task. */
|
|
911
|
+
export type AbsorbableEvent = Extract<ConversationEvent, {
|
|
912
|
+
type: "user_message" | "background_task_finished";
|
|
913
|
+
}>;
|
|
914
|
+
/**
|
|
915
|
+
* Whether `e` is absorbed like an interjection (spec 2026-11-05-background-bash-design §2.4): the
|
|
916
|
+
* loop takes it at its next step boundary, `consumed_seq` moves past it, and request building
|
|
917
|
+
* places it where the model call that absorbed it was built.
|
|
918
|
+
*/
|
|
919
|
+
export declare const isAbsorbable: (e: ConversationEvent) => e is AbsorbableEvent;
|
|
842
920
|
/**
|
|
843
921
|
* What the person typed for a skill invocation (phase D): `/<plugin>:<name> <arguments>` (no
|
|
844
922
|
* plugin: `/<name>`). Titles and eval case titles use it instead of the rendered skill in
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DOCUMENT_MEDIA_TYPES, hasControlChars, IMAGE_MEDIA_TYPES, isAttachmentId, isSkillName, MEDIA_NAME_MAX_CHARS, } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { AgentDefinitionSchema, AgentToolRef, ModelRef } from "../agents/definition.js";
|
|
4
|
+
import { ORG_ROLES } from "../orgs/roles.js";
|
|
4
5
|
import { TOOL_VIEW_DIFF_MAX_LINES, TOOL_VIEW_LINE_MAX_CHARS, TOOL_VIEW_PATH_MAX_CHARS, } from "../tools/view.js";
|
|
5
6
|
/** 供应商私有数据(`ProviderOpaque`):原样保存、只回放给同一供应商。 */
|
|
6
7
|
const ProviderOpaqueSchema = z.object({
|
|
@@ -17,6 +18,15 @@ const RefMediaSourceSchema = z.object({
|
|
|
17
18
|
kind: z.literal("ref"),
|
|
18
19
|
attachmentId: AttachmentIdSchema,
|
|
19
20
|
});
|
|
21
|
+
/**
|
|
22
|
+
* Who may decide an approval, as the approval row says (display only, absent in older logs): the
|
|
23
|
+
* assigned account (`requestedFor`), else the escalation role (`approverRole`). Pages word the
|
|
24
|
+
* waiting state with it ("等待 张三 批准") for viewers who cannot decide.
|
|
25
|
+
*/
|
|
26
|
+
const ApproverFields = {
|
|
27
|
+
requestedFor: z.string().nullable().optional(),
|
|
28
|
+
approverRole: z.enum(ORG_ROLES).nullable().optional(),
|
|
29
|
+
};
|
|
20
30
|
/** The longest deny reason (characters): the decision route's limit and `approval_decided.reason`'s. */
|
|
21
31
|
export const APPROVAL_DENY_REASON_MAX_CHARS = 500;
|
|
22
32
|
/** 一条 `media_excluded` 事件最多的附件数。 */
|
|
@@ -75,12 +85,22 @@ const STOP_REASONS = ["end_turn", "tool_use", "max_tokens", "refusal", "other"];
|
|
|
75
85
|
const EFFORT_ENUM = ["low", "medium", "high", "xhigh", "max"];
|
|
76
86
|
const seqNo = z.number().int().nonnegative();
|
|
77
87
|
const count = z.number().int().nonnegative();
|
|
88
|
+
/**
|
|
89
|
+
* The state of a file a `Read` / `Write` / `Edit` saw or left (display only, but the kernel reads it
|
|
90
|
+
* back from the log to decide read-before-write): the full normalized path, the file's full size and
|
|
91
|
+
* the sha256 of the bytes handled (the first bytes only for a file over `Read`'s byte limit).
|
|
92
|
+
*/
|
|
93
|
+
const FileStateViewSchema = z.object({
|
|
94
|
+
path: z.string().max(4096),
|
|
95
|
+
size: count,
|
|
96
|
+
sha256: z.string().regex(/^[0-9a-f]{64}$/),
|
|
97
|
+
});
|
|
78
98
|
/**
|
|
79
99
|
* Structured view of a builtin tool's result (UI refresh B, spec §5.5 / §5.9): display only, like
|
|
80
|
-
* `display`. `command`: `
|
|
100
|
+
* `display`. `command`: `Bash` (the model's `description`, the exit code, null when the
|
|
81
101
|
* command was stopped, and whether it timed out; the web shows "Failed" for a non-zero exit even
|
|
82
|
-
* though `isError` stays false); `edit`: `
|
|
83
|
-
* `read`: `
|
|
102
|
+
* though `isError` stays false); `edit`: `Edit` / `Write` (a capped line diff);
|
|
103
|
+
* `read`: `Read` (the line range shown).
|
|
84
104
|
*/
|
|
85
105
|
export const ToolViewSchema = z.discriminatedUnion("kind", [
|
|
86
106
|
z.object({
|
|
@@ -96,6 +116,7 @@ export const ToolViewSchema = z.discriminatedUnion("kind", [
|
|
|
96
116
|
added: count,
|
|
97
117
|
removed: count,
|
|
98
118
|
truncated: z.boolean(),
|
|
119
|
+
file: FileStateViewSchema.optional(),
|
|
99
120
|
hunks: z
|
|
100
121
|
.array(z.object({
|
|
101
122
|
oldStart: count,
|
|
@@ -114,6 +135,7 @@ export const ToolViewSchema = z.discriminatedUnion("kind", [
|
|
|
114
135
|
path: z.string().max(TOOL_VIEW_PATH_MAX_CHARS),
|
|
115
136
|
fromLine: count.optional(),
|
|
116
137
|
toLine: count.optional(),
|
|
138
|
+
file: FileStateViewSchema.optional(),
|
|
117
139
|
}),
|
|
118
140
|
]);
|
|
119
141
|
const ModelUsageShape = {
|
|
@@ -227,6 +249,14 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
227
249
|
agentVersion: z.number().int().positive(),
|
|
228
250
|
model: ModelRef,
|
|
229
251
|
triggerAccountId: z.string(),
|
|
252
|
+
/**
|
|
253
|
+
* What started the run (display only): absent or `message` = a person's message (or a
|
|
254
|
+
* sub-agent's task), `background_task` = a finished background task woke the conversation
|
|
255
|
+
* (spec 2026-11-05-background-bash-design §3).
|
|
256
|
+
*/
|
|
257
|
+
trigger: z.enum(["message", "background_task"]).optional(),
|
|
258
|
+
/** A wake run's boundary: the seq of the finish that woke it (full-run replay seeds from it). */
|
|
259
|
+
triggerSeq: seqNo.optional(),
|
|
230
260
|
})),
|
|
231
261
|
ev("model_call", z.object({
|
|
232
262
|
step: count,
|
|
@@ -260,13 +290,13 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
260
290
|
*/
|
|
261
291
|
absorbedUpToSeq: seqNo.optional(),
|
|
262
292
|
/**
|
|
263
|
-
* 本次请求带给模型的工具(按发送顺序:未启用
|
|
293
|
+
* 本次请求带给模型的工具(按发送顺序:未启用 ToolSearch 时按 key 排序;启用时为内置工具按 key 排序,
|
|
264
294
|
* 其后是已加载工具按首次加载顺序)及其定义指纹(`ResolvedTool.specHash`)。
|
|
265
295
|
* 模型不支持工具时为空数组。较早的事件可能没有。
|
|
266
296
|
*/
|
|
267
297
|
tools: z.array(z.object({ key: z.string(), specHash: z.string() })).optional(),
|
|
268
298
|
/**
|
|
269
|
-
* 启用
|
|
299
|
+
* 启用 ToolSearch 时 system 第二块目录里的工具(按 key 排序)及定义指纹;定义同样存在
|
|
270
300
|
* `capybara.tool_specs`,目录文本可由它们还原。未启用时不写。
|
|
271
301
|
*/
|
|
272
302
|
catalog: z.array(z.object({ key: z.string(), specHash: z.string() })).optional(),
|
|
@@ -314,14 +344,18 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
314
344
|
* Usage of one model call. Absent `purpose` = the step's call (written with its
|
|
315
345
|
* `assistant_message`); `compaction` = the compaction call before the step (I-1: billed and
|
|
316
346
|
* reported, but no step consumer may pair it with the step's `model_call`); `title` = the
|
|
317
|
-
* conversation title call (UI refresh B: no run, `step` 0, not model-visible, billed and reported)
|
|
347
|
+
* conversation title call (UI refresh B: no run, `step` 0, not model-visible, billed and reported);
|
|
348
|
+
* `web_fetch` = a `WebFetch` extraction call (web tools spec §5: the tool call's run and step,
|
|
349
|
+
* `callId` = the call; not model-visible, billed and reported, counted on a sub-agent's parent).
|
|
318
350
|
*/
|
|
319
351
|
ev("usage", z.object({
|
|
320
352
|
step: count,
|
|
321
353
|
provider: z.string(),
|
|
322
354
|
model: z.string(),
|
|
323
355
|
...ModelUsageShape,
|
|
324
|
-
purpose: z.enum(["compaction", "title"]).optional(),
|
|
356
|
+
purpose: z.enum(["compaction", "title", "web_fetch"]).optional(),
|
|
357
|
+
/** The tool call a `web_fetch` usage belongs to. */
|
|
358
|
+
callId: z.string().optional(),
|
|
325
359
|
})),
|
|
326
360
|
ev("reminder", z.object({ step: count, text: z.string() })),
|
|
327
361
|
/** 工具调用开始执行之前写入(续跑时「有开始无结果」的调用记为结果未知,不再执行)。 */
|
|
@@ -339,7 +373,7 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
339
373
|
outputId: z.string().optional(),
|
|
340
374
|
contentTypes: z.array(z.string()).optional(),
|
|
341
375
|
/**
|
|
342
|
-
* `
|
|
376
|
+
* `ToolSearch` 本次加载的工具 key(没有匹配时不写)。已加载集合 = 会话中全部 tool_result 的
|
|
343
377
|
* `loadedTools` 并集(含已被摘要覆盖的部分),构建请求时由日志还原,不放进程内存。
|
|
344
378
|
*/
|
|
345
379
|
loadedTools: z.array(z.string()).optional(),
|
|
@@ -380,6 +414,7 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
380
414
|
expiresAt: z.string(),
|
|
381
415
|
/** Which rule asked (UI refresh B; display only, absent in older logs). */
|
|
382
416
|
policy: z.enum(["agent", "connector", "default", "role", "org", "fixed"]).optional(),
|
|
417
|
+
...ApproverFields,
|
|
383
418
|
})),
|
|
384
419
|
/** 审批已处理(批准 / 拒绝 / 超时 / 取消);`scope` 只在批准时出现,`byAccountId` 为处理人(超时 / 取消为 null)。 */
|
|
385
420
|
ev("approval_decided", z.object({
|
|
@@ -395,7 +430,7 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
395
430
|
reason: z.string().max(APPROVAL_DENY_REASON_MAX_CHARS).optional(),
|
|
396
431
|
})),
|
|
397
432
|
/**
|
|
398
|
-
* 工具调用需要用户输入(`
|
|
433
|
+
* 工具调用需要用户输入(`AskUserQuestion`、插件工具的 `input_required`、MCP elicitation):输入请求已建,
|
|
399
434
|
* run 暂停等待回答。界面据此显示表单卡片(不进模型请求)。
|
|
400
435
|
*/
|
|
401
436
|
ev("question_asked", z.object({
|
|
@@ -423,7 +458,7 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
423
458
|
reason: z.enum(["provider_rejected"]),
|
|
424
459
|
})),
|
|
425
460
|
/**
|
|
426
|
-
* agent 经 `
|
|
461
|
+
* agent 经 `Deliver` 把沙箱里的文件交付给用户(M5 T8,C3):字节在对象存储
|
|
427
462
|
* `kernel/<orgId>/<objectKey>`(`objectKey` = `artifacts/<conversationId>/<artifactId>`,相对内核前缀),
|
|
428
463
|
* 这里只有元数据。网页从日志重建产物列表;不进模型请求(模型看到的是同一调用的 tool_result 确认)。
|
|
429
464
|
*/
|
|
@@ -439,7 +474,7 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
439
474
|
/**
|
|
440
475
|
* 本对话此刻生效的技能(M5 T14,Ruling M17):运行开始时内核解析生效的技能集合(agent 版本选中的组织技能 +
|
|
441
476
|
* agent 自己的技能,未删除,取 current_version),与日志里上一份快照不同才写。模型看到的技能目录只来自这里:
|
|
442
|
-
* 第一份(在任何 `model_call` 之前)进 system 缓存段,之后的在所在位置渲染为英文变更提醒;`
|
|
477
|
+
* 第一份(在任何 `model_call` 之前)进 system 缓存段,之后的在所在位置渲染为英文变更提醒;`Skill` 按最新一份
|
|
443
478
|
* 把名字解析为 id 与版本。按 name 排序。
|
|
444
479
|
*/
|
|
445
480
|
ev("skills_catalog", z.object({
|
|
@@ -451,12 +486,12 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
451
486
|
version: z.number().int().positive(),
|
|
452
487
|
/**
|
|
453
488
|
* 内容来源(对象前缀,T15):已生成的版本为 `skill_versions.object_prefix`,试用中的草稿为申请的
|
|
454
|
-
* `object_prefix`。同号的草稿与正式版本靠它区分;`
|
|
489
|
+
* `object_prefix`。同号的草稿与正式版本靠它区分;`Skill` 只按它解析。
|
|
455
490
|
*/
|
|
456
491
|
source: z.string().min(1).max(512),
|
|
457
492
|
/**
|
|
458
493
|
* The catalog item (plugin) name the skill came from (phase B); absent for the org's
|
|
459
|
-
* own and the agent's skills, and in snapshots written before phase B. `
|
|
494
|
+
* own and the agent's skills, and in snapshots written before phase B. `Skill`
|
|
460
495
|
* resolves `<plugin>:<name>` with it; it is not model-visible otherwise.
|
|
461
496
|
*/
|
|
462
497
|
plugin: z.string().min(1).max(64).optional(),
|
|
@@ -465,7 +500,7 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
465
500
|
/**
|
|
466
501
|
* Pinned skills (phase B, spec §9.1) in the agent's order: each a skill of `skills` (same
|
|
467
502
|
* id, version and source) with its SKILL.md body as read at run start or written by
|
|
468
|
-
*
|
|
503
|
+
* SkillWrite. Absent means none (every snapshot before phase B).
|
|
469
504
|
*/
|
|
470
505
|
pinned: z
|
|
471
506
|
.array(z.object({
|
|
@@ -534,7 +569,7 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
534
569
|
warnings: z.array(z.string()).optional(),
|
|
535
570
|
})),
|
|
536
571
|
/**
|
|
537
|
-
* Parent log (phase C, spec §14.1): the `
|
|
572
|
+
* Parent log (phase C, spec §14.1): the `Agent` call `callId` started (or resumed) the sub-agent
|
|
538
573
|
* `subagentId` (its child conversation id) with run `childRunId`. Not model-visible: the model
|
|
539
574
|
* sees the call's tool_call / tool_result pair.
|
|
540
575
|
*/
|
|
@@ -550,7 +585,7 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
550
585
|
tierFallback: z.boolean().optional(),
|
|
551
586
|
/**
|
|
552
587
|
* Phase D: the seq of the person's fork invocation this dispatch runs (`callId` is
|
|
553
|
-
* `skill-<seq>`, step 0, no tool call); absent for an `
|
|
588
|
+
* `skill-<seq>`, step 0, no tool call); absent for an `Agent` call.
|
|
554
589
|
*/
|
|
555
590
|
invokedSeq: seqNo.optional(),
|
|
556
591
|
})),
|
|
@@ -563,6 +598,8 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
563
598
|
questionId: z.string().optional(),
|
|
564
599
|
toolKey: z.string(),
|
|
565
600
|
expiresAt: z.string().optional(),
|
|
601
|
+
/** An approval's approver (`kind: "approval"`), as in `approval_requested`. */
|
|
602
|
+
...ApproverFields,
|
|
566
603
|
})),
|
|
567
604
|
/** Parent log: a sub-agent's run ended. Not model-visible (its reply is the call's tool_result). */
|
|
568
605
|
ev("subagent_finished", z.object({
|
|
@@ -597,6 +634,30 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
597
634
|
childRunId: z.string().optional(),
|
|
598
635
|
text: z.string(),
|
|
599
636
|
})),
|
|
637
|
+
/**
|
|
638
|
+
* A background Bash task ended (spec 2026-11-05-background-bash-design §2). Model-visible: it is
|
|
639
|
+
* absorbed like an interjection and rendered as a system message (`renderBackgroundFinished`).
|
|
640
|
+
* `reported`: a TaskOutput or TaskStop in the same run already told the model; it is absorbed
|
|
641
|
+
* like any other, renders as one short line and never wakes a run. `lastLines` is the tail of
|
|
642
|
+
* the task's output.
|
|
643
|
+
*/
|
|
644
|
+
ev("background_task_finished", z.object({
|
|
645
|
+
taskId: z.string().min(1).max(64),
|
|
646
|
+
description: z.string(),
|
|
647
|
+
status: z.enum(["completed", "failed", "stopped", "timed_out", "lost"]),
|
|
648
|
+
exitCode: z.number().int().nullable(),
|
|
649
|
+
elapsedMs: count,
|
|
650
|
+
lastLines: z.string().max(4000),
|
|
651
|
+
outputPath: z.string(),
|
|
652
|
+
reported: z.boolean(),
|
|
653
|
+
lostReason: z.string().optional(),
|
|
654
|
+
/**
|
|
655
|
+
* The finish never wakes a run, but the next run absorbs it like any other (background
|
|
656
|
+
* Bash §3): `person`, a person stopped the task (the conversation's background section);
|
|
657
|
+
* `deletion`, the conversation was being deleted.
|
|
658
|
+
*/
|
|
659
|
+
stoppedBy: z.enum(["person", "deletion"]).optional(),
|
|
660
|
+
})),
|
|
600
661
|
ev("compaction_summary", z.object({ coversUpToSeq: seqNo, text: z.string() })),
|
|
601
662
|
ev("compaction_failed", z.object({ attempt: count, reason: z.string() })),
|
|
602
663
|
ev("run_finished", z.object({
|
|
@@ -618,6 +679,12 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
618
679
|
.optional(),
|
|
619
680
|
})),
|
|
620
681
|
]);
|
|
682
|
+
/**
|
|
683
|
+
* Whether `e` is absorbed like an interjection (spec 2026-11-05-background-bash-design §2.4): the
|
|
684
|
+
* loop takes it at its next step boundary, `consumed_seq` moves past it, and request building
|
|
685
|
+
* places it where the model call that absorbed it was built.
|
|
686
|
+
*/
|
|
687
|
+
export const isAbsorbable = (e) => e.type === "user_message" || e.type === "background_task_finished";
|
|
621
688
|
/**
|
|
622
689
|
* What the person typed for a skill invocation (phase D): `/<plugin>:<name> <arguments>` (no
|
|
623
690
|
* plugin: `/<name>`). Titles and eval case titles use it instead of the rendered skill in
|
|
@@ -125,6 +125,7 @@ export declare function queuedUserMessage(r: QueueRow): AppendEvent;
|
|
|
125
125
|
export declare function appendQueuedIn(t: KernelTrx, eventLog: Pick<EventLog, "appendIn">, conversationId: string, r: QueueRow): Promise<{
|
|
126
126
|
event: ConversationEvent;
|
|
127
127
|
switched: boolean;
|
|
128
|
+
unarchived: boolean;
|
|
128
129
|
}>;
|
|
129
130
|
/**
|
|
130
131
|
* Why a queued item's skill can no longer be invoked, or null (also null for a plain message).
|
|
@@ -145,11 +146,12 @@ export declare const queueFull: () => ApiError;
|
|
|
145
146
|
* when the queue is empty. An item whose message is already in the log (a retried enqueue after it
|
|
146
147
|
* was sent) is dropped and the next one is taken. A head item whose skill can no longer be invoked
|
|
147
148
|
* stays queued and the queue pauses (`skill_not_invocable`): `{ paused }`. The caller notifies
|
|
148
|
-
* after commit.
|
|
149
|
+
* after commit (and publishes `archived` when the send unarchived the conversation).
|
|
149
150
|
*/
|
|
150
151
|
export declare function dispatchQueuedIn(t: KernelTrx, eventLog: Pick<EventLog, "appendIn">, conversationId: string): Promise<{
|
|
151
152
|
event: ConversationEvent;
|
|
152
153
|
switched: boolean;
|
|
154
|
+
unarchived: boolean;
|
|
153
155
|
} | {
|
|
154
156
|
paused: QueuePauseReason;
|
|
155
157
|
} | null>;
|
|
@@ -129,7 +129,18 @@ export async function appendQueuedIn(t, eventLog, conversationId, r) {
|
|
|
129
129
|
.where("id", "=", conversationId)
|
|
130
130
|
.execute();
|
|
131
131
|
}
|
|
132
|
-
|
|
132
|
+
// As a direct send: the message brings an archived conversation back into the default lists
|
|
133
|
+
const unarchived = await t
|
|
134
|
+
.updateTable("conversations")
|
|
135
|
+
.set({ archived_at: null })
|
|
136
|
+
.where("id", "=", conversationId)
|
|
137
|
+
.where("archived_at", "is not", null)
|
|
138
|
+
.executeTakeFirst();
|
|
139
|
+
return {
|
|
140
|
+
event: written.at(-1),
|
|
141
|
+
switched: next !== null,
|
|
142
|
+
unarchived: Number(unarchived.numUpdatedRows) > 0,
|
|
143
|
+
};
|
|
133
144
|
}
|
|
134
145
|
/** The model of the conversation agent's current version (inside `t`). */
|
|
135
146
|
async function agentModel(t, conversationId) {
|
|
@@ -206,7 +217,7 @@ export const queueFull = () => new ApiError("conversation.queue_full", `A conver
|
|
|
206
217
|
* when the queue is empty. An item whose message is already in the log (a retried enqueue after it
|
|
207
218
|
* was sent) is dropped and the next one is taken. A head item whose skill can no longer be invoked
|
|
208
219
|
* stays queued and the queue pauses (`skill_not_invocable`): `{ paused }`. The caller notifies
|
|
209
|
-
* after commit.
|
|
220
|
+
* after commit (and publishes `archived` when the send unarchived the conversation).
|
|
210
221
|
*/
|
|
211
222
|
export async function dispatchQueuedIn(t, eventLog, conversationId) {
|
|
212
223
|
for (;;) {
|
|
@@ -240,11 +240,13 @@ let ConversationQueue = class ConversationQueue {
|
|
|
240
240
|
*/
|
|
241
241
|
async sendNow(orgId, conversationId, accountId, itemId) {
|
|
242
242
|
await this.conversations.writable(orgId, conversationId, accountId);
|
|
243
|
-
const { event, fresh, switched } = await this.sendNowIn(conversationId, itemId);
|
|
243
|
+
const { event, fresh, switched, unarchived } = await this.sendNowIn(conversationId, itemId);
|
|
244
244
|
if (fresh)
|
|
245
245
|
await this.eventLog.notify(conversationId, event.seq);
|
|
246
246
|
if (switched)
|
|
247
247
|
await this.eventLog.publishChanged(conversationId, "selection");
|
|
248
|
+
if (unarchived)
|
|
249
|
+
await this.eventLog.publishChanged(conversationId, "archived");
|
|
248
250
|
await this.eventLog.publishChanged(conversationId, "queue");
|
|
249
251
|
await this.runs.ensureRun(conversationId);
|
|
250
252
|
return event;
|
|
@@ -33,6 +33,13 @@ export declare const TITLE_MAX_OUTPUT_TOKENS = 32;
|
|
|
33
33
|
export declare const TITLE_MAX_CHARS = 120;
|
|
34
34
|
/** Each side of the excerpt is cut to this many characters. */
|
|
35
35
|
export declare const TITLE_EXCERPT_CHARS = 1000;
|
|
36
|
+
/**
|
|
37
|
+
* Parameters of the title call where the target model declares them and the `title` purpose does
|
|
38
|
+
* not set them: no thinking, so the {@link TITLE_MAX_OUTPUT_TOKENS} budget goes to the title.
|
|
39
|
+
*/
|
|
40
|
+
export declare const TITLE_PARAM_DEFAULTS: {
|
|
41
|
+
readonly thinking: "off";
|
|
42
|
+
};
|
|
36
43
|
/** Time limit of one title call. */
|
|
37
44
|
export declare const TITLE_TIMEOUT_MS = 60000;
|
|
38
45
|
/** The system prompt of the title call (model-facing, English). */
|
|
@@ -51,6 +51,11 @@ export const TITLE_MAX_OUTPUT_TOKENS = 32;
|
|
|
51
51
|
export const TITLE_MAX_CHARS = 120;
|
|
52
52
|
/** Each side of the excerpt is cut to this many characters. */
|
|
53
53
|
export const TITLE_EXCERPT_CHARS = 1000;
|
|
54
|
+
/**
|
|
55
|
+
* Parameters of the title call where the target model declares them and the `title` purpose does
|
|
56
|
+
* not set them: no thinking, so the {@link TITLE_MAX_OUTPUT_TOKENS} budget goes to the title.
|
|
57
|
+
*/
|
|
58
|
+
export const TITLE_PARAM_DEFAULTS = { thinking: "off" };
|
|
54
59
|
/** Time limit of one title call. */
|
|
55
60
|
export const TITLE_TIMEOUT_MS = 60_000;
|
|
56
61
|
/** How far into the log the excerpt is looked for (events). */
|
|
@@ -204,6 +209,8 @@ export async function runTitleJob(d, conversationId, attempt) {
|
|
|
204
209
|
maxOutputTokens: TITLE_MAX_OUTPUT_TOKENS,
|
|
205
210
|
}, signal, {
|
|
206
211
|
...(fallback && { fallback: { model: fallback, params: {} } }),
|
|
212
|
+
// a thinking model spends the small output budget on thinking and returns no text
|
|
213
|
+
paramDefaults: TITLE_PARAM_DEFAULTS,
|
|
207
214
|
beforeSend: async (target, request) => {
|
|
208
215
|
await checkTitleHooks(d, scope, target, request, signal);
|
|
209
216
|
sent = { ...target, at: Date.now() };
|
|
@@ -246,6 +253,14 @@ export async function runTitleJob(d, conversationId, attempt) {
|
|
|
246
253
|
if (sent && d.hooks)
|
|
247
254
|
observeTitle(d, scope, sent, out, null, signal);
|
|
248
255
|
const title = cleanTitle(textOf(out.content));
|
|
256
|
+
if (title === null) {
|
|
257
|
+
d.log.warn("conversation title call returned no title", {
|
|
258
|
+
conversationId,
|
|
259
|
+
attempt,
|
|
260
|
+
stopReason: out.stopReason,
|
|
261
|
+
outputTokens: out.usage.outputTokens,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
249
264
|
const { written, usage } = await d.writes.writeResult(conversationId, attempt, out, title);
|
|
250
265
|
if (usage) {
|
|
251
266
|
await d.eventLog.notify(conversationId, usage.seq);
|