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

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 (101) hide show
  1. package/bootstrap.json +31 -31
  2. package/dist/admin/admin.controller.d.ts +2 -2
  3. package/dist/admin/admin.controller.js +1 -1
  4. package/dist/admin/health.service.js +5 -5
  5. package/dist/admin/overview.service.d.ts +2 -2
  6. package/dist/admin/overview.service.js +1 -1
  7. package/dist/agents/agents.module.js +4 -0
  8. package/dist/agents/agents.schemas.js +1 -0
  9. package/dist/agents/models.controller.d.ts +2 -2
  10. package/dist/agents/onboarding-checklist.d.ts +30 -0
  11. package/dist/agents/onboarding-checklist.js +176 -0
  12. package/dist/agents/readiness.controller.d.ts +1 -0
  13. package/dist/agents/readiness.controller.js +12 -2
  14. package/dist/agents/readiness.service.d.ts +5 -2
  15. package/dist/agents/readiness.service.js +14 -3
  16. package/dist/automations/automations.service.js +7 -21
  17. package/dist/automations/events/acceptance.d.ts +2 -0
  18. package/dist/automations/events/acceptance.js +14 -3
  19. package/dist/automations/events/sweep.job.d.ts +3 -36
  20. package/dist/automations/events/sweep.job.js +5 -127
  21. package/dist/automations/fire.d.ts +3 -0
  22. package/dist/automations/fire.js +18 -1
  23. package/dist/automations/grant-rules.d.ts +0 -14
  24. package/dist/automations/grant-rules.js +0 -18
  25. package/dist/automations/scan.job.js +22 -16
  26. package/dist/catalog/catalog.module.d.ts +4 -7
  27. package/dist/catalog/catalog.module.js +4 -10
  28. package/dist/catalog/marketplaces.service.d.ts +1 -1
  29. package/dist/catalog/plugin-import.js +2 -1
  30. package/dist/catalog/plugin-install.d.ts +2 -2
  31. package/dist/catalog/plugin-install.js +2 -2
  32. package/dist/catalog/template-connector-ensure.d.ts +4 -7
  33. package/dist/catalog/template-connector-ensure.js +11 -15
  34. package/dist/channels/supervisor.js +34 -23
  35. package/dist/channels/webhook.d.ts +1 -0
  36. package/dist/channels/webhook.js +10 -5
  37. package/dist/conversations/job-org.d.ts +2 -0
  38. package/dist/conversations/job-org.js +12 -0
  39. package/dist/ctx/create-ctx.js +2 -1
  40. package/dist/db/kernel-schema.d.ts +1 -0
  41. package/dist/dial-in/auth.controller.js +3 -2
  42. package/dist/dial-in/auth.service.js +3 -2
  43. package/dist/dial-in/gateway.d.ts +0 -1
  44. package/dist/dial-in/gateway.js +6 -9
  45. package/dist/extensions/host.d.ts +2 -2
  46. package/dist/extensions/host.js +22 -13
  47. package/dist/extensions/installs.d.ts +1 -0
  48. package/dist/extensions/installs.js +2 -0
  49. package/dist/html/html-document.controller.js +3 -0
  50. package/dist/html/html-document.service.js +2 -0
  51. package/dist/http/plugin-route-access.js +7 -2
  52. package/dist/identity/account-avatar.controller.js +4 -2
  53. package/dist/identity/accounts.js +19 -32
  54. package/dist/identity/api-tokens.d.ts +2 -0
  55. package/dist/identity/api-tokens.js +14 -10
  56. package/dist/identity/audit.js +10 -5
  57. package/dist/identity/binding.d.ts +1 -1
  58. package/dist/identity/binding.js +19 -10
  59. package/dist/lifecycle/kernel-lifecycle.d.ts +1 -8
  60. package/dist/lifecycle/kernel-lifecycle.js +11 -37
  61. package/dist/models/purposes.d.ts +24 -3
  62. package/dist/models/purposes.js +131 -14
  63. package/dist/orgs/directory-sync.js +6 -4
  64. package/dist/orgs/roles.d.ts +1 -1
  65. package/dist/orgs/roles.js +1 -0
  66. package/dist/platform/exclusions.js +5 -0
  67. package/dist/platform/ops/admin.ops.js +1 -1
  68. package/dist/platform/ops/agents.ops.js +1 -1
  69. package/dist/platform/ops/models.ops.js +3 -3
  70. package/dist/push/fanout.d.ts +1 -0
  71. package/dist/push/fanout.js +11 -4
  72. package/dist/push/recipients.d.ts +3 -1
  73. package/dist/push/recipients.js +29 -22
  74. package/dist/runtime/maintenance.d.ts +5 -1
  75. package/dist/runtime/maintenance.js +50 -11
  76. package/dist/runtime/providers.d.ts +12 -9
  77. package/dist/runtime/providers.js +2 -23
  78. package/dist/runtime/run-orphan-check.job.d.ts +1 -0
  79. package/dist/runtime/run-orphan-check.job.js +23 -21
  80. package/dist/runtime/usage-report.d.ts +2 -1
  81. package/dist/runtime/usage-report.js +26 -4
  82. package/dist/sandbox/providers.d.ts +2 -0
  83. package/dist/sandbox/providers.js +2 -0
  84. package/dist/shares/liveness.d.ts +3 -2
  85. package/dist/shares/liveness.js +26 -11
  86. package/dist/shares/share-open.service.js +2 -0
  87. package/dist/skills/usable.d.ts +2 -0
  88. package/dist/skills/usable.js +56 -0
  89. package/dist/tools/builtins/platform.js +17 -12
  90. package/dist/tools/connector-setup.d.ts +5 -1
  91. package/dist/tools/connector-setup.js +14 -0
  92. package/dist/tools/credentials.d.ts +5 -0
  93. package/dist/tools/credentials.js +10 -0
  94. package/dist/tools/oauth/flow.d.ts +1 -0
  95. package/dist/tools/oauth/flow.js +8 -3
  96. package/dist/tools/registry.d.ts +2 -0
  97. package/dist/tools/registry.js +6 -0
  98. package/package.json +3 -3
  99. package/src/migrations/0209_onboarding_checklist.sql +5 -0
  100. package/dist/catalog/template-connector-reconcile.d.ts +0 -44
  101. package/dist/catalog/template-connector-reconcile.js +0 -114
package/bootstrap.json CHANGED
@@ -3,103 +3,103 @@
3
3
  "schemaVersion": 1,
4
4
  "marketplace": {
5
5
  "url": "https://github.com/capybara-hq/plugins.git",
6
- "commit": "a2883f98b7b7d207d9ffafddd486f365dfb9c08c"
6
+ "commit": "e5cc914a56d4c1dbb1383ba1729fcac8233dfd16"
7
7
  },
8
8
  "plugins": [
9
9
  {
10
10
  "name": "openai-compatible",
11
11
  "source": "npm",
12
12
  "npm": "@capybara-hq/plugin-openai-compatible",
13
- "version": "0.1.0-rc.16",
14
- "integrity": "sha512-a0A0cFcv6gcf8Pa4GxYYrc7algrOxE+VlnzIvZo2z58ckZWwAoLXcj2USAcBrZRLRLN11mTmT7QwWfaKia1G+A==",
13
+ "version": "0.1.0-rc.17",
14
+ "integrity": "sha512-ly1FFSEK5uwWqs+TPGmbiGeURqTXRuUjpakcj1wEsryxgueIDe2uyj+yvyIf/jwyTU3728tmxxZmgucGh9b1Qg==",
15
15
  "required": false
16
16
  },
17
17
  {
18
18
  "name": "object-store-s3",
19
19
  "source": "npm",
20
20
  "npm": "@capybara-hq/plugin-object-store-s3",
21
- "version": "0.1.0-rc.12",
22
- "integrity": "sha512-hPKfoH25RbEB8aA/Feqwfvbs2OR6B/MrXfj1DngBWEhSYvBoPfcezEC+LJDr35nRmfzsnqLc+Ho9Y4pT02tcyw==",
21
+ "version": "0.1.0-rc.13",
22
+ "integrity": "sha512-J0bhmRafIoifcZsI6ESTTKClZMSN/cPLVFKfVBIjGTzhGcZobAuTY5+m+j3zMeZCQcEzirBhtF3t76KpslWTZg==",
23
23
  "required": true
24
24
  },
25
25
  {
26
26
  "name": "anthropic",
27
27
  "source": "npm",
28
28
  "npm": "@capybara-hq/plugin-anthropic",
29
- "version": "0.1.0-rc.12",
30
- "integrity": "sha512-ABCkExMaGJUxcbDClv2mip931CmQGvbPcy9KV73vYEWUFGf/chU9I1irEKItIbx0I/yJRG1144GkpO3hfcmGrQ==",
29
+ "version": "0.1.0-rc.13",
30
+ "integrity": "sha512-9r5EWfkJl6y+MqGTk8dkX4Lz8KuJMrx7Q7o+CQUqaGkhLYZW6ZvvmXjnlpexJdSV0bomUeBpRo1nPSy54lvsNQ==",
31
31
  "required": false
32
32
  },
33
33
  {
34
34
  "name": "openai",
35
35
  "source": "npm",
36
36
  "npm": "@capybara-hq/plugin-openai",
37
- "version": "0.1.0-rc.15",
38
- "integrity": "sha512-D6iGu0lJMoXxHAPubBxPdF7NK8qxZhzF4DP27fI3p2oA3OvEaysQlU3EhMiGYgB31zjl9dqJMjIgVBaXHL711Q==",
37
+ "version": "0.1.0-rc.16",
38
+ "integrity": "sha512-QG87aBbF+de82lTAO2H+opusoWhCZYQWU9RljYpsL766v/AivdVW2gZhLhdine60C6dNCEP7zPzeECUxHtmEGA==",
39
39
  "required": false
40
40
  },
41
41
  {
42
42
  "name": "deepseek",
43
43
  "source": "npm",
44
44
  "npm": "@capybara-hq/plugin-deepseek",
45
- "version": "0.1.0-rc.14",
46
- "integrity": "sha512-+kWGoKIzTanvC/PyKZGsEg8ZqjoV11W/ynAXekCaFnH4QTZ8FrRZrQdSDtARyyU73EfNNiEV2V8dUVxvemhS/w==",
45
+ "version": "0.1.0-rc.15",
46
+ "integrity": "sha512-96WxB2yo6ohakBtGH1l6unG86e3gR/8T40WNzqcN0P/tyytTkBLFu2+fLDFuHKM2SMViP3HWAwoqFSUE6yDDPQ==",
47
47
  "required": false
48
48
  },
49
49
  {
50
50
  "name": "bailian",
51
51
  "source": "npm",
52
52
  "npm": "@capybara-hq/plugin-bailian",
53
- "version": "0.1.0-rc.15",
54
- "integrity": "sha512-Khi4XEy5gdyOfWEObqixyMYunF8eGwqewRvay5t/k7cYeCORsrHx7pVqti2/Uubf//oAM7hLLUMygRSiQo0uEw==",
53
+ "version": "0.1.0-rc.16",
54
+ "integrity": "sha512-rrDYU4ryQvFtb9XTpf5vDJ8EtGR+wtOqp3w8U+U/I4HL+LNSV8ckwtwNHC4bxhqhq3joi2KIdJQswUYkSJYLhA==",
55
55
  "required": false
56
56
  },
57
57
  {
58
58
  "name": "ark",
59
59
  "source": "npm",
60
60
  "npm": "@capybara-hq/plugin-ark",
61
- "version": "0.1.0-rc.15",
62
- "integrity": "sha512-IgsN+PARqkaO6wt5ndM+28UESleVEp0btmH/rUvNAsWp47IghYObGOikYkjHWVlWTApuFefKLkro+fKsS5HHPQ==",
61
+ "version": "0.1.0-rc.16",
62
+ "integrity": "sha512-ezWTJn2FJdsbBuWfpuoEbcxnTFlZxIQRA70nKkqf9cCeSXnZCwij2lc+6Og1qeUfSmYnFHcrXicp8RV2mmXjPw==",
63
63
  "required": false
64
64
  },
65
65
  {
66
66
  "name": "connector-mcp",
67
67
  "source": "npm",
68
68
  "npm": "@capybara-hq/plugin-connector-mcp",
69
- "version": "0.1.0-rc.13",
70
- "integrity": "sha512-buU17l5BhnfEnoe5m4uYIOTb25SodN1YrejLBZrWm/dgFCz4LowFSiE18gsTgInoUt02+Noo6E13mdzFURQRsg==",
69
+ "version": "0.1.0-rc.14",
70
+ "integrity": "sha512-/dzF1Pw6V2r4lsU1pCmAlAxjVWoX2LSlJ/zVj7nwM8yje90n9+/b17UX9ZSNVXQHs/h/6FH2uearnzM0iYDYxg==",
71
71
  "required": false
72
72
  },
73
73
  {
74
74
  "name": "connector-openapi",
75
75
  "source": "npm",
76
76
  "npm": "@capybara-hq/plugin-connector-openapi",
77
- "version": "0.1.0-rc.13",
78
- "integrity": "sha512-3kI76wL9WL8dPkjLxpXliRzQzI66Xs2fp/mYT6t5svCobJpoan/b6X72h46TeDO9SsXiT+5X9licvRxwSWf6Sw==",
77
+ "version": "0.1.0-rc.14",
78
+ "integrity": "sha512-Zt881ix9pgLQcyYl9r9HMRWld0pq2o4qi/k9L19ZmIWkDlaYavz6SZ5gocD8jYvzZPKMdA1RXu0Y/HWdYJXpXQ==",
79
79
  "required": false
80
80
  },
81
81
  {
82
82
  "name": "jina",
83
83
  "source": "npm",
84
84
  "npm": "@capybara-hq/plugin-jina",
85
- "version": "0.1.0-rc.10",
86
- "integrity": "sha512-Sxsg2qMz//QcZMqRCGvK7o8CqFDS5XMXpESmiyJasCoNYRE/cb/Q7v4XcSIc/WXccVTN9kWUBPJDU6c6gpiAjA==",
85
+ "version": "0.1.0-rc.11",
86
+ "integrity": "sha512-zmGyRObcS4aEOI1SZoHqMFbeBKvgNNVoYKYk+h69hMheYIiChe+oIXVedysxsXZisucpwzoDPRQ/un0gHIn2XA==",
87
87
  "required": false
88
88
  },
89
89
  {
90
90
  "name": "device-docker",
91
91
  "source": "npm",
92
92
  "npm": "@capybara-hq/plugin-device-docker",
93
- "version": "0.1.0-rc.35",
94
- "integrity": "sha512-9Aegf1i/JFzEURfO6L7DbPkVlYgrmQ3TkHSx4OS8fHr9C53MM5kSRHOyv1UfDTNbXlyKn6NOHn/oy1kiwQSkDQ==",
93
+ "version": "0.1.0-rc.36",
94
+ "integrity": "sha512-29vne4OcJDkOG0lq4AHEivdgFiAM7v+OnWhShDkLDfI0laet1jYRAglut+OqskoerOyi+gVTFGsBtid/dEuetg==",
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.15",
102
- "integrity": "sha512-Na+G/nd53xoKLI8gYYasIjUgnEjXTtky9tv7JvFAEoOqwPp5EJD0Wri9nQd3QREuJkL3ZO7XdaBZ0XmgaMFS8w==",
101
+ "version": "0.1.0-rc.17",
102
+ "integrity": "sha512-1cO8hRNz5mlArA+QxXkwr39Aluza0njOIyZidtI8wmX61eEuCxEiPv5W/+dBuUCatshwhjCGG+E0rB2udjliLA==",
103
103
  "required": false,
104
104
  "scope": "all"
105
105
  },
@@ -107,16 +107,16 @@
107
107
  "name": "todo",
108
108
  "source": "npm",
109
109
  "npm": "@capybara-hq/plugin-todo",
110
- "version": "0.1.0-rc.15",
111
- "integrity": "sha512-mfGmDbr14cPfp8CIqlChgSze/kdQVl2ij4Px5nlf4EOQA74qWhmNnjrJOK0vfXdkJP4J4D97zMBTiwupaHJb9Q==",
110
+ "version": "0.1.0-rc.16",
111
+ "integrity": "sha512-4jJ8uJ96d9Z1s30j9gDi+EKxgLyOctRw0rZXd20eSRW80/a+obmuSYPoZStuBxB7O+4SqF+dzGZxmBDlYRjWmA==",
112
112
  "required": false
113
113
  },
114
114
  {
115
115
  "name": "skills-core",
116
116
  "source": "npm",
117
117
  "npm": "@capybara-hq/plugin-skills-core",
118
- "version": "0.1.0-rc.2",
119
- "integrity": "sha512-I0jlrKU+bqiGRW65jVLftT2S5Oa4QVaG1hDr6+1TT8gtAMjOkl87lNNrWJFHeOvp1bJBbx6ccLGffSUVesHqlA==",
118
+ "version": "0.1.0-rc.3",
119
+ "integrity": "sha512-z4vqSFBZnh/Fh0/xHZ55Fw17cjb56i+Yfi8c5pmF5v4BTRCtEPp4416uyvisbLKBZ6oGjNMxI01UBddDXNntrg==",
120
120
  "required": false,
121
121
  "builtin": true
122
122
  },
@@ -124,8 +124,8 @@
124
124
  "name": "file-preview",
125
125
  "source": "npm",
126
126
  "npm": "@capybara-hq/plugin-file-preview",
127
- "version": "0.1.0-rc.5",
128
- "integrity": "sha512-/GSQeVc2AlO3q69pLm4EKFo8Q85nQG3PXbKPdL2UV+PeTBvXgqEL2bWO1upSVhD+SQaq3OTU85GZ097QjzDkrA==",
127
+ "version": "0.1.0-rc.6",
128
+ "integrity": "sha512-CNaziqin6RbmFGNesCoBTFcCLhko6DZBmUXsh6XcAoIE7cQvQBzjO8U4SsbGwBaLCQqKiaNrCxowAi3p/2zJVA==",
129
129
  "required": false,
130
130
  "builtin": true
131
131
  }
@@ -15,7 +15,7 @@ import { type ModelPrice, type ModelPricePut, PricesService } from "../models/pr
15
15
  import { ModelPurposesService, type PurposeListing, type PurposePut } from "../models/purposes.js";
16
16
  import { type Member, MembersService } from "../orgs/members.service.js";
17
17
  import { type Org, OrgsService } from "../orgs/orgs.service.js";
18
- import { ProviderRegistry, type ProviderStatus } from "../runtime/providers.js";
18
+ import { type PlatformProviderState, ProviderRegistry, type ProviderStatus } from "../runtime/providers.js";
19
19
  import { AccountListQuery, AccountParams, AdminOrgParams, CreateAccountBody, DeploymentSettingsBody, PurposeParams, UpdateAccountBody } from "./admin.schemas.js";
20
20
  import { type LimitDefaults } from "./limit-defaults.js";
21
21
  /**
@@ -81,7 +81,7 @@ export declare class AdminController {
81
81
  * (the platform's disabled list, spec B §5.3).
82
82
  */
83
83
  getModels(): Promise<{
84
- providers: (ProviderStatus & {
84
+ providers: (ProviderStatus<PlatformProviderState> & {
85
85
  displayName: LocalizedName | null;
86
86
  icon: string | null;
87
87
  })[];
@@ -28,7 +28,7 @@ import { purposeTargetOf } from "../models/purposes.controller.js";
28
28
  import { ModelPurposesService, PurposePutDto, withDeclaredByNames, } from "../models/purposes.js";
29
29
  import { MembersService } from "../orgs/members.service.js";
30
30
  import { OrgsService } from "../orgs/orgs.service.js";
31
- import { ProviderRegistry } from "../runtime/providers.js";
31
+ import { ProviderRegistry, } from "../runtime/providers.js";
32
32
  import { AccountListQuery, AccountParams, AdminOrgParams, CreateAccountBody, DeploymentSettingsBody, PurposeParams, UpdateAccountBody, } from "./admin.schemas.js";
33
33
  import { limitDefaults } from "./limit-defaults.js";
34
34
  class AccountListQueryDto extends createZodDto(AccountListQuery, "AccountListQuery") {
@@ -18,6 +18,7 @@ import { TITLE_QUEUE } from "../conversations/titles.js";
18
18
  import { EVAL_QUEUE_NAME } from "../evals/jobs.js";
19
19
  import { LIFECYCLE_QUEUE } from "../extensions/lifecycle-hooks.js";
20
20
  import { KernelDb } from "../infra/database/kernel-db.js";
21
+ import { asPlatform } from "../infra/database/org-scope.js";
21
22
  import { ReplicaPresence } from "../infra/presence/replica-presence.js";
22
23
  import { KERNEL_LOGGER, REDIS } from "../infra/tokens.js";
23
24
  import { PUSH_QUEUE } from "../push/jobs.js";
@@ -97,11 +98,10 @@ let AdminHealthService = class AdminHealthService {
97
98
  ];
98
99
  }
99
100
  async read() {
100
- const [r, d] = await Promise.allSettled([
101
- within(this.readRedis(), HEALTH_READ_TIMEOUT_MS),
102
- // a query left running past the limit finishes on its pooled connection
103
- within(this.readDb(), HEALTH_READ_TIMEOUT_MS),
104
- ]);
101
+ const redisRead = within(this.readRedis(), HEALTH_READ_TIMEOUT_MS);
102
+ // org-filter: deployment-wide counts of live channels, devices and sandbox instances
103
+ const dbRead = asPlatform("read deployment health counts", () => this.readDb());
104
+ const [r, d] = await Promise.allSettled([redisRead, within(dbRead, HEALTH_READ_TIMEOUT_MS)]);
105
105
  const unavailable = [];
106
106
  const redis = r.status === "fulfilled" ? r.value : null;
107
107
  if (r.status === "rejected") {
@@ -8,7 +8,7 @@ import { PluginIcons } from "../extensions/plugin-icons.js";
8
8
  import { AccountsService } from "../identity/accounts.js";
9
9
  import { PlatformInboxService } from "../inbox/platform-inbox.service.js";
10
10
  import { OrgsService } from "../orgs/orgs.service.js";
11
- import { ProviderRegistry, type ProviderStatus } from "../runtime/providers.js";
11
+ import { type PlatformProviderState, ProviderRegistry, type ProviderStatus } from "../runtime/providers.js";
12
12
  import { QueueLostJobs } from "../runtime/queue-lost-jobs.js";
13
13
  import { OutboxDeadService } from "./outbox-dead.service.js";
14
14
  /** The most rows each attention list returns; the rest are counted in `more`. */
@@ -105,7 +105,7 @@ export interface AdminAttention {
105
105
  /** The reason an extension is listed, or null when it needs nothing. */
106
106
  export declare function extensionReason(e: Pick<AdminExtensionView, "status" | "configValid">): AttentionExtensionReason | null;
107
107
  /** The problem of a provider in the platform view, or null (`org_configured` is not one). */
108
- export declare function providerProblem(p: ProviderStatus): AttentionProviderProblem | null;
108
+ export declare function providerProblem(p: ProviderStatus<PlatformProviderState>): AttentionProviderProblem | null;
109
109
  /**
110
110
  * The admin overview (spec §4.1, §5.2): its numbers and the 待处理 lists, read live from the sources
111
111
  * the admin pages read (`ExtensionAdmin`, the catalog, the provider registry's cached lists, the
@@ -17,7 +17,7 @@ import { AccountsService } from "../identity/accounts.js";
17
17
  import { PlatformInboxService } from "../inbox/platform-inbox.service.js";
18
18
  import { KERNEL_LOGGER } from "../infra/tokens.js";
19
19
  import { OrgsService } from "../orgs/orgs.service.js";
20
- import { ProviderRegistry } from "../runtime/providers.js";
20
+ import { ProviderRegistry, } from "../runtime/providers.js";
21
21
  import { QueueLostJobs } from "../runtime/queue-lost-jobs.js";
22
22
  import { OutboxDeadService } from "./outbox-dead.service.js";
23
23
  /** The most rows each attention list returns; the rest are counted in `more`. */
@@ -6,6 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { Module } from "@nestjs/common";
8
8
  import { AttachmentsModule } from "../conversations/attachments.module.js";
9
+ import { DeviceProviderSelectionModule } from "../devices/device-provider-selection.module.js";
9
10
  import { EvalBudgetModule } from "../evals/budget.js";
10
11
  import { ExtensionsModule } from "../extensions/extensions.module.js";
11
12
  import { LifecycleHooksModule } from "../extensions/lifecycle-hooks.js";
@@ -20,6 +21,7 @@ import { AgentLookupModule } from "./agent-lookup.js";
20
21
  import { AgentProfileService } from "./agent-profile.service.js";
21
22
  import { AgentsService } from "./agents.service.js";
22
23
  import { AgentsFromTemplate } from "./from-template.service.js";
24
+ import { OnboardingChecklist } from "./onboarding-checklist.js";
23
25
  import { OrgAgentTemplates } from "./org-templates.js";
24
26
  import { PendingConnectorRequests } from "./pending-connector-requests.js";
25
27
  import { PendingConnectorsService } from "./pending-connectors.service.js";
@@ -40,6 +42,7 @@ AgentsModule = __decorate([
40
42
  Module({
41
43
  imports: [
42
44
  AgentLookupModule,
45
+ DeviceProviderSelectionModule,
43
46
  // avatar uploads
44
47
  AttachmentsModule,
45
48
  OrgLockModule,
@@ -66,6 +69,7 @@ AgentsModule = __decorate([
66
69
  PendingConnectorRequests,
67
70
  PendingConnectorsService,
68
71
  ReadinessService,
72
+ OnboardingChecklist,
69
73
  ],
70
74
  exports: [
71
75
  AgentLookupModule,
@@ -142,4 +142,5 @@ export const AGENT_ROUTES = [
142
142
  params: AgentPathParams,
143
143
  },
144
144
  { route: "GET /api/v1/orgs/:orgId/readiness" },
145
+ { route: "POST /api/v1/orgs/:orgId/readiness/dismiss" },
145
146
  ];
@@ -4,7 +4,7 @@ import { ExtensionDisplayNames } from "../extensions/display-name.js";
4
4
  import { PluginIcons } from "../extensions/plugin-icons.js";
5
5
  import { type Principal } from "../identity/principal.js";
6
6
  import { type OrgContext } from "../orgs/org.guard.js";
7
- import { type KernelModelInfo, ProviderRegistry, type ProviderStatus } from "../runtime/providers.js";
7
+ import { type KernelModelInfo, type OrgProviderState, ProviderRegistry, type ProviderStatus } from "../runtime/providers.js";
8
8
  export declare const ModelsQuery: z.ZodObject<{
9
9
  kind: z.ZodOptional<z.ZodEnum<{
10
10
  chat: "chat";
@@ -43,7 +43,7 @@ export declare class ModelsController {
43
43
  * org's own list.
44
44
  */
45
45
  catalog(principal: Principal, org: OrgContext): Promise<{
46
- providers: (ProviderStatus & {
46
+ providers: (ProviderStatus<OrgProviderState> & {
47
47
  displayName: LocalizedName | null;
48
48
  icon: string | null;
49
49
  })[];
@@ -0,0 +1,30 @@
1
+ import { DeviceProviderSelection } from "../devices/device-provider-selection.js";
2
+ import { KernelDb } from "../infra/database/kernel-db.js";
3
+ import { TransactionHost } from "../infra/database/transaction-host.js";
4
+ import { ToolRegistry } from "../tools/registry.js";
5
+ export interface OptionalReadiness {
6
+ members: boolean;
7
+ sandbox: boolean;
8
+ connectors: boolean;
9
+ channels: boolean;
10
+ skills: boolean;
11
+ connections: boolean;
12
+ device: boolean;
13
+ }
14
+ export interface OnboardingStatus {
15
+ optional: OptionalReadiness;
16
+ checklistDismissed: boolean;
17
+ }
18
+ /** Read-only signals for the workspace checklist and its per-membership dismissal. */
19
+ export declare class OnboardingChecklist {
20
+ private readonly db;
21
+ readonly txHost: TransactionHost;
22
+ private readonly devices;
23
+ private readonly tools;
24
+ constructor(db: KernelDb, txHost: TransactionHost, devices: DeviceProviderSelection, tools: ToolRegistry);
25
+ get(orgId: string, viewer: string | null): Promise<OnboardingStatus>;
26
+ dismiss(orgId: string, viewer: string): Promise<void>;
27
+ private sandboxReady;
28
+ private personalSteps;
29
+ private adminSteps;
30
+ }
@@ -0,0 +1,176 @@
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 { sql } from "kysely";
12
+ import { DeviceProviderSelection } from "../devices/device-provider-selection.js";
13
+ import { KernelDb } from "../infra/database/kernel-db.js";
14
+ import { TransactionHost } from "../infra/database/transaction-host.js";
15
+ import { Transactional } from "../infra/database/transactional.decorator.js";
16
+ import { can } from "../orgs/roles.js";
17
+ import { LOCAL_DEVICE_PROVIDER, servesDialIn } from "../sandbox/providers.js";
18
+ import { hasNonBuiltinSkill } from "../skills/usable.js";
19
+ import { connectorReady } from "../tools/connector-setup.js";
20
+ import { connectorCredentialExists } from "../tools/credentials.js";
21
+ import { ToolRegistry } from "../tools/registry.js";
22
+ const EMPTY_OPTIONAL = {
23
+ members: false,
24
+ sandbox: false,
25
+ connectors: false,
26
+ channels: false,
27
+ skills: false,
28
+ connections: false,
29
+ device: false,
30
+ };
31
+ /** Read-only signals for the workspace checklist and its per-membership dismissal. */
32
+ let OnboardingChecklist = class OnboardingChecklist {
33
+ db;
34
+ txHost;
35
+ devices;
36
+ tools;
37
+ constructor(db, txHost, devices, tools) {
38
+ this.db = db;
39
+ this.txHost = txHost;
40
+ this.devices = devices;
41
+ this.tools = tools;
42
+ }
43
+ async get(orgId, viewer) {
44
+ const empty = { optional: EMPTY_OPTIONAL, checklistDismissed: false };
45
+ if (viewer === null)
46
+ return empty;
47
+ const membership = await this.db
48
+ .selectFrom("memberships")
49
+ .select(["role", "checklist_dismissed"])
50
+ .where("org_id", "=", orgId)
51
+ .where("account_id", "=", viewer)
52
+ .executeTakeFirst();
53
+ if (!membership)
54
+ return empty;
55
+ const admin = can(membership.role, "org.invitations.manage");
56
+ const [personal, org, sandbox, skills] = await Promise.all([
57
+ this.personalSteps(orgId, viewer),
58
+ admin ? this.adminSteps(orgId, viewer) : undefined,
59
+ admin ? this.sandboxReady(orgId) : false,
60
+ can(membership.role, "skills.read") && hasNonBuiltinSkill(this.db.db, orgId),
61
+ ]);
62
+ return {
63
+ optional: { ...EMPTY_OPTIONAL, ...org, ...personal, sandbox, skills },
64
+ checklistDismissed: membership.checklist_dismissed,
65
+ };
66
+ }
67
+ async dismiss(orgId, viewer) {
68
+ await this.db
69
+ .updateTable("memberships")
70
+ .set({ checklist_dismissed: true })
71
+ .where("org_id", "=", orgId)
72
+ .where("account_id", "=", viewer)
73
+ .where("checklist_dismissed", "=", false)
74
+ .execute();
75
+ }
76
+ async sandboxReady(orgId) {
77
+ const providers = await this.devices.onInOrg(orgId);
78
+ if (providers.some((provider) => !servesDialIn(provider)))
79
+ return true;
80
+ if (providers.length === 0)
81
+ return false;
82
+ return ((await this.db
83
+ .selectFrom("devices")
84
+ .select("id")
85
+ .where("org_id", "=", orgId)
86
+ .where("provider", "in", providers.map(({ plugin }) => plugin))
87
+ .where("deleted_at", "is", null)
88
+ .limit(1)
89
+ .executeTakeFirst()) !== undefined);
90
+ }
91
+ personalSteps(orgId, viewer) {
92
+ const db = this.db.db;
93
+ return db
94
+ .selectNoFrom((eb) => [
95
+ eb
96
+ .exists(db
97
+ .selectFrom("devices")
98
+ .select("id")
99
+ .where("org_id", "=", orgId)
100
+ .where("owner_kind", "=", "personal")
101
+ .where("owner_account_id", "=", viewer)
102
+ .where("provider", "=", LOCAL_DEVICE_PROVIDER)
103
+ .where("deleted_at", "is", null))
104
+ .$castTo()
105
+ .as("device"),
106
+ eb
107
+ .exists(db
108
+ .selectFrom("connectors as c")
109
+ .select("c.id")
110
+ .where("c.org_id", "=", orgId)
111
+ .where("c.deleted_at", "is", null)
112
+ .where(sql `c.auth->>'ownership'`, "=", "personal")
113
+ .where(({ ref }) => connectorCredentialExists(db, orgId, ref("c.id"), { accountId: viewer })))
114
+ .$castTo()
115
+ .as("connections"),
116
+ ])
117
+ .executeTakeFirstOrThrow();
118
+ }
119
+ adminSteps(orgId, viewer) {
120
+ const db = this.db.db;
121
+ const kinds = this.tools.loadedConnectorKinds();
122
+ return db
123
+ .selectNoFrom((eb) => [
124
+ eb
125
+ .or([
126
+ eb.exists(db
127
+ .selectFrom("memberships")
128
+ .select("account_id")
129
+ .where("org_id", "=", orgId)
130
+ .where("account_id", "!=", viewer)),
131
+ eb.exists(db
132
+ .selectFrom("invitations")
133
+ .select("id")
134
+ .where("org_id", "=", orgId)
135
+ .where("accepted_at", "is", null)
136
+ .where("revoked_at", "is", null)
137
+ .where("expires_at", ">", sql `now()`)),
138
+ ])
139
+ .$castTo()
140
+ .as("members"),
141
+ eb
142
+ .exists(db
143
+ .selectFrom("channel_connections")
144
+ .select("id")
145
+ .where("org_id", "=", orgId)
146
+ .where("deleted_at", "is", null))
147
+ .$castTo()
148
+ .as("channels"),
149
+ kinds.length === 0
150
+ ? sql `false`.as("connectors")
151
+ : eb
152
+ .exists(db
153
+ .selectFrom("connectors as c")
154
+ .select("c.id")
155
+ .where("c.org_id", "=", orgId)
156
+ .where("c.deleted_at", "is", null)
157
+ .where("c.status", "=", "active")
158
+ .where("c.connector", "in", kinds)
159
+ .where(({ ref }) => connectorReady(db, orgId, ref("c.id"), ref("c.auth"))))
160
+ .$castTo()
161
+ .as("connectors"),
162
+ ])
163
+ .executeTakeFirstOrThrow();
164
+ }
165
+ };
166
+ __decorate([
167
+ Transactional()
168
+ ], OnboardingChecklist.prototype, "dismiss", null);
169
+ OnboardingChecklist = __decorate([
170
+ Injectable(),
171
+ __param(0, Inject(KernelDb)),
172
+ __param(1, Inject(TransactionHost)),
173
+ __param(2, Inject(DeviceProviderSelection)),
174
+ __param(3, Inject(ToolRegistry))
175
+ ], OnboardingChecklist);
176
+ export { OnboardingChecklist };
@@ -13,4 +13,5 @@ export declare class ReadinessController {
13
13
  private readonly readiness;
14
14
  constructor(readiness: ReadinessService);
15
15
  get(principal: Principal, org: OrgContext): Promise<OrgReadiness>;
16
+ dismiss(principal: Principal, org: OrgContext): Promise<void>;
16
17
  }
@@ -7,8 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
- import { Controller, Get, Inject } from "@nestjs/common";
11
- import { CurrentPrincipal } from "../identity/principal.js";
10
+ import { Controller, Get, HttpCode, Inject, Post } from "@nestjs/common";
11
+ import { CurrentPrincipal, requireUser } from "../identity/principal.js";
12
12
  import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
13
13
  import { ReadinessService } from "./readiness.service.js";
14
14
  /** Service tokens have no account: they see `visibility='org'` agents only (as the agent list). */
@@ -29,6 +29,9 @@ let ReadinessController = class ReadinessController {
29
29
  get(principal, org) {
30
30
  return this.readiness.get(org.orgId, viewerOf(principal));
31
31
  }
32
+ dismiss(principal, org) {
33
+ return this.readiness.dismissChecklist(org.orgId, requireUser(principal).account.id);
34
+ }
32
35
  };
33
36
  __decorate([
34
37
  Get(),
@@ -36,6 +39,13 @@ __decorate([
36
39
  __param(0, CurrentPrincipal()),
37
40
  __param(1, CurrentOrg())
38
41
  ], ReadinessController.prototype, "get", null);
42
+ __decorate([
43
+ Post("dismiss"),
44
+ OrgAction("org.onboarding.dismiss"),
45
+ HttpCode(204),
46
+ __param(0, CurrentPrincipal()),
47
+ __param(1, CurrentOrg())
48
+ ], ReadinessController.prototype, "dismiss", null);
39
49
  ReadinessController = __decorate([
40
50
  Controller("api/v1/orgs/:orgId/readiness"),
41
51
  __param(0, Inject(ReadinessService))
@@ -3,6 +3,7 @@ import { ExtensionDisplayNames } from "../extensions/display-name.js";
3
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
+ import { OnboardingChecklist, type OnboardingStatus } from "./onboarding-checklist.js";
6
7
  /**
7
8
  * A model provider an org admin can make usable on `/settings/models`, and what it waits for:
8
9
  * `not_enabled`, the org has not switched it on (it may also need the org's config then);
@@ -34,7 +35,7 @@ export type UnusableProvider = {
34
35
  reason: "no_chat_models";
35
36
  });
36
37
  /** What `GET /orgs/:orgId/readiness` and the `agents.readiness` operation answer. */
37
- export interface OrgReadiness {
38
+ export interface OrgReadiness extends OnboardingStatus {
38
39
  /**
39
40
  * `ready`: the org has a chat model an agent can pick (the agent form's list:
40
41
  * `GET /orgs/:orgId/models?kind=chat`); `no_models`: providers are on with a valid config but
@@ -75,7 +76,9 @@ export declare class ReadinessService {
75
76
  private readonly configs;
76
77
  private readonly agents;
77
78
  private readonly displayNames;
78
- constructor(registry: ProviderRegistry, configs: OrgExtensionConfigs, agents: AgentsService, displayNames: ExtensionDisplayNames);
79
+ private readonly checklist;
80
+ constructor(registry: ProviderRegistry, configs: OrgExtensionConfigs, agents: AgentsService, displayNames: ExtensionDisplayNames, checklist: OnboardingChecklist);
79
81
  get(orgId: string, viewer: string | null): Promise<OrgReadiness>;
82
+ dismissChecklist(orgId: string, viewer: string): Promise<void>;
80
83
  private unusable;
81
84
  }
@@ -13,6 +13,7 @@ import { ExtensionDisplayNames } from "../extensions/display-name.js";
13
13
  import { OrgExtensionConfigs, providesOf, } from "../extensions/org-config.js";
14
14
  import { ProviderRegistry } from "../runtime/providers.js";
15
15
  import { AgentsService } from "./agents.service.js";
16
+ import { OnboardingChecklist } from "./onboarding-checklist.js";
16
17
  const MODEL_PROVIDER = parseExtensionPoint(MODEL_PROVIDER_EXTENSION_POINT_V2).name;
17
18
  const isModelProvider = (v) => providesOf(v).some((ref) => parseExtensionPoint(ref).name === MODEL_PROVIDER);
18
19
  /** The org can fill the config the extension waits for: it has an overridable field. */
@@ -45,16 +46,19 @@ let ReadinessService = class ReadinessService {
45
46
  configs;
46
47
  agents;
47
48
  displayNames;
48
- constructor(registry, configs, agents, displayNames) {
49
+ checklist;
50
+ constructor(registry, configs, agents, displayNames, checklist) {
49
51
  this.registry = registry;
50
52
  this.configs = configs;
51
53
  this.agents = agents;
52
54
  this.displayNames = displayNames;
55
+ this.checklist = checklist;
53
56
  }
54
57
  async get(orgId, viewer) {
55
- const [gate, visible] = await Promise.all([
58
+ const [gate, visible, checklist] = await Promise.all([
56
59
  this.registry.hasProvider(orgId),
57
60
  this.agents.listVisible(orgId, viewer),
61
+ this.checklist.get(orgId, viewer),
58
62
  ]);
59
63
  const usability = gate ? await this.registry.chatUsability(orgId) : [];
60
64
  if (usability.some((u) => u.state === "usable")) {
@@ -63,6 +67,7 @@ let ReadinessService = class ReadinessService {
63
67
  orgFixableProviders: [],
64
68
  unusableProviders: [],
65
69
  agents: visible.length,
70
+ ...checklist,
66
71
  };
67
72
  }
68
73
  const views = await this.configs.list(orgId);
@@ -73,6 +78,7 @@ let ReadinessService = class ReadinessService {
73
78
  orgFixableProviders: fixable,
74
79
  unusableProviders: await this.unusable(usability, views),
75
80
  agents: visible.length,
81
+ ...checklist,
76
82
  };
77
83
  }
78
84
  return {
@@ -80,8 +86,12 @@ let ReadinessService = class ReadinessService {
80
86
  orgFixableProviders: fixable,
81
87
  unusableProviders: [],
82
88
  agents: visible.length,
89
+ ...checklist,
83
90
  };
84
91
  }
92
+ dismissChecklist(orgId, viewer) {
93
+ return this.checklist.dismiss(orgId, viewer);
94
+ }
85
95
  async unusable(usability, views) {
86
96
  const byPlugin = new Map(views.map((v) => [v.plugin, v]));
87
97
  const names = await this.displayNames.many(usability.map((u) => u.provider));
@@ -105,7 +115,8 @@ ReadinessService = __decorate([
105
115
  __param(0, Inject(ProviderRegistry)),
106
116
  __param(1, Inject(OrgExtensionConfigs)),
107
117
  __param(2, Inject(AgentsService)),
108
- __param(3, Inject(ExtensionDisplayNames))
118
+ __param(3, Inject(ExtensionDisplayNames)),
119
+ __param(4, Inject(OnboardingChecklist))
109
120
  ], ReadinessService);
110
121
  export { ReadinessService };
111
122
  function orgFixableOf(views) {