@capybara-hq/kernel 0.1.0-rc.12 → 0.1.0-rc.14
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.schemas.d.ts +13 -0
- package/dist/agents/agent-lookup.d.ts +5 -0
- package/dist/agents/agent-lookup.js +15 -0
- package/dist/background/background.module.js +2 -2
- package/dist/background/launch-lock.d.ts +1 -1
- package/dist/background/launch-lock.js +1 -1
- package/dist/background/poll.job.d.ts +2 -2
- package/dist/background/poll.job.js +10 -10
- package/dist/background/stop.d.ts +1 -1
- package/dist/background/stop.js +3 -3
- package/dist/background/store.d.ts +5 -5
- package/dist/background/store.js +5 -5
- package/dist/background/tasks.service.d.ts +6 -6
- package/dist/background/tasks.service.js +13 -13
- package/dist/catalog/admin-catalog.controller.d.ts +13 -2
- package/dist/catalog/admin-catalog.controller.js +24 -3
- package/dist/catalog/admin-catalog.schemas.d.ts +10 -0
- package/dist/catalog/admin-catalog.schemas.js +7 -0
- package/dist/catalog/catalog-content.d.ts +9 -1
- package/dist/catalog/catalog-content.js +2 -1
- package/dist/catalog/catalog-files.d.ts +3 -2
- package/dist/catalog/catalog-files.js +8 -5
- package/dist/catalog/component-scope.service.d.ts +14 -1
- package/dist/catalog/component-scope.service.js +12 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.controller.d.ts +5 -4
- package/dist/catalog/org-catalog.controller.js +5 -4
- package/dist/catalog/org-catalog.schemas.d.ts +18 -2
- package/dist/catalog/org-catalog.schemas.js +16 -2
- package/dist/catalog/org-catalog.service.js +8 -2
- package/dist/catalog/plugin-import.js +1 -1
- package/dist/catalog/plugin-package.js +37 -9
- package/dist/catalog/plugin-upgrade.d.ts +15 -1
- package/dist/catalog/plugin-upgrade.js +18 -5
- package/dist/channels/channels.module.js +2 -2
- package/dist/channels/connections.controller.d.ts +1 -1
- package/dist/channels/connections.controller.js +1 -1
- package/dist/channels/connections.service.d.ts +22 -5
- package/dist/channels/connections.service.js +56 -10
- package/dist/channels/inbound.d.ts +8 -8
- package/dist/channels/inbound.js +31 -31
- package/dist/channels/phrases.d.ts +27 -27
- package/dist/channels/phrases.js +27 -27
- package/dist/channels/webhook.d.ts +21 -1
- package/dist/channels/webhook.js +39 -4
- package/dist/config/docs.js +1 -1
- package/dist/config/schema.d.ts +2 -2
- package/dist/config/schema.js +21 -21
- package/dist/conversations/conversations.controller.d.ts +11 -11
- package/dist/conversations/conversations.controller.js +15 -15
- package/dist/conversations/conversations.module.d.ts +1 -1
- package/dist/conversations/conversations.module.js +7 -7
- package/dist/conversations/conversations.schemas.js +1 -1
- package/dist/conversations/conversations.service.d.ts +14 -14
- package/dist/conversations/conversations.service.js +19 -19
- package/dist/conversations/{environment-status.d.ts → device-status.d.ts} +9 -9
- package/dist/conversations/{environment-status.js → device-status.js} +18 -18
- package/dist/conversations/event-log.d.ts +1 -1
- package/dist/conversations/event-log.js +1 -1
- package/dist/conversations/events.d.ts +1 -1
- package/dist/conversations/events.js +2 -2
- package/dist/ctx/create-ctx.d.ts +26 -3
- package/dist/ctx/create-ctx.js +134 -26
- package/dist/db/kernel-schema.d.ts +37 -25
- package/dist/{environments → devices}/access.d.ts +19 -19
- package/dist/{environments → devices}/access.js +28 -28
- package/dist/devices/conversation-devices.d.ts +75 -0
- package/dist/{environments/conversation-environments.js → devices/conversation-devices.js} +71 -72
- package/dist/devices/devices.controller.d.ts +36 -0
- package/dist/{environments/environments.controller.js → devices/devices.controller.js} +37 -37
- package/dist/devices/devices.module.d.ts +5 -13
- package/dist/devices/devices.module.js +16 -29
- package/dist/devices/devices.schemas.d.ts +3 -0
- package/dist/devices/devices.schemas.js +14 -0
- package/dist/{environments/environments.service.d.ts → devices/devices.service.d.ts} +70 -70
- package/dist/{environments/environments.service.js → devices/devices.service.js} +122 -122
- package/dist/devices/dto.d.ts +13 -54
- package/dist/devices/dto.js +7 -39
- package/dist/devices/label.d.ts +11 -0
- package/dist/{environments → devices}/label.js +7 -7
- package/dist/{environments → devices}/legacy-cleanup.job.d.ts +3 -3
- package/dist/{environments → devices}/legacy-cleanup.job.js +3 -3
- package/dist/errors.d.ts +29 -25
- package/dist/errors.js +29 -25
- package/dist/evals/recorded-tools.d.ts +2 -2
- package/dist/evals/recorded-tools.js +6 -6
- package/dist/extensions/admin-ops.js +1 -0
- package/dist/extensions/admin-view.js +2 -0
- package/dist/extensions/effective-config.d.ts +6 -0
- package/dist/extensions/effective-config.js +18 -7
- package/dist/extensions/guide-places.d.ts +66 -0
- package/dist/extensions/guide-places.js +152 -0
- package/dist/extensions/host.d.ts +13 -2
- package/dist/extensions/host.js +27 -6
- package/dist/extensions/instance.d.ts +17 -2
- package/dist/extensions/instance.js +21 -0
- package/dist/extensions/ledger.d.ts +1 -1
- package/dist/extensions/permission-set.d.ts +16 -2
- package/dist/extensions/permission-set.js +17 -3
- package/dist/extensions/permission-view.d.ts +10 -1
- package/dist/extensions/plugin-guides.d.ts +207 -54
- package/dist/extensions/plugin-guides.js +436 -165
- package/dist/files/previewers.d.ts +1 -1
- package/dist/files/previewers.js +1 -1
- package/dist/http/api.module.js +16 -6
- package/dist/http/gateway-routes.d.ts +1 -1
- package/dist/http/gateway-routes.js +1 -1
- package/dist/identity/settings.d.ts +32 -0
- package/dist/identity/settings.js +26 -2
- package/dist/infra/config/kernel-config.service.js +4 -4
- package/dist/infra/lock/lock.service.d.ts +8 -0
- package/dist/infra/lock/lock.service.js +27 -0
- package/dist/infra/throttler/named-throttlers.d.ts +4 -1
- package/dist/infra/throttler/named-throttlers.js +16 -1
- package/dist/infra/throttler/throttler.guard.js +1 -1
- package/dist/kernel.module.js +3 -3
- package/dist/{devices → local-devices}/device-auth.controller.d.ts +6 -6
- package/dist/{devices → local-devices}/device-auth.controller.js +5 -5
- package/dist/{devices → local-devices}/device-auth.d.ts +20 -20
- package/dist/{devices → local-devices}/device-auth.js +51 -53
- package/dist/local-devices/device-auth.module.d.ts +7 -0
- package/dist/{devices → local-devices}/device-auth.module.js +5 -5
- package/dist/{devices → local-devices}/device-routes.d.ts +3 -3
- package/dist/{devices → local-devices}/device-routes.js +2 -2
- package/dist/local-devices/dto.d.ts +66 -0
- package/dist/local-devices/dto.js +44 -0
- package/dist/{devices → local-devices}/keys.d.ts +11 -11
- package/dist/{devices → local-devices}/keys.js +11 -11
- package/dist/{devices/device-gateway.d.ts → local-devices/local-device-gateway.d.ts} +14 -14
- package/dist/{devices/device-gateway.js → local-devices/local-device-gateway.js} +44 -44
- package/dist/{devices/device-provider.d.ts → local-devices/local-device-provider.d.ts} +15 -15
- package/dist/{devices/device-provider.js → local-devices/local-device-provider.js} +23 -23
- package/dist/local-devices/local-devices.module.d.ts +16 -0
- package/dist/local-devices/local-devices.module.js +44 -0
- package/dist/{devices → local-devices}/machines.d.ts +26 -26
- package/dist/{devices → local-devices}/machines.js +71 -71
- package/dist/{devices → local-devices}/relay.d.ts +15 -15
- package/dist/{devices → local-devices}/relay.js +55 -55
- package/dist/{devices → local-devices}/targets.d.ts +8 -8
- package/dist/{devices → local-devices}/targets.js +14 -14
- package/dist/orgs/offboarding.d.ts +6 -6
- package/dist/orgs/offboarding.js +12 -12
- package/dist/orgs/settings.service.d.ts +28 -0
- package/dist/orgs/settings.service.js +20 -1
- package/dist/overrides.d.ts +3 -1
- package/dist/overrides.js +2 -0
- package/dist/platform/exclusions.js +48 -8
- package/dist/platform/operation.js +10 -2
- package/dist/platform/ops/admin.ops.js +8 -2
- package/dist/platform/ops/connectors.ops.js +2 -0
- package/dist/platform/ops/conversations.ops.d.ts +3 -3
- package/dist/platform/ops/conversations.ops.js +9 -9
- package/dist/platform/ops/devices.ops.d.ts +26 -0
- package/dist/platform/ops/devices.ops.js +311 -0
- package/dist/platform/ops/org-settings.ops.js +2 -2
- package/dist/platform/ops/orgs.ops.js +1 -0
- package/dist/platform/ops/setup.ops.d.ts +24 -0
- package/dist/platform/ops/setup.ops.js +212 -0
- package/dist/platform/ops/ui.ops.d.ts +8 -0
- package/dist/platform/ops/ui.ops.js +41 -0
- package/dist/platform/platform-ops.module.d.ts +4 -2
- package/dist/platform/platform-ops.module.js +13 -5
- package/dist/platform/route-schemas.js +11 -3
- package/dist/roles/gateway-role.d.ts +3 -3
- package/dist/roles/gateway-role.js +4 -4
- package/dist/roles/gateway.module.d.ts +1 -1
- package/dist/roles/gateway.module.js +5 -5
- package/dist/roles/worker.module.js +1 -1
- package/dist/runtime/context/build.d.ts +1 -1
- package/dist/runtime/context/build.js +6 -6
- package/dist/runtime/context/compaction.js +1 -1
- package/dist/runtime/context/{environment-paths.d.ts → device-paths.d.ts} +11 -11
- package/dist/runtime/context/{environment-paths.js → device-paths.js} +13 -13
- package/dist/runtime/maintenance.d.ts +1 -1
- package/dist/sandbox/jobs.d.ts +13 -13
- package/dist/sandbox/jobs.js +20 -20
- package/dist/sandbox/leases.d.ts +9 -9
- package/dist/sandbox/leases.js +14 -14
- package/dist/sandbox/providers.d.ts +8 -8
- package/dist/sandbox/providers.js +8 -8
- package/dist/sandbox/sandbox.module.d.ts +1 -1
- package/dist/sandbox/sandbox.module.js +1 -1
- package/dist/sandbox/sandbox.service.d.ts +76 -76
- package/dist/sandbox/sandbox.service.js +230 -230
- package/dist/setup/kernel-checks.d.ts +91 -0
- package/dist/setup/kernel-checks.js +295 -0
- package/dist/setup/oauth-token-probe.d.ts +47 -0
- package/dist/setup/oauth-token-probe.js +108 -0
- package/dist/setup/redact-check.d.ts +18 -0
- package/dist/setup/redact-check.js +46 -0
- package/dist/setup/setup-check-registry.d.ts +86 -0
- package/dist/setup/setup-check-registry.js +75 -0
- package/dist/setup/setup-checks.controller.d.ts +28 -0
- package/dist/setup/setup-checks.controller.js +78 -0
- package/dist/setup/setup-checks.schemas.d.ts +38 -0
- package/dist/setup/setup-checks.schemas.js +43 -0
- package/dist/setup/setup-checks.service.d.ts +144 -0
- package/dist/setup/setup-checks.service.js +683 -0
- package/dist/setup/setup-guides.controller.d.ts +18 -0
- package/dist/setup/setup-guides.controller.js +48 -0
- package/dist/setup/setup-guides.schemas.d.ts +10 -0
- package/dist/setup/setup-guides.schemas.js +6 -0
- package/dist/setup/setup-guides.service.d.ts +126 -0
- package/dist/setup/setup-guides.service.js +315 -0
- package/dist/setup/setup.module.d.ts +8 -0
- package/dist/setup/setup.module.js +31 -0
- package/dist/tools/builtins/builtin-tools.d.ts +2 -2
- package/dist/tools/builtins/builtin-tools.js +5 -5
- package/dist/tools/builtins/platform.js +1 -1
- package/dist/tools/builtins/sandbox/bash.js +6 -6
- package/dist/tools/builtins/sandbox/common.d.ts +25 -25
- package/dist/tools/builtins/sandbox/common.js +51 -51
- package/dist/tools/builtins/sandbox/edit.js +2 -2
- package/dist/tools/builtins/sandbox/index.d.ts +1 -1
- package/dist/tools/builtins/sandbox/index.js +1 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +6 -6
- package/dist/tools/builtins/sandbox/task-output.js +10 -10
- package/dist/tools/builtins/sandbox/task-stop.js +2 -2
- package/dist/tools/builtins/sandbox/write.js +2 -2
- package/dist/tools/builtins/skill-load.d.ts +1 -1
- package/dist/tools/builtins/skill-load.js +2 -2
- package/dist/tools/connectors.controller.d.ts +28 -11
- package/dist/tools/connectors.controller.js +49 -14
- package/dist/tools/connectors.schemas.d.ts +4 -0
- package/dist/tools/connectors.schemas.js +4 -0
- package/dist/tools/connectors.service.d.ts +30 -2
- package/dist/tools/connectors.service.js +98 -3
- package/dist/tools/credentials.d.ts +20 -0
- package/dist/tools/credentials.js +90 -1
- package/dist/tools/oauth/tokens.d.ts +20 -0
- package/dist/tools/oauth/tokens.js +49 -24
- package/dist/tools/pipeline.js +4 -3
- package/dist/tools/registry.d.ts +2 -2
- package/dist/tools/tools.module.js +3 -3
- package/dist/ui/admin-ui.controller.d.ts +56 -0
- package/dist/ui/admin-ui.controller.js +192 -0
- package/dist/ui/arrangement.d.ts +74 -0
- package/dist/ui/arrangement.js +98 -0
- package/dist/ui/embed-token.d.ts +2 -2
- package/dist/ui/embed-token.js +30 -5
- package/dist/ui/registry.d.ts +29 -14
- package/dist/ui/registry.js +31 -10
- package/dist/ui/slots.controller.d.ts +11 -0
- package/dist/ui/slots.controller.js +25 -0
- package/dist/ui/ui-stream.d.ts +20 -3
- package/dist/ui/ui-stream.js +25 -7
- package/dist/ui/ui.schemas.d.ts +66 -0
- package/dist/ui/ui.schemas.js +65 -0
- package/dist/ui/views.controller.d.ts +35 -49
- package/dist/ui/views.controller.js +48 -70
- package/dist/ui/views.d.ts +84 -18
- package/dist/ui/views.js +201 -38
- package/package.json +3 -3
- package/src/migrations/0105_devices_rename.sql +136 -0
- package/src/migrations/0106_setup_guides_v2.sql +10 -0
- package/dist/devices/device-auth.module.d.ts +0 -7
- package/dist/environments/conversation-environments.d.ts +0 -75
- package/dist/environments/dto.d.ts +0 -25
- package/dist/environments/dto.js +0 -12
- package/dist/environments/environments.controller.d.ts +0 -36
- package/dist/environments/environments.module.d.ts +0 -8
- package/dist/environments/environments.module.js +0 -31
- package/dist/environments/environments.schemas.d.ts +0 -3
- package/dist/environments/environments.schemas.js +0 -14
- package/dist/environments/label.d.ts +0 -11
- package/dist/platform/ops/environments.ops.d.ts +0 -26
- package/dist/platform/ops/environments.ops.js +0 -311
package/dist/config/schema.js
CHANGED
|
@@ -1037,14 +1037,14 @@ export const KernelConfigSchema = z.object({
|
|
|
1037
1037
|
.min(1)
|
|
1038
1038
|
.optional()
|
|
1039
1039
|
.meta(meta({
|
|
1040
|
-
description: "Image for
|
|
1040
|
+
description: "Image for cloud device instances, passed to the sandbox extension; unset (the default), each extension uses the image published with its own version (ghcr.io/capybara-hq/capybara-sandbox). Set it to a locally built or mirrored image for offline deployments; an extension that builds instances from its own template may ignore it",
|
|
1041
1041
|
})),
|
|
1042
1042
|
lockWaitSeconds: z
|
|
1043
1043
|
.number()
|
|
1044
1044
|
.positive()
|
|
1045
1045
|
.default(75)
|
|
1046
1046
|
.meta(meta({
|
|
1047
|
-
description: "Seconds a sandbox call waits for the
|
|
1047
|
+
description: "Seconds a sandbox call waits for the device's instance (while it is being created, resumed or suspended, or all its concurrent command slots are taken) before failing with sandbox.busy; keep it above the 60-second sandbox lock TTL so a call after a replica crash waits for the dead replica's lock to expire",
|
|
1048
1048
|
})),
|
|
1049
1049
|
maxConcurrentCommands: z
|
|
1050
1050
|
.number()
|
|
@@ -1054,7 +1054,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1054
1054
|
.default(6)
|
|
1055
1055
|
.meta(meta({
|
|
1056
1056
|
hot: true,
|
|
1057
|
-
description: "Sandbox commands and file operations that may run at the same time in one
|
|
1057
|
+
description: "Sandbox commands and file operations that may run at the same time in one device, shared by all its conversations and their sub-agents; 1 runs them one at a time",
|
|
1058
1058
|
})),
|
|
1059
1059
|
deliverMaxBytes: z
|
|
1060
1060
|
.number()
|
|
@@ -1073,7 +1073,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1073
1073
|
.max(100)
|
|
1074
1074
|
.default(4)
|
|
1075
1075
|
.meta(meta({
|
|
1076
|
-
description: "Most background Bash tasks (run_in_background) that may run at once in one conversation, its sub-agents included (counted per root conversation, not per
|
|
1076
|
+
description: "Most background Bash tasks (run_in_background) that may run at once in one conversation, its sub-agents included (counted per root conversation, not per device); a launch beyond it is refused",
|
|
1077
1077
|
})),
|
|
1078
1078
|
maxSeconds: z
|
|
1079
1079
|
.number()
|
|
@@ -1089,7 +1089,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1089
1089
|
.min(1)
|
|
1090
1090
|
.default(10)
|
|
1091
1091
|
.meta(meta({
|
|
1092
|
-
description: "How often the worker checks the running background Bash tasks of every
|
|
1092
|
+
description: "How often the worker checks the running background Bash tasks of every device for a finish, in seconds; read when the worker starts",
|
|
1093
1093
|
})),
|
|
1094
1094
|
})
|
|
1095
1095
|
.prefault({}),
|
|
@@ -1100,7 +1100,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1100
1100
|
.positive()
|
|
1101
1101
|
.default(1)
|
|
1102
1102
|
.meta(meta({
|
|
1103
|
-
description: "CPU cores for each
|
|
1103
|
+
description: "CPU cores for each cloud device instance; applies to instances created after the change (an extension that sizes instances by its own template, such as E2B, may not apply it)",
|
|
1104
1104
|
})),
|
|
1105
1105
|
memoryMb: z
|
|
1106
1106
|
.number()
|
|
@@ -1108,7 +1108,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1108
1108
|
.positive()
|
|
1109
1109
|
.default(2048)
|
|
1110
1110
|
.meta(meta({
|
|
1111
|
-
description: "Memory limit of each
|
|
1111
|
+
description: "Memory limit of each cloud device instance in MiB; applies to instances created after the change (an extension that sizes instances by its own template, such as E2B, may not apply it)",
|
|
1112
1112
|
})),
|
|
1113
1113
|
diskMb: z
|
|
1114
1114
|
.number()
|
|
@@ -1116,7 +1116,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1116
1116
|
.positive()
|
|
1117
1117
|
.default(5120)
|
|
1118
1118
|
.meta(meta({
|
|
1119
|
-
description: "Disk limit of each
|
|
1119
|
+
description: "Disk limit of each cloud device's file system in MiB; applies to file systems created after the change (Docker: only with a volume driver that supports size; an extension whose storage cannot be sized may not apply it)",
|
|
1120
1120
|
})),
|
|
1121
1121
|
maxCommandSeconds: z
|
|
1122
1122
|
.number()
|
|
@@ -1132,7 +1132,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1132
1132
|
.positive()
|
|
1133
1133
|
.default(10)
|
|
1134
1134
|
.meta(meta({
|
|
1135
|
-
description: "Minutes without a command from any conversation of the
|
|
1135
|
+
description: "Minutes without a command from any conversation of the device before its running instance is suspended (files are kept, processes end)",
|
|
1136
1136
|
})),
|
|
1137
1137
|
destroyAfterInactiveDays: z
|
|
1138
1138
|
.number()
|
|
@@ -1140,7 +1140,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1140
1140
|
.positive()
|
|
1141
1141
|
.default(7)
|
|
1142
1142
|
.meta(meta({
|
|
1143
|
-
description: "Days without use before
|
|
1143
|
+
description: "Days without use before a device's instance is destroyed; its files are kept until the device is deleted, and the next use starts a new instance on them",
|
|
1144
1144
|
})),
|
|
1145
1145
|
maxRunningMinutes: z
|
|
1146
1146
|
.number()
|
|
@@ -1148,13 +1148,13 @@ export const KernelConfigSchema = z.object({
|
|
|
1148
1148
|
.positive()
|
|
1149
1149
|
.default(120)
|
|
1150
1150
|
.meta(meta({
|
|
1151
|
-
description: "Minutes
|
|
1151
|
+
description: "Minutes a device's instance may run continuously before it is suspended even while in use (skipped while a command is running)",
|
|
1152
1152
|
})),
|
|
1153
1153
|
egress: z
|
|
1154
1154
|
.enum(["none", "allowlist", "open"])
|
|
1155
1155
|
.default("allowlist")
|
|
1156
1156
|
.meta(meta({
|
|
1157
|
-
description: "Outbound network from
|
|
1157
|
+
description: "Outbound network from cloud device instances: none, allowlist (only allowHosts) or open; applies to instances created after the change, existing ones keep theirs until destroyed",
|
|
1158
1158
|
})),
|
|
1159
1159
|
allowHosts: z
|
|
1160
1160
|
.array(z.string())
|
|
@@ -1167,13 +1167,13 @@ export const KernelConfigSchema = z.object({
|
|
|
1167
1167
|
});
|
|
1168
1168
|
})
|
|
1169
1169
|
.meta(meta({
|
|
1170
|
-
description: "Hosts
|
|
1170
|
+
description: "Hosts cloud device instances may reach when egress is allowlist: lowercase hostnames, optional leading '*.', no IPs, ports or internal-only names; applies to instances created after the change",
|
|
1171
1171
|
})),
|
|
1172
1172
|
})
|
|
1173
1173
|
.prefault({}),
|
|
1174
1174
|
})
|
|
1175
1175
|
.prefault({}),
|
|
1176
|
-
|
|
1176
|
+
devices: z
|
|
1177
1177
|
.object({
|
|
1178
1178
|
maxPersonal: z
|
|
1179
1179
|
.number()
|
|
@@ -1182,9 +1182,9 @@ export const KernelConfigSchema = z.object({
|
|
|
1182
1182
|
.default(10)
|
|
1183
1183
|
.meta(meta({
|
|
1184
1184
|
hot: true,
|
|
1185
|
-
description: "Most personal
|
|
1185
|
+
description: "Most personal devices a member may have in one org, the default one and local devices included; creating one more fails with device.limit_reached",
|
|
1186
1186
|
})),
|
|
1187
|
-
|
|
1187
|
+
local: z
|
|
1188
1188
|
.object({
|
|
1189
1189
|
reconnectGraceSeconds: z
|
|
1190
1190
|
.number()
|
|
@@ -1193,7 +1193,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1193
1193
|
.default(120)
|
|
1194
1194
|
.meta(meta({
|
|
1195
1195
|
hot: true,
|
|
1196
|
-
description: "Seconds a
|
|
1196
|
+
description: "Seconds a local device's machine may stay disconnected before the device is reported offline; also sent to capybara-device at sign-in",
|
|
1197
1197
|
})),
|
|
1198
1198
|
leaseTtlMs: z
|
|
1199
1199
|
.number()
|
|
@@ -1201,7 +1201,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1201
1201
|
.min(6000)
|
|
1202
1202
|
.default(30000)
|
|
1203
1203
|
.meta(meta({
|
|
1204
|
-
description: "Milliseconds the replica holding a
|
|
1204
|
+
description: "Milliseconds the replica holding a local device's connection keeps its lease without renewing it; at least 6000",
|
|
1205
1205
|
})),
|
|
1206
1206
|
authCodeTtlSeconds: z
|
|
1207
1207
|
.number()
|
|
@@ -1209,7 +1209,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1209
1209
|
.positive()
|
|
1210
1210
|
.default(600)
|
|
1211
1211
|
.meta(meta({
|
|
1212
|
-
description: "Seconds a device sign-in code stays valid before
|
|
1212
|
+
description: "Seconds a device sign-in code stays valid before capybara-device must start over (device_sign_in.expired)",
|
|
1213
1213
|
})),
|
|
1214
1214
|
pollIntervalSeconds: z
|
|
1215
1215
|
.number()
|
|
@@ -1217,7 +1217,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1217
1217
|
.positive()
|
|
1218
1218
|
.default(5)
|
|
1219
1219
|
.meta(meta({
|
|
1220
|
-
description: "Seconds
|
|
1220
|
+
description: "Seconds capybara-device waits between token polls during sign-in; polling faster gets device_sign_in.slow_down",
|
|
1221
1221
|
})),
|
|
1222
1222
|
maxFrameBytes: z
|
|
1223
1223
|
.number()
|
|
@@ -1225,7 +1225,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1225
1225
|
.positive()
|
|
1226
1226
|
.default(16 * 1024 * 1024)
|
|
1227
1227
|
.meta(meta({
|
|
1228
|
-
description: "Largest WebSocket frame in bytes accepted from or sent to a
|
|
1228
|
+
description: "Largest WebSocket frame in bytes accepted from or sent to a local device's machine",
|
|
1229
1229
|
})),
|
|
1230
1230
|
})
|
|
1231
1231
|
.prefault({}),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FastifyReply } from "fastify";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import type {
|
|
3
|
+
import type { DeviceView } from "../devices/devices.service.js";
|
|
4
4
|
import { type Principal } from "../identity/principal.js";
|
|
5
5
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
6
6
|
import { ConversationToolInfo, type ToolInfo } from "../tools/info.js";
|
|
@@ -8,7 +8,7 @@ import type { AgentTreeNode } from "./agent-tree.js";
|
|
|
8
8
|
import { type ArtifactPreview, ConversationArtifacts } from "./artifacts.js";
|
|
9
9
|
import { EventsQuery, FilesQuery, IdParams, ListQuery, PatchBody, SubagentsQuery } from "./conversations.schemas.js";
|
|
10
10
|
import { type ConversationGroup, ConversationsService, type ConversationView, type SubagentView, type UsageTotals } from "./conversations.service.js";
|
|
11
|
-
import {
|
|
11
|
+
import { ConversationDeviceStatus } from "./device-status.js";
|
|
12
12
|
import type { ConversationEvent } from "./events.js";
|
|
13
13
|
import { ConversationFiles, type FileOutput } from "./files.js";
|
|
14
14
|
import { ConversationOutputs, type OutputPage } from "./outputs-read.js";
|
|
@@ -78,12 +78,12 @@ declare const MessageBody: z.ZodObject<{
|
|
|
78
78
|
* `POST /conversations`: `message` creates the conversation with its first message (create on
|
|
79
79
|
* first send; `clientMessageId` is required and makes a retry return the same conversation).
|
|
80
80
|
* Without it the conversation is created empty (API clients; the web never does).
|
|
81
|
-
* `
|
|
82
|
-
*
|
|
81
|
+
* `deviceId` binds it to one of the caller's devices; without it the caller's default
|
|
82
|
+
* device (environments spec §4.1 item 1).
|
|
83
83
|
*/
|
|
84
84
|
declare const CreateBody: z.ZodObject<{
|
|
85
85
|
agentId: z.ZodString;
|
|
86
|
-
|
|
86
|
+
deviceId: z.ZodOptional<z.ZodString>;
|
|
87
87
|
message: z.ZodOptional<z.ZodObject<{
|
|
88
88
|
text: z.ZodString;
|
|
89
89
|
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -156,11 +156,11 @@ export declare class ConversationsController {
|
|
|
156
156
|
private readonly conversations;
|
|
157
157
|
private readonly outputs;
|
|
158
158
|
private readonly artifacts;
|
|
159
|
-
private readonly
|
|
159
|
+
private readonly deviceStatus;
|
|
160
160
|
private readonly toolInfo;
|
|
161
161
|
private readonly queue;
|
|
162
162
|
private readonly files;
|
|
163
|
-
constructor(conversations: ConversationsService, outputs: ConversationOutputs, artifacts: ConversationArtifacts,
|
|
163
|
+
constructor(conversations: ConversationsService, outputs: ConversationOutputs, artifacts: ConversationArtifacts, deviceStatus: ConversationDeviceStatus, toolInfo: ConversationToolInfo, queue: ConversationQueue, files: ConversationFiles);
|
|
164
164
|
/**
|
|
165
165
|
* 201 when created; 200 when `message.clientMessageId` repeats an earlier first send. With a
|
|
166
166
|
* message the answer has `event` (the `user_message`) and `events`: every event the first send
|
|
@@ -266,12 +266,12 @@ export declare class ConversationsController {
|
|
|
266
266
|
*/
|
|
267
267
|
fileContent(principal: Principal, org: OrgContext, id: string, fileId: string, q: z.infer<typeof FileContentQuery>, reply: FastifyReply): Promise<void>;
|
|
268
268
|
/**
|
|
269
|
-
* The
|
|
270
|
-
* with its instance state; `null` while unbound, or when the
|
|
269
|
+
* The device the conversation works in (a sub-agent: its root's), as its owner sees it,
|
|
270
|
+
* with its instance state; `null` while unbound, or when the device was deleted. Same
|
|
271
271
|
* visibility as the event stream.
|
|
272
272
|
*/
|
|
273
|
-
|
|
274
|
-
|
|
273
|
+
device(principal: Principal, org: OrgContext, id: string): Promise<{
|
|
274
|
+
device: DeviceView | null;
|
|
275
275
|
}>;
|
|
276
276
|
/**
|
|
277
277
|
* Display metadata (title, kind, key arguments, source) of the tools a conversation's calls name,
|
|
@@ -19,7 +19,7 @@ import { ConversationToolInfo, TOOL_INFO_KEY_MAX, TOOL_INFO_MAX_KEYS, } from "..
|
|
|
19
19
|
import { ARTIFACT_DOWNLOAD_CACHE_SECONDS, ConversationArtifacts, } from "./artifacts.js";
|
|
20
20
|
import { EventsQuery, FilesQuery, IdParams, ListQuery, PatchBody, SubagentsQuery, searchFields, } from "./conversations.schemas.js";
|
|
21
21
|
import { ConversationsService, } from "./conversations.service.js";
|
|
22
|
-
import {
|
|
22
|
+
import { ConversationDeviceStatus } from "./device-status.js";
|
|
23
23
|
import { ConversationFiles, FILE_CONTENT_MAX_BYTES } from "./files.js";
|
|
24
24
|
import { ConversationOutputs, OUTPUT_PAGE_MAX_CHARS } from "./outputs-read.js";
|
|
25
25
|
import { ConversationQueue } from "./queue.service.js";
|
|
@@ -106,13 +106,13 @@ const MessageBody = MessageFields.strict().refine(...textRule);
|
|
|
106
106
|
* `POST /conversations`: `message` creates the conversation with its first message (create on
|
|
107
107
|
* first send; `clientMessageId` is required and makes a retry return the same conversation).
|
|
108
108
|
* Without it the conversation is created empty (API clients; the web never does).
|
|
109
|
-
* `
|
|
110
|
-
*
|
|
109
|
+
* `deviceId` binds it to one of the caller's devices; without it the caller's default
|
|
110
|
+
* device (environments spec §4.1 item 1).
|
|
111
111
|
*/
|
|
112
112
|
const CreateBody = z
|
|
113
113
|
.object({
|
|
114
114
|
agentId: z.string().min(1).max(100),
|
|
115
|
-
|
|
115
|
+
deviceId: z.string().min(1).max(100).optional(),
|
|
116
116
|
message: MessageFields.omit({ retryOf: true })
|
|
117
117
|
.extend({ clientMessageId: z.string().min(1).max(200) })
|
|
118
118
|
.strict()
|
|
@@ -167,15 +167,15 @@ let ConversationsController = class ConversationsController {
|
|
|
167
167
|
conversations;
|
|
168
168
|
outputs;
|
|
169
169
|
artifacts;
|
|
170
|
-
|
|
170
|
+
deviceStatus;
|
|
171
171
|
toolInfo;
|
|
172
172
|
queue;
|
|
173
173
|
files;
|
|
174
|
-
constructor(conversations, outputs, artifacts,
|
|
174
|
+
constructor(conversations, outputs, artifacts, deviceStatus, toolInfo, queue, files) {
|
|
175
175
|
this.conversations = conversations;
|
|
176
176
|
this.outputs = outputs;
|
|
177
177
|
this.artifacts = artifacts;
|
|
178
|
-
this.
|
|
178
|
+
this.deviceStatus = deviceStatus;
|
|
179
179
|
this.toolInfo = toolInfo;
|
|
180
180
|
this.queue = queue;
|
|
181
181
|
this.files = files;
|
|
@@ -187,7 +187,7 @@ let ConversationsController = class ConversationsController {
|
|
|
187
187
|
*/
|
|
188
188
|
async create(principal, org, body, reply) {
|
|
189
189
|
const p = requireUser(principal);
|
|
190
|
-
const pick = body.
|
|
190
|
+
const pick = body.deviceId === undefined ? {} : { deviceId: body.deviceId };
|
|
191
191
|
if (body.message === undefined) {
|
|
192
192
|
return {
|
|
193
193
|
conversation: await this.conversations.create(org.orgId, p.account.id, body.agentId, pick),
|
|
@@ -371,13 +371,13 @@ let ConversationsController = class ConversationsController {
|
|
|
371
371
|
await reply.send(c.body);
|
|
372
372
|
}
|
|
373
373
|
/**
|
|
374
|
-
* The
|
|
375
|
-
* with its instance state; `null` while unbound, or when the
|
|
374
|
+
* The device the conversation works in (a sub-agent: its root's), as its owner sees it,
|
|
375
|
+
* with its instance state; `null` while unbound, or when the device was deleted. Same
|
|
376
376
|
* visibility as the event stream.
|
|
377
377
|
*/
|
|
378
|
-
async
|
|
378
|
+
async device(principal, org, id) {
|
|
379
379
|
const p = requireUser(principal);
|
|
380
|
-
return {
|
|
380
|
+
return { device: await this.deviceStatus.get(org.orgId, id, p.account.id) };
|
|
381
381
|
}
|
|
382
382
|
/**
|
|
383
383
|
* Display metadata (title, kind, key arguments, source) of the tools a conversation's calls name,
|
|
@@ -590,13 +590,13 @@ __decorate([
|
|
|
590
590
|
__param(5, Res())
|
|
591
591
|
], ConversationsController.prototype, "fileContent", null);
|
|
592
592
|
__decorate([
|
|
593
|
-
Get(":id/
|
|
593
|
+
Get(":id/device"),
|
|
594
594
|
Header("cache-control", "private, no-store"),
|
|
595
595
|
OrgAction("agents.use"),
|
|
596
596
|
__param(0, CurrentPrincipal()),
|
|
597
597
|
__param(1, CurrentOrg()),
|
|
598
598
|
__param(2, Param("id"))
|
|
599
|
-
], ConversationsController.prototype, "
|
|
599
|
+
], ConversationsController.prototype, "device", null);
|
|
600
600
|
__decorate([
|
|
601
601
|
Get(":id/tools"),
|
|
602
602
|
Header("cache-control", "private, no-store"),
|
|
@@ -680,7 +680,7 @@ ConversationsController = __decorate([
|
|
|
680
680
|
__param(0, Inject(ConversationsService)),
|
|
681
681
|
__param(1, Inject(ConversationOutputs)),
|
|
682
682
|
__param(2, Inject(ConversationArtifacts)),
|
|
683
|
-
__param(3, Inject(
|
|
683
|
+
__param(3, Inject(ConversationDeviceStatus)),
|
|
684
684
|
__param(4, Inject(ConversationToolInfo)),
|
|
685
685
|
__param(5, Inject(ConversationQueue)),
|
|
686
686
|
__param(6, Inject(ConversationFiles))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Conversations: the one {@link ConversationsService} (messages, model switches, skill
|
|
3
3
|
* invocations, sub-agent views, abort), the queue, the file / artifact / output reads and the
|
|
4
|
-
* conversation's
|
|
4
|
+
* conversation's device. The event log, the access check and the attachments are their own modules (the
|
|
5
5
|
* skills and tools use them too) and are re-exported here.
|
|
6
6
|
*/
|
|
7
7
|
export declare class ConversationsModule {
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { Module } from "@nestjs/common";
|
|
8
8
|
import { AgentLookupModule } from "../agents/agent-lookup.js";
|
|
9
9
|
import { BackgroundModule } from "../background/background.module.js";
|
|
10
|
-
import {
|
|
10
|
+
import { DevicesModule } from "../devices/devices.module.js";
|
|
11
11
|
import { ProvidersModule } from "../runtime/providers.js";
|
|
12
12
|
import { RuntimeModule } from "../runtime/runtime.module.js";
|
|
13
13
|
import { SkillsModule } from "../skills/skills.module.js";
|
|
@@ -17,7 +17,7 @@ import { ConversationAccessModule } from "./access.js";
|
|
|
17
17
|
import { ConversationArtifacts } from "./artifacts.js";
|
|
18
18
|
import { AttachmentsModule } from "./attachments.module.js";
|
|
19
19
|
import { ConversationsService } from "./conversations.service.js";
|
|
20
|
-
import {
|
|
20
|
+
import { ConversationDeviceStatus } from "./device-status.js";
|
|
21
21
|
import { EventLogModule } from "./event-log.js";
|
|
22
22
|
import { ConversationFiles } from "./files.js";
|
|
23
23
|
import { ConversationOutputs } from "./outputs-read.js";
|
|
@@ -25,7 +25,7 @@ import { ConversationQueue } from "./queue.service.js";
|
|
|
25
25
|
/**
|
|
26
26
|
* Conversations: the one {@link ConversationsService} (messages, model switches, skill
|
|
27
27
|
* invocations, sub-agent views, abort), the queue, the file / artifact / output reads and the
|
|
28
|
-
* conversation's
|
|
28
|
+
* conversation's device. The event log, the access check and the attachments are their own modules (the
|
|
29
29
|
* skills and tools use them too) and are re-exported here.
|
|
30
30
|
*/
|
|
31
31
|
let ConversationsModule = class ConversationsModule {
|
|
@@ -43,8 +43,8 @@ ConversationsModule = __decorate([
|
|
|
43
43
|
// the run control (start a run after a message, stop runs) and the model provider registry
|
|
44
44
|
RuntimeModule,
|
|
45
45
|
ProvidersModule,
|
|
46
|
-
// the
|
|
47
|
-
|
|
46
|
+
// the device a conversation is bound to, and its view
|
|
47
|
+
DevicesModule,
|
|
48
48
|
// the stop of a deleted conversation's background tasks
|
|
49
49
|
BackgroundModule,
|
|
50
50
|
],
|
|
@@ -54,7 +54,7 @@ ConversationsModule = __decorate([
|
|
|
54
54
|
ConversationOutputs,
|
|
55
55
|
ConversationArtifacts,
|
|
56
56
|
ConversationFiles,
|
|
57
|
-
|
|
57
|
+
ConversationDeviceStatus,
|
|
58
58
|
],
|
|
59
59
|
exports: [
|
|
60
60
|
EventLogModule,
|
|
@@ -65,7 +65,7 @@ ConversationsModule = __decorate([
|
|
|
65
65
|
ConversationOutputs,
|
|
66
66
|
ConversationArtifacts,
|
|
67
67
|
ConversationFiles,
|
|
68
|
-
|
|
68
|
+
ConversationDeviceStatus,
|
|
69
69
|
],
|
|
70
70
|
})
|
|
71
71
|
], ConversationsModule);
|
|
@@ -74,6 +74,6 @@ export const CONVERSATION_ROUTES = [
|
|
|
74
74
|
{ route: "GET /api/v1/orgs/:orgId/conversations/:id/agent-tree", params: IdParams },
|
|
75
75
|
{ route: "GET /api/v1/orgs/:orgId/conversations/:id/usage", params: IdParams },
|
|
76
76
|
{ route: "GET /api/v1/orgs/:orgId/conversations/:id/files", params: IdParams, query: FilesQuery },
|
|
77
|
-
{ route: "GET /api/v1/orgs/:orgId/conversations/:id/
|
|
77
|
+
{ route: "GET /api/v1/orgs/:orgId/conversations/:id/device", params: IdParams },
|
|
78
78
|
{ route: "POST /api/v1/orgs/:orgId/conversations/:id/abort", params: IdParams },
|
|
79
79
|
];
|
|
@@ -3,7 +3,7 @@ import type { ModelRef } from "../agents/definition.js";
|
|
|
3
3
|
import type { AgentAvatar } from "../agents/profile.js";
|
|
4
4
|
import { BackgroundTaskStopper } from "../background/stop.js";
|
|
5
5
|
import type { TitleSource } from "../db/kernel-schema.js";
|
|
6
|
-
import {
|
|
6
|
+
import { ConversationDevices, type NewConversationDevice } from "../devices/conversation-devices.js";
|
|
7
7
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
8
8
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
9
9
|
import type { KernelLogger } from "../log.js";
|
|
@@ -39,11 +39,11 @@ export interface ConversationView {
|
|
|
39
39
|
/** When the owner archived it; null = not archived (hidden from the default lists). */
|
|
40
40
|
archivedAt: Date | null;
|
|
41
41
|
/**
|
|
42
|
-
* The
|
|
43
|
-
* provider when it was created, an anonymous IM sender's, or created before
|
|
42
|
+
* The device it works in (environments spec §4.1 item 1); null while unbound (no sandbox
|
|
43
|
+
* provider when it was created, an anonymous IM sender's, or created before devices). A
|
|
44
44
|
* sub-agent's is null: it works in its root conversation's.
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
deviceId: string | null;
|
|
47
47
|
/**
|
|
48
48
|
* What the latest run is doing: `running` (queued or running), `waiting` (an approval or a
|
|
49
49
|
* question), else null. Only the list queries compute it; other responses carry null.
|
|
@@ -205,8 +205,8 @@ export declare class ConversationsService {
|
|
|
205
205
|
private readonly invoker;
|
|
206
206
|
/** Stops a deleted conversation's background tasks. */
|
|
207
207
|
private readonly background;
|
|
208
|
-
/** The
|
|
209
|
-
private readonly
|
|
208
|
+
/** The device a new conversation is bound to (environments spec §4.1 item 1). */
|
|
209
|
+
private readonly devices;
|
|
210
210
|
readonly txHost: TransactionHost;
|
|
211
211
|
constructor(db: KernelDb, eventLog: EventLog, agents: Pick<AgentLookup, "get">, access: Pick<ConversationAccess, "isAccessible">,
|
|
212
212
|
/** Starts and stops the conversation's runs. */
|
|
@@ -221,20 +221,20 @@ export declare class ConversationsService {
|
|
|
221
221
|
invoker: Pick<SkillInvoker, "prepare">,
|
|
222
222
|
/** Stops a deleted conversation's background tasks. */
|
|
223
223
|
background: Pick<BackgroundTaskStopper, "stopForDeletedConversation">,
|
|
224
|
-
/** The
|
|
225
|
-
|
|
224
|
+
/** The device a new conversation is bound to (environments spec §4.1 item 1). */
|
|
225
|
+
devices: Pick<ConversationDevices, "forNew">, txHost: TransactionHost);
|
|
226
226
|
/**
|
|
227
227
|
* 不阻塞地调用一次 `ensureRun`(打开 SSE、读事件时):它幂等,并顺带清理孤儿运行,
|
|
228
228
|
* 会话不会因为某次运行结束后的投递失败而永远停在「运行中」。失败只记日志。
|
|
229
229
|
*/
|
|
230
230
|
kickRun(conversationId: string): void;
|
|
231
231
|
/**
|
|
232
|
-
* Creates an empty conversation bound to its
|
|
233
|
-
* {@link
|
|
234
|
-
* `agent.not_found`,
|
|
235
|
-
* `
|
|
232
|
+
* Creates an empty conversation bound to its device (`pick`, see
|
|
233
|
+
* {@link ConversationDevices.forNew}); an agent the account cannot use →
|
|
234
|
+
* `agent.not_found`, a device it may not use → `device.not_found` /
|
|
235
|
+
* `device.unavailable`, and nothing is created.
|
|
236
236
|
*/
|
|
237
|
-
create(orgId: string, accountId: string, agentId: string, pick?:
|
|
237
|
+
create(orgId: string, accountId: string, agentId: string, pick?: NewConversationDevice): Promise<ConversationView>;
|
|
238
238
|
/**
|
|
239
239
|
* Creates a conversation together with its first message (UI refresh B, create on first send):
|
|
240
240
|
* the conversation row and the `user_message` are written in one transaction, keyed by the
|
|
@@ -246,7 +246,7 @@ export declare class ConversationsService {
|
|
|
246
246
|
*/
|
|
247
247
|
createWithMessage(orgId: string, accountId: string, agentId: string, input: UserMessageInput & {
|
|
248
248
|
clientMessageId: string;
|
|
249
|
-
}, pick?:
|
|
249
|
+
}, pick?: NewConversationDevice): Promise<{
|
|
250
250
|
conversation: ConversationView;
|
|
251
251
|
event: ConversationEvent;
|
|
252
252
|
events: ConversationEvent[];
|
|
@@ -13,7 +13,7 @@ import { sql } from "kysely";
|
|
|
13
13
|
import { AgentLookup, visibleTo } from "../agents/agent-lookup.js";
|
|
14
14
|
import { BackgroundTaskStopper } from "../background/stop.js";
|
|
15
15
|
import { unbindConversation } from "../channels/threads.js";
|
|
16
|
-
import {
|
|
16
|
+
import { ConversationDevices, } from "../devices/conversation-devices.js";
|
|
17
17
|
import { ApiError } from "../errors.js";
|
|
18
18
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
19
19
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
@@ -69,7 +69,7 @@ const COLUMNS = [
|
|
|
69
69
|
"parent_conversation_id",
|
|
70
70
|
"subagent_type",
|
|
71
71
|
"archived_at",
|
|
72
|
-
"
|
|
72
|
+
"device_id",
|
|
73
73
|
];
|
|
74
74
|
function toView(r) {
|
|
75
75
|
return {
|
|
@@ -86,7 +86,7 @@ function toView(r) {
|
|
|
86
86
|
parentConversationId: r.parent_conversation_id,
|
|
87
87
|
subagentType: r.subagent_type,
|
|
88
88
|
archivedAt: r.archived_at,
|
|
89
|
-
|
|
89
|
+
deviceId: r.device_id,
|
|
90
90
|
activity: r.activity ?? null,
|
|
91
91
|
};
|
|
92
92
|
}
|
|
@@ -129,7 +129,7 @@ let ConversationsService = class ConversationsService {
|
|
|
129
129
|
attachments;
|
|
130
130
|
invoker;
|
|
131
131
|
background;
|
|
132
|
-
|
|
132
|
+
devices;
|
|
133
133
|
txHost;
|
|
134
134
|
constructor(db, eventLog, agents, access,
|
|
135
135
|
/** Starts and stops the conversation's runs. */
|
|
@@ -144,8 +144,8 @@ let ConversationsService = class ConversationsService {
|
|
|
144
144
|
invoker,
|
|
145
145
|
/** Stops a deleted conversation's background tasks. */
|
|
146
146
|
background,
|
|
147
|
-
/** The
|
|
148
|
-
|
|
147
|
+
/** The device a new conversation is bound to (environments spec §4.1 item 1). */
|
|
148
|
+
devices, txHost) {
|
|
149
149
|
this.db = db;
|
|
150
150
|
this.eventLog = eventLog;
|
|
151
151
|
this.agents = agents;
|
|
@@ -157,7 +157,7 @@ let ConversationsService = class ConversationsService {
|
|
|
157
157
|
this.attachments = attachments;
|
|
158
158
|
this.invoker = invoker;
|
|
159
159
|
this.background = background;
|
|
160
|
-
this.
|
|
160
|
+
this.devices = devices;
|
|
161
161
|
this.txHost = txHost;
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
@@ -170,14 +170,14 @@ let ConversationsService = class ConversationsService {
|
|
|
170
170
|
.catch((err) => this.log.warn("ensureRun on conversation open failed", { conversationId, err }));
|
|
171
171
|
}
|
|
172
172
|
/**
|
|
173
|
-
* Creates an empty conversation bound to its
|
|
174
|
-
* {@link
|
|
175
|
-
* `agent.not_found`,
|
|
176
|
-
* `
|
|
173
|
+
* Creates an empty conversation bound to its device (`pick`, see
|
|
174
|
+
* {@link ConversationDevices.forNew}); an agent the account cannot use →
|
|
175
|
+
* `agent.not_found`, a device it may not use → `device.not_found` /
|
|
176
|
+
* `device.unavailable`, and nothing is created.
|
|
177
177
|
*/
|
|
178
178
|
async create(orgId, accountId, agentId, pick = {}) {
|
|
179
179
|
await this.agents.get(orgId, agentId, accountId);
|
|
180
|
-
const
|
|
180
|
+
const deviceId = await this.devices.forNew(orgId, accountId, pick);
|
|
181
181
|
const row = await this.db
|
|
182
182
|
.insertInto("conversations")
|
|
183
183
|
.values({
|
|
@@ -185,7 +185,7 @@ let ConversationsService = class ConversationsService {
|
|
|
185
185
|
org_id: orgId,
|
|
186
186
|
agent_id: agentId,
|
|
187
187
|
account_id: accountId,
|
|
188
|
-
|
|
188
|
+
device_id: deviceId,
|
|
189
189
|
})
|
|
190
190
|
.returning(COLUMNS)
|
|
191
191
|
.executeTakeFirstOrThrow();
|
|
@@ -205,12 +205,12 @@ let ConversationsService = class ConversationsService {
|
|
|
205
205
|
const prior = await this.findCreated(orgId, accountId, agentId, input.clientMessageId);
|
|
206
206
|
if (prior)
|
|
207
207
|
return prior;
|
|
208
|
-
const
|
|
208
|
+
const deviceId = await this.devices.forNew(orgId, accountId, pick);
|
|
209
209
|
const next = await this.planSwitch(orgId, agent.definition, NO_SELECTION, input);
|
|
210
210
|
const extra = await this.resolveExtra(orgId, accountId, input);
|
|
211
211
|
const invoked = await this.prepareSkill(orgId, agentId, undefined, agent.definition, input);
|
|
212
212
|
const id = randomUUID();
|
|
213
|
-
const all = await this.createIn({ id, orgId, accountId, agentId,
|
|
213
|
+
const all = await this.createIn({ id, orgId, accountId, agentId, deviceId }, input, next, extra, invoked);
|
|
214
214
|
const written = all?.at(-1);
|
|
215
215
|
if (!all || !written) {
|
|
216
216
|
const raced = await this.findCreated(orgId, accountId, agentId, input.clientMessageId);
|
|
@@ -233,7 +233,7 @@ let ConversationsService = class ConversationsService {
|
|
|
233
233
|
org_id: orgId,
|
|
234
234
|
agent_id: conv.agentId,
|
|
235
235
|
account_id: accountId,
|
|
236
|
-
|
|
236
|
+
device_id: conv.deviceId,
|
|
237
237
|
create_request_id: input.clientMessageId,
|
|
238
238
|
})
|
|
239
239
|
.onConflict((oc) => oc
|
|
@@ -484,14 +484,14 @@ let ConversationsService = class ConversationsService {
|
|
|
484
484
|
SELECT page.agent_id, page.latest_at, v.definition ->> 'name' AS agent_name,
|
|
485
485
|
a.profile_avatar, a.profile_updated_at, cs.id, cs.org_id, cs.account_id, cs.title, cs.title_source, cs.selection, cs.last_seq,
|
|
486
486
|
cs.created_at, cs.updated_at, cs.parent_conversation_id, cs.subagent_type,
|
|
487
|
-
cs.archived_at, cs.
|
|
487
|
+
cs.archived_at, cs.device_id, cs.activity
|
|
488
488
|
FROM page
|
|
489
489
|
JOIN capybara.agents a ON a.id = page.agent_id
|
|
490
490
|
JOIN capybara.agent_versions v ON v.agent_id = a.id AND v.version = a.current_version
|
|
491
491
|
CROSS JOIN LATERAL (
|
|
492
492
|
SELECT c.id, c.org_id, c.account_id, c.title, c.title_source, c.selection, c.last_seq,
|
|
493
493
|
c.created_at, c.updated_at, c.parent_conversation_id, c.subagent_type,
|
|
494
|
-
c.archived_at, c.
|
|
494
|
+
c.archived_at, c.device_id, ${activitySql("c")} AS activity
|
|
495
495
|
FROM capybara.conversations c
|
|
496
496
|
WHERE c.org_id = ${orgId} AND c.account_id = ${accountId} AND c.kind = 'chat'
|
|
497
497
|
AND c.deleted_at IS NULL AND ${archivedFilter} ${searchFilter} ${stateFilter}
|
|
@@ -959,7 +959,7 @@ ConversationsService = __decorate([
|
|
|
959
959
|
__param(8, Inject(AttachmentsService)),
|
|
960
960
|
__param(9, Inject(SkillInvoker)),
|
|
961
961
|
__param(10, Inject(BackgroundTaskStopper)),
|
|
962
|
-
__param(11, Inject(
|
|
962
|
+
__param(11, Inject(ConversationDevices)),
|
|
963
963
|
__param(12, Inject(TransactionHost))
|
|
964
964
|
], ConversationsService);
|
|
965
965
|
export { ConversationsService };
|