@capybara-hq/kernel 0.1.0-rc.76 → 0.1.0-rc.78
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 +6 -6
- package/dist/admin/outbox-dead.service.js +4 -1
- package/dist/agents/admin-agents.js +2 -0
- package/dist/agents/agent-lookup.js +4 -0
- package/dist/agents/agent-profile.service.js +3 -0
- package/dist/agents/agents.service.js +7 -0
- package/dist/agents/org-templates.js +1 -0
- package/dist/agents/pending-connector-requests.js +6 -0
- package/dist/agents/pending-connectors.service.js +2 -0
- package/dist/agents/readiness.service.d.ts +9 -3
- package/dist/agents/readiness.service.js +3 -3
- package/dist/agents/templates.js +1 -0
- package/dist/background/finish.js +3 -0
- package/dist/background/stop.js +2 -0
- package/dist/background/store.js +44 -0
- package/dist/background/tasks.service.js +3 -2
- package/dist/background/wake-rules.js +1 -0
- package/dist/catalog/admin-catalog.controller.d.ts +6 -0
- package/dist/catalog/admin-catalog.controller.js +13 -0
- package/dist/catalog/catalog-content.d.ts +6 -0
- package/dist/catalog/catalog-content.js +1 -0
- package/dist/catalog/catalog-items.js +4 -0
- package/dist/catalog/catalog-scope.service.js +4 -1
- package/dist/catalog/component-promotion.js +2 -0
- package/dist/catalog/component-scope.controller.d.ts +9 -15
- package/dist/catalog/component-scope.controller.js +14 -9
- package/dist/catalog/component-scope.service.js +5 -0
- package/dist/catalog/component-state.js +2 -0
- package/dist/catalog/marketplaces.service.d.ts +6 -1
- package/dist/catalog/marketplaces.service.js +8 -3
- package/dist/catalog/org-catalog.controller.d.ts +9 -0
- package/dist/catalog/org-catalog.controller.js +18 -0
- package/dist/catalog/org-catalog.schemas.d.ts +2 -4
- package/dist/catalog/org-catalog.schemas.js +2 -3
- package/dist/catalog/org-catalog.service.d.ts +10 -1
- package/dist/catalog/org-catalog.service.js +34 -23
- package/dist/catalog/org-extension-switch.d.ts +3 -10
- package/dist/catalog/org-extension-switch.js +14 -60
- package/dist/catalog/org-extension.controller.d.ts +6 -7
- package/dist/catalog/org-extension.controller.js +4 -4
- package/dist/catalog/org-extension.schemas.d.ts +1 -2
- package/dist/catalog/org-extension.schemas.js +1 -3
- package/dist/catalog/owned-items.js +10 -1
- package/dist/catalog/ownership.js +2 -0
- package/dist/catalog/plugin-import.js +8 -0
- package/dist/catalog/plugin-install.d.ts +1 -4
- package/dist/catalog/plugin-install.js +11 -12
- package/dist/catalog/plugin-upgrade.js +4 -1
- package/dist/catalog/request-rules.js +6 -0
- package/dist/catalog/requests.service.js +4 -0
- package/dist/catalog/scope-orgs.js +1 -0
- package/dist/catalog/scope-sync.d.ts +8 -5
- package/dist/catalog/scope-sync.js +21 -23
- package/dist/catalog/unshare.js +3 -0
- package/dist/channels/connections.service.js +1 -0
- package/dist/channels/inbound.js +1 -0
- package/dist/channels/jobs.js +1 -0
- package/dist/channels/outbound.js +6 -0
- package/dist/channels/supervisor.js +1 -0
- package/dist/channels/threads.js +1 -0
- package/dist/client/client-reports.service.js +1 -0
- package/dist/config/fields.js +20 -4
- package/dist/conversations/access.js +1 -0
- package/dist/conversations/attachments.service.js +16 -4
- package/dist/conversations/conversations.service.js +17 -3
- package/dist/conversations/event-log.js +2 -0
- package/dist/conversations/events.d.ts +1 -0
- package/dist/conversations/events.js +3 -1
- package/dist/conversations/files.js +3 -2
- package/dist/conversations/permission-profiles.service.js +1 -0
- package/dist/conversations/prompt-suggestions.js +2 -0
- package/dist/conversations/queue.js +8 -0
- package/dist/conversations/queue.service.js +6 -2
- package/dist/conversations/source.js +2 -0
- package/dist/conversations/titles.js +10 -2
- package/dist/conversations/tree.js +6 -0
- package/dist/db/kernel-schema.d.ts +3 -1
- package/dist/devices/conversation-devices.js +3 -0
- package/dist/devices/device-projects.service.js +2 -0
- package/dist/devices/devices.service.js +5 -0
- package/dist/devices/legacy-cleanup.job.js +5 -2
- package/dist/dial-in/handlers.js +2 -0
- package/dist/dial-in/machines.js +11 -2
- package/dist/dial-in/targets.d.ts +0 -2
- package/dist/dial-in/targets.js +0 -10
- package/dist/errors.d.ts +0 -1
- package/dist/errors.js +0 -1
- package/dist/evals/budget.js +14 -1
- package/dist/evals/run-replay.js +4 -0
- package/dist/evals/runs.service.js +13 -7
- package/dist/evals/sets.service.js +23 -8
- package/dist/evals/trajectory.service.d.ts +1 -1
- package/dist/evals/trajectory.service.js +1 -0
- package/dist/evals/worker.js +5 -1
- package/dist/extensions/admin-ops.js +1 -0
- package/dist/extensions/admin-view.js +3 -1
- package/dist/extensions/bootstrap-packages.d.ts +12 -1
- package/dist/extensions/bootstrap-packages.js +49 -9
- package/dist/extensions/bootstrap.d.ts +36 -4
- package/dist/extensions/bootstrap.js +103 -16
- package/dist/extensions/config-json-schema.d.ts +2 -2
- package/dist/extensions/config-json-schema.js +1 -3
- package/dist/extensions/deployment-config.d.ts +5 -3
- package/dist/extensions/deployment-config.js +3 -3
- package/dist/extensions/effective-config.d.ts +8 -7
- package/dist/extensions/effective-config.js +8 -7
- package/dist/extensions/enabled.js +1 -0
- package/dist/extensions/host.d.ts +4 -3
- package/dist/extensions/host.js +11 -12
- package/dist/extensions/instance.d.ts +1 -1
- package/dist/extensions/instance.js +17 -2
- package/dist/extensions/org-config.d.ts +35 -97
- package/dist/extensions/org-config.js +48 -315
- package/dist/extensions/org-levels.d.ts +22 -9
- package/dist/extensions/org-levels.js +100 -20
- package/dist/extensions/org-overrides.d.ts +14 -15
- package/dist/extensions/org-overrides.js +20 -20
- package/dist/extensions/package.js +1 -1
- package/dist/extensions/permission-set.d.ts +1 -3
- package/dist/extensions/permission-set.js +3 -7
- package/dist/extensions/permission-view.d.ts +3 -1
- package/dist/extensions/permission-view.js +5 -4
- package/dist/extensions/plugin-icons.d.ts +72 -1
- package/dist/extensions/plugin-icons.js +194 -2
- package/dist/extensions/point-defaults.d.ts +17 -18
- package/dist/extensions/point-defaults.js +25 -28
- package/dist/identity/accounts.js +6 -0
- package/dist/identity/api-tokens.js +8 -0
- package/dist/infra/outbox/outbox.dispatcher.js +4 -1
- package/dist/infra/outbox/outbox.service.js +2 -0
- package/dist/orgs/directory-sync.d.ts +9 -6
- package/dist/orgs/directory-sync.js +15 -12
- package/dist/orgs/invitations.service.js +2 -0
- package/dist/orgs/members.service.js +2 -0
- package/dist/orgs/offboarding.js +2 -0
- package/dist/packages/npm.d.ts +9 -1
- package/dist/packages/npm.js +37 -5
- package/dist/platform/exclusions.js +20 -0
- package/dist/platform/ops/admin-items.ops.js +1 -0
- package/dist/platform/ops/agents.ops.js +1 -0
- package/dist/platform/ops/extensions.ops.d.ts +6 -8
- package/dist/platform/ops/extensions.ops.js +18 -97
- package/dist/platform/ops/org-plugins.ops.d.ts +3 -6
- package/dist/platform/ops/org-plugins.ops.js +14 -65
- package/dist/platform/ops/outbox.ops.js +1 -0
- package/dist/platform/ops/person-inputs.d.ts +0 -4
- package/dist/platform/ops/person-inputs.js +0 -8
- package/dist/platform/ops/plugins.ops.d.ts +4 -1
- package/dist/platform/ops/plugins.ops.js +27 -34
- package/dist/platform/person-fields.d.ts +1 -1
- package/dist/platform/person-fields.js +1 -1
- package/dist/platform/sealed-reveals.js +2 -0
- package/dist/push/recipients.js +9 -2
- package/dist/runtime/permission-context.service.js +1 -0
- package/dist/runtime/plugin-context.service.js +1 -0
- package/dist/runtime/project/knowledge.service.js +1 -0
- package/dist/runtime/run-context.service.js +1 -0
- package/dist/runtime/run-deletion.js +4 -0
- package/dist/runtime/run-execution.js +2 -0
- package/dist/runtime/run-finish.js +3 -0
- package/dist/runtime/run-jobs.js +3 -0
- package/dist/runtime/run-orphan-check.job.js +7 -0
- package/dist/runtime/run-queue.js +21 -2
- package/dist/runtime/run-worker.js +5 -0
- package/dist/runtime/step-log.js +1 -0
- package/dist/runtime/subagents/child.js +2 -0
- package/dist/runtime/subagents/deliveries.js +3 -0
- package/dist/runtime/subagents/dispatch.js +5 -1
- package/dist/runtime/subagents/messages.js +2 -0
- package/dist/runtime/subagents/org-agents.d.ts +1 -1
- package/dist/runtime/subagents/org-agents.js +2 -1
- package/dist/runtime/usage-report-jobs.js +1 -0
- package/dist/runtime/usage-report.js +3 -0
- package/dist/runtime/waits.js +5 -0
- package/dist/sandbox/cloud-permission-snapshot.js +9 -3
- package/dist/sandbox/device-reports.js +3 -0
- package/dist/sandbox/legacy-retirement.js +5 -1
- package/dist/sandbox/managed-device-context.js +1 -0
- package/dist/sandbox/modes.d.ts +5 -2
- package/dist/sandbox/modes.js +8 -4
- package/dist/sandbox/network-grants.js +2 -0
- package/dist/sandbox/operation-intents.js +58 -0
- package/dist/sandbox/operation-reconcile.job.js +2 -0
- package/dist/sandbox/permission-authority-lock.js +12 -6
- package/dist/sandbox/permission-call-grants.js +6 -0
- package/dist/sandbox/permission-ceiling-writes.js +5 -0
- package/dist/sandbox/permission-config-publication.js +5 -0
- package/dist/sandbox/permission-instance-writes.js +4 -0
- package/dist/sandbox/permission-runtime-reports.js +10 -1
- package/dist/sandbox/permission-transitions.js +3 -0
- package/dist/sandbox/review/review.service.js +8 -5
- package/dist/sandbox/sandbox.service.d.ts +14 -0
- package/dist/sandbox/sandbox.service.js +195 -29
- package/dist/sandbox/unreachable.js +4 -1
- package/dist/schedules/fire.js +9 -3
- package/dist/schedules/pause.js +2 -0
- package/dist/schedules/run-tracker.js +16 -1
- package/dist/schedules/scheduled-tasks.service.js +4 -2
- package/dist/schedules/store.js +8 -0
- package/dist/schedules/unattended.js +4 -0
- package/dist/setup/setup-checks.service.d.ts +1 -10
- package/dist/setup/setup-checks.service.js +19 -29
- package/dist/shares/share-open.service.js +1 -0
- package/dist/shares/shares.service.js +2 -0
- package/dist/skills/agent-skills.service.d.ts +1 -1
- package/dist/skills/agent-skills.service.js +13 -2
- package/dist/skills/catalog.js +3 -0
- package/dist/skills/changes.service.js +10 -2
- package/dist/skills/conversation-catalog.js +1 -0
- package/dist/skills/skills.service.js +4 -0
- package/dist/tools/approvals.service.js +40 -0
- package/dist/tools/builtins/schedules.js +11 -6
- package/dist/tools/builtins/skill-load.d.ts +10 -9
- package/dist/tools/builtins/skill-load.js +15 -19
- package/dist/tools/builtins/web/fetch.js +1 -1
- package/dist/tools/builtins/web/search.js +1 -1
- package/dist/tools/connector-account-policies.js +3 -0
- package/dist/tools/connectors.controller.d.ts +20 -8
- package/dist/tools/connectors.controller.js +30 -12
- package/dist/tools/connectors.service.d.ts +8 -0
- package/dist/tools/connectors.service.js +21 -1
- package/dist/tools/drift.js +5 -0
- package/dist/tools/git-push-policy.js +3 -0
- package/dist/tools/oauth/flow.js +1 -0
- package/dist/tools/outputs.js +2 -0
- package/dist/tools/permission-approval-jobs.js +3 -0
- package/dist/tools/pipeline.js +2 -0
- package/dist/tools/policy.js +3 -0
- package/dist/tools/questions.service.js +13 -0
- package/package.json +3 -3
|
@@ -25,6 +25,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
25
25
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
26
26
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
27
27
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
28
|
+
import { UUID_RE } from "../ui/registry.js";
|
|
28
29
|
import { CredentialMissing, Credentials, isOAuth, } from "./credentials.js";
|
|
29
30
|
import { snapshot, ToolDrift, toolIssue, } from "./drift.js";
|
|
30
31
|
import { endpointCredentialIssues, endpointView } from "./endpoint.js";
|
|
@@ -577,6 +578,7 @@ let ConnectorsService = class ConnectorsService {
|
|
|
577
578
|
updated_at: sql `now()`,
|
|
578
579
|
})
|
|
579
580
|
.where("id", "=", connectorId)
|
|
581
|
+
.where("org_id", "=", orgId)
|
|
580
582
|
.execute();
|
|
581
583
|
// Tools at a default the org did not set (template or derived): a tool the new template names
|
|
582
584
|
// takes its policy (`template`); an unnamed `template` one returns to the derived policy;
|
|
@@ -981,6 +983,16 @@ let ConnectorsService = class ConnectorsService {
|
|
|
981
983
|
.execute();
|
|
982
984
|
return rows.map((r) => this.summary(r));
|
|
983
985
|
}
|
|
986
|
+
/**
|
|
987
|
+
* Where a live connector of the org takes its icon from: its platform template and its plugin
|
|
988
|
+
* (catalog item). Unknown -> `connector.not_found`.
|
|
989
|
+
*/
|
|
990
|
+
async iconRef(orgId, connectorId) {
|
|
991
|
+
if (!UUID_RE.test(connectorId))
|
|
992
|
+
throw notFound();
|
|
993
|
+
const r = await this.row(this.db, orgId, connectorId);
|
|
994
|
+
return { templateId: r.platform_template_id ?? null, itemId: r.catalog_item_id ?? null };
|
|
995
|
+
}
|
|
984
996
|
async get(orgId, connectorId, viewerAccountId) {
|
|
985
997
|
return this.detail(this.db, orgId, connectorId, viewerAccountId);
|
|
986
998
|
}
|
|
@@ -1070,6 +1082,7 @@ let ConnectorsService = class ConnectorsService {
|
|
|
1070
1082
|
updated_at: sql `now()`,
|
|
1071
1083
|
})
|
|
1072
1084
|
.where("id", "=", connectorId)
|
|
1085
|
+
.where("org_id", "=", orgId)
|
|
1073
1086
|
.execute();
|
|
1074
1087
|
}
|
|
1075
1088
|
const allowed = [];
|
|
@@ -1149,6 +1162,7 @@ let ConnectorsService = class ConnectorsService {
|
|
|
1149
1162
|
.updateTable("connectors")
|
|
1150
1163
|
.set({ git_push_policy: policy, updated_at: sql `now()` })
|
|
1151
1164
|
.where("id", "=", connectorId)
|
|
1165
|
+
.where("org_id", "=", orgId)
|
|
1152
1166
|
.execute();
|
|
1153
1167
|
await audit(t, {
|
|
1154
1168
|
actorAccountId,
|
|
@@ -1246,6 +1260,7 @@ let ConnectorsService = class ConnectorsService {
|
|
|
1246
1260
|
// leaves the connector as the platform set it
|
|
1247
1261
|
.set({ status, disabled_by_plugin_id: null, updated_at: sql `now()` })
|
|
1248
1262
|
.where("id", "=", connectorId)
|
|
1263
|
+
.where("org_id", "=", orgId)
|
|
1249
1264
|
.execute();
|
|
1250
1265
|
await audit(t, {
|
|
1251
1266
|
actorAccountId: actor.accountId,
|
|
@@ -1289,10 +1304,15 @@ let ConnectorsService = class ConnectorsService {
|
|
|
1289
1304
|
.updateTable("connectors")
|
|
1290
1305
|
.set({ deleted_at: sql `now()`, updated_at: sql `now()` })
|
|
1291
1306
|
.where("id", "=", connectorId)
|
|
1307
|
+
.where("org_id", "=", orgId)
|
|
1292
1308
|
.execute();
|
|
1293
1309
|
await this.credentials.clearConnector(orgId, connectorId);
|
|
1294
1310
|
// 授权绑定连接器 id(软删除不触发外键级联):一并删掉,不留给任何后来的连接器
|
|
1295
|
-
await t
|
|
1311
|
+
await t
|
|
1312
|
+
.deleteFrom("tool_grants")
|
|
1313
|
+
.where("org_id", "=", orgId)
|
|
1314
|
+
.where("connector_id", "=", connectorId)
|
|
1315
|
+
.execute();
|
|
1296
1316
|
await t
|
|
1297
1317
|
.deleteFrom("conversation_tool_grants")
|
|
1298
1318
|
.where("connector_id", "=", connectorId)
|
package/dist/tools/drift.js
CHANGED
|
@@ -260,6 +260,8 @@ let ToolDrift = class ToolDrift {
|
|
|
260
260
|
* 把新快照与当前工具行比对并写入(调用方已在事务内锁住连接器行:`mandatory`);返回按名排序的变化。
|
|
261
261
|
* 规则见文件头。待复核的新定义也写进 `tool_specs`(内容寻址,只增不改)。
|
|
262
262
|
*/
|
|
263
|
+
// org-filter: app is the connector row the caller read with its org filter and holds locked
|
|
264
|
+
// FOR UPDATE (applyChecked, ConnectorsService's refresh); connector_tools has no org column
|
|
263
265
|
async apply(app, rows) {
|
|
264
266
|
const t = this.db.db;
|
|
265
267
|
const current = await t
|
|
@@ -485,6 +487,7 @@ let ToolDrift = class ToolDrift {
|
|
|
485
487
|
.selectFrom("connectors")
|
|
486
488
|
.select(["id", "tools_synced_at"])
|
|
487
489
|
.where("id", "=", connectorId)
|
|
490
|
+
.where("org_id", "=", orgId)
|
|
488
491
|
.where("deleted_at", "is", null)
|
|
489
492
|
.where("status", "=", "active")
|
|
490
493
|
.forUpdate()
|
|
@@ -530,6 +533,8 @@ let ToolDrift = class ToolDrift {
|
|
|
530
533
|
* 周期扫描:给本周期内还没检查过的活动连接器(`tools_synced_at` 为空或早于半个周期)各投递一次检查,
|
|
531
534
|
* jobId 按周期桶去重——即使扫描在多个副本上重复执行,每个连接器每周期也只检查一次。返回投递数。
|
|
532
535
|
*/
|
|
536
|
+
// org-filter: deployment-wide sweep across all orgs (LockedInterval in ToolJobs); each job
|
|
537
|
+
// carries its connector's own org_id
|
|
533
538
|
async scan() {
|
|
534
539
|
const interval = this.intervalMs();
|
|
535
540
|
const bucket = Math.floor(Date.now() / interval);
|
|
@@ -64,6 +64,7 @@ export async function decideGitPush(db, config, input) {
|
|
|
64
64
|
const row = await db
|
|
65
65
|
.selectFrom("connector_tool_account_policies")
|
|
66
66
|
.select("policy")
|
|
67
|
+
.where("org_id", "=", input.orgId)
|
|
67
68
|
.where("connector_id", "=", input.connectorId)
|
|
68
69
|
.where("account_id", "=", input.accountId)
|
|
69
70
|
.where("tool_name", "=", gitPushPolicyName(host, repo))
|
|
@@ -150,6 +151,8 @@ async function hasRunGrant(db, input, host, repo) {
|
|
|
150
151
|
* repositories granted and refused in the tree (keyed `<host>/<owner>/<repo>`, {@link gitRepoKey}),
|
|
151
152
|
* this run's asks, a pending ask of the tree.
|
|
152
153
|
*/
|
|
154
|
+
// org-filter: takes a runtime run id (no HTTP or tool input reaches it; only kernel code and tests
|
|
155
|
+
// call it), and the rows are that run tree's
|
|
153
156
|
export async function gitRunState(db, runId) {
|
|
154
157
|
const root = await budgetRunOf(db, runId);
|
|
155
158
|
const rows = await db
|
package/dist/tools/oauth/flow.js
CHANGED
package/dist/tools/outputs.js
CHANGED
|
@@ -77,6 +77,8 @@ export const OUTPUT_CLEANUP_BATCH = 1000;
|
|
|
77
77
|
* 删除已过期(`expires_at < now()`)的输出存档,每批 `batch` 行,直到删完;返回删除的总行数。
|
|
78
78
|
* 每批一条独立语句(不开长事务);多个 worker 同时清理时 `SKIP LOCKED` 互不等待。
|
|
79
79
|
*/
|
|
80
|
+
// org-filter: deployment-wide cleanup of expired archives across all orgs (a worker job), by
|
|
81
|
+
// expiry only
|
|
80
82
|
export async function deleteExpiredOutputs(db, batch = OUTPUT_CLEANUP_BATCH) {
|
|
81
83
|
let total = 0;
|
|
82
84
|
for (;;) {
|
|
@@ -54,6 +54,7 @@ let PermissionApprovalJobs = class PermissionApprovalJobs {
|
|
|
54
54
|
.selectFrom("conversations")
|
|
55
55
|
.select("id")
|
|
56
56
|
.where("id", "=", root.id)
|
|
57
|
+
.where("org_id", "=", data.orgId)
|
|
57
58
|
.unionAll((q) => q
|
|
58
59
|
.selectFrom("conversations as c")
|
|
59
60
|
.innerJoin("tree", "tree.id", "c.parent_conversation_id")
|
|
@@ -62,12 +63,14 @@ let PermissionApprovalJobs = class PermissionApprovalJobs {
|
|
|
62
63
|
.selectFrom("conversations")
|
|
63
64
|
.select("id")
|
|
64
65
|
.where("id", "in", (q) => q.selectFrom("tree").select("id"))
|
|
66
|
+
.where("org_id", "=", data.orgId)
|
|
65
67
|
.orderBy("id")
|
|
66
68
|
.forUpdate()
|
|
67
69
|
.execute();
|
|
68
70
|
const cards = await this.db
|
|
69
71
|
.selectFrom("approvals")
|
|
70
72
|
.select(["run_id", "conversation_id"])
|
|
73
|
+
.where("org_id", "=", data.orgId)
|
|
71
74
|
.where("conversation_id", "in", tree.map((c) => c.id))
|
|
72
75
|
.where("kind", "=", "command")
|
|
73
76
|
.where("status", "=", "superseded")
|
package/dist/tools/pipeline.js
CHANGED
|
@@ -1907,6 +1907,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1907
1907
|
* full reach, under any profile): an intent past admission, or one revoked after dispatch, whose
|
|
1908
1908
|
* device-wide scope came from the call's escalation grant.
|
|
1909
1909
|
*/
|
|
1910
|
+
// org-filter: runId is the call context's own run (ctx.runId), a runtime uuid, never caller input
|
|
1910
1911
|
async admittedOutsideSandbox(runId, callId) {
|
|
1911
1912
|
const rows = await this.deps.db
|
|
1912
1913
|
.selectFrom("sandbox_operation_intents as i")
|
|
@@ -2211,6 +2212,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
2211
2212
|
}
|
|
2212
2213
|
}
|
|
2213
2214
|
/** The highest attempt of any approval of the call, of every kind (0: none yet). */
|
|
2215
|
+
// org-filter: runId is the call context's own run (ctx.runId), a runtime uuid, never caller input
|
|
2214
2216
|
async lastAttempt(runId, callId) {
|
|
2215
2217
|
const row = await this.deps.db
|
|
2216
2218
|
.selectFrom("approvals")
|
package/dist/tools/policy.js
CHANGED
|
@@ -159,6 +159,7 @@ log) {
|
|
|
159
159
|
const mine = await db
|
|
160
160
|
.selectFrom("connector_tool_account_policies")
|
|
161
161
|
.select("policy")
|
|
162
|
+
.where("org_id", "=", ctx.orgId)
|
|
162
163
|
.where("connector_id", "=", tool.source.connectorId)
|
|
163
164
|
.where("account_id", "=", ctx.accountId)
|
|
164
165
|
.where("tool_name", "=", tool.source.name)
|
|
@@ -200,6 +201,7 @@ log) {
|
|
|
200
201
|
.onRef("agent_versions.version", "=", "agents.current_version"))
|
|
201
202
|
.select(["agent_versions.definition"])
|
|
202
203
|
.where("agents.id", "=", ctx.agentId)
|
|
204
|
+
.where("agents.org_id", "=", ctx.orgId)
|
|
203
205
|
.executeTakeFirst();
|
|
204
206
|
const currentDef = current === undefined ? undefined : normalizeStoredDefinition(current.definition);
|
|
205
207
|
const currentPolicies = currentDef?.toolPolicies;
|
|
@@ -340,6 +342,7 @@ async function parentAgentSetting(db, toolKey, policyKey, ctx) {
|
|
|
340
342
|
.innerJoin("agent_versions as v", (j) => j.onRef("v.agent_id", "=", "a.id").onRef("v.version", "=", "a.current_version"))
|
|
341
343
|
.select(["a.id", "v.definition"])
|
|
342
344
|
.where("c.id", "=", ctx.parentConversationId ?? "")
|
|
345
|
+
.where("c.org_id", "=", ctx.orgId)
|
|
343
346
|
.executeTakeFirst();
|
|
344
347
|
if (!row || row.id === ctx.agentId)
|
|
345
348
|
return undefined;
|
|
@@ -110,6 +110,7 @@ let QuestionsService = class QuestionsService {
|
|
|
110
110
|
const row = await t
|
|
111
111
|
.selectFrom("questions")
|
|
112
112
|
.selectAll()
|
|
113
|
+
.where("org_id", "=", input.orgId)
|
|
113
114
|
.where("run_id", "=", input.runId)
|
|
114
115
|
.where("call_id", "=", input.callId)
|
|
115
116
|
.where("attempt", "=", input.attempt)
|
|
@@ -158,6 +159,8 @@ let QuestionsService = class QuestionsService {
|
|
|
158
159
|
return { ...rest, answeredByPerson };
|
|
159
160
|
}
|
|
160
161
|
/** 某个调用的全部输入请求(按轮次升序)。 */
|
|
162
|
+
// org-filter: runId is a runtime run (the pipeline's ctx.runId, or a run id from the
|
|
163
|
+
// conversation's own event log in channel outbound), never caller input
|
|
161
164
|
async forCall(runId, callId) {
|
|
162
165
|
const rows = await this.db
|
|
163
166
|
.selectFrom("questions")
|
|
@@ -201,6 +204,8 @@ let QuestionsService = class QuestionsService {
|
|
|
201
204
|
const row = await q.executeTakeFirst();
|
|
202
205
|
if (!row)
|
|
203
206
|
return false;
|
|
207
|
+
// org-filter: the conversation of the question row read just above (org-filtered when the
|
|
208
|
+
// caller passes orgId; otherwise a kernel-written question id, see expireIn)
|
|
204
209
|
await t
|
|
205
210
|
.selectFrom("conversations")
|
|
206
211
|
.select("id")
|
|
@@ -248,6 +253,8 @@ let QuestionsService = class QuestionsService {
|
|
|
248
253
|
if (problems.length > 0) {
|
|
249
254
|
throw new ApiError("validation_failed", "Answer does not match the form", problems.map((message) => ({ path: "answer", message })));
|
|
250
255
|
}
|
|
256
|
+
// org-filter: by primary key of the question row locked above (in orgId when given; both
|
|
257
|
+
// callers, the HTTP route and IM card actions, pass the caller's org)
|
|
251
258
|
const updated = await t
|
|
252
259
|
.updateTable("questions")
|
|
253
260
|
.set({
|
|
@@ -275,6 +282,7 @@ let QuestionsService = class QuestionsService {
|
|
|
275
282
|
}
|
|
276
283
|
return r.record ? { outcome: r.outcome, record: r.record } : { outcome: r.outcome };
|
|
277
284
|
}
|
|
285
|
+
// org-filter: questionId comes from the kernel-written timeout job payload (Waits), not caller input
|
|
278
286
|
async expireIn(questionId) {
|
|
279
287
|
const t = this.db.db;
|
|
280
288
|
if (!(await this.lockConversationOf(questionId)))
|
|
@@ -306,6 +314,8 @@ let QuestionsService = class QuestionsService {
|
|
|
306
314
|
* 在调用方的事务内(`mandatory`)取消运行的全部 pending 输入请求(运行在等待中被中止),各写
|
|
307
315
|
* `question_answered{cancelled}`。返回被取消的记录;调用方提交后发布事件。
|
|
308
316
|
*/
|
|
317
|
+
// org-filter: runId is the run the kernel is stopping or finishing (Waits, RunFinish), not caller
|
|
318
|
+
// input
|
|
309
319
|
async cancelPendingIn(runId) {
|
|
310
320
|
const t = this.db.db;
|
|
311
321
|
const rows = await t
|
|
@@ -378,6 +388,7 @@ let QuestionsService = class QuestionsService {
|
|
|
378
388
|
.updateTable("questions")
|
|
379
389
|
.set({ status: "cancelled", answered_at: sql `now()` })
|
|
380
390
|
.where("id", "=", row.id)
|
|
391
|
+
.where("org_id", "=", orgId)
|
|
381
392
|
.returningAll()
|
|
382
393
|
.executeTakeFirstOrThrow();
|
|
383
394
|
const seq = await this.answeredEvent(toRecord(row), null, null, "cancelled");
|
|
@@ -398,6 +409,8 @@ let QuestionsService = class QuestionsService {
|
|
|
398
409
|
* the highest seq written (null: none); the caller notifies and emits `question.answered` after
|
|
399
410
|
* the commit.
|
|
400
411
|
*/
|
|
412
|
+
// org-filter: conversationId is the conversation the caller just wrote the person's message in and
|
|
413
|
+
// holds locked (ConversationsService, checked in its org); the rows are that conversation's
|
|
401
414
|
async skipPendingIn(conversationId, accountId, messageSeq) {
|
|
402
415
|
const t = this.db.db;
|
|
403
416
|
const rows = await t
|
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.78",
|
|
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": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"yaml": "^2.9.1",
|
|
67
67
|
"yauzl": "3.4.0",
|
|
68
68
|
"zod": "^4.6.7",
|
|
69
|
-
"@capybara-hq/plugin-sdk": "^0.1.0-rc.
|
|
69
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.64"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@langchain/langgraph-checkpoint-validation": "^1.2.0",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@types/ws": "^8.18.2",
|
|
76
76
|
"@types/yauzl": "3.4.0",
|
|
77
77
|
"ws": "^8.22.0",
|
|
78
|
-
"@capybara-hq/testing": "0.1.0-rc.
|
|
78
|
+
"@capybara-hq/testing": "0.1.0-rc.38"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"build": "tsc -b"
|