@capybara-hq/kernel 0.1.0-rc.124 → 0.1.0-rc.126

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.
Files changed (40) hide show
  1. package/dist/agents/onboarding-checklist.d.ts +1 -0
  2. package/dist/agents/onboarding-checklist.js +14 -1
  3. package/dist/catalog/catalog.module.js +0 -3
  4. package/dist/catalog/org-catalog.service.d.ts +0 -2
  5. package/dist/catalog/org-catalog.service.js +0 -4
  6. package/dist/catalog/org-extension.controller.d.ts +5 -9
  7. package/dist/catalog/org-extension.controller.js +22 -22
  8. package/dist/catalog/org-extension.schemas.d.ts +0 -1
  9. package/dist/catalog/org-extension.schemas.js +0 -2
  10. package/dist/catalog/plugin-install.d.ts +4 -1
  11. package/dist/catalog/plugin-install.js +4 -1
  12. package/dist/conversations/events.d.ts +10 -154
  13. package/dist/conversations/events.js +8 -83
  14. package/dist/devices/conversation-devices.d.ts +1 -2
  15. package/dist/devices/devices.service.d.ts +8 -1
  16. package/dist/devices/devices.service.js +1 -1
  17. package/dist/errors.d.ts +5 -0
  18. package/dist/errors.js +5 -0
  19. package/dist/evals/recorded-permission-context.js +1 -3
  20. package/dist/evals/recorded-tools.d.ts +3 -4
  21. package/dist/evals/recorded-tools.js +6 -7
  22. package/dist/extensions/org-config.d.ts +35 -8
  23. package/dist/extensions/org-config.js +61 -14
  24. package/dist/extensions/plugin-items.d.ts +16 -0
  25. package/dist/extensions/plugin-items.js +35 -0
  26. package/dist/platform/operation.d.ts +0 -2
  27. package/dist/platform/ops/extensions.ops.d.ts +4 -6
  28. package/dist/platform/ops/extensions.ops.js +17 -34
  29. package/dist/runtime/context/build.d.ts +1 -1
  30. package/dist/runtime/context/build.js +1 -10
  31. package/dist/runtime/context/device-paths.d.ts +5 -82
  32. package/dist/runtime/context/device-paths.js +3 -174
  33. package/dist/runtime/context/permission-profile.d.ts +3 -13
  34. package/dist/runtime/context/permission-profile.js +9 -26
  35. package/dist/runtime/permission-context.service.js +3 -4
  36. package/dist/runtime/run-worker.js +6 -5
  37. package/package.json +1 -1
  38. package/src/migrations/0210_normalize_conversation_history.sql +1012 -0
  39. package/dist/catalog/org-extension-switch.d.ts +0 -41
  40. package/dist/catalog/org-extension-switch.js +0 -123
@@ -1,41 +0,0 @@
1
- import { OrgExtensionConfigs, type OrgExtensionInput, type OrgExtensionView } from "../extensions/org-config.js";
2
- import { TransactionHost } from "../infra/database/transaction-host.js";
3
- import { OrgCatalogService } from "./org-catalog.service.js";
4
- import type { UninstallPreview } from "./plugin-install.js";
5
- /** The result of {@link OrgExtensionSwitch.put}: the extension, or the plugin uninstall preview. */
6
- export type OrgExtensionPutResult = {
7
- kind: "done";
8
- view: OrgExtensionView;
9
- } | {
10
- kind: "preview";
11
- preview: UninstallPreview;
12
- confirm: string;
13
- };
14
- /**
15
- * `PUT orgs/:orgId/extensions/:extension`: for an extension that ships in a catalog plugin, `enabled`
16
- * is the plugin's org switch ({@link OrgCatalogService.setSwitch}); anything else is the direct
17
- * {@link OrgExtensionConfigs.put}. Lives in the catalog module because the catalog depends on the
18
- * extensions, not the other way round. No in-process state. Switching never checks a config: an
19
- * extension whose effective config is not valid in the org is switched on and reported
20
- * `needsConfig` (spec A §6).
21
- */
22
- export declare class OrgExtensionSwitch {
23
- readonly txHost: TransactionHost;
24
- private readonly configs;
25
- private readonly catalog;
26
- constructor(txHost: TransactionHost, configs: OrgExtensionConfigs, catalog: OrgCatalogService);
27
- /**
28
- * - `enabled` on an extension of one catalog plugin: that plugin's switch; off without `confirm`
29
- * returns the preview and its hash, with the hash uninstalls; a builtin plugin (any of several
30
- * source items) -> 409 `plugin.scope_locked` (an `all` one may go off, layering spec §4).
31
- * - A required bootstrap plugin, a config-declared extension and one sourced from several items
32
- * keep the direct write.
33
- */
34
- put(orgId: string, actor: string, extension: string, body: OrgExtensionInput & {
35
- confirm?: string | undefined;
36
- }, actorTokenId?: string,
37
- /** Merged into the audit details (a Platform operation's `via: "agent"`). */
38
- auditDetail?: Record<string, unknown>): Promise<OrgExtensionPutResult>;
39
- private applyAtomic;
40
- private apply;
41
- }
@@ -1,123 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __param = (this && this.__param) || function (paramIndex, decorator) {
8
- return function (target, key) { decorator(target, key, paramIndex); }
9
- };
10
- import { Inject, Injectable } from "@nestjs/common";
11
- import { ApiError } from "../errors.js";
12
- import { OrgExtensionConfigs, } from "../extensions/org-config.js";
13
- import { TransactionHost } from "../infra/database/transaction-host.js";
14
- import { Transactional } from "../infra/database/transactional.decorator.js";
15
- import { OrgCatalogService } from "./org-catalog.service.js";
16
- /**
17
- * `PUT orgs/:orgId/extensions/:extension`: for an extension that ships in a catalog plugin, `enabled`
18
- * is the plugin's org switch ({@link OrgCatalogService.setSwitch}); anything else is the direct
19
- * {@link OrgExtensionConfigs.put}. Lives in the catalog module because the catalog depends on the
20
- * extensions, not the other way round. No in-process state. Switching never checks a config: an
21
- * extension whose effective config is not valid in the org is switched on and reported
22
- * `needsConfig` (spec A §6).
23
- */
24
- let OrgExtensionSwitch = class OrgExtensionSwitch {
25
- txHost;
26
- configs;
27
- catalog;
28
- constructor(txHost, configs, catalog) {
29
- this.txHost = txHost;
30
- this.configs = configs;
31
- this.catalog = catalog;
32
- }
33
- /**
34
- * - `enabled` on an extension of one catalog plugin: that plugin's switch; off without `confirm`
35
- * returns the preview and its hash, with the hash uninstalls; a builtin plugin (any of several
36
- * source items) -> 409 `plugin.scope_locked` (an `all` one may go off, layering spec §4).
37
- * - A required bootstrap plugin, a config-declared extension and one sourced from several items
38
- * keep the direct write.
39
- */
40
- async put(orgId, actor, extension, body, actorTokenId,
41
- /** Merged into the audit details (a Platform operation's `via: "agent"`). */
42
- auditDetail) {
43
- const { confirm, ...input } = body;
44
- const audited = auditDetail !== undefined ? { auditDetail } : {};
45
- const plan = input.enabled === undefined
46
- ? { kind: "direct" }
47
- : await this.configs.switchPlan(extension, input.enabled);
48
- if (plan.kind === "locked") {
49
- throw new ApiError("plugin.scope_locked", "This plugin is built in: it is on for every organization and cannot be switched off here");
50
- }
51
- if (plan.kind === "direct") {
52
- return {
53
- kind: "done",
54
- view: await this.configs.put(orgId, extension, input, actor, actorTokenId, audited),
55
- };
56
- }
57
- const { enabled } = input;
58
- // A fresh install is a multi-step saga that commits on its own and already enables the
59
- // extension: no transaction spans it. Everything else (the switch row, an uninstall, reading
60
- // the result back) is one transaction.
61
- const installing = enabled === true && !(await this.catalog.hasLiveInstall(orgId, plan.itemId));
62
- const args = {
63
- orgId,
64
- actor,
65
- extension,
66
- itemId: plan.itemId,
67
- enabled,
68
- confirm,
69
- actorTokenId,
70
- auditDetail,
71
- };
72
- const r = await (installing ? this.apply(args, true) : this.applyAtomic(args));
73
- if (r !== "readBack")
74
- return r;
75
- // Read after the commit: the list reads its own snapshot, which sees only committed rows
76
- const view = (await this.configs.list(orgId)).find((v) => v.plugin === extension);
77
- if (view)
78
- return { kind: "done", view };
79
- return {
80
- kind: "done",
81
- view: await this.configs.put(orgId, extension, { enabled: true }, actor, actorTokenId, {
82
- ifDisabled: { skipped: false },
83
- ...audited,
84
- }),
85
- };
86
- }
87
- applyAtomic(a) {
88
- return this.apply(a, false);
89
- }
90
- async apply(a, installing) {
91
- const { orgId, actor, extension, itemId, enabled, confirm, actorTokenId, auditDetail } = a;
92
- const audited = auditDetail !== undefined ? { auditDetail } : {};
93
- // Switching on inside the transaction relies on the live install seen before it: one removed
94
- // meanwhile would run the install saga here, which commits on its own. Refuse instead; the
95
- // retry takes the install path.
96
- if (!installing && enabled === true && !(await this.catalog.hasLiveInstall(orgId, itemId))) {
97
- throw new ApiError("conflict", "The plugin's install in this organization changed while it was being switched on; try again");
98
- }
99
- const r = await this.catalog.setSwitch(orgId, actor, itemId, enabled ? { enabled: true } : { enabled: false, ...(confirm !== undefined && { confirm }) }, actorTokenId, auditDetail);
100
- if (r.kind === "preview")
101
- return r;
102
- if (!enabled)
103
- return "readBack";
104
- // Switching on: the install enabled it already (no second write)
105
- return {
106
- kind: "done",
107
- view: await this.configs.put(orgId, extension, { enabled: true }, actor, actorTokenId, {
108
- ifDisabled: { skipped: false },
109
- ...audited,
110
- }),
111
- };
112
- }
113
- };
114
- __decorate([
115
- Transactional()
116
- ], OrgExtensionSwitch.prototype, "applyAtomic", null);
117
- OrgExtensionSwitch = __decorate([
118
- Injectable(),
119
- __param(0, Inject(TransactionHost)),
120
- __param(1, Inject(OrgExtensionConfigs)),
121
- __param(2, Inject(OrgCatalogService))
122
- ], OrgExtensionSwitch);
123
- export { OrgExtensionSwitch };