@capybara-hq/kernel 0.1.0-rc.84 → 0.1.0-rc.86

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 (157) hide show
  1. package/dist/admin/admin.module.js +5 -0
  2. package/dist/admin/health.service.d.ts +2 -2
  3. package/dist/admin/health.service.js +10 -2
  4. package/dist/catalog/admin-catalog.controller.d.ts +2 -1
  5. package/dist/catalog/admin-catalog.controller.js +2 -1
  6. package/dist/catalog/catalog-content.d.ts +5 -15
  7. package/dist/catalog/catalog-content.js +5 -56
  8. package/dist/catalog/catalog-scope.service.d.ts +3 -3
  9. package/dist/catalog/catalog-scope.service.js +4 -3
  10. package/dist/catalog/catalog.module.d.ts +3 -1
  11. package/dist/catalog/catalog.module.js +14 -1
  12. package/dist/catalog/component-scope.service.d.ts +6 -1
  13. package/dist/catalog/component-scope.service.js +16 -2
  14. package/dist/catalog/job-ids.d.ts +29 -0
  15. package/dist/catalog/job-ids.js +29 -0
  16. package/dist/catalog/jobs.d.ts +12 -3
  17. package/dist/catalog/jobs.js +28 -7
  18. package/dist/catalog/marketplaces.service.d.ts +1 -1
  19. package/dist/catalog/org-catalog.controller.d.ts +2 -30
  20. package/dist/catalog/org-catalog.controller.js +3 -29
  21. package/dist/catalog/org-catalog.schemas.d.ts +9 -46
  22. package/dist/catalog/org-catalog.schemas.js +9 -23
  23. package/dist/catalog/org-catalog.service.js +14 -23
  24. package/dist/catalog/plugin-import.d.ts +21 -0
  25. package/dist/catalog/plugin-import.js +33 -3
  26. package/dist/catalog/plugin-install.d.ts +69 -76
  27. package/dist/catalog/plugin-install.js +156 -234
  28. package/dist/catalog/plugin-upgrade.d.ts +71 -11
  29. package/dist/catalog/plugin-upgrade.js +222 -43
  30. package/dist/catalog/scope-sync.d.ts +22 -20
  31. package/dist/catalog/scope-sync.js +57 -42
  32. package/dist/catalog/template-connector-ensure.d.ts +100 -0
  33. package/dist/catalog/template-connector-ensure.js +285 -0
  34. package/dist/catalog/template-connector-jobs.d.ts +28 -0
  35. package/dist/catalog/template-connector-jobs.js +54 -0
  36. package/dist/catalog/template-connector-reconcile.d.ts +44 -0
  37. package/dist/catalog/template-connector-reconcile.js +114 -0
  38. package/dist/catalog/template-connectors.processor.d.ts +32 -0
  39. package/dist/catalog/template-connectors.processor.js +101 -0
  40. package/dist/channels/cards.d.ts +7 -3
  41. package/dist/channels/cards.js +9 -4
  42. package/dist/channels/phrases.d.ts +10 -0
  43. package/dist/channels/phrases.js +10 -0
  44. package/dist/config/docs.js +1 -1
  45. package/dist/config/schema.d.ts +3 -0
  46. package/dist/config/schema.js +18 -12
  47. package/dist/ctx/create-ctx.d.ts +10 -1
  48. package/dist/ctx/create-ctx.js +42 -2
  49. package/dist/db/kernel-schema.d.ts +2 -1
  50. package/dist/device-access/device-access.module.d.ts +7 -0
  51. package/dist/device-access/device-access.module.js +41 -0
  52. package/dist/device-access/device-access.service.d.ts +142 -0
  53. package/dist/device-access/device-access.service.js +464 -0
  54. package/dist/device-access/token.d.ts +6 -0
  55. package/dist/device-access/token.js +6 -0
  56. package/dist/device-access/viewer-routes.d.ts +45 -0
  57. package/dist/device-access/viewer-routes.js +81 -0
  58. package/dist/device-access/viewer.d.ts +244 -0
  59. package/dist/device-access/viewer.js +844 -0
  60. package/dist/dial-in/access.d.ts +19 -0
  61. package/dist/dial-in/access.js +23 -0
  62. package/dist/dial-in/gateway.d.ts +48 -6
  63. package/dist/dial-in/gateway.js +145 -10
  64. package/dist/dial-in/keys.d.ts +7 -0
  65. package/dist/dial-in/keys.js +7 -0
  66. package/dist/dial-in/routes.d.ts +11 -3
  67. package/dist/dial-in/routes.js +15 -4
  68. package/dist/dial-in/streams.d.ts +58 -0
  69. package/dist/dial-in/streams.js +283 -0
  70. package/dist/errors.d.ts +2 -0
  71. package/dist/errors.js +2 -0
  72. package/dist/extensions/host.d.ts +13 -1
  73. package/dist/extensions/host.js +20 -1
  74. package/dist/extensions/org-config.d.ts +6 -1
  75. package/dist/extensions/org-config.js +15 -2
  76. package/dist/extensions/permission-set.d.ts +15 -1
  77. package/dist/extensions/permission-set.js +13 -1
  78. package/dist/extensions/permission-view.d.ts +6 -4
  79. package/dist/extensions/permission-view.js +6 -1
  80. package/dist/git/gateway.js +3 -1
  81. package/dist/http/error.filter.js +2 -0
  82. package/dist/http/gateway-routes.d.ts +8 -4
  83. package/dist/http/gateway-routes.js +4 -3
  84. package/dist/infra/lock/lock.service.d.ts +5 -1
  85. package/dist/infra/lock/lock.service.js +10 -4
  86. package/dist/infra/outbox/registry.d.ts +28 -0
  87. package/dist/infra/outbox/registry.js +33 -0
  88. package/dist/infra/queue/queue-names.d.ts +1 -1
  89. package/dist/infra/queue/queue-names.js +2 -0
  90. package/dist/infra/throttler/named-throttlers.d.ts +3 -0
  91. package/dist/infra/throttler/named-throttlers.js +16 -0
  92. package/dist/kernel.module.js +3 -0
  93. package/dist/lifecycle/kernel-lifecycle.d.ts +8 -1
  94. package/dist/lifecycle/kernel-lifecycle.js +37 -11
  95. package/dist/orgs/org-owner.d.ts +7 -0
  96. package/dist/orgs/org-owner.js +16 -0
  97. package/dist/platform/operation.d.ts +3 -4
  98. package/dist/platform/ops/connectors.ops.js +8 -1
  99. package/dist/platform/ops/org-plugins.ops.d.ts +0 -9
  100. package/dist/platform/ops/org-plugins.ops.js +18 -235
  101. package/dist/platform/ops/plugins.ops.d.ts +0 -1
  102. package/dist/platform/ops/plugins.ops.js +3 -31
  103. package/dist/roles/gateway-role.d.ts +13 -6
  104. package/dist/roles/gateway-role.js +27 -9
  105. package/dist/roles/gateway.module.d.ts +2 -1
  106. package/dist/roles/gateway.module.js +13 -3
  107. package/dist/roles/worker-role.d.ts +9 -4
  108. package/dist/roles/worker-role.js +18 -5
  109. package/dist/roles/worker.module.d.ts +1 -1
  110. package/dist/roles/worker.module.js +8 -1
  111. package/dist/sandbox/device-services.d.ts +62 -0
  112. package/dist/sandbox/device-services.js +183 -0
  113. package/dist/sandbox/leases.d.ts +18 -1
  114. package/dist/sandbox/leases.js +75 -1
  115. package/dist/sandbox/network-grants.js +5 -2
  116. package/dist/sandbox/sandbox.module.d.ts +2 -1
  117. package/dist/sandbox/sandbox.module.js +5 -2
  118. package/dist/sandbox/sandbox.service.d.ts +44 -1
  119. package/dist/sandbox/sandbox.service.js +142 -5
  120. package/dist/setup/setup-guides.service.d.ts +9 -1
  121. package/dist/setup/setup-guides.service.js +38 -8
  122. package/dist/tools/admin-connectors.d.ts +3 -2
  123. package/dist/tools/admin-connectors.js +5 -4
  124. package/dist/tools/approvals.service.d.ts +45 -20
  125. package/dist/tools/approvals.service.js +19 -9
  126. package/dist/tools/call-scope.d.ts +60 -0
  127. package/dist/tools/call-scope.js +23 -0
  128. package/dist/tools/connector-setup.d.ts +28 -0
  129. package/dist/tools/connector-setup.js +33 -0
  130. package/dist/tools/connector-tools-jobs.d.ts +35 -0
  131. package/dist/tools/connector-tools-jobs.js +40 -0
  132. package/dist/tools/connector-tools.processor.d.ts +32 -0
  133. package/dist/tools/connector-tools.processor.js +97 -0
  134. package/dist/tools/connectors.controller.d.ts +1 -0
  135. package/dist/tools/connectors.schemas.d.ts +1 -0
  136. package/dist/tools/connectors.schemas.js +5 -0
  137. package/dist/tools/connectors.service.d.ts +138 -14
  138. package/dist/tools/connectors.service.js +410 -50
  139. package/dist/tools/credentials.d.ts +35 -0
  140. package/dist/tools/credentials.js +89 -1
  141. package/dist/tools/drift.d.ts +5 -0
  142. package/dist/tools/drift.js +21 -2
  143. package/dist/tools/editable-endpoint.d.ts +23 -0
  144. package/dist/tools/editable-endpoint.js +92 -0
  145. package/dist/tools/network-asks.d.ts +13 -0
  146. package/dist/tools/network-asks.js +26 -2
  147. package/dist/tools/oauth/flow.d.ts +1 -1
  148. package/dist/tools/oauth/flow.js +3 -2
  149. package/dist/tools/pipeline.d.ts +30 -1
  150. package/dist/tools/pipeline.js +299 -59
  151. package/dist/tools/questions.service.d.ts +24 -3
  152. package/dist/tools/questions.service.js +3 -1
  153. package/dist/tools/registry.d.ts +14 -2
  154. package/dist/tools/registry.js +27 -6
  155. package/dist/tools/tools.module.js +4 -0
  156. package/package.json +3 -3
  157. package/src/migrations/0183_connectors_created_by_nullable.sql +5 -0
@@ -12,6 +12,7 @@ import type { PersonFieldSpec } from "../platform/person-fields.js";
12
12
  import type { ConversationKindForHooks } from "../runtime/hook-calls.js";
13
13
  import type { ExecutionClaim } from "../runtime/run-execution.js";
14
14
  import { BuiltinTools } from "./builtins/builtin-tools.js";
15
+ import { Credentials } from "./credentials.js";
15
16
  import { OrgToolSwitches } from "./org-tool-switches.js";
16
17
  export { BUILTIN_TOOL_NAMES } from "./builtin-names.js";
17
18
  export { canonicalJson } from "./canonical-json.js";
@@ -347,8 +348,9 @@ export interface AgentTools {
347
348
  * the org (`extension_org_configs.enabled`; required bootstrap plugins and builtin plugins'
348
349
  * extensions are enabled in every org, `enabled.ts`), whose effective config for the org is valid (layering spec A §6) and that the
349
350
  * org did not switch off (§7: the org's switch wins);
350
- * - connector tools: every enabled tool of every live, active connector of the org whose
351
- * connector extension is installed, with a valid key.
351
+ * - connector tools: every enabled tool of every live, active, `ready` connector of the org
352
+ * (a `needs_config` one offers none, plugin pages spec §5.2.1) whose connector extension is
353
+ * installed, with a valid key.
352
354
  * What cannot be offered goes to `hidden` with the reason; nothing is reported to the model as
353
355
  * unavailable except two sources with one key (the first wins).
354
356
  */
@@ -366,6 +368,11 @@ export declare class ToolRegistry {
366
368
  private readonly effective;
367
369
  /** The org's switches of single extension tools (layering spec A §7). */
368
370
  private readonly switches;
371
+ /**
372
+ * The org inputs connectors need (plugin pages spec §5.2.1): a `needs_config` connector
373
+ * offers no tools.
374
+ */
375
+ private readonly credentials;
369
376
  /**
370
377
  * `tools.searchThreshold*` and the sub-agent limits. Absent (some tests): `ToolSearch` is never
371
378
  * offered and the sub-agent limits are the schema defaults.
@@ -383,6 +390,11 @@ export declare class ToolRegistry {
383
390
  effective: Pick<EffectiveConfigs, "get">,
384
391
  /** The org's switches of single extension tools (layering spec A §7). */
385
392
  switches: Pick<OrgToolSwitches, "offKeys">,
393
+ /**
394
+ * The org inputs connectors need (plugin pages spec §5.2.1): a `needs_config` connector
395
+ * offers no tools.
396
+ */
397
+ credentials: Pick<Credentials, "orgInputs">,
386
398
  /**
387
399
  * `tools.searchThreshold*` and the sub-agent limits. Absent (some tests): `ToolSearch` is never
388
400
  * offered and the sub-agent limits are the schema defaults.
@@ -24,6 +24,8 @@ import { AGENT_BUILTIN_NAMES, AGENT_TOOL, BASH_COMPANION_TOOLS, BUILTIN, SEND_ME
24
24
  import { agentToolSpec } from "./builtins/agent.js";
25
25
  import { BuiltinTools } from "./builtins/builtin-tools.js";
26
26
  import { canonicalJson } from "./canonical-json.js";
27
+ import { connectorSetups } from "./connector-setup.js";
28
+ import { Credentials } from "./credentials.js";
27
29
  import { toolKeyIssue } from "./naming.js";
28
30
  import { OrgToolSwitches, toolTurnedOffReason } from "./org-tool-switches.js";
29
31
  export { BUILTIN_TOOL_NAMES } from "./builtin-names.js";
@@ -98,8 +100,9 @@ const builtinTool = (b, spec) => ({
98
100
  * the org (`extension_org_configs.enabled`; required bootstrap plugins and builtin plugins'
99
101
  * extensions are enabled in every org, `enabled.ts`), whose effective config for the org is valid (layering spec A §6) and that the
100
102
  * org did not switch off (§7: the org's switch wins);
101
- * - connector tools: every enabled tool of every live, active connector of the org whose
102
- * connector extension is installed, with a valid key.
103
+ * - connector tools: every enabled tool of every live, active, `ready` connector of the org
104
+ * (a `needs_config` one offers none, plugin pages spec §5.2.1) whose connector extension is
105
+ * installed, with a valid key.
103
106
  * What cannot be offered goes to `hidden` with the reason; nothing is reported to the model as
104
107
  * unavailable except two sources with one key (the first wins).
105
108
  */
@@ -110,6 +113,7 @@ let ToolRegistry = class ToolRegistry {
110
113
  builtinTools;
111
114
  effective;
112
115
  switches;
116
+ credentials;
113
117
  config;
114
118
  constructor(db,
115
119
  /** Extension tools and the organization's enabled extensions. */
@@ -123,6 +127,11 @@ let ToolRegistry = class ToolRegistry {
123
127
  effective,
124
128
  /** The org's switches of single extension tools (layering spec A §7). */
125
129
  switches,
130
+ /**
131
+ * The org inputs connectors need (plugin pages spec §5.2.1): a `needs_config` connector
132
+ * offers no tools.
133
+ */
134
+ credentials,
126
135
  /**
127
136
  * `tools.searchThreshold*` and the sub-agent limits. Absent (some tests): `ToolSearch` is never
128
137
  * offered and the sub-agent limits are the schema defaults.
@@ -134,6 +143,7 @@ let ToolRegistry = class ToolRegistry {
134
143
  this.builtinTools = builtinTools;
135
144
  this.effective = effective;
136
145
  this.switches = switches;
146
+ this.credentials = credentials;
137
147
  this.config = config;
138
148
  }
139
149
  /** The kernel's builtin tools (`ToolSearch` is added by {@link forAgent}, not by definitions). */
@@ -458,8 +468,10 @@ let ToolRegistry = class ToolRegistry {
458
468
  });
459
469
  }
460
470
  }
461
- // connector tools: the org's live connectors
462
- for (const app of await this.loadOrgConnectors(orgId, { includeDeleted: false })) {
471
+ // connector tools: the org's live connectors, none from one that needs an org admin's input
472
+ const apps = await this.loadOrgConnectors(orgId, { includeDeleted: false });
473
+ const setups = await connectorSetups(this.credentials, orgId, apps);
474
+ for (const app of apps) {
463
475
  if (disabled.some((r) => r.kind === "connector" && r.connectorId === app.id && r.tools === "all")) {
464
476
  continue;
465
477
  }
@@ -468,6 +480,13 @@ let ToolRegistry = class ToolRegistry {
468
480
  hidden.push({ ref: all, reason: `App ${app.slug} is disabled` });
469
481
  continue;
470
482
  }
483
+ if (setups.get(app.id) !== "ready") {
484
+ hidden.push({
485
+ ref: all,
486
+ reason: `Connector ${app.slug} needs to be configured by an organization admin`,
487
+ });
488
+ continue;
489
+ }
471
490
  if (!this.findConnector(app.connector)) {
472
491
  hidden.push({
473
492
  ref: all,
@@ -536,7 +555,7 @@ let ToolRegistry = class ToolRegistry {
536
555
  async loadOrgConnectors(orgId, _opts) {
537
556
  const apps = await this.db
538
557
  .selectFrom("connectors")
539
- .select(["id", "slug", "connector", "status"])
558
+ .select(["id", "slug", "connector", "auth", "status"])
540
559
  .where("org_id", "=", orgId)
541
560
  .where("deleted_at", "is", null)
542
561
  .orderBy("slug")
@@ -563,6 +582,7 @@ let ToolRegistry = class ToolRegistry {
563
582
  id: a.id,
564
583
  slug: a.slug,
565
584
  connector: a.connector,
585
+ auth: a.auth,
566
586
  status: a.status,
567
587
  tools: toolRows
568
588
  .filter((t) => t.connector_id === a.id)
@@ -586,7 +606,8 @@ ToolRegistry = __decorate([
586
606
  __param(3, Inject(BuiltinTools)),
587
607
  __param(4, Inject(EffectiveConfigs)),
588
608
  __param(5, Inject(OrgToolSwitches)),
589
- __param(6, Inject(KernelConfigService))
609
+ __param(6, Inject(Credentials)),
610
+ __param(7, Inject(KernelConfigService))
590
611
  ], ToolRegistry);
591
612
  export { ToolRegistry };
592
613
  /**
@@ -40,6 +40,7 @@ import { ScheduleToolsPort, ScheduleUpdates } from "./builtins/schedules.js";
40
40
  import { WebPages } from "./builtins/web/page-cache.js";
41
41
  import { ConnectorAccountPolicies } from "./connector-account-policies.js";
42
42
  import { ConnectorContent } from "./connector-content.js";
43
+ import { ConnectorToolsQueueModule } from "./connector-tools-jobs.js";
43
44
  import { ConnectorsService } from "./connectors.service.js";
44
45
  import { CredentialsModule } from "./credentials.module.js";
45
46
  import { ToolDrift } from "./drift.js";
@@ -101,6 +102,9 @@ ToolsModule = __decorate([
101
102
  // the `Platform` tool's operations, actor facts and agent docs (imports no domain module)
102
103
  PlatformModule,
103
104
  QueueModule.registerQueue(MAINTENANCE_QUEUE_NAME),
105
+ // the connector tool listings owed after a create or a setup (consumer: the worker role's
106
+ // ConnectorToolsProcessor)
107
+ ConnectorToolsQueueModule,
104
108
  // a trial run's approvals become its scheduled task's grants (scheduled tasks spec §7)
105
109
  ScheduledTaskStoreModule,
106
110
  // connector credentials (also the git gateway's, without importing this module)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/kernel",
3
- "version": "0.1.0-rc.84",
3
+ "version": "0.1.0-rc.86",
4
4
  "description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -66,7 +66,7 @@
66
66
  "yaml": "^2.9.1",
67
67
  "yauzl": "3.4.0",
68
68
  "zod": "^4.6.7",
69
- "@capybara-hq/plugin-sdk": "^0.1.0-rc.69"
69
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.70"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@langchain/langgraph-checkpoint-validation": "^1.2.0",
@@ -75,7 +75,7 @@
75
75
  "@types/ws": "^8.18.2",
76
76
  "@types/yauzl": "3.4.0",
77
77
  "ws": "^8.22.0",
78
- "@capybara-hq/testing": "0.1.0-rc.38"
78
+ "@capybara-hq/testing": "0.1.0-rc.40"
79
79
  },
80
80
  "scripts": {
81
81
  "build": "tsc -b"
@@ -0,0 +1,5 @@
1
+ -- Plugin pages spec §5.2.1 (ruling R17): the kernel creates template connectors as no person (a
2
+ -- plugin scope sync, the startup reconciliation), so such a connector has no creator. Relaxing NOT
3
+ -- NULL is expand-only: rows written before keep their creator, and dropping NOT NULL on a nullable
4
+ -- column is a no-op.
5
+ ALTER TABLE connectors ALTER COLUMN created_by DROP NOT NULL;