@capybara-hq/kernel 0.1.0-rc.134 → 0.1.0-rc.136
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/bootstrap.json +1 -1
- package/dist/admin/admin.module.js +3 -0
- package/dist/admin/health.service.d.ts +2 -2
- package/dist/admin/health.service.js +6 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/config/schema.d.ts +7 -0
- package/dist/config/schema.js +60 -2
- package/dist/conversations/access.d.ts +15 -7
- package/dist/conversations/access.js +59 -10
- package/dist/conversations/conversation-agent.d.ts +18 -0
- package/dist/conversations/conversation-agent.js +23 -0
- package/dist/conversations/conversation-ref.d.ts +3 -2
- package/dist/conversations/conversation-ref.js +6 -1
- package/dist/conversations/conversations.controller.d.ts +28 -5
- package/dist/conversations/conversations.controller.js +99 -10
- package/dist/conversations/conversations.module.js +10 -0
- package/dist/conversations/conversations.schemas.d.ts +6 -0
- package/dist/conversations/conversations.schemas.js +15 -0
- package/dist/conversations/conversations.service.d.ts +125 -21
- package/dist/conversations/conversations.service.js +260 -90
- package/dist/conversations/event-log.d.ts +9 -1
- package/dist/conversations/event-log.js +2 -0
- package/dist/conversations/events.d.ts +57 -0
- package/dist/conversations/events.js +73 -1
- package/dist/conversations/external/external-calls.d.ts +75 -0
- package/dist/conversations/external/external-calls.js +91 -0
- package/dist/conversations/external/external-calls.processor.d.ts +45 -0
- package/dist/conversations/external/external-calls.processor.js +144 -0
- package/dist/conversations/external/external-conversations.service.d.ts +266 -0
- package/dist/conversations/external/external-conversations.service.js +1138 -0
- package/dist/conversations/external/external.schemas.d.ts +63 -0
- package/dist/conversations/external/external.schemas.js +52 -0
- package/dist/conversations/external/token.d.ts +6 -0
- package/dist/conversations/external/token.js +6 -0
- package/dist/conversations/permission-profile-store.d.ts +4 -1
- package/dist/conversations/permission-profiles.controller.d.ts +33 -9
- package/dist/conversations/permission-profiles.controller.js +86 -6
- package/dist/conversations/prompt-suggestions.js +2 -1
- package/dist/conversations/queue.js +2 -1
- package/dist/conversations/titles.js +4 -3
- package/dist/ctx/create-ctx.d.ts +7 -0
- package/dist/ctx/create-ctx.js +45 -2
- package/dist/db/extension-db.d.ts +8 -3
- package/dist/db/extension-db.js +107 -7
- package/dist/db/extension-role-provision.d.ts +9 -0
- package/dist/db/extension-role-provision.js +89 -0
- package/dist/db/extension-schema-transfer.d.ts +2 -1
- package/dist/db/extension-schema-transfer.js +103 -19
- package/dist/db/kernel-schema.d.ts +31 -4
- package/dist/db/migrator.d.ts +2 -0
- package/dist/db/migrator.js +4 -3
- package/dist/device-access/host-services.js +3 -2
- package/dist/device-access/person-handles.d.ts +16 -7
- package/dist/device-access/person-handles.js +14 -9
- package/dist/devices/conversation-devices.d.ts +5 -0
- package/dist/devices/conversation-devices.js +16 -0
- package/dist/erasure/org-catalog.js +2 -2
- package/dist/errors.d.ts +34 -0
- package/dist/errors.js +34 -0
- package/dist/evals/snapshot.js +3 -1
- package/dist/evals/trajectory.service.d.ts +2 -2
- package/dist/evals/trajectory.service.js +11 -7
- package/dist/extensions/admin-ops.js +17 -1
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/host.d.ts +9 -1
- package/dist/extensions/host.js +14 -2
- package/dist/extensions/migrate-lock.js +1 -0
- package/dist/extensions/permission-view.d.ts +3 -1
- package/dist/extensions/permission-view.js +4 -1
- package/dist/extensions/point-defaults.d.ts +13 -21
- package/dist/extensions/point-defaults.js +32 -72
- package/dist/extensions/point-serving.d.ts +56 -0
- package/dist/extensions/point-serving.js +120 -0
- package/dist/inbox/inbox-items.service.d.ts +11 -0
- package/dist/inbox/inbox-items.service.js +39 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/infra/database/rls-role.d.ts +4 -11
- package/dist/infra/database/rls-role.js +71 -27
- package/dist/infra/outbox/registry.d.ts +70 -0
- package/dist/infra/outbox/registry.js +44 -0
- package/dist/infra/queue/queue-names.d.ts +1 -1
- package/dist/infra/queue/queue-names.js +1 -0
- package/dist/kernel.d.ts +2 -0
- package/dist/kernel.js +12 -2
- package/dist/kernel.module.js +4 -0
- package/dist/lifecycle/kernel-lifecycle.js +2 -3
- package/dist/platform/exclusions.js +10 -0
- package/dist/platform/ops/conversations.ops.d.ts +8 -1
- package/dist/platform/ops/conversations.ops.js +52 -14
- package/dist/plugin-reads/plugin-reads.service.js +4 -1
- package/dist/push/recipients.js +5 -2
- package/dist/retention/worker.js +2 -1
- package/dist/roles/worker-role.d.ts +3 -1
- package/dist/roles/worker-role.js +8 -2
- package/dist/roles/worker.module.js +3 -0
- package/dist/runtime/context/build.js +8 -0
- package/dist/runtime/context/compaction.js +7 -0
- package/dist/runtime/idle-arm.js +3 -1
- package/dist/runtime/idle-compaction.js +2 -1
- package/dist/runtime/run-finish.js +2 -1
- package/dist/runtime/run-jobs.js +2 -1
- package/dist/runtime/run-queue.js +4 -2
- package/dist/runtime/run-worker.js +5 -2
- package/dist/runtime/stream.js +10 -0
- package/dist/runtime/usage-report.js +2 -1
- package/dist/runtime/waits.js +2 -1
- package/dist/tools/approvals.service.js +6 -2
- package/dist/tools/builtins/skill-load.js +3 -2
- package/dist/tools/tool-watch.service.js +3 -1
- package/package.json +3 -3
- package/src/migrations/0226_enable_kernel_rls.sql +30 -0
- package/src/migrations/0227_external_conversations.sql +33 -0
|
@@ -15,6 +15,7 @@ import { normalizeStoredDefinition } from "../agents/definition.js";
|
|
|
15
15
|
import { GIT_GRANT_SPEC_HASH, gitGrantRefusal, gitPushGrantKey, grantRefusalOf, NETWORK_GRANT_PREFIX, NETWORK_GRANT_SPEC_HASH, networkGrantRefusal, normalizeGitRepo, } from "../automations/grant-rules.js";
|
|
16
16
|
import { AutomationStore } from "../automations/store.js";
|
|
17
17
|
import { unattendedRunOf, unattendedTaskRunOf } from "../automations/unattended.js";
|
|
18
|
+
import { agentIdOf } from "../conversations/conversation-agent.js";
|
|
18
19
|
import { EventLog } from "../conversations/event-log.js";
|
|
19
20
|
import { COMMAND_ASK_TEXT_MAX_CHARS, GIT_ASK_MAX_REFS, GIT_REF_MAX_CHARS, NETWORK_ASK_MAX_HOSTS, NETWORK_HOST_MAX_CHARS, SECURE_INPUT_MAX_FIELDS, } from "../conversations/events.js";
|
|
20
21
|
import { ConversationLeakCheck } from "../conversations/leak-check.js";
|
|
@@ -1675,7 +1676,8 @@ let ApprovalsService = class ApprovalsService {
|
|
|
1675
1676
|
.values({
|
|
1676
1677
|
org_id: orgId,
|
|
1677
1678
|
account_id: before.requestedFor,
|
|
1678
|
-
|
|
1679
|
+
// a run's conversation always has an agent (an external one has no runs)
|
|
1680
|
+
agent_id: agentIdOf(ctx),
|
|
1679
1681
|
tool_key: before.toolKey,
|
|
1680
1682
|
spec_hash: hash,
|
|
1681
1683
|
connector_id: connectorId,
|
|
@@ -2432,7 +2434,9 @@ let ApprovalsService = class ApprovalsService {
|
|
|
2432
2434
|
"conversations.parent_conversation_id",
|
|
2433
2435
|
])
|
|
2434
2436
|
.where("runs.id", "in", [...new Set(recs.map((r) => r.runId))])
|
|
2435
|
-
.execute()
|
|
2437
|
+
.execute()
|
|
2438
|
+
// a run's conversation always has an agent (an external one has no runs)
|
|
2439
|
+
.then((rows) => rows.map((r) => ({ ...r, agent_id: agentIdOf(r) })));
|
|
2436
2440
|
const ctx = new Map(ctxRows.map((r) => [r.id, r]));
|
|
2437
2441
|
// a sub-agent's approval links to the root conversation of its tree (agent map spec §7)
|
|
2438
2442
|
const roots = new Map();
|
|
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { parseSkillMd, renderSkillBody, SKILL_ENTRY_FILE, SKILL_INVOCATION_LIMITS, SKILLS_SANDBOX_ROOT, skillDigest, skillInvocation, skillSandboxDir, skillSandboxPath, ToolError, validateSandboxPathShape, } from "@capybara-hq/plugin-sdk";
|
|
3
3
|
import { sql } from "kysely";
|
|
4
4
|
import { normalizeStoredDefinition } from "../../agents/definition.js";
|
|
5
|
+
import { agentIdOf } from "../../conversations/conversation-agent.js";
|
|
5
6
|
import { ApiError } from "../../errors.js";
|
|
6
7
|
import { callableProjectSkills, projectSkillName, projectSkillOf, } from "../../runtime/context/project-root.js";
|
|
7
8
|
import { latestInvocation } from "../../runtime/context/skills.js";
|
|
@@ -292,7 +293,7 @@ async function runAgent(db, ctx) {
|
|
|
292
293
|
.where("conversations.org_id", "=", ctx.orgId)
|
|
293
294
|
.executeTakeFirst();
|
|
294
295
|
return row
|
|
295
|
-
? { agentId: row
|
|
296
|
+
? { agentId: agentIdOf(row), definition: normalizeStoredDefinition(row.definition) }
|
|
296
297
|
: undefined;
|
|
297
298
|
}
|
|
298
299
|
/**
|
|
@@ -323,7 +324,7 @@ async function invocationScope(db, ctx) {
|
|
|
323
324
|
.executeTakeFirst();
|
|
324
325
|
return row
|
|
325
326
|
? {
|
|
326
|
-
agentId: row
|
|
327
|
+
agentId: agentIdOf(row),
|
|
327
328
|
definition: normalizeStoredDefinition(row.definition),
|
|
328
329
|
conversationId: dispatch.parentConversationId,
|
|
329
330
|
}
|
|
@@ -11,6 +11,7 @@ import { parseToolKey } from "@capybara-hq/plugin-sdk";
|
|
|
11
11
|
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
12
12
|
import { DelayedError } from "bullmq";
|
|
13
13
|
import { sql } from "kysely";
|
|
14
|
+
import { agentIdOf } from "../conversations/conversation-agent.js";
|
|
14
15
|
import { EffectiveConfigs } from "../extensions/effective-config.js";
|
|
15
16
|
import { isExtensionEnabled } from "../extensions/enabled.js";
|
|
16
17
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
@@ -151,7 +152,8 @@ let ToolWatchService = class ToolWatchService {
|
|
|
151
152
|
...extensionCallContext({
|
|
152
153
|
orgId: row.org_id,
|
|
153
154
|
accountId: row.trigger_account_id,
|
|
154
|
-
|
|
155
|
+
// a question belongs to a run: its conversation has an agent (an external one has none)
|
|
156
|
+
agentId: agentIdOf(row),
|
|
155
157
|
conversationId: row.conversation_id,
|
|
156
158
|
rootConversationId,
|
|
157
159
|
runId: row.run_id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/kernel",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.136",
|
|
4
4
|
"description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"yaml": "^2.9.1",
|
|
71
71
|
"yauzl": "3.4.0",
|
|
72
72
|
"zod": "^4.6.7",
|
|
73
|
-
"@capybara-hq/plugin-sdk": "^0.1.0-rc.
|
|
73
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.100"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@langchain/langgraph-checkpoint-validation": "^1.2.0",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@types/yauzl": "3.4.0",
|
|
83
83
|
"pg-cursor": "^2.22.1",
|
|
84
84
|
"ws": "^8.22.0",
|
|
85
|
-
"@capybara-hq/testing": "0.1.0-rc.
|
|
85
|
+
"@capybara-hq/testing": "0.1.0-rc.56"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
88
|
"build": "tsc -b"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
-- Phase 5 activates the existing kernel policies. Bound the wait for table locks while serving.
|
|
2
|
+
SET LOCAL lock_timeout = '2s';
|
|
3
|
+
|
|
4
|
+
-- capybara:allow-destructive catalog-driven verification and activation of existing kernel policies
|
|
5
|
+
DO $$
|
|
6
|
+
DECLARE
|
|
7
|
+
target record;
|
|
8
|
+
BEGIN
|
|
9
|
+
FOR target IN
|
|
10
|
+
SELECT c.relname, EXISTS (
|
|
11
|
+
SELECT FROM pg_catalog.pg_policy p
|
|
12
|
+
WHERE p.polrelid = c.oid AND p.polname = 'org_scope'
|
|
13
|
+
) AS has_policy
|
|
14
|
+
FROM pg_catalog.pg_class c
|
|
15
|
+
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
16
|
+
JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid
|
|
17
|
+
WHERE n.nspname = 'capybara' AND c.relkind IN ('r', 'p')
|
|
18
|
+
AND a.attname = 'org_id' AND NOT a.attisdropped
|
|
19
|
+
ORDER BY has_policy, c.relname
|
|
20
|
+
LOOP
|
|
21
|
+
IF NOT target.has_policy THEN
|
|
22
|
+
RAISE EXCEPTION 'Missing org_scope policy on capybara.%', target.relname;
|
|
23
|
+
END IF;
|
|
24
|
+
EXECUTE format(
|
|
25
|
+
'ALTER TABLE ONLY capybara.%I ENABLE ROW LEVEL SECURITY, FORCE ROW LEVEL SECURITY',
|
|
26
|
+
target.relname
|
|
27
|
+
);
|
|
28
|
+
END LOOP;
|
|
29
|
+
END
|
|
30
|
+
$$;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
-- External conversations (local agents spec 2026-12-01, Part 2): a conversation the person holds
|
|
2
|
+
-- with a `conversation-target@1` target (a local agent on their device). The kernel mirrors it and
|
|
3
|
+
-- never runs it, so it has no agent.
|
|
4
|
+
-- - kind gains 'external'; agent_id becomes nullable: null exactly for 'external', which names its
|
|
5
|
+
-- target in `external` ({ extension, targetKey, label }) instead (one CHECK).
|
|
6
|
+
-- - external_state: what the target last reported (running / waiting / idle / ended).
|
|
7
|
+
-- - external_delivered_seq: the highest `external_user_message.deliverySeq` handed to the target;
|
|
8
|
+
-- -1 (written only by the kernel) marks a conversation whose `start` was dropped after its retries.
|
|
9
|
+
-- Additive only: the new columns have a default or are nullable and the CHECKs admit every
|
|
10
|
+
-- existing row, so a running older version keeps working during a rolling upgrade (it never
|
|
11
|
+
-- writes 'external' and always writes an agent).
|
|
12
|
+
-- The widened kind CHECK is re-added NOT VALID: the old CHECK implies the new one, so existing
|
|
13
|
+
-- rows need no scan. The shape CHECK is new, so it is added NOT VALID and then validated: the scan
|
|
14
|
+
-- proves every existing row (all of them have an agent and no target) fits it.
|
|
15
|
+
|
|
16
|
+
-- capybara:allow-destructive the CHECK is re-added with one more allowed value in the same transaction
|
|
17
|
+
ALTER TABLE conversations DROP CONSTRAINT IF EXISTS conversations_kind_check;
|
|
18
|
+
ALTER TABLE conversations ADD CONSTRAINT conversations_kind_check
|
|
19
|
+
CHECK (kind IN ('chat', 'eval', 'subagent', 'external')) NOT VALID;
|
|
20
|
+
|
|
21
|
+
ALTER TABLE conversations ALTER COLUMN agent_id DROP NOT NULL;
|
|
22
|
+
ALTER TABLE conversations ADD COLUMN IF NOT EXISTS external jsonb;
|
|
23
|
+
ALTER TABLE conversations ADD COLUMN IF NOT EXISTS external_state text NOT NULL DEFAULT 'idle'
|
|
24
|
+
CONSTRAINT conversations_external_state_check
|
|
25
|
+
CHECK (external_state IN ('running', 'waiting', 'idle', 'ended'));
|
|
26
|
+
ALTER TABLE conversations ADD COLUMN IF NOT EXISTS external_delivered_seq bigint NOT NULL DEFAULT 0;
|
|
27
|
+
|
|
28
|
+
ALTER TABLE conversations DROP CONSTRAINT IF EXISTS conversations_external_shape;
|
|
29
|
+
ALTER TABLE conversations ADD CONSTRAINT conversations_external_shape CHECK (
|
|
30
|
+
kind = 'external' AND agent_id IS NULL AND external IS NOT NULL
|
|
31
|
+
OR kind <> 'external' AND agent_id IS NOT NULL AND external IS NULL
|
|
32
|
+
) NOT VALID;
|
|
33
|
+
ALTER TABLE conversations VALIDATE CONSTRAINT conversations_external_shape;
|