@capybara-hq/kernel 0.1.0-rc.77 → 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 +17 -2
- package/dist/extensions/bootstrap.js +41 -9
- 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/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
package/bootstrap.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"schemaVersion": 1,
|
|
4
4
|
"marketplace": {
|
|
5
5
|
"url": "https://github.com/capybara-hq/plugins.git",
|
|
6
|
-
"commit": "
|
|
6
|
+
"commit": "03a53c895cc9993306203fc0d41a6cc71acc3107"
|
|
7
7
|
},
|
|
8
8
|
"plugins": [
|
|
9
9
|
{
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"npm": "@capybara-hq/plugin-openai-compatible",
|
|
13
13
|
"version": "0.1.0-rc.11",
|
|
14
14
|
"integrity": "sha512-xhLYmzgzC6I8VAx/xzGSrW53On9hVT9aXrNJaeLYBMVr84lY765MZ6P6qt5hDhHIH13sxyfaCf+3FQ6muc4U/w==",
|
|
15
|
-
"required":
|
|
15
|
+
"required": false
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"name": "object-store-s3",
|
|
@@ -90,16 +90,16 @@
|
|
|
90
90
|
"name": "device-docker",
|
|
91
91
|
"source": "npm",
|
|
92
92
|
"npm": "@capybara-hq/plugin-device-docker",
|
|
93
|
-
"version": "0.1.0-rc.
|
|
94
|
-
"integrity": "sha512-
|
|
93
|
+
"version": "0.1.0-rc.25",
|
|
94
|
+
"integrity": "sha512-2ooWuxVKvGoXWNQTpEwwFRZP2/qUiPvihP/858VDwiRqkEU9DY3zsf2QrcIOUeL6NcjGhNRWsz6r5ReKdXUc8w==",
|
|
95
95
|
"required": false
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
98
|
"name": "device-local",
|
|
99
99
|
"source": "npm",
|
|
100
100
|
"npm": "@capybara-hq/plugin-device-local",
|
|
101
|
-
"version": "0.1.0-rc.
|
|
102
|
-
"integrity": "sha512-
|
|
101
|
+
"version": "0.1.0-rc.7",
|
|
102
|
+
"integrity": "sha512-IGhfG42LMy8Rf95vHEjGKkEHHhASClFvPZZnLZAHjdHr6fqox6z2q1c4Kn1BRee2kSVT31AOw8hiTurfIXyalA==",
|
|
103
103
|
"required": false,
|
|
104
104
|
"scope": "all"
|
|
105
105
|
},
|
|
@@ -239,7 +239,10 @@ __decorate([
|
|
|
239
239
|
Transactional()
|
|
240
240
|
], OutboxDeadService.prototype, "discard", null);
|
|
241
241
|
OutboxDeadService = __decorate([
|
|
242
|
-
Injectable()
|
|
242
|
+
Injectable()
|
|
243
|
+
// org-filter: super-admin service (callers authorize through SuperAdminLock / admin routes); the
|
|
244
|
+
// outbox is deployment-wide and every dead row of every org is listed and handled on purpose
|
|
245
|
+
,
|
|
243
246
|
__param(0, Inject(TransactionHost)),
|
|
244
247
|
__param(1, Inject(KernelDb)),
|
|
245
248
|
__param(2, Inject(OUTBOX_FAST_PATH)),
|
|
@@ -109,6 +109,8 @@ let AdminAgents = class AdminAgents {
|
|
|
109
109
|
const db = this.db.db;
|
|
110
110
|
const builtinPlugins = await builtinSkillPlugins(db);
|
|
111
111
|
const agentIds = [...byOrg.values()].flat().map((a) => a.id);
|
|
112
|
+
// org-filter: super admin's cross-org agent list; skills are matched by the agent ids loaded
|
|
113
|
+
// across orgs above (origin_agent_id is unique to one org's agent), not by caller input
|
|
112
114
|
const sharedRows = await db
|
|
113
115
|
.selectFrom("skills")
|
|
114
116
|
.select(["id", "origin_agent_id"])
|
|
@@ -61,6 +61,8 @@ export function visibleTo(viewerAccountId) {
|
|
|
61
61
|
* the live org). Deleted agents are never visible.
|
|
62
62
|
*/
|
|
63
63
|
export async function isAgentVisibleTo(db, agentId, accountId) {
|
|
64
|
+
// org-filter: visibleTo requires the account's membership in the agent's own org; callers load
|
|
65
|
+
// the agent with their org filter first (isAgentVisibleIn is the org-pinned variant)
|
|
64
66
|
const row = await db
|
|
65
67
|
.selectFrom("agents")
|
|
66
68
|
.select("id")
|
|
@@ -132,6 +134,8 @@ let AgentLookup = class AgentLookup {
|
|
|
132
134
|
return v;
|
|
133
135
|
}
|
|
134
136
|
/** 按给定 id 顺序组装视图(调用方已完成可见性判定)。 */
|
|
137
|
+
// org-filter: assembles views for ids the caller already resolved with its org and visibility
|
|
138
|
+
// filter (get / listVisible and the services' own org-filtered reads)
|
|
135
139
|
async views(ids) {
|
|
136
140
|
if (ids.length === 0)
|
|
137
141
|
return [];
|
|
@@ -69,6 +69,7 @@ let AgentProfileService = class AgentProfileService {
|
|
|
69
69
|
.selectFrom("agents")
|
|
70
70
|
.select(sql `to_char(profile_updated_at at time zone 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"')`.as("at"))
|
|
71
71
|
.where("id", "=", agentId)
|
|
72
|
+
.where("org_id", "=", orgId)
|
|
72
73
|
.executeTakeFirstOrThrow();
|
|
73
74
|
if (current.at !== expectedUpdatedAt) {
|
|
74
75
|
throw new ApiError("agent.profile_conflict", "The profile was changed by someone else; reload it and apply your changes again");
|
|
@@ -92,6 +93,7 @@ let AgentProfileService = class AgentProfileService {
|
|
|
92
93
|
profile_updated_at: sql `greatest(date_trunc('milliseconds', now()), profile_updated_at + interval '1 millisecond')`,
|
|
93
94
|
})
|
|
94
95
|
.where("id", "=", agentId)
|
|
96
|
+
.where("org_id", "=", orgId)
|
|
95
97
|
.execute();
|
|
96
98
|
if (patch.avatar !== undefined) {
|
|
97
99
|
// the avatar changed: every other upload bound to this agent is garbage; the cleanup job
|
|
@@ -99,6 +101,7 @@ let AgentProfileService = class AgentProfileService {
|
|
|
99
101
|
await t
|
|
100
102
|
.updateTable("attachments")
|
|
101
103
|
.set({ expires_at: sql `now()` })
|
|
104
|
+
.where("org_id", "=", orgId)
|
|
102
105
|
.where("agent_id", "=", agentId)
|
|
103
106
|
.where("purpose", "=", "agent-avatar")
|
|
104
107
|
.$if(patch.avatar?.kind === "upload", (q) => q.where("id", "<>", patch.avatar.uploadId))
|
|
@@ -577,6 +577,7 @@ let AgentsService = class AgentsService {
|
|
|
577
577
|
.selectFrom("agents")
|
|
578
578
|
.select("id")
|
|
579
579
|
.where("id", "=", agentId)
|
|
580
|
+
.where("org_id", "=", orgId)
|
|
580
581
|
.where(visibleTo(actorAccountId))
|
|
581
582
|
.executeTakeFirst();
|
|
582
583
|
if (!visible)
|
|
@@ -608,6 +609,7 @@ let AgentsService = class AgentsService {
|
|
|
608
609
|
* deleted org → `agent.not_found`. The super admin check is the caller's (`@SuperAdmin()`).
|
|
609
610
|
*/
|
|
610
611
|
async lockForPlatform(agentId) {
|
|
612
|
+
// org-filter: platform path (super admin, checked by the caller): finds the agent's org
|
|
611
613
|
const found = await this.db.db
|
|
612
614
|
.selectFrom("agents")
|
|
613
615
|
.select("org_id")
|
|
@@ -660,6 +662,7 @@ let AgentsService = class AgentsService {
|
|
|
660
662
|
.updateTable("agents")
|
|
661
663
|
.set({ profile_description: definition.description ?? "" })
|
|
662
664
|
.where("id", "=", agentId)
|
|
665
|
+
.where("org_id", "=", orgId)
|
|
663
666
|
.execute();
|
|
664
667
|
}
|
|
665
668
|
// what the current version already turns off is not checked again (skills default-on §4)
|
|
@@ -714,6 +717,7 @@ let AgentsService = class AgentsService {
|
|
|
714
717
|
.updateTable("agents")
|
|
715
718
|
.set({ visibility, current_version: toVersion, updated_at: sql `now()` })
|
|
716
719
|
.where("id", "=", agentId)
|
|
720
|
+
.where("org_id", "=", orgId)
|
|
717
721
|
.execute();
|
|
718
722
|
await audit(t, {
|
|
719
723
|
actorAccountId,
|
|
@@ -768,11 +772,13 @@ let AgentsService = class AgentsService {
|
|
|
768
772
|
.updateTable("agents")
|
|
769
773
|
.set({ deleted_at: sql `now()`, updated_at: sql `now()` })
|
|
770
774
|
.where("id", "=", agentId)
|
|
775
|
+
.where("org_id", "=", orgId)
|
|
771
776
|
.execute();
|
|
772
777
|
// the avatar upload is garbage now: the cleanup job deletes it (and its object) once expired
|
|
773
778
|
await t
|
|
774
779
|
.updateTable("attachments")
|
|
775
780
|
.set({ expires_at: sql `now()` })
|
|
781
|
+
.where("org_id", "=", orgId)
|
|
776
782
|
.where("agent_id", "=", agentId)
|
|
777
783
|
.where("purpose", "=", "agent-avatar")
|
|
778
784
|
.execute();
|
|
@@ -836,6 +842,7 @@ let AgentsService = class AgentsService {
|
|
|
836
842
|
.updateTable("agents")
|
|
837
843
|
.set({ owner_account_id: newOwnerId, needs_reassignment: false, updated_at: sql `now()` })
|
|
838
844
|
.where("id", "=", agentId)
|
|
845
|
+
.where("org_id", "=", orgId)
|
|
839
846
|
.execute();
|
|
840
847
|
// the new owner hears about the agent's connector setup request (P4-T6-4)
|
|
841
848
|
await this.setupRequests.retargetIn([agentId], newOwnerId);
|
|
@@ -885,6 +885,7 @@ let OrgAgentTemplates = class OrgAgentTemplates {
|
|
|
885
885
|
.selectFrom("agent_templates")
|
|
886
886
|
.select("platform_template_id")
|
|
887
887
|
.where("id", "=", t.id)
|
|
888
|
+
.where("org_id", "=", orgId)
|
|
888
889
|
.executeTakeFirst())?.platform_template_id ??
|
|
889
890
|
null;
|
|
890
891
|
if (pid !== null) {
|
|
@@ -22,6 +22,8 @@ import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
|
22
22
|
export async function retargetSetupRequests(db, agentIds, owner) {
|
|
23
23
|
if (agentIds.length === 0)
|
|
24
24
|
return;
|
|
25
|
+
// org-filter: the agent ids were resolved in the caller's org (owner change, offboarding) and a
|
|
26
|
+
// setup request lives in its agent's org
|
|
25
27
|
await db
|
|
26
28
|
.updateTable("catalog_requests")
|
|
27
29
|
.set({ requested_by: owner })
|
|
@@ -129,6 +131,7 @@ let PendingConnectorRequests = class PendingConnectorRequests {
|
|
|
129
131
|
const existing = await t
|
|
130
132
|
.selectFrom("catalog_requests")
|
|
131
133
|
.select("id")
|
|
134
|
+
.where("org_id", "=", a.orgId)
|
|
132
135
|
.where("agent_id", "=", a.agentId)
|
|
133
136
|
.where("kind", "=", "connector_setup")
|
|
134
137
|
.where("status", "=", "pending")
|
|
@@ -157,6 +160,7 @@ let PendingConnectorRequests = class PendingConnectorRequests {
|
|
|
157
160
|
const row = await t
|
|
158
161
|
.selectFrom("catalog_requests")
|
|
159
162
|
.select(["id", "pending_keys", "requested_by"])
|
|
163
|
+
.where("org_id", "=", a.orgId)
|
|
160
164
|
.where("agent_id", "=", a.agentId)
|
|
161
165
|
.where("kind", "=", "connector_setup")
|
|
162
166
|
.where("status", "=", "pending")
|
|
@@ -172,6 +176,7 @@ let PendingConnectorRequests = class PendingConnectorRequests {
|
|
|
172
176
|
.updateTable("catalog_requests")
|
|
173
177
|
.set({ pending_keys: JSON.stringify(left) })
|
|
174
178
|
.where("id", "=", row.id)
|
|
179
|
+
.where("org_id", "=", a.orgId)
|
|
175
180
|
.execute();
|
|
176
181
|
}
|
|
177
182
|
return;
|
|
@@ -187,6 +192,7 @@ let PendingConnectorRequests = class PendingConnectorRequests {
|
|
|
187
192
|
row.requested_by === a.actor && { dismissed_at: sql `now()` }),
|
|
188
193
|
})
|
|
189
194
|
.where("id", "=", row.id)
|
|
195
|
+
.where("org_id", "=", a.orgId)
|
|
190
196
|
.execute();
|
|
191
197
|
await audit(t, {
|
|
192
198
|
actorAccountId: a.actor,
|
|
@@ -166,6 +166,7 @@ let PendingConnectorsService = class PendingConnectorsService {
|
|
|
166
166
|
.updateTable("agents")
|
|
167
167
|
.set({ current_version: toVersion, updated_at: sql `now()` })
|
|
168
168
|
.where("id", "=", agentId)
|
|
169
|
+
.where("org_id", "=", orgId)
|
|
169
170
|
.execute();
|
|
170
171
|
await audit(t, {
|
|
171
172
|
actorAccountId: actor,
|
|
@@ -208,6 +209,7 @@ let PendingConnectorsService = class PendingConnectorsService {
|
|
|
208
209
|
.selectFrom("agents")
|
|
209
210
|
.select("owner_account_id")
|
|
210
211
|
.where("id", "=", agentId)
|
|
212
|
+
.where("org_id", "=", orgId)
|
|
211
213
|
.executeTakeFirstOrThrow();
|
|
212
214
|
const r = await this.requests.open({
|
|
213
215
|
orgId,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { type LocalizedName } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { ExtensionDisplayNames } from "../extensions/display-name.js";
|
|
3
|
-
import { OrgExtensionConfigs } from "../extensions/org-config.js";
|
|
3
|
+
import { OrgExtensionConfigs, type OrgExtensionView } from "../extensions/org-config.js";
|
|
4
4
|
import { type ListErrorKind, ProviderRegistry } from "../runtime/providers.js";
|
|
5
5
|
import { AgentsService } from "./agents.service.js";
|
|
6
6
|
/**
|
|
7
7
|
* A model provider an org admin can make usable on `/settings/models`, and what it waits for:
|
|
8
8
|
* `not_enabled`, the org has not switched it on (it may also need the org's config then);
|
|
9
|
-
* `needs_config`, it is on but waits for the org's own
|
|
10
|
-
*
|
|
9
|
+
* `needs_config`, it is on but waits for the org's own copy of an overridable deployment field
|
|
10
|
+
* the platform left empty.
|
|
11
11
|
*/
|
|
12
12
|
export interface OrgFixableProvider {
|
|
13
13
|
provider: string;
|
|
@@ -53,6 +53,12 @@ export interface OrgReadiness {
|
|
|
53
53
|
/** The agents the caller can see (the agent list's visibility). */
|
|
54
54
|
agents: number;
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* What the org admin must do to make `v` usable here, or null when they cannot (or need not). The
|
|
58
|
+
* view comes from the org's extension list, which shows an extension only when it is offered to
|
|
59
|
+
* the org (`offeredToOrg`): not named to other orgs only, not disabled while off.
|
|
60
|
+
*/
|
|
61
|
+
export declare function fixOf(v: OrgExtensionView): OrgFixableProvider["reason"] | null;
|
|
56
62
|
/**
|
|
57
63
|
* Whether the org can run (web-order spec §3.8), the one place it is computed (the readiness
|
|
58
64
|
* route and the `agents.readiness` operation): the web app decides between the shell and the setup
|
|
@@ -15,14 +15,14 @@ import { ProviderRegistry } from "../runtime/providers.js";
|
|
|
15
15
|
import { AgentsService } from "./agents.service.js";
|
|
16
16
|
const MODEL_PROVIDER = parseExtensionPoint(MODEL_PROVIDER_EXTENSION_POINT_V2).name;
|
|
17
17
|
const isModelProvider = (v) => providesOf(v).some((ref) => parseExtensionPoint(ref).name === MODEL_PROVIDER);
|
|
18
|
-
/** The org can fill the config the extension waits for:
|
|
19
|
-
const orgCanConfigure = (v) => v.configurable
|
|
18
|
+
/** The org can fill the config the extension waits for: it has an overridable field. */
|
|
19
|
+
const orgCanConfigure = (v) => v.configurable;
|
|
20
20
|
/**
|
|
21
21
|
* What the org admin must do to make `v` usable here, or null when they cannot (or need not). The
|
|
22
22
|
* view comes from the org's extension list, which shows an extension only when it is offered to
|
|
23
23
|
* the org (`offeredToOrg`): not named to other orgs only, not disabled while off.
|
|
24
24
|
*/
|
|
25
|
-
function fixOf(v) {
|
|
25
|
+
export function fixOf(v) {
|
|
26
26
|
if (!v.available)
|
|
27
27
|
return null;
|
|
28
28
|
if (!v.enabled)
|
package/dist/agents/templates.js
CHANGED
|
@@ -74,6 +74,7 @@ let BackgroundTaskFinisher = class BackgroundTaskFinisher {
|
|
|
74
74
|
.selectFrom("sandbox_operation_intents")
|
|
75
75
|
.select("operation_id")
|
|
76
76
|
.where("operation_id", "=", task.operationId)
|
|
77
|
+
.where("org_id", "=", task.orgId)
|
|
77
78
|
.forUpdate()
|
|
78
79
|
.executeTakeFirst();
|
|
79
80
|
if (!(await this.store.finish(task.id, to, {
|
|
@@ -86,6 +87,7 @@ let BackgroundTaskFinisher = class BackgroundTaskFinisher {
|
|
|
86
87
|
.updateTable("sandbox_operation_intents")
|
|
87
88
|
.set({ state: "completed", updated_at: new Date() })
|
|
88
89
|
.where("operation_id", "=", task.operationId)
|
|
90
|
+
.where("org_id", "=", task.orgId)
|
|
89
91
|
.where("state", "=", "background-running")
|
|
90
92
|
.execute();
|
|
91
93
|
// A lost end (supervision lost, instance gone or replaced) is no proof the process is gone:
|
|
@@ -96,6 +98,7 @@ let BackgroundTaskFinisher = class BackgroundTaskFinisher {
|
|
|
96
98
|
.updateTable("sandbox_operation_intents")
|
|
97
99
|
.set({ state: "revoked", outcome_unknown: true, updated_at: new Date() })
|
|
98
100
|
.where("operation_id", "=", task.operationId)
|
|
101
|
+
.where("org_id", "=", task.orgId)
|
|
99
102
|
.where("state", "=", "background-running")
|
|
100
103
|
.returning("operation_id")
|
|
101
104
|
.executeTakeFirst();
|
package/dist/background/stop.js
CHANGED
|
@@ -122,6 +122,7 @@ let BackgroundTaskStopper = class BackgroundTaskStopper {
|
|
|
122
122
|
.selectFrom("conversations")
|
|
123
123
|
.select(["id", "deleted_at"])
|
|
124
124
|
.where("id", "in", ids)
|
|
125
|
+
.where("org_id", "=", cur.orgId)
|
|
125
126
|
.execute(),
|
|
126
127
|
this.db.db
|
|
127
128
|
.selectFrom("orgs")
|
|
@@ -218,6 +219,7 @@ let BackgroundTaskStopper = class BackgroundTaskStopper {
|
|
|
218
219
|
*/
|
|
219
220
|
async stopSubagentTasks(conversationId, runId) {
|
|
220
221
|
try {
|
|
222
|
+
// org-filter: conversationId is kernel-supplied (the run that just ended), not caller input
|
|
221
223
|
const conv = await this.db
|
|
222
224
|
.selectFrom("conversations")
|
|
223
225
|
.select("kind")
|
package/dist/background/store.js
CHANGED
|
@@ -87,6 +87,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
87
87
|
*/
|
|
88
88
|
async reserveManaged(row, maxTasks) {
|
|
89
89
|
await this.launchLock.lock(row.sandboxConversationId);
|
|
90
|
+
// org-filter: launch reservation keyed by the launching run's run id and call id (kernel-
|
|
91
|
+
// supplied by the Bash tool call)
|
|
90
92
|
const previous = await this.db
|
|
91
93
|
.selectFrom("background_tasks")
|
|
92
94
|
.selectAll()
|
|
@@ -130,6 +132,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
130
132
|
* when `executionId` is still the run's current execution claim.
|
|
131
133
|
* A dispatched row is never failed here: a null reference is no proof that nothing launched.
|
|
132
134
|
*/
|
|
135
|
+
// org-filter: by task id: callers check ownership first (ownedTask: the calling conversation;
|
|
136
|
+
// TasksService.owned: org and conversation scope) or pass the id of a row they already read
|
|
133
137
|
async failManagedPreEffect(id, reason, executionId) {
|
|
134
138
|
const r = await this.db
|
|
135
139
|
.updateTable("background_tasks")
|
|
@@ -155,6 +159,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
155
159
|
* Claims a running task for a stop (`stopping_at`): false when it is no longer running or another
|
|
156
160
|
* live stop claimed it ({@link STOP_CLAIM_TTL_MS}). While claimed the poller leaves it alone.
|
|
157
161
|
*/
|
|
162
|
+
// org-filter: by task id: callers check ownership first (ownedTask: the calling conversation;
|
|
163
|
+
// TasksService.owned: org and conversation scope) or pass the id of a row they already read
|
|
158
164
|
async claimStop(id) {
|
|
159
165
|
const r = await this.db
|
|
160
166
|
.updateTable("background_tasks")
|
|
@@ -166,6 +172,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
166
172
|
return Number(r.numUpdatedRows) > 0;
|
|
167
173
|
}
|
|
168
174
|
/** Gives up a stop's claim (the stop failed while the sandbox runs: the task keeps running). */
|
|
175
|
+
// org-filter: by task id: callers check ownership first (ownedTask: the calling conversation;
|
|
176
|
+
// TasksService.owned: org and conversation scope) or pass the id of a row they already read
|
|
169
177
|
async releaseStop(id) {
|
|
170
178
|
await this.db
|
|
171
179
|
.updateTable("background_tasks")
|
|
@@ -185,6 +193,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
185
193
|
* Returns the rows it finished (their owner and sandbox conversations, for the caller's
|
|
186
194
|
* `changed: "background"` frames).
|
|
187
195
|
*/
|
|
196
|
+
// org-filter: deployment-wide background-task poller sweep across all orgs; each row is
|
|
197
|
+
// handled in its own org
|
|
188
198
|
async failAbandonedLaunches(before) {
|
|
189
199
|
const r = await this.db
|
|
190
200
|
.updateTable("background_tasks")
|
|
@@ -240,6 +250,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
240
250
|
.execute();
|
|
241
251
|
}
|
|
242
252
|
/** The managed task launched by start operation `operationId`, if its row still exists. */
|
|
253
|
+
// org-filter: by start operation id read from a kernel-written row (operation intent or
|
|
254
|
+
// retirement marker), not caller input
|
|
243
255
|
async byOperation(operationId) {
|
|
244
256
|
const r = await this.db
|
|
245
257
|
.selectFrom("background_tasks")
|
|
@@ -252,6 +264,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
252
264
|
* A finished managed task whose owed cancellation was later established by its exact ref (the
|
|
253
265
|
* revoke worker): its record becomes `terminal`. Its finish and event stay as they were.
|
|
254
266
|
*/
|
|
267
|
+
// org-filter: by task id: callers check ownership first (ownedTask: the calling conversation;
|
|
268
|
+
// TasksService.owned: org and conversation scope) or pass the id of a row they already read
|
|
255
269
|
async settleOwedCancel(id) {
|
|
256
270
|
await this.db
|
|
257
271
|
.updateTable("background_tasks")
|
|
@@ -261,6 +275,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
261
275
|
.where("launch_state", "=", "cancel-pending")
|
|
262
276
|
.execute();
|
|
263
277
|
}
|
|
278
|
+
// org-filter: by task id: callers check ownership first (ownedTask: the calling conversation;
|
|
279
|
+
// TasksService.owned: org and conversation scope) or pass the id of a row they already read
|
|
264
280
|
async get(id) {
|
|
265
281
|
const r = await this.db
|
|
266
282
|
.selectFrom("background_tasks")
|
|
@@ -270,6 +286,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
270
286
|
return r === undefined ? undefined : toRow(r);
|
|
271
287
|
}
|
|
272
288
|
/** The running tasks of one root conversation's tree, oldest first. */
|
|
289
|
+
// org-filter: by conversation id the caller already resolved in its org (the tool call's
|
|
290
|
+
// conversation, TasksService.scope(orgId, ...), or a kernel launch / deletion path)
|
|
273
291
|
async runningIn(sandboxConversationId) {
|
|
274
292
|
const rows = await this.db
|
|
275
293
|
.selectFrom("background_tasks")
|
|
@@ -287,6 +305,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
287
305
|
* exec). A legacy reservation that never started is failed as abandoned, a claimed task is left
|
|
288
306
|
* to its stop.
|
|
289
307
|
*/
|
|
308
|
+
// org-filter: deployment-wide background-task poller sweep across all orgs; each row is
|
|
309
|
+
// handled in its own org
|
|
290
310
|
async runningLegacy() {
|
|
291
311
|
const rows = await this.db
|
|
292
312
|
.selectFrom("background_tasks")
|
|
@@ -304,6 +324,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
304
324
|
* Every running acknowledged managed task with no live stop claim, oldest first: what the
|
|
305
325
|
* poller checks by exact status.
|
|
306
326
|
*/
|
|
327
|
+
// org-filter: deployment-wide background-task poller sweep across all orgs; each row is
|
|
328
|
+
// handled in its own org
|
|
307
329
|
async runningManaged() {
|
|
308
330
|
const rows = await this.db
|
|
309
331
|
.selectFrom("background_tasks")
|
|
@@ -322,6 +344,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
322
344
|
* claim), least recently attempted first. A task whose recorded instance is suspended is left
|
|
323
345
|
* out: a stop never resumes it, so it cannot progress there.
|
|
324
346
|
*/
|
|
347
|
+
// org-filter: deployment-wide background-task poller sweep across all orgs; each row is
|
|
348
|
+
// handled in its own org
|
|
325
349
|
async owedCancels() {
|
|
326
350
|
const rows = await this.db
|
|
327
351
|
.selectFrom("background_tasks")
|
|
@@ -339,6 +363,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
339
363
|
return rows.map(toRow);
|
|
340
364
|
}
|
|
341
365
|
/** Records that an exact stop of the task is being attempted now (its owed-stop turn moves back). */
|
|
366
|
+
// org-filter: by task id: callers check ownership first (ownedTask: the calling conversation;
|
|
367
|
+
// TasksService.owned: org and conversation scope) or pass the id of a row they already read
|
|
342
368
|
async noteCancelAttempt(id) {
|
|
343
369
|
await this.db
|
|
344
370
|
.updateTable("background_tasks")
|
|
@@ -353,6 +379,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
353
379
|
* is given up, so the poller owes the exact stop; without, the claim stays (a task without its
|
|
354
380
|
* ref yet: the dispatch binding or the acknowledgement turns the claim into the owed cancel).
|
|
355
381
|
*/
|
|
382
|
+
// org-filter: by task id: callers check ownership first (ownedTask: the calling conversation;
|
|
383
|
+
// TasksService.owned: org and conversation scope) or pass the id of a row they already read
|
|
356
384
|
async requestCancel(id, by, release) {
|
|
357
385
|
await this.db
|
|
358
386
|
.updateTable("background_tasks")
|
|
@@ -370,6 +398,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
370
398
|
.execute();
|
|
371
399
|
}
|
|
372
400
|
/** The running tasks one conversation owns (not those of its sub-agents), oldest first. */
|
|
401
|
+
// org-filter: by conversation id the caller already resolved in its org (the tool call's
|
|
402
|
+
// conversation, TasksService.scope(orgId, ...), or a kernel launch / deletion path)
|
|
373
403
|
async runningOwnedBy(conversationId) {
|
|
374
404
|
const rows = await this.db
|
|
375
405
|
.selectFrom("background_tasks")
|
|
@@ -385,6 +415,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
385
415
|
* The finished tasks one conversation owns (not those of its sub-agents), the most recently
|
|
386
416
|
* finished first, at most `limit` of them, with how many it owns in all (`TaskList`).
|
|
387
417
|
*/
|
|
418
|
+
// org-filter: by conversation id the caller already resolved in its org (the tool call's
|
|
419
|
+
// conversation, TasksService.scope(orgId, ...), or a kernel launch / deletion path)
|
|
388
420
|
async finishedOwnedBy(conversationId, limit) {
|
|
389
421
|
const [rows, count] = await Promise.all([
|
|
390
422
|
this.db
|
|
@@ -406,6 +438,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
406
438
|
return { rows: rows.map(toRow), total: Number(count.n) };
|
|
407
439
|
}
|
|
408
440
|
/** The running tasks of one root conversation's tree (what `maxTasks` limits). */
|
|
441
|
+
// org-filter: by conversation id the caller already resolved in its org (the tool call's
|
|
442
|
+
// conversation, TasksService.scope(orgId, ...), or a kernel launch / deletion path)
|
|
409
443
|
async countRunning(sandboxConversationId) {
|
|
410
444
|
const r = await this.db
|
|
411
445
|
.selectFrom("background_tasks")
|
|
@@ -416,6 +450,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
416
450
|
return Number(r.n);
|
|
417
451
|
}
|
|
418
452
|
/** The tasks owned by any of the conversations, newest first. */
|
|
453
|
+
// org-filter: by conversation id the caller already resolved in its org (the tool call's
|
|
454
|
+
// conversation, TasksService.scope(orgId, ...), or a kernel launch / deletion path)
|
|
419
455
|
async listFor(conversationIds) {
|
|
420
456
|
if (conversationIds.length === 0)
|
|
421
457
|
return [];
|
|
@@ -434,6 +470,9 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
434
470
|
* The caller's transaction also appends the finished event.
|
|
435
471
|
*/
|
|
436
472
|
async finish(id, to, opts = {}) {
|
|
473
|
+
// org-filter: by task id: callers check ownership first (ownedTask: the calling
|
|
474
|
+
// conversation; TasksService.owned: org and conversation scope) or pass the id of a row
|
|
475
|
+
// they already read
|
|
437
476
|
let q = this.db
|
|
438
477
|
.updateTable("background_tasks")
|
|
439
478
|
.set({
|
|
@@ -457,6 +496,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
457
496
|
return Number(r.numUpdatedRows) > 0;
|
|
458
497
|
}
|
|
459
498
|
/** Moves the read offset forward only (a concurrent reader never moves it back). */
|
|
499
|
+
// org-filter: by task id: callers check ownership first (ownedTask: the calling conversation;
|
|
500
|
+
// TasksService.owned: org and conversation scope) or pass the id of a row they already read
|
|
460
501
|
async advanceOffset(id, to) {
|
|
461
502
|
await this.db
|
|
462
503
|
.updateTable("background_tasks")
|
|
@@ -465,6 +506,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
465
506
|
.where(sql `read_offset < ${to}`)
|
|
466
507
|
.execute();
|
|
467
508
|
}
|
|
509
|
+
// org-filter: by task id: callers check ownership first (ownedTask: the calling conversation;
|
|
510
|
+
// TasksService.owned: org and conversation scope) or pass the id of a row they already read
|
|
468
511
|
async clearKill(ids) {
|
|
469
512
|
if (ids.length === 0)
|
|
470
513
|
return;
|
|
@@ -479,6 +522,7 @@ let BackgroundTaskStore = class BackgroundTaskStore {
|
|
|
479
522
|
* managed record whose launch or cancellation is still uncertain (only `legacy` and settled
|
|
480
523
|
* `terminal` rows go).
|
|
481
524
|
*/
|
|
525
|
+
// org-filter: deployment-wide retention sweep across all orgs (finished rows past their age)
|
|
482
526
|
async pruneFinished(before) {
|
|
483
527
|
const r = await this.db
|
|
484
528
|
.deleteFrom("background_tasks")
|
|
@@ -159,7 +159,7 @@ let BackgroundTasks = class BackgroundTasks {
|
|
|
159
159
|
return { ...read.value, source: "live" };
|
|
160
160
|
const unavailable = {
|
|
161
161
|
reason: read.reason,
|
|
162
|
-
provider: await this.providerOf(task.deviceId),
|
|
162
|
+
provider: await this.providerOf(task.orgId, task.deviceId),
|
|
163
163
|
};
|
|
164
164
|
if (task.status !== "running") {
|
|
165
165
|
const ev = await this.eventLog.findByIdem(task.conversationId, finishedEventKey(task.id));
|
|
@@ -170,13 +170,14 @@ let BackgroundTasks = class BackgroundTasks {
|
|
|
170
170
|
throw new ApiError("background_task.output_unavailable", `The task's output cannot be read now (${unavailable.reason})`, [unavailable]);
|
|
171
171
|
}
|
|
172
172
|
/** The provider of the device the task ran on (`devices.provider`); null when none is known. */
|
|
173
|
-
async providerOf(deviceId) {
|
|
173
|
+
async providerOf(orgId, deviceId) {
|
|
174
174
|
if (deviceId === null)
|
|
175
175
|
return null;
|
|
176
176
|
const row = await this.db.db
|
|
177
177
|
.selectFrom("devices")
|
|
178
178
|
.select("provider")
|
|
179
179
|
.where("id", "=", deviceId)
|
|
180
|
+
.where("org_id", "=", orgId)
|
|
180
181
|
.executeTakeFirst();
|
|
181
182
|
return row?.provider ?? null;
|
|
182
183
|
}
|
|
@@ -86,6 +86,7 @@ export async function wakeDecisionIn(t, conv, consumed, deploymentOn, canSend) {
|
|
|
86
86
|
.selectFrom("conversations")
|
|
87
87
|
.select(["queue_paused", "deleted_at", "tree_stopped_at"])
|
|
88
88
|
.where("id", "=", conv.rootId)
|
|
89
|
+
.where("org_id", "=", conv.orgId)
|
|
89
90
|
.executeTakeFirst();
|
|
90
91
|
if (!root || root.queue_paused || !isLive(root.deleted_at))
|
|
91
92
|
return null;
|
|
@@ -165,6 +165,12 @@ export declare class AdminCatalogController {
|
|
|
165
165
|
* `sendCatalogIcon`). No icon -> 404 `catalog.icon_not_found`.
|
|
166
166
|
*/
|
|
167
167
|
icon(id: string, reply: FastifyReply): Promise<void>;
|
|
168
|
+
/**
|
|
169
|
+
* A platform connector template's own icon (any live template; same response headers as the
|
|
170
|
+
* item icon). Unknown template -> 404 `component.not_found`; no icon of its own -> 404
|
|
171
|
+
* `catalog.icon_not_found`.
|
|
172
|
+
*/
|
|
173
|
+
templateIcon(templateId: string, reply: FastifyReply): Promise<void>;
|
|
168
174
|
/**
|
|
169
175
|
* A setup guide of the item as the platform sees it (spec 2026-11-09-setup-guides-v2-design.md
|
|
170
176
|
* §9.3; the admin console's connector template page): any live item, the admin audience, no org
|
|
@@ -255,6 +255,14 @@ let AdminCatalogController = class AdminCatalogController {
|
|
|
255
255
|
async icon(id, reply) {
|
|
256
256
|
await sendCatalogIcon(reply, await this.orgCatalog.icon(id, true));
|
|
257
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* A platform connector template's own icon (any live template; same response headers as the
|
|
260
|
+
* item icon). Unknown template -> 404 `component.not_found`; no icon of its own -> 404
|
|
261
|
+
* `catalog.icon_not_found`.
|
|
262
|
+
*/
|
|
263
|
+
async templateIcon(templateId, reply) {
|
|
264
|
+
await sendCatalogIcon(reply, await this.icons.readTemplateIcon(templateId, { kind: "admin" }));
|
|
265
|
+
}
|
|
258
266
|
/**
|
|
259
267
|
* A setup guide of the item as the platform sees it (spec 2026-11-09-setup-guides-v2-design.md
|
|
260
268
|
* §9.3; the admin console's connector template page): any live item, the admin audience, no org
|
|
@@ -424,6 +432,11 @@ __decorate([
|
|
|
424
432
|
__param(0, Param("id")),
|
|
425
433
|
__param(1, Res())
|
|
426
434
|
], AdminCatalogController.prototype, "icon", null);
|
|
435
|
+
__decorate([
|
|
436
|
+
Get("connector-templates/:templateId/icon"),
|
|
437
|
+
__param(0, Param("templateId")),
|
|
438
|
+
__param(1, Res())
|
|
439
|
+
], AdminCatalogController.prototype, "templateIcon", null);
|
|
427
440
|
__decorate([
|
|
428
441
|
Get(":itemId/guides/:guideId"),
|
|
429
442
|
__param(0, Param("itemId")),
|
|
@@ -98,6 +98,11 @@ export interface OrgCatalogTemplate {
|
|
|
98
98
|
itemId: string;
|
|
99
99
|
guideId: string;
|
|
100
100
|
} | null;
|
|
101
|
+
/**
|
|
102
|
+
* The template's icon on the org's routes: its own icon, else its plugin's, else null
|
|
103
|
+
* (`PluginIcons.ofItemTemplates`).
|
|
104
|
+
*/
|
|
105
|
+
icon: string | null;
|
|
101
106
|
}
|
|
102
107
|
/** `GET /orgs/:orgId/catalog/:itemId`: the item and what the install wizard needs (latest version). */
|
|
103
108
|
export interface OrgCatalogDetail {
|
|
@@ -135,6 +140,7 @@ export declare function orgTemplateView(id: string, file: ConnectorTemplateFile,
|
|
|
135
140
|
guide?: OrgCatalogTemplate["guide"];
|
|
136
141
|
on?: boolean;
|
|
137
142
|
connected?: boolean;
|
|
143
|
+
icon?: string | null;
|
|
138
144
|
}): OrgCatalogTemplate;
|
|
139
145
|
/** An item's icon (the latest version's plugin icon). */
|
|
140
146
|
export interface CatalogIcon {
|
|
@@ -32,6 +32,7 @@ export function orgTemplateView(id, file, o = {}) {
|
|
|
32
32
|
on: o.on ?? true,
|
|
33
33
|
connected: o.connected ?? false,
|
|
34
34
|
guide: o.guide ?? null,
|
|
35
|
+
icon: o.icon ?? null,
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
const iconNotFound = () => new ApiError("catalog.icon_not_found", "This catalog item has no icon");
|
|
@@ -450,6 +450,8 @@ export async function marketplaceLatest(db, config, items, versions) {
|
|
|
450
450
|
/** Org install counts per item (see {@link CatalogItemView.installs}). */
|
|
451
451
|
export async function countInstalls(db, items, versions) {
|
|
452
452
|
const orgs = new Map(items.map((i) => [i.id, new Set()]));
|
|
453
|
+
// org-filter: the platform catalog's install count per item (super admin's catalog view): it
|
|
454
|
+
// counts the orgs on purpose and returns no org row
|
|
453
455
|
const installed = await db
|
|
454
456
|
.selectFrom("plugin_installs")
|
|
455
457
|
.select(["item_id", "org_id"])
|
|
@@ -585,6 +587,8 @@ export async function itemScopeFacts(db, items, confirmations) {
|
|
|
585
587
|
return out;
|
|
586
588
|
const ids = items.map((i) => i.id);
|
|
587
589
|
// one after the other: `db` may be a transaction's single connection
|
|
590
|
+
// org-filter: the platform catalog's scope facts per item (super admin's catalog and import
|
|
591
|
+
// views): the named orgs of each item are listed across orgs on purpose
|
|
588
592
|
const listed = await db
|
|
589
593
|
.selectFrom("catalog_item_scope_orgs")
|
|
590
594
|
.select(["item_id", "org_id"])
|