@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
|
@@ -11,7 +11,7 @@ import { Inject, Injectable } from "@nestjs/common";
|
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
import { AppearanceService } from "../../catalog/appearance.service.js";
|
|
13
13
|
import { CatalogScopeService } from "../../catalog/catalog-scope.service.js";
|
|
14
|
-
import { CatalogConnectorInput, CatalogItemPathParams,
|
|
14
|
+
import { CatalogConnectorInput, CatalogItemPathParams, PluginInstallPathParams, } from "../../catalog/org-catalog.schemas.js";
|
|
15
15
|
import { OrgCatalogService } from "../../catalog/org-catalog.service.js";
|
|
16
16
|
import { OrgExtensionParams } from "../../catalog/org-extension.schemas.js";
|
|
17
17
|
import { OrgPluginUploads } from "../../catalog/org-plugin-uploads.js";
|
|
@@ -19,19 +19,18 @@ import { OrgOwnedDeleteBody, OrgOwnedPluginParams, OrgOwnedShareableBody, OrgUpl
|
|
|
19
19
|
import { OwnedItems } from "../../catalog/owned-items.js";
|
|
20
20
|
import { PluginInstaller } from "../../catalog/plugin-install.js";
|
|
21
21
|
import { ApiError } from "../../errors.js";
|
|
22
|
-
import { OrgExtensionConfigs } from "../../extensions/org-config.js";
|
|
23
22
|
import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
|
|
24
23
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
25
24
|
import { ThemesService } from "../../themes/themes.service.js";
|
|
26
25
|
import { clientProblem, headersWebOnly, templateConnectorInput, templatePersonFields, } from "../connector-person-fields.js";
|
|
27
26
|
import { FileRefSchema } from "../file-ref.js";
|
|
28
27
|
import { defineOperation, } from "../operation.js";
|
|
29
|
-
import {
|
|
28
|
+
import { personFieldParams } from "../person-fields.js";
|
|
30
29
|
import { PlatformOperations } from "../registry.js";
|
|
31
30
|
import { appearanceSummary, reviewBrief } from "./catalog-admin.ops.js";
|
|
32
31
|
import { precheckBy, viaAgent } from "./errors.js";
|
|
33
32
|
import { Cursor, pageOf, startOf } from "./paging.js";
|
|
34
|
-
import { afterTaken,
|
|
33
|
+
import { afterTaken, takePersonInputs } from "./person-inputs.js";
|
|
35
34
|
import { localized, named, orElse } from "./summary.js";
|
|
36
35
|
const InstallId = PluginInstallPathParams.shape.installId.max(100);
|
|
37
36
|
/** An org-owned plugin's catalog item id (`:id` of the owned-plugins routes). */
|
|
@@ -58,7 +57,6 @@ const InstallInput = z
|
|
|
58
57
|
.object({
|
|
59
58
|
itemId: ItemId,
|
|
60
59
|
templates: Templates.optional().describe("Per connector template id (plugins.get lists them), the connector's name, slug, endpoint fields and OAuth client id; never a credential."),
|
|
61
|
-
extensionConfig: OrgPluginInstallBody.shape.extensionConfig.describe("The plugin's extension org config without its secret fields (extensions.org-config shows the schema)."),
|
|
62
60
|
askPerson: personFieldParams.askPerson,
|
|
63
61
|
})
|
|
64
62
|
.strict();
|
|
@@ -164,9 +162,8 @@ let OrgPluginsOperations = class OrgPluginsOperations {
|
|
|
164
162
|
kdb;
|
|
165
163
|
appearance;
|
|
166
164
|
themes;
|
|
167
|
-
extensions;
|
|
168
165
|
config;
|
|
169
|
-
constructor(registry, installer, orgCatalog, uploads, owned, scope, kdb, appearance, themes,
|
|
166
|
+
constructor(registry, installer, orgCatalog, uploads, owned, scope, kdb, appearance, themes, config) {
|
|
170
167
|
this.registry = registry;
|
|
171
168
|
this.installer = installer;
|
|
172
169
|
this.orgCatalog = orgCatalog;
|
|
@@ -176,46 +173,17 @@ let OrgPluginsOperations = class OrgPluginsOperations {
|
|
|
176
173
|
this.kdb = kdb;
|
|
177
174
|
this.appearance = appearance;
|
|
178
175
|
this.themes = themes;
|
|
179
|
-
this.extensions = extensions;
|
|
180
176
|
this.config = config;
|
|
181
177
|
}
|
|
182
178
|
/**
|
|
183
179
|
* What installing a plugin asks the person for (platform web parity spec §7.2): the connector
|
|
184
180
|
* templates whose connector the install creates (on in the org, none kept from an earlier
|
|
185
|
-
* switch-off, as the install wizard asks)
|
|
186
|
-
*
|
|
187
|
-
* only). An extension whose org view cannot be read refuses the call: its secrets are unknown.
|
|
181
|
+
* switch-off, as the install wizard asks). The extension's config for the org is its copy of the
|
|
182
|
+
* overridable fields, saved apart (`extensions.save-org-config`).
|
|
188
183
|
*/
|
|
189
184
|
async installTargets(ctx, itemId) {
|
|
190
185
|
const d = await this.orgCatalog.detail(ctx.orgId, ctx.actorAccountId, itemId);
|
|
191
186
|
const templates = d.templates.filter((t) => t.on && !t.connected).map(targetOf);
|
|
192
|
-
let fields = [];
|
|
193
|
-
let recordOnly = [];
|
|
194
|
-
if (d.extension !== null) {
|
|
195
|
-
const views = await this.extensions.list(ctx.orgId);
|
|
196
|
-
// the view of this catalog item; by plugin name only when that name is unambiguous
|
|
197
|
-
const byName = views.filter((e) => e.plugin === d.extension);
|
|
198
|
-
const v = views.find((e) => e.catalogItem?.itemId === itemId) ??
|
|
199
|
-
(byName.length === 1 ? byName[0] : undefined);
|
|
200
|
-
if (v === undefined && byName.length > 1) {
|
|
201
|
-
throw new PersonFieldsRefused(`Several extensions named ${d.extension} are in this org, so the secret fields of this plugin's extension are not known; install the plugin on the web (Plugins page).`);
|
|
202
|
-
}
|
|
203
|
-
if (v === undefined) {
|
|
204
|
-
throw new PersonFieldsRefused(`Cannot read the config schema of the plugin's extension ${d.extension} now, so its secret fields are unknown; try again, or install the plugin on the web (Plugins page).`);
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
const stored = new Set(v.secrets.filter((x) => x.set).map((x) => x.path));
|
|
208
|
-
const found = secretFieldsOf(v.orgConfigSchema, stored);
|
|
209
|
-
const asked = new Set(found.fields.map((f) => f.path));
|
|
210
|
-
fields = found.fields.map((f) => ({ ...f, path: `extensionConfig.${f.path}` }));
|
|
211
|
-
recordOnly = [
|
|
212
|
-
...new Set([
|
|
213
|
-
...found.recordOnly,
|
|
214
|
-
...v.secrets.map((x) => x.path).filter((p) => !asked.has(p)),
|
|
215
|
-
]),
|
|
216
|
-
].map((p) => `extensionConfig.${p}`);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
187
|
return {
|
|
220
188
|
item: d.item,
|
|
221
189
|
templates,
|
|
@@ -224,8 +192,8 @@ let OrgPluginsOperations = class OrgPluginsOperations {
|
|
|
224
192
|
zh: `插件「${localized(d.item.displayName, d.item.name).zh}」的安装`,
|
|
225
193
|
en: `${localized(d.item.displayName, d.item.name).en}: install`,
|
|
226
194
|
},
|
|
227
|
-
fields:
|
|
228
|
-
recordOnly,
|
|
195
|
+
fields: templatePersonFields(templates),
|
|
196
|
+
recordOnly: [],
|
|
229
197
|
},
|
|
230
198
|
};
|
|
231
199
|
}
|
|
@@ -612,7 +580,7 @@ let OrgPluginsOperations = class OrgPluginsOperations {
|
|
|
612
580
|
}),
|
|
613
581
|
defineOperation({
|
|
614
582
|
id: "plugins.install",
|
|
615
|
-
description: "Install a plugin in this org with its inputs (org admins; the web's install wizard): per connector template the connector's name, slug, endpoint fields and OAuth client id (templates)
|
|
583
|
+
description: "Install a plugin in this org with its inputs (org admins; the web's install wizard): per connector template the connector's name, slug, endpoint fields and OAuth client id (templates). Secrets are never params: the person enters them in a secure input request, at connectors.<templateId>.credential.token (or .credential.username / .credential.password, .client.clientSecret). The extension's config for the org is its copy of the overridable fields (extensions.save-org-config). Required ones are asked even when not listed in askPerson. A plugin that needs no input is switched on with plugins.set-enabled instead.",
|
|
616
584
|
input: InstallInput,
|
|
617
585
|
example: {
|
|
618
586
|
itemId: EXAMPLE_ID,
|
|
@@ -643,7 +611,7 @@ let OrgPluginsOperations = class OrgPluginsOperations {
|
|
|
643
611
|
},
|
|
644
612
|
{
|
|
645
613
|
code: "validation_failed",
|
|
646
|
-
next: "The error's details name the fields (connectors.<templateId>.…
|
|
614
|
+
next: "The error's details name the fields (connectors.<templateId>.…); correct the params and call again.",
|
|
647
615
|
},
|
|
648
616
|
{
|
|
649
617
|
code: "platform.secret_record_web_only",
|
|
@@ -666,18 +634,7 @@ let OrgPluginsOperations = class OrgPluginsOperations {
|
|
|
666
634
|
}
|
|
667
635
|
return templatesRefusal(r.templates, i.templates);
|
|
668
636
|
},
|
|
669
|
-
personFields: async (i, ctx) =>
|
|
670
|
-
const { target } = await this.installTargets(ctx, i.itemId);
|
|
671
|
-
// the extension config is a dynamic record: its secrets are checked like values
|
|
672
|
-
const plan = planPersonFields(target, {
|
|
673
|
-
values: { extensionConfig: i.extensionConfig ?? {} },
|
|
674
|
-
askPerson: [],
|
|
675
|
-
clearSecrets: [],
|
|
676
|
-
});
|
|
677
|
-
if (!plan.ok)
|
|
678
|
-
throw new PersonFieldsRefused(plan.message);
|
|
679
|
-
return target;
|
|
680
|
-
},
|
|
637
|
+
personFields: async (i, ctx) => (await this.installTargets(ctx, i.itemId)).target,
|
|
681
638
|
summary: async (i, ctx) => {
|
|
682
639
|
const { item, templates } = await this.installTargets(ctx, i.itemId);
|
|
683
640
|
const n = localized(item.displayName, item.name);
|
|
@@ -693,15 +650,8 @@ let OrgPluginsOperations = class OrgPluginsOperations {
|
|
|
693
650
|
// values are taken first (takePersonInputs)
|
|
694
651
|
const { entered, auditDetail } = await takePersonInputs("plugins.install", ctx);
|
|
695
652
|
const connectors = connectorInputs(templates, input.templates, entered);
|
|
696
|
-
const ext = enteredUnder(entered, "extensionConfig.");
|
|
697
|
-
const extensionConfig = input.extensionConfig !== undefined || Object.keys(ext).length > 0
|
|
698
|
-
? nestedConfig(input.extensionConfig ?? {}, ext, [])
|
|
699
|
-
: undefined;
|
|
700
653
|
const r = await this.orgCatalog
|
|
701
|
-
.install(ctx.orgId, ctx.actorAccountId, input.itemId, {
|
|
702
|
-
...(connectors !== undefined && { connectors }),
|
|
703
|
-
...(extensionConfig !== undefined && { extensionConfig }),
|
|
704
|
-
}, undefined, auditDetail)
|
|
654
|
+
.install(ctx.orgId, ctx.actorAccountId, input.itemId, (connectors !== undefined ? { connectors } : {}), undefined, auditDetail)
|
|
705
655
|
.catch((e) => {
|
|
706
656
|
throw afterTaken(e, entered);
|
|
707
657
|
});
|
|
@@ -730,7 +680,7 @@ let OrgPluginsOperations = class OrgPluginsOperations {
|
|
|
730
680
|
},
|
|
731
681
|
{
|
|
732
682
|
code: "validation_failed",
|
|
733
|
-
next: "The error's details name the fields (connectors.<templateId>.…
|
|
683
|
+
next: "The error's details name the fields (connectors.<templateId>.…); correct the params and call again.",
|
|
734
684
|
},
|
|
735
685
|
{
|
|
736
686
|
code: "platform.secret_record_web_only",
|
|
@@ -792,7 +742,6 @@ OrgPluginsOperations = __decorate([
|
|
|
792
742
|
__param(6, Inject(KernelDb)),
|
|
793
743
|
__param(7, Inject(AppearanceService)),
|
|
794
744
|
__param(8, Inject(ThemesService)),
|
|
795
|
-
__param(9, Inject(
|
|
796
|
-
__param(10, Inject(KernelConfigService))
|
|
745
|
+
__param(9, Inject(KernelConfigService))
|
|
797
746
|
], OrgPluginsOperations);
|
|
798
747
|
export { OrgPluginsOperations };
|
|
@@ -31,6 +31,7 @@ let OutboxOperations = class OutboxOperations {
|
|
|
31
31
|
this.kdb = kdb;
|
|
32
32
|
}
|
|
33
33
|
/** The dead row's job (queue and name) for a card, or null when no dead row has the id. */
|
|
34
|
+
// org-filter: super-admin operations (authz superAdmin); dead outbox rows of every org are listed
|
|
34
35
|
async jobOf(id) {
|
|
35
36
|
const row = await this.kdb.db
|
|
36
37
|
.selectFrom("outbox")
|
|
@@ -33,10 +33,6 @@ export declare const VALUES_USED_UP_TEXT = "The values the person entered were u
|
|
|
33
33
|
* `ToolError` naming only its class (as the pipeline would), with the original as `cause`.
|
|
34
34
|
*/
|
|
35
35
|
export declare function afterTaken(e: unknown, entered: Readonly<Record<string, string>>): unknown;
|
|
36
|
-
/**
|
|
37
|
-
* The values under `prefix` (`connectors.<templateId>.`), keyed by the rest of their path.
|
|
38
|
-
*/
|
|
39
|
-
export declare function enteredUnder(entered: Readonly<Record<string, string>>, prefix: string): Record<string, string>;
|
|
40
36
|
/**
|
|
41
37
|
* The `values` of a config route keyed by field dot path (deployment config, the org's copy): the
|
|
42
38
|
* model's non-secret values, the person's entered secrets, and `null` (clear) for each path in
|
|
@@ -56,14 +56,6 @@ export function afterTaken(e, entered) {
|
|
|
56
56
|
Object.defineProperty(out, "cause", { value: e });
|
|
57
57
|
return out;
|
|
58
58
|
}
|
|
59
|
-
/**
|
|
60
|
-
* The values under `prefix` (`connectors.<templateId>.`), keyed by the rest of their path.
|
|
61
|
-
*/
|
|
62
|
-
export function enteredUnder(entered, prefix) {
|
|
63
|
-
return Object.fromEntries(Object.entries(entered)
|
|
64
|
-
.filter(([p]) => p.startsWith(prefix))
|
|
65
|
-
.map(([p, v]) => [p.slice(prefix.length), v]));
|
|
66
|
-
}
|
|
67
59
|
/**
|
|
68
60
|
* The `values` of a config route keyed by field dot path (deployment config, the org's copy): the
|
|
69
61
|
* model's non-secret values, the person's entered secrets, and `null` (clear) for each path in
|
|
@@ -9,7 +9,10 @@ import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
|
9
9
|
import { PlatformOperations } from "../registry.js";
|
|
10
10
|
export { OTHER_ORG } from "./other-orgs.js";
|
|
11
11
|
export declare const NEEDS_INPUT = "This plugin needs connector input (endpoints, credentials): install it with plugins.install, or for an installed plugin missing connectors create them with plugins.configure-connectors; the person enters the credentials in a secure input request.";
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* What `plugins.set-enabled` adds to its result when the plugin is on but its extension's
|
|
14
|
+
* effective config for the org is not valid yet (switching on never waits for it, as on the web).
|
|
15
|
+
*/
|
|
13
16
|
export declare const needsOrgConfig: (extension: string) => string;
|
|
14
17
|
/**
|
|
15
18
|
* Plugin operations of the `Platform` tool (spec §7): the org's view (list, get, switch on or off)
|
|
@@ -41,8 +41,11 @@ const LOCKED = "This plugin is on for every org (or shipped with the platform) a
|
|
|
41
41
|
/** The confirm value of switching off a plugin with nothing installed in the org. */
|
|
42
42
|
const NOTHING_INSTALLED = "nothing-installed";
|
|
43
43
|
export const NEEDS_INPUT = "This plugin needs connector input (endpoints, credentials): install it with plugins.install, or for an installed plugin missing connectors create them with plugins.configure-connectors; the person enters the credentials in a secure input request.";
|
|
44
|
-
/**
|
|
45
|
-
|
|
44
|
+
/**
|
|
45
|
+
* What `plugins.set-enabled` adds to its result when the plugin is on but its extension's
|
|
46
|
+
* effective config for the org is not valid yet (switching on never waits for it, as on the web).
|
|
47
|
+
*/
|
|
48
|
+
export const needsOrgConfig = (extension) => `The plugin is on, but its extension ${extension} has no valid config for this org yet and gets no calls until it does: read what is missing with extensions.org-config, then fill in the org's own copy of the overridable fields with extensions.save-org-config (the person enters secrets in a secure input request). If only platform-only fields are missing, the super admin must set them.`;
|
|
46
49
|
/** The English name of a plugin as next steps and messages name it. */
|
|
47
50
|
const enName = (i) => localized(i.displayName, i.name).en;
|
|
48
51
|
/** The item with the reason its extension stopped loading (state unchanged), when it has one. */
|
|
@@ -81,35 +84,23 @@ const row = (i, role) => ({
|
|
|
81
84
|
switchable: i.switchable,
|
|
82
85
|
request: i.request,
|
|
83
86
|
});
|
|
84
|
-
const hasConfigFields = (schema) => {
|
|
85
|
-
const props = schema?.properties;
|
|
86
|
-
return typeof props === "object" && props !== null && Object.keys(props).length > 0;
|
|
87
|
-
};
|
|
88
87
|
/**
|
|
89
|
-
* Why switching the plugin on needs input first, as the `plugin.needs_input` message, or null:
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
88
|
+
* Why switching the plugin on needs input first, as the `plugin.needs_input` message, or null:
|
|
89
|
+
* connector input only (an installed plugin whose connector template misses its connector, or a
|
|
90
|
+
* plugin not installed yet that has connector templates: `plugins.install`,
|
|
91
|
+
* `plugins.configure-connectors`). Its extension's config never blocks the switch, as on the web
|
|
92
|
+
* and the route: the plugin goes on and its extension stays `needsConfig` until the org's copy
|
|
93
|
+
* (or the platform config) is valid ({@link configStillNeeded}).
|
|
94
94
|
*/
|
|
95
|
-
function needsInput(item
|
|
96
|
-
const own = extensions.find((e) => e.catalogItem?.itemId === item.id);
|
|
97
|
-
// `needs_config` also means connector templates without their connector
|
|
98
|
-
if (item.state === "needs_config") {
|
|
99
|
-
return own?.needsConfig === true ? needsOrgConfig(own.plugin) : NEEDS_INPUT;
|
|
100
|
-
}
|
|
95
|
+
function needsInput(item) {
|
|
101
96
|
if (item.installed !== null)
|
|
102
|
-
return null;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
hasConfigFields(own.orgConfigSchema) &&
|
|
110
|
-
own.needsConfig
|
|
111
|
-
? needsOrgConfig(own.plugin)
|
|
112
|
-
: null;
|
|
97
|
+
return item.state === "needs_config" ? NEEDS_INPUT : null;
|
|
98
|
+
return item.componentCounts.connectorTemplates > 0 ? NEEDS_INPUT : null;
|
|
99
|
+
}
|
|
100
|
+
/** The note for a plugin switched on whose extension's effective config is not valid, or null. */
|
|
101
|
+
function configStillNeeded(item, extensions) {
|
|
102
|
+
const own = extensions.find((e) => e.catalogItem?.itemId === item.id);
|
|
103
|
+
return own?.needsConfig === true ? needsOrgConfig(own.plugin) : null;
|
|
113
104
|
}
|
|
114
105
|
/**
|
|
115
106
|
* Plugin operations of the `Platform` tool (spec §7): the org's view (list, get, switch on or off)
|
|
@@ -222,7 +213,7 @@ let PluginsOperations = class PluginsOperations {
|
|
|
222
213
|
}),
|
|
223
214
|
defineOperation({
|
|
224
215
|
id: "plugins.set-enabled",
|
|
225
|
-
description: "Switch a plugin on or off in this org. Switching on installs it; a plugin whose enabling needs connector input is refused: install it with plugins.install instead. Switching off removes what the plugin brought and needs confirm: the value plugins.disable-preview returned with the preview the person saw.",
|
|
216
|
+
description: "Switch a plugin on or off in this org. Switching on installs it; a plugin whose enabling needs connector input is refused: install it with plugins.install instead. A plugin whose extension has no valid config for the org yet is switched on anyway, and the result's configNeeded says how to fill in the org's copy (extensions.save-org-config). Switching off removes what the plugin brought and needs confirm: the value plugins.disable-preview returned with the preview the person saw.",
|
|
226
217
|
input: z.discriminatedUnion("enabled", [
|
|
227
218
|
z.object({ itemId: ItemId, enabled: z.literal(true) }).strict(),
|
|
228
219
|
z.object({ itemId: ItemId, enabled: z.literal(false), confirm: Confirm }).strict(),
|
|
@@ -262,7 +253,7 @@ let PluginsOperations = class PluginsOperations {
|
|
|
262
253
|
},
|
|
263
254
|
{
|
|
264
255
|
code: "plugin.needs_input",
|
|
265
|
-
next: "
|
|
256
|
+
next: "The plugin needs connector input: install it with plugins.install (or plugins.configure-connectors once installed), the person entering the credentials on the card.",
|
|
266
257
|
},
|
|
267
258
|
{
|
|
268
259
|
code: "catalog.approval_required",
|
|
@@ -303,9 +294,7 @@ let PluginsOperations = class PluginsOperations {
|
|
|
303
294
|
next: unavailableNext(item.reason, name),
|
|
304
295
|
};
|
|
305
296
|
}
|
|
306
|
-
const missing = i.enabled
|
|
307
|
-
? needsInput(item, await this.extensions.list(ctx.orgId))
|
|
308
|
-
: null;
|
|
297
|
+
const missing = i.enabled ? needsInput(item) : null;
|
|
309
298
|
if (missing !== null)
|
|
310
299
|
return { ok: false, code: "plugin.needs_input", message: missing };
|
|
311
300
|
return { ok: true };
|
|
@@ -335,14 +324,18 @@ let PluginsOperations = class PluginsOperations {
|
|
|
335
324
|
run: async (input, ctx) => {
|
|
336
325
|
if (input.enabled) {
|
|
337
326
|
const [item] = await this.orgCatalog.list(ctx.orgId, ctx.actorAccountId, input.itemId);
|
|
338
|
-
const missing = item ? needsInput(item
|
|
327
|
+
const missing = item ? needsInput(item) : null;
|
|
339
328
|
if (missing !== null)
|
|
340
329
|
throw new ToolError(missing);
|
|
341
330
|
}
|
|
342
331
|
const r = await this.orgCatalog.setSwitch(ctx.orgId, ctx.actorAccountId, input.itemId, input.enabled ? { enabled: true } : { enabled: false, confirm: input.confirm }, undefined, viaAgent("plugins.set-enabled", ctx));
|
|
343
332
|
if (r.kind === "done") {
|
|
333
|
+
const configNeeded = input.enabled
|
|
334
|
+
? configStillNeeded(r.item, await this.extensions.list(ctx.orgId))
|
|
335
|
+
: null;
|
|
344
336
|
return {
|
|
345
337
|
item: brief(r.item, await roleFor(this.kdb.db, ctx)),
|
|
338
|
+
...(configNeeded !== null && { configNeeded }),
|
|
346
339
|
};
|
|
347
340
|
}
|
|
348
341
|
// unreachable: confirm is required when switching off
|
|
@@ -76,7 +76,7 @@ export declare function secretFieldsOf(jsonSchema: unknown, stored: ReadonlySet<
|
|
|
76
76
|
/**
|
|
77
77
|
* A refusal of a call's person fields (model-visible English, never a value): thrown by the plan,
|
|
78
78
|
* or by an operation's `personFields` for an input the plan cannot see (a dynamic record such as
|
|
79
|
-
*
|
|
79
|
+
* a channel connection config). The tool denies the call with the message before the card.
|
|
80
80
|
*/
|
|
81
81
|
export declare class PersonFieldsRefused extends Error {
|
|
82
82
|
}
|
|
@@ -246,7 +246,7 @@ export function secretFieldsOf(jsonSchema, stored) {
|
|
|
246
246
|
/**
|
|
247
247
|
* A refusal of a call's person fields (model-visible English, never a value): thrown by the plan,
|
|
248
248
|
* or by an operation's `personFields` for an input the plan cannot see (a dynamic record such as
|
|
249
|
-
*
|
|
249
|
+
* a channel connection config). The tool denies the call with the message before the card.
|
|
250
250
|
*/
|
|
251
251
|
export class PersonFieldsRefused extends Error {
|
|
252
252
|
}
|
|
@@ -99,6 +99,7 @@ let SealedReveals = class SealedReveals {
|
|
|
99
99
|
.selectFrom("invitations")
|
|
100
100
|
.select("invitations.id")
|
|
101
101
|
.whereRef("invitations.id", "=", "platform_sealed_reveals.id")
|
|
102
|
+
.where("invitations.org_id", "=", orgId)
|
|
102
103
|
.where("invitations.accepted_at", "is", null)
|
|
103
104
|
.where("invitations.revoked_at", "is", null)
|
|
104
105
|
.where(sql `invitations.expires_at > now()`)))
|
|
@@ -142,6 +143,7 @@ SealedReveals = __decorate([
|
|
|
142
143
|
export { SealedReveals };
|
|
143
144
|
/** Deletes the sealed reveals past `expires_at`; returns how many. */
|
|
144
145
|
export async function deleteExpiredSealedReveals(db) {
|
|
146
|
+
// org-filter: deployment-wide expiry sweep over every org's sealed reveals (maintenance job)
|
|
145
147
|
const r = await db
|
|
146
148
|
.deleteFrom("platform_sealed_reveals")
|
|
147
149
|
.where("expires_at", "<=", sql `now()`)
|
package/dist/push/recipients.js
CHANGED
|
@@ -41,6 +41,8 @@ async function resolveConversation(db, conversationId, seq) {
|
|
|
41
41
|
const trigger = pushTriggerOf({ type: event.type, payload: event.payload });
|
|
42
42
|
if (trigger === null)
|
|
43
43
|
return null;
|
|
44
|
+
// org-filter: conversationId comes from the kernel-written push fan-out job; this read learns
|
|
45
|
+
// the conversation's org, which every later read filters by
|
|
44
46
|
const conv = await db
|
|
45
47
|
.selectFrom("conversations")
|
|
46
48
|
.select(["org_id", "kind", "account_id", "deleted_at"])
|
|
@@ -60,6 +62,7 @@ async function resolveConversation(db, conversationId, seq) {
|
|
|
60
62
|
.selectFrom("conversations")
|
|
61
63
|
.select(["org_id", "kind", "account_id", "deleted_at"])
|
|
62
64
|
.where("id", "=", rootId)
|
|
65
|
+
.where("org_id", "=", orgId)
|
|
63
66
|
.executeTakeFirst();
|
|
64
67
|
if (root !== null &&
|
|
65
68
|
(root === undefined ||
|
|
@@ -148,6 +151,7 @@ async function resolveConversation(db, conversationId, seq) {
|
|
|
148
151
|
.selectFrom("conversations")
|
|
149
152
|
.select(["agent_id", "title"])
|
|
150
153
|
.where("id", "=", rootId)
|
|
154
|
+
.where("org_id", "=", orgId)
|
|
151
155
|
.executeTakeFirstOrThrow();
|
|
152
156
|
const org = encodeURIComponent(orgId);
|
|
153
157
|
const path = rootId === conversationId
|
|
@@ -159,12 +163,14 @@ async function resolveConversation(db, conversationId, seq) {
|
|
|
159
163
|
category: trigger.category,
|
|
160
164
|
path,
|
|
161
165
|
threadId: rootId,
|
|
162
|
-
title: await agentName(db, rootRow.agent_id),
|
|
166
|
+
title: await agentName(db, orgId, rootRow.agent_id),
|
|
163
167
|
conversationTitle: rootRow.title,
|
|
164
168
|
text: trigger.text,
|
|
165
169
|
};
|
|
166
170
|
}
|
|
167
171
|
async function resolveSchedule(db, taskRunId) {
|
|
172
|
+
// org-filter: taskRunId comes from the kernel-written push fan-out job; this read learns the
|
|
173
|
+
// run's org (checked against its task's below), which every later read filters by
|
|
168
174
|
const row = await db
|
|
169
175
|
.selectFrom("scheduled_task_runs")
|
|
170
176
|
.innerJoin("scheduled_tasks", "scheduled_tasks.id", "scheduled_task_runs.task_id")
|
|
@@ -249,7 +255,7 @@ async function activeMembers(db, orgId, ids) {
|
|
|
249
255
|
return rows.map((r) => r.id);
|
|
250
256
|
}
|
|
251
257
|
/** The agent's name in its current version (empty when it has none). */
|
|
252
|
-
async function agentName(db, agentId) {
|
|
258
|
+
async function agentName(db, orgId, agentId) {
|
|
253
259
|
const row = await db
|
|
254
260
|
.selectFrom("agents")
|
|
255
261
|
.innerJoin("agent_versions", (j) => j
|
|
@@ -257,6 +263,7 @@ async function agentName(db, agentId) {
|
|
|
257
263
|
.onRef("agent_versions.version", "=", "agents.current_version"))
|
|
258
264
|
.select("agent_versions.definition")
|
|
259
265
|
.where("agents.id", "=", agentId)
|
|
266
|
+
.where("agents.org_id", "=", orgId)
|
|
260
267
|
.executeTakeFirst();
|
|
261
268
|
const name = row?.definition?.name;
|
|
262
269
|
return typeof name === "string" ? name : "";
|
|
@@ -137,6 +137,7 @@ let PermissionContextRecorder = class PermissionContextRecorder {
|
|
|
137
137
|
.selectFrom("conversations")
|
|
138
138
|
.select(["org_id", "kind", "eval_run_id"])
|
|
139
139
|
.where("id", "=", input.conversationId)
|
|
140
|
+
.where("org_id", "=", input.orgId)
|
|
140
141
|
.executeTakeFirst();
|
|
141
142
|
if (!conv || conv.org_id !== input.orgId)
|
|
142
143
|
throw new ApiError("conversation.not_found", "Conversation not found");
|
|
@@ -160,6 +160,7 @@ let PluginContextService = class PluginContextService {
|
|
|
160
160
|
.selectFrom("conversations")
|
|
161
161
|
.select("id")
|
|
162
162
|
.where("id", "=", input.conversationId)
|
|
163
|
+
.where("org_id", "=", input.orgId)
|
|
163
164
|
.forUpdate()
|
|
164
165
|
.executeTakeFirst();
|
|
165
166
|
if (await runEndedIn(t, input.runId))
|
|
@@ -297,6 +297,7 @@ let ProjectKnowledgeService = class ProjectKnowledgeService {
|
|
|
297
297
|
.selectFrom("conversations")
|
|
298
298
|
.select("id")
|
|
299
299
|
.where("id", "=", input.conversationId)
|
|
300
|
+
.where("org_id", "=", input.orgId)
|
|
300
301
|
.forUpdate()
|
|
301
302
|
.executeTakeFirst();
|
|
302
303
|
if (await runEndedIn(t, input.runId))
|
|
@@ -76,12 +76,15 @@ let RunDeletion = class RunDeletion {
|
|
|
76
76
|
.selectFrom("background_tasks as b")
|
|
77
77
|
.select("b.id")
|
|
78
78
|
.whereRef("b.sandbox_conversation_id", "=", "c.id")
|
|
79
|
+
.whereRef("b.org_id", "=", "c.org_id")
|
|
79
80
|
.where("b.status", "=", RUNNING_TASK_STATUS)),
|
|
80
81
|
]))
|
|
81
82
|
.orderBy("c.id")
|
|
82
83
|
.limit(100)
|
|
83
84
|
.execute();
|
|
84
85
|
}
|
|
86
|
+
// org-filter: the id is the deleted root (ConversationsService.remove checked writable(orgId)
|
|
87
|
+
// first, or the outbox row it wrote); only a deleted conversation is acted on
|
|
85
88
|
async stopTree(conversationId, byAccountId) {
|
|
86
89
|
const root = await this.db
|
|
87
90
|
.selectFrom("conversations")
|
|
@@ -107,6 +110,7 @@ let RunDeletion = class RunDeletion {
|
|
|
107
110
|
await this.stopConversationIn(conversationId, byAccountId);
|
|
108
111
|
await this.background.stopForDeletedConversation(conversationId);
|
|
109
112
|
}
|
|
113
|
+
// org-filter: locks a conversation stopTree / stopDeletedConversation / the org sweep resolved
|
|
110
114
|
async stopConversationIn(conversationId, byAccountId, reason = "user") {
|
|
111
115
|
await this.db
|
|
112
116
|
.selectFrom("conversations")
|
|
@@ -90,6 +90,7 @@ let RunExecution = class RunExecution {
|
|
|
90
90
|
async claim(conversationId, runId, executionId, live = () => true) {
|
|
91
91
|
if (!live())
|
|
92
92
|
return null;
|
|
93
|
+
// org-filter: the worker's claim of a kernel-written run job; reads the conversation's own org
|
|
93
94
|
const conv = await this.db
|
|
94
95
|
.selectFrom("conversations")
|
|
95
96
|
.select("org_id")
|
|
@@ -156,6 +157,7 @@ let RunExecution = class RunExecution {
|
|
|
156
157
|
.selectFrom("conversations")
|
|
157
158
|
.select("deleted_at")
|
|
158
159
|
.where("id", "=", claim.rootId)
|
|
160
|
+
.where("org_id", "=", claim.orgId)
|
|
159
161
|
.forNoKeyUpdate()
|
|
160
162
|
.executeTakeFirst();
|
|
161
163
|
if (!root || !isLive(root.deleted_at))
|
|
@@ -84,6 +84,8 @@ let RunFinish = class RunFinish {
|
|
|
84
84
|
* approval and input request rows, the run row; they never deadlock with each other.
|
|
85
85
|
* 调用方在提交后对非 null 的返回值调用 {@link notifyFinished}。
|
|
86
86
|
*/
|
|
87
|
+
// org-filter: ends a run by its kernel-resolved run and conversation ids (worker claim, stop and
|
|
88
|
+
// decision paths that checked the org); the conversation's own org is read here
|
|
87
89
|
async finishIn(a) {
|
|
88
90
|
const t = this.kdb.db;
|
|
89
91
|
const conv = await t
|
|
@@ -178,6 +180,7 @@ let RunFinish = class RunFinish {
|
|
|
178
180
|
.selectFrom("conversations")
|
|
179
181
|
.select("id")
|
|
180
182
|
.where("parent_conversation_id", "=", a.conversationId)
|
|
183
|
+
.where("org_id", "=", orgId)
|
|
181
184
|
.where("kind", "=", "subagent")
|
|
182
185
|
.limit(1)
|
|
183
186
|
.executeTakeFirst()) !== undefined;
|
package/dist/runtime/run-jobs.js
CHANGED
|
@@ -38,6 +38,8 @@ export { TERMINAL_STATUSES } from "./run-status.js";
|
|
|
38
38
|
* that writes them (conversation, decided rows, run; ruling R19), so a stop, a run's end, a decision
|
|
39
39
|
* and a timeout never deadlock. Returns whether any of them is still pending.
|
|
40
40
|
*/
|
|
41
|
+
// org-filter: locks the wait rows of a run the caller already holds (its conversation row is
|
|
42
|
+
// locked first); run ids are kernel-resolved, never request input
|
|
41
43
|
export async function lockWaitRowsIn(t, runId) {
|
|
42
44
|
const approvals = await t
|
|
43
45
|
.selectFrom("approvals")
|
|
@@ -253,6 +255,7 @@ let RunResume = class RunResume {
|
|
|
253
255
|
.executeTakeFirst();
|
|
254
256
|
if (!row)
|
|
255
257
|
return "other-wait-pending";
|
|
258
|
+
// org-filter: the conversation of the run row just resumed above; reads its own org
|
|
256
259
|
const conv = await t
|
|
257
260
|
.selectFrom("conversations")
|
|
258
261
|
.select(["kind", "org_id"])
|
|
@@ -92,6 +92,8 @@ export async function orphanCandidates(db, statuses, minAgeMs, limit, after) {
|
|
|
92
92
|
}
|
|
93
93
|
/** Whether delivery is still owed by a pending outbox row; dead copies are not active work.
|
|
94
94
|
*/
|
|
95
|
+
// org-filter: outbox rows looked up by queue and deterministic kernel job id (unique across the
|
|
96
|
+
// deployment) in the deployment-wide orphan check; outbox.org_id is nullable
|
|
95
97
|
export async function jobInOutbox(db, queue, jobId) {
|
|
96
98
|
const row = await db
|
|
97
99
|
.selectFrom("outbox")
|
|
@@ -266,6 +268,8 @@ let RunOrphanCheck = class RunOrphanCheck {
|
|
|
266
268
|
.onConflict((oc) => oc.column("name").doUpdateSet(values))
|
|
267
269
|
.execute();
|
|
268
270
|
}
|
|
271
|
+
// org-filter: outbox rows looked up by queue and deterministic kernel job id (unique across the
|
|
272
|
+
// deployment) in the deployment-wide orphan check; outbox.org_id is nullable
|
|
269
273
|
async hasDeadDelivery(c) {
|
|
270
274
|
return ((await this.db
|
|
271
275
|
.selectFrom("outbox")
|
|
@@ -321,6 +325,8 @@ let RunOrphanCheck = class RunOrphanCheck {
|
|
|
321
325
|
if (deliveryFailed) {
|
|
322
326
|
// Lock dead rows against admin retry. A pending retry always takes precedence over a
|
|
323
327
|
// historical dead copy. Producers of replacement jobs also hold this conversation lock.
|
|
328
|
+
// org-filter: outbox rows by queue and deterministic kernel job id (unique across the
|
|
329
|
+
// deployment); outbox.org_id is nullable
|
|
324
330
|
const deliveries = await this.db
|
|
325
331
|
.selectFrom("outbox")
|
|
326
332
|
.select("dead_at")
|
|
@@ -370,6 +376,7 @@ let RunOrphanCheck = class RunOrphanCheck {
|
|
|
370
376
|
.selectFrom("conversations")
|
|
371
377
|
.select("id")
|
|
372
378
|
.where("id", "=", c.conversationId)
|
|
379
|
+
.where("org_id", "=", c.orgId)
|
|
373
380
|
.forUpdate()
|
|
374
381
|
.executeTakeFirst();
|
|
375
382
|
const r = await this.db
|