@capybara-hq/kernel 0.1.0-rc.62 → 0.1.0-rc.64

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 (120) hide show
  1. package/bootstrap.json +3 -3
  2. package/dist/app.d.ts +2 -0
  3. package/dist/catalog/catalog.service.d.ts +13 -0
  4. package/dist/catalog/catalog.service.js +17 -8
  5. package/dist/catalog/git-source.d.ts +8 -0
  6. package/dist/catalog/git-source.js +14 -6
  7. package/dist/catalog/marketplaces.controller.d.ts +3 -2
  8. package/dist/catalog/marketplaces.controller.js +5 -2
  9. package/dist/catalog/marketplaces.schemas.d.ts +7 -0
  10. package/dist/catalog/marketplaces.schemas.js +13 -0
  11. package/dist/catalog/marketplaces.service.d.ts +65 -11
  12. package/dist/catalog/marketplaces.service.js +208 -30
  13. package/dist/catalog/org-catalog.schemas.d.ts +1 -1
  14. package/dist/catalog/org-catalog.schemas.js +1 -1
  15. package/dist/channels/actions.d.ts +2 -5
  16. package/dist/channels/actions.js +20 -8
  17. package/dist/channels/cards.d.ts +4 -3
  18. package/dist/channels/cards.js +6 -4
  19. package/dist/channels/outbound.js +3 -2
  20. package/dist/config/schema.d.ts +2 -0
  21. package/dist/config/schema.js +22 -2
  22. package/dist/conversations/approval-profile.d.ts +30 -0
  23. package/dist/conversations/approval-profile.js +62 -0
  24. package/dist/conversations/conversations.service.js +0 -2
  25. package/dist/conversations/events.d.ts +43 -0
  26. package/dist/conversations/events.js +52 -0
  27. package/dist/conversations/permission-profiles.controller.d.ts +3 -2
  28. package/dist/conversations/permission-profiles.service.d.ts +3 -2
  29. package/dist/conversations/permission-profiles.service.js +12 -8
  30. package/dist/db/kernel-schema.d.ts +8 -2
  31. package/dist/errors.d.ts +7 -0
  32. package/dist/errors.js +7 -0
  33. package/dist/extensions/bootstrap-defaults.d.ts +24 -0
  34. package/dist/extensions/bootstrap-defaults.js +78 -0
  35. package/dist/extensions/bootstrap-extra.d.ts +74 -0
  36. package/dist/extensions/bootstrap-extra.js +131 -0
  37. package/dist/extensions/bootstrap.d.ts +77 -13
  38. package/dist/extensions/bootstrap.js +282 -48
  39. package/dist/identity/initial-passwords.controller.d.ts +8 -6
  40. package/dist/identity/initial-passwords.controller.js +13 -7
  41. package/dist/identity/initial-passwords.d.ts +22 -13
  42. package/dist/identity/initial-passwords.js +25 -29
  43. package/dist/identity/settings.d.ts +10 -0
  44. package/dist/identity/settings.js +46 -0
  45. package/dist/index.d.ts +2 -0
  46. package/dist/index.js +3 -0
  47. package/dist/kernel.module.js +3 -0
  48. package/dist/lifecycle/kernel-lifecycle.d.ts +7 -1
  49. package/dist/lifecycle/kernel-lifecycle.js +69 -16
  50. package/dist/local-devices/relay.js +3 -1
  51. package/dist/models/images.js +5 -4
  52. package/dist/platform/connector-person-fields.js +2 -2
  53. package/dist/platform/exclusions.js +4 -4
  54. package/dist/platform/method.js +1 -1
  55. package/dist/platform/operation.d.ts +9 -7
  56. package/dist/platform/operation.js +1 -1
  57. package/dist/platform/ops/accounts.ops.d.ts +1 -1
  58. package/dist/platform/ops/accounts.ops.js +3 -3
  59. package/dist/platform/ops/channels.ops.d.ts +1 -1
  60. package/dist/platform/ops/channels.ops.js +2 -2
  61. package/dist/platform/ops/connectors.ops.d.ts +2 -2
  62. package/dist/platform/ops/connectors.ops.js +8 -8
  63. package/dist/platform/ops/extensions-admin.ops.d.ts +1 -1
  64. package/dist/platform/ops/extensions-admin.ops.js +3 -3
  65. package/dist/platform/ops/extensions.ops.d.ts +1 -1
  66. package/dist/platform/ops/extensions.ops.js +4 -4
  67. package/dist/platform/ops/marketplaces.ops.js +27 -4
  68. package/dist/platform/ops/org-plugins.ops.js +2 -2
  69. package/dist/platform/ops/orgs.ops.d.ts +1 -1
  70. package/dist/platform/ops/orgs.ops.js +3 -3
  71. package/dist/platform/ops/plugins.ops.d.ts +1 -1
  72. package/dist/platform/ops/plugins.ops.js +2 -2
  73. package/dist/platform/person-fields.d.ts +4 -3
  74. package/dist/platform/person-fields.js +6 -5
  75. package/dist/platform/sealed-inputs.d.ts +2 -2
  76. package/dist/platform/sealed-inputs.js +2 -2
  77. package/dist/platform/sealed-reveals.controller.d.ts +5 -8
  78. package/dist/platform/sealed-reveals.controller.js +8 -8
  79. package/dist/platform/sealed-reveals.d.ts +19 -17
  80. package/dist/platform/sealed-reveals.js +30 -33
  81. package/dist/runtime/context/build.js +3 -0
  82. package/dist/runtime/context/compaction.js +2 -0
  83. package/dist/runtime/waits.js +3 -2
  84. package/dist/sandbox/operation-authority.js +16 -15
  85. package/dist/sandbox/operation-intents.js +2 -2
  86. package/dist/sandbox/permission-availability.d.ts +49 -3
  87. package/dist/sandbox/permission-availability.js +61 -6
  88. package/dist/sandbox/permission-call-types.d.ts +3 -0
  89. package/dist/sandbox/permission-facts.d.ts +29 -1
  90. package/dist/sandbox/permission-facts.js +29 -6
  91. package/dist/sandbox/review/classifier.d.ts +72 -2
  92. package/dist/sandbox/review/classifier.js +113 -38
  93. package/dist/sandbox/review/index.d.ts +2 -2
  94. package/dist/sandbox/review/index.js +1 -1
  95. package/dist/sandbox/review/review.service.d.ts +1 -4
  96. package/dist/sandbox/review/review.service.js +4 -33
  97. package/dist/setup/setup-guides.service.js +1 -1
  98. package/dist/tools/approvals.service.d.ts +71 -16
  99. package/dist/tools/approvals.service.js +139 -13
  100. package/dist/tools/builtins/builtin-tools.d.ts +1 -1
  101. package/dist/tools/builtins/builtin-tools.js +12 -6
  102. package/dist/tools/builtins/platform.d.ts +15 -11
  103. package/dist/tools/builtins/platform.js +49 -39
  104. package/dist/tools/builtins/sandbox/bash.d.ts +1 -1
  105. package/dist/tools/builtins/sandbox/bash.js +32 -14
  106. package/dist/tools/builtins/sandbox/common.d.ts +12 -3
  107. package/dist/tools/builtins/sandbox/common.js +29 -5
  108. package/dist/tools/connectors.schemas.d.ts +1 -1
  109. package/dist/tools/connectors.schemas.js +1 -1
  110. package/dist/tools/pipeline.d.ts +70 -10
  111. package/dist/tools/pipeline.js +356 -48
  112. package/dist/tools/policy.d.ts +4 -3
  113. package/dist/tools/policy.js +6 -6
  114. package/dist/tools/registry.d.ts +25 -9
  115. package/dist/tools/tool-review.d.ts +113 -0
  116. package/dist/tools/tool-review.js +303 -0
  117. package/dist/tools/tools.module.js +6 -0
  118. package/package.json +4 -4
  119. package/src/migrations/0174_marketplace_managed_username.sql +4 -0
  120. package/src/migrations/0175_secure_input_kind.sql +8 -0
@@ -0,0 +1,30 @@
1
+ import type { PermissionProfile } from "@capybara-hq/plugin-sdk";
2
+ import { KernelDb } from "../infra/database/kernel-db.js";
3
+ import { PermissionFacts } from "../sandbox/permission-facts.js";
4
+ /** A root conversation's effective permission profile and the revision it was read at. */
5
+ export interface ApprovalProfile {
6
+ profile: PermissionProfile;
7
+ revision: number;
8
+ }
9
+ /**
10
+ * Resolves the profile that decides an ask addressed to the conversation's person (profiles govern
11
+ * every approval, ruling R1). Only an interactive chat (`kind = 'chat'`, no scheduled task) whose
12
+ * owner is the person asked has one: any other root, a scheduled task's conversation or an ask
13
+ * addressed to another account keeps asking. The profile is the root's effective one as the
14
+ * permission view reads it (Auto falls back to Approve for me where a bound device's consent no
15
+ * longer holds; without a device Auto holds, ruling R8).
16
+ */
17
+ export declare class ConversationApprovalProfile {
18
+ private readonly db;
19
+ private readonly facts;
20
+ constructor(db: KernelDb, facts: Pick<PermissionFacts, "viewWithAccess">);
21
+ /** The root's effective profile for an ask addressed to `requestedFor`; null: the profile does not apply (R1). */
22
+ resolve(input: {
23
+ orgId: string;
24
+ rootConversationId: string;
25
+ requestedFor: string;
26
+ }): Promise<ApprovalProfile | null>;
27
+ }
28
+ /** {@link ConversationApprovalProfile} on its own (the tools module reads it; no module cycle). */
29
+ export declare class ConversationApprovalProfileModule {
30
+ }
@@ -0,0 +1,62 @@
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, Module } from "@nestjs/common";
11
+ import { KernelDb } from "../infra/database/kernel-db.js";
12
+ import { PermissionFacts } from "../sandbox/permission-facts.js";
13
+ import { PermissionFactsModule } from "../sandbox/permission-facts.module.js";
14
+ /**
15
+ * Resolves the profile that decides an ask addressed to the conversation's person (profiles govern
16
+ * every approval, ruling R1). Only an interactive chat (`kind = 'chat'`, no scheduled task) whose
17
+ * owner is the person asked has one: any other root, a scheduled task's conversation or an ask
18
+ * addressed to another account keeps asking. The profile is the root's effective one as the
19
+ * permission view reads it (Auto falls back to Approve for me where a bound device's consent no
20
+ * longer holds; without a device Auto holds, ruling R8).
21
+ */
22
+ let ConversationApprovalProfile = class ConversationApprovalProfile {
23
+ db;
24
+ facts;
25
+ constructor(db, facts) {
26
+ this.db = db;
27
+ this.facts = facts;
28
+ }
29
+ /** The root's effective profile for an ask addressed to `requestedFor`; null: the profile does not apply (R1). */
30
+ async resolve(input) {
31
+ const row = await this.db.db
32
+ .selectFrom("conversations")
33
+ .selectAll()
34
+ .where("id", "=", input.rootConversationId)
35
+ .where("org_id", "=", input.orgId)
36
+ .executeTakeFirst();
37
+ if (row === undefined ||
38
+ row.kind !== "chat" ||
39
+ row.scheduled_task_id !== null ||
40
+ row.account_id !== input.requestedFor)
41
+ return null;
42
+ const { view } = await this.facts.viewWithAccess(input.orgId, row.account_id, row);
43
+ return { profile: view.profile, revision: view.revision };
44
+ }
45
+ };
46
+ ConversationApprovalProfile = __decorate([
47
+ Injectable(),
48
+ __param(0, Inject(KernelDb)),
49
+ __param(1, Inject(PermissionFacts))
50
+ ], ConversationApprovalProfile);
51
+ export { ConversationApprovalProfile };
52
+ /** {@link ConversationApprovalProfile} on its own (the tools module reads it; no module cycle). */
53
+ let ConversationApprovalProfileModule = class ConversationApprovalProfileModule {
54
+ };
55
+ ConversationApprovalProfileModule = __decorate([
56
+ Module({
57
+ imports: [PermissionFactsModule],
58
+ providers: [ConversationApprovalProfile],
59
+ exports: [ConversationApprovalProfile],
60
+ })
61
+ ], ConversationApprovalProfileModule);
62
+ export { ConversationApprovalProfileModule };
@@ -260,8 +260,6 @@ let ConversationsService = class ConversationsService {
260
260
  * retry answers with the conversation the first send created, its binding unchanged.
261
261
  */
262
262
  async createWithMessage(orgId, accountId, agentId, input, pick = {}, internal) {
263
- if (internal.initialPermission?.profile === "full-access" && !pick.deviceId)
264
- throw new ApiError("conflict", "Full access requires an explicit device selection");
265
263
  const requestHash = internal.initialPermission
266
264
  ? permissionScopeHash({ agentId, input, pick, permission: internal.initialPermission })
267
265
  : undefined;
@@ -503,6 +503,10 @@ export type LogContentBlock = Exclude<ContentBlock, MediaBlock> | (MediaBlock ex
503
503
  } : never : never);
504
504
  /** The longest handoff card title (`ToolViewSchema` kind `handoff`), per language. */
505
505
  export declare const HANDOFF_TITLE_MAX_CHARS = 200;
506
+ /** The longest secure input target name (`approval_requested.secureInput.target`), per language. */
507
+ export declare const SECURE_INPUT_TARGET_MAX_CHARS = 200;
508
+ /** The most field paths one secure input request lists (as `approval_decided.inputsProvided`). */
509
+ export declare const SECURE_INPUT_MAX_FIELDS = 32;
506
510
  /** The longest handoff link (a relative web path). */
507
511
  export declare const HANDOFF_URL_MAX_CHARS = 2000;
508
512
  /**
@@ -569,6 +573,12 @@ export declare const ToolViewSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
569
573
  }>;
570
574
  }, z.core.$strip>, z.ZodObject<{
571
575
  kind: z.ZodLiteral<"not_loaded">;
576
+ }, z.core.$strip>, z.ZodObject<{
577
+ kind: z.ZodLiteral<"reveal">;
578
+ reveal: z.ZodEnum<{
579
+ initial_password: "initial_password";
580
+ invitation_link: "invitation_link";
581
+ }>;
572
582
  }, z.core.$strip>, z.ZodObject<{
573
583
  kind: z.ZodLiteral<"handoff">;
574
584
  title: z.ZodObject<{
@@ -760,6 +770,26 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
760
770
  perCallHosts: z.ZodOptional<z.ZodBoolean>;
761
771
  }, z.core.$strict>>;
762
772
  }, z.core.$strict>;
773
+ }, z.core.$strip>, z.ZodObject<{
774
+ type: z.ZodLiteral<"tool_ask_decided">;
775
+ payload: z.ZodObject<{
776
+ step: z.ZodNumber;
777
+ callId: z.ZodString;
778
+ toolKey: z.ZodString;
779
+ specHash: z.ZodString;
780
+ bindingHash: z.ZodString;
781
+ outcome: z.ZodEnum<{
782
+ allow: "allow";
783
+ deny: "deny";
784
+ }>;
785
+ decisionSource: z.ZodEnum<{
786
+ "full-access": "full-access";
787
+ "review-model": "review-model";
788
+ }>;
789
+ reason: z.ZodString;
790
+ profileRevision: z.ZodNumber;
791
+ fileSha256: z.ZodOptional<z.ZodString>;
792
+ }, z.core.$strip>;
763
793
  }, z.core.$strip>, z.ZodObject<{
764
794
  type: z.ZodLiteral<"permission_reviewed">;
765
795
  payload: z.ZodObject<{
@@ -1445,6 +1475,12 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
1445
1475
  }>;
1446
1476
  }, z.core.$strip>, z.ZodObject<{
1447
1477
  kind: z.ZodLiteral<"not_loaded">;
1478
+ }, z.core.$strip>, z.ZodObject<{
1479
+ kind: z.ZodLiteral<"reveal">;
1480
+ reveal: z.ZodEnum<{
1481
+ initial_password: "initial_password";
1482
+ invitation_link: "invitation_link";
1483
+ }>;
1448
1484
  }, z.core.$strip>, z.ZodObject<{
1449
1485
  kind: z.ZodLiteral<"handoff">;
1450
1486
  title: z.ZodObject<{
@@ -1543,6 +1579,13 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
1543
1579
  sandbox: "sandbox";
1544
1580
  }>;
1545
1581
  }, z.core.$strict>>;
1582
+ secureInput: z.ZodOptional<z.ZodObject<{
1583
+ target: z.ZodObject<{
1584
+ zh: z.ZodString;
1585
+ en: z.ZodString;
1586
+ }, z.core.$strip>;
1587
+ fields: z.ZodArray<z.ZodString>;
1588
+ }, z.core.$strip>>;
1546
1589
  }, z.core.$strip>;
1547
1590
  }, z.core.$strip>, z.ZodObject<{
1548
1591
  type: z.ZodLiteral<"approval_decided">;
@@ -518,6 +518,10 @@ const FileStateViewSchema = z.object({
518
518
  });
519
519
  /** The longest handoff card title (`ToolViewSchema` kind `handoff`), per language. */
520
520
  export const HANDOFF_TITLE_MAX_CHARS = 200;
521
+ /** The longest secure input target name (`approval_requested.secureInput.target`), per language. */
522
+ export const SECURE_INPUT_TARGET_MAX_CHARS = 200;
523
+ /** The most field paths one secure input request lists (as `approval_decided.inputsProvided`). */
524
+ export const SECURE_INPUT_MAX_FIELDS = 32;
521
525
  /** The longest handoff link (a relative web path). */
522
526
  export const HANDOFF_URL_MAX_CHARS = 2000;
523
527
  /** A relative web path: one leading `/`, never `//` (another host) or a backslash. */
@@ -579,6 +583,15 @@ export const ToolViewSchema = z.discriminatedUnion("kind", [
579
583
  reason: z.enum(["not_read", "modified"]),
580
584
  }),
581
585
  z.object({ kind: z.literal("not_loaded") }),
586
+ /**
587
+ * A `Platform` operation whose result is shown to the run's person once, read by call (the
588
+ * initial password, the invitation link; profiles govern every approval, ruling R6): the web
589
+ * draws the reveal under the tool row. Display only.
590
+ */
591
+ z.object({
592
+ kind: z.literal("reveal"),
593
+ reveal: z.enum(["initial_password", "invitation_link"]),
594
+ }),
582
595
  z.object({
583
596
  kind: z.literal("handoff"),
584
597
  title: z.object({
@@ -711,6 +724,31 @@ export const PluginContextSchema = z.object({
711
724
  */
712
725
  export const ConversationEventSchema = z.discriminatedUnion("type", [
713
726
  ev("permission_context", PermissionContextV2Schema),
727
+ /**
728
+ * An ask addressed to the conversation's person that the profile decided without asking (Auto,
729
+ * or the review model under Approve for me; profiles govern every approval, ruling R2). Only
730
+ * `allow` and `deny` are recorded; an unsure review creates the person's approval instead.
731
+ * Idempotency key `tool_ask_decided:<runId>:<callId>:<bindingHash>`. Not model-visible: display
732
+ * and audit only, so it needs no `DriftReason`.
733
+ */
734
+ ev("tool_ask_decided", z.object({
735
+ step: count,
736
+ callId: z.string(),
737
+ /** The call's policy key. */
738
+ toolKey: z.string(),
739
+ specHash: z.string(),
740
+ /** First 16 hex chars of `sha256(canonicalJson([policyKey, specHash, call.input]))`. */
741
+ bindingHash: z.string(),
742
+ outcome: z.enum(["allow", "deny"]),
743
+ decisionSource: z.enum(["review-model", "full-access"]),
744
+ reason: z.string().max(2000),
745
+ profileRevision: z.number().int().nonnegative(),
746
+ /** The file bytes the decision was bound to (ruling R7), when the call references a file. */
747
+ fileSha256: z
748
+ .string()
749
+ .regex(/^[a-f0-9]{64}$/)
750
+ .optional(),
751
+ })),
714
752
  ev("permission_reviewed", z.object({
715
753
  binding: PermissionCallBindingSchema,
716
754
  permissionScope: PermissionExpansionSchema,
@@ -1284,6 +1322,20 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
1284
1322
  * model-visible, as `network` and `git`; the model sees the call's `tool_result` only.
1285
1323
  */
1286
1324
  command: CommandAskSchema.optional(),
1325
+ /**
1326
+ * A secure input request (`kind = 'secure_input'`; profiles govern every approval): what the
1327
+ * values are for and the field paths the person enters. Display only, never a value and
1328
+ * never model-visible.
1329
+ */
1330
+ secureInput: z
1331
+ .object({
1332
+ target: z.object({
1333
+ zh: z.string().min(1).max(SECURE_INPUT_TARGET_MAX_CHARS),
1334
+ en: z.string().min(1).max(SECURE_INPUT_TARGET_MAX_CHARS),
1335
+ }),
1336
+ fields: z.array(z.string().min(1).max(200)).min(1).max(SECURE_INPUT_MAX_FIELDS),
1337
+ })
1338
+ .optional(),
1287
1339
  ...ApproverFields,
1288
1340
  })),
1289
1341
  /**
@@ -51,6 +51,7 @@ export declare class PermissionProfilesController {
51
51
  private readonly conversations;
52
52
  constructor(permissions: PermissionProfilesService, conversations: ConversationsService);
53
53
  get(org: OrgContext, p: Principal, { id }: z.infer<typeof PermissionGetParams>): Promise<{
54
+ availability: import("../sandbox/permission-availability.js").PermissionAvailability;
54
55
  profile: import("@capybara-hq/plugin-sdk").PermissionProfile;
55
56
  revision: number;
56
57
  rootConversationId: string;
@@ -60,7 +61,6 @@ export declare class PermissionProfilesController {
60
61
  scopeRevision: string;
61
62
  } | null;
62
63
  scopeRevision: string | null;
63
- availability: import("../sandbox/permission-availability.js").PermissionAvailability;
64
64
  outsideSandboxCeiling: boolean;
65
65
  broadProjectReach: boolean;
66
66
  sandbox: import("../sandbox/device-sandbox.js").DeviceSandbox | null;
@@ -81,10 +81,11 @@ export declare class PermissionProfilesController {
81
81
  restrictedProjectReach: "os-user" | "workspace";
82
82
  hostCeiling: import("../sandbox/device-sandbox.js").HostGrantCeiling;
83
83
  };
84
- availability: import("../sandbox/permission-availability.js").PermissionAvailability;
84
+ location: "cloud" | "local";
85
85
  sandbox: import("../sandbox/device-sandbox.js").DeviceSandbox;
86
86
  outsideSandboxCeiling: boolean;
87
87
  broadProjectReach: boolean;
88
+ availability: import("../sandbox/permission-availability.js").PermissionAvailability;
88
89
  }>;
89
90
  first(org: OrgContext, p: Principal, body: z.infer<typeof FirstMessageBody>, reply: FastifyReply): Promise<{
90
91
  conversation: import("./conversations.service.js").ConversationView;
@@ -32,12 +32,14 @@ export declare class PermissionProfilesService {
32
32
  restrictedProjectReach: "os-user" | "workspace";
33
33
  hostCeiling: import("../sandbox/device-sandbox.js").HostGrantCeiling;
34
34
  };
35
- availability: import("../sandbox/permission-availability.js").PermissionAvailability;
35
+ location: "cloud" | "local";
36
36
  sandbox: import("../sandbox/device-sandbox.js").DeviceSandbox;
37
37
  outsideSandboxCeiling: boolean;
38
38
  broadProjectReach: boolean;
39
+ availability: import("../sandbox/permission-availability.js").PermissionAvailability;
39
40
  }>;
40
41
  get(orgId: string, id: string, accountId: string): Promise<{
42
+ availability: import("../sandbox/permission-availability.js").PermissionAvailability;
41
43
  profile: import("@capybara-hq/plugin-sdk").PermissionProfile;
42
44
  revision: number;
43
45
  rootConversationId: string;
@@ -47,7 +49,6 @@ export declare class PermissionProfilesService {
47
49
  scopeRevision: string;
48
50
  } | null;
49
51
  scopeRevision: string | null;
50
- availability: import("../sandbox/permission-availability.js").PermissionAvailability;
51
52
  outsideSandboxCeiling: boolean;
52
53
  broadProjectReach: boolean;
53
54
  sandbox: import("../sandbox/device-sandbox.js").DeviceSandbox | null;
@@ -45,7 +45,7 @@ let PermissionProfilesService = class PermissionProfilesService {
45
45
  return this.facts.preview(orgId, accountId, deviceId, project);
46
46
  }
47
47
  async get(orgId, id, accountId) {
48
- return this.facts.view(orgId, accountId, await this.store.readOwnedRoot(orgId, id, accountId));
48
+ return this.facts.peopleView(orgId, accountId, await this.store.readOwnedRoot(orgId, id, accountId));
49
49
  }
50
50
  /** Reserve the root ID and authority before resolving its project or inserting first-send state. */
51
51
  async lockInitial(orgId, id, deviceId) {
@@ -88,14 +88,18 @@ let PermissionProfilesService = class PermissionProfilesService {
88
88
  await this.devices.usable(orgId, accountId, deviceId);
89
89
  if (selection.profile !== "full-access")
90
90
  return null;
91
- if (!deviceId || !selection.consentScopeRevision)
92
- throw new ApiError("conflict", "Full access requires an explicitly selected device and displayed scope consent");
91
+ // Auto without a device has no scope to consent to: accepted with no consent row (R8); a
92
+ // device bound later needs a confirmation of Auto for that device (`consentHolds`)
93
+ if (!deviceId)
94
+ return null;
95
+ if (!selection.consentScopeRevision)
96
+ throw new ApiError("conflict", "Auto on a device requires its displayed scope consent");
93
97
  const preview = await this.facts.scope(orgId, deviceId, projectPath, project);
94
- // Full access is available wherever any profile is: the sandbox stays, and the consent binds
95
- // the device and the crossing ceilings it auto-approves within (`scopeRevision`)
96
- if (preview.availability.state === "unsupported" ||
97
- preview.scopeRevision !== selection.consentScopeRevision)
98
- throw new ApiError("conflict", "Device authority changed; refresh the permission preview and confirm Full access again");
98
+ // Auto is available on every device, whatever it supports (device tools refuse at admission):
99
+ // the sandbox stays, and the consent binds the device and the crossing ceilings it
100
+ // auto-approves within (`scopeRevision`)
101
+ if (preview.scopeRevision !== selection.consentScopeRevision)
102
+ throw new ApiError("conflict", "Device authority changed; refresh the permission preview and confirm Auto again");
99
103
  // what the consent covers: a later narrowing keeps it, a widening needs a new one
100
104
  return {
101
105
  deviceId,
@@ -737,9 +737,11 @@ export interface ApprovalsTable {
737
737
  scopes: ColumnType<("once" | "session" | "always")[] | null, ("once" | "session" | "always")[] | null | undefined, ("once" | "session" | "always")[] | null>;
738
738
  /**
739
739
  * 0114: what is asked: a tool call ('tool') or a refused network domain ('network'); 0126: a
740
- * git push the gateway held ('git'); 0130: a command review ask ('command').
740
+ * git push the gateway held ('git'); 0130: a command review ask ('command'); a secure input
741
+ * request for a call's secret fields ('secure_input'; profiles govern every approval, R4; the
742
+ * migration widening the CHECK comes with the approvals service change).
741
743
  */
742
- kind: Generated<"tool" | "network" | "git" | "command">;
744
+ kind: Generated<"tool" | "network" | "git" | "command" | "secure_input">;
743
745
  /** 0114: a network or git ask's facts, kept result and outcome; 0130: a command ask's facts. */
744
746
  detail: ColumnType<unknown | null, string | null | undefined, string | null>;
745
747
  }
@@ -2181,6 +2183,10 @@ export interface MarketplacesTable {
2181
2183
  }[], string | undefined, string>;
2182
2184
  /** 0101: the git commit whose repository-path icons were last stored completely. */
2183
2185
  icons_commit: ColumnType<string | null, string | null | undefined, string | null>;
2186
+ /** 0169: `config` when the deployment config (bootstrap.extraManifest) owns the row. */
2187
+ managed: ColumnType<"config" | null, "config" | null | undefined, "config" | null>;
2188
+ /** 0169: the Basic auth username sent with the git token (null: x-access-token). */
2189
+ username: ColumnType<string | null, string | null | undefined, string | null>;
2184
2190
  }
2185
2191
  /**
2186
2192
  * 0035, renamed in 0042, reshaped in 0044: cached marketplace entries (replaced as a whole on each
package/dist/errors.d.ts CHANGED
@@ -147,6 +147,12 @@ export declare const ERROR_CODES: {
147
147
  readonly "bootstrap.integrity_mismatch": 500;
148
148
  readonly "bootstrap.download_failed": 502;
149
149
  readonly "bootstrap.missing_file": 500;
150
+ /** The extra bootstrap manifest cannot be read, is invalid, or a git entry's marketplace is not git form. */
151
+ readonly "bootstrap.extra_invalid": 500;
152
+ /** The extra bootstrap manifest names a plugin the built-in manifest already pins. */
153
+ readonly "bootstrap.extra_conflict": 500;
154
+ /** A git entry's tree cannot be read from its marketplace (the git error, never the token). */
155
+ readonly "bootstrap.git_read_failed": 502;
150
156
  readonly "catalog.invalid_manifest": 422;
151
157
  readonly "catalog.no_extension": 409;
152
158
  readonly "catalog.dependency_unresolved": 409;
@@ -280,6 +286,7 @@ export declare const ERROR_CODES: {
280
286
  readonly "marketplace.entry_deprecated": 409;
281
287
  readonly "marketplace.package_mismatch": 409;
282
288
  readonly "marketplace.builtin": 409;
289
+ readonly "marketplace.config_managed": 409;
283
290
  readonly "marketplace.git_failed": 502;
284
291
  readonly "marketplace.git_too_large": 422;
285
292
  readonly "marketplace.git_unsupported_entry": 422;
package/dist/errors.js CHANGED
@@ -147,6 +147,12 @@ export const ERROR_CODES = {
147
147
  "bootstrap.integrity_mismatch": 500,
148
148
  "bootstrap.download_failed": 502,
149
149
  "bootstrap.missing_file": 500,
150
+ /** The extra bootstrap manifest cannot be read, is invalid, or a git entry's marketplace is not git form. */
151
+ "bootstrap.extra_invalid": 500,
152
+ /** The extra bootstrap manifest names a plugin the built-in manifest already pins. */
153
+ "bootstrap.extra_conflict": 500,
154
+ /** A git entry's tree cannot be read from its marketplace (the git error, never the token). */
155
+ "bootstrap.git_read_failed": 502,
150
156
  "catalog.invalid_manifest": 422,
151
157
  "catalog.no_extension": 409,
152
158
  "catalog.dependency_unresolved": 409,
@@ -280,6 +286,7 @@ export const ERROR_CODES = {
280
286
  "marketplace.entry_deprecated": 409,
281
287
  "marketplace.package_mismatch": 409,
282
288
  "marketplace.builtin": 409,
289
+ "marketplace.config_managed": 409,
283
290
  "marketplace.git_failed": 502,
284
291
  "marketplace.git_too_large": 422,
285
292
  "marketplace.git_unsupported_entry": 422,
@@ -0,0 +1,24 @@
1
+ import { SettingsService } from "../identity/settings.js";
2
+ import { KernelDb } from "../infra/database/kernel-db.js";
3
+ import type { KernelLogger } from "../log.js";
4
+ /**
5
+ * The deployment defaults of the extra bootstrap manifest (bootstrap extra manifest spec §7),
6
+ * applied at every kernel start after the extensions loaded (and the bootstrap step's second pass),
7
+ * whether or not the step ran in that start: cheap, and a no-op once applied or once a super admin
8
+ * chose, so a default that could not be applied yet (its theme not imported, not eligible) is
9
+ * retried at the next start. Never fails the start.
10
+ */
11
+ export declare class BootstrapDefaultsService {
12
+ private readonly db;
13
+ private readonly settings;
14
+ private readonly log;
15
+ constructor(db: KernelDb, settings: SettingsService, log: Pick<KernelLogger, "info" | "warn" | "error">);
16
+ /**
17
+ * `defaultTheme`: the platform default theme, `(plugin, theme)` resolved to the live
18
+ * platform-owned `platform_themes` row and handed to {@link SettingsService.applyBootstrapUiTheme}.
19
+ */
20
+ apply(defaultTheme?: {
21
+ plugin: string;
22
+ theme: string;
23
+ }): Promise<void>;
24
+ }
@@ -0,0 +1,78 @@
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 { SettingsService } from "../identity/settings.js";
13
+ import { KernelDb } from "../infra/database/kernel-db.js";
14
+ import { KERNEL_LOGGER } from "../infra/tokens.js";
15
+ const errMsg = (e) => (e instanceof Error ? e.message : String(e));
16
+ /**
17
+ * The deployment defaults of the extra bootstrap manifest (bootstrap extra manifest spec §7),
18
+ * applied at every kernel start after the extensions loaded (and the bootstrap step's second pass),
19
+ * whether or not the step ran in that start: cheap, and a no-op once applied or once a super admin
20
+ * chose, so a default that could not be applied yet (its theme not imported, not eligible) is
21
+ * retried at the next start. Never fails the start.
22
+ */
23
+ let BootstrapDefaultsService = class BootstrapDefaultsService {
24
+ db;
25
+ settings;
26
+ log;
27
+ constructor(db, settings, log) {
28
+ this.db = db;
29
+ this.settings = settings;
30
+ this.log = log;
31
+ }
32
+ /**
33
+ * `defaultTheme`: the platform default theme, `(plugin, theme)` resolved to the live
34
+ * platform-owned `platform_themes` row and handed to {@link SettingsService.applyBootstrapUiTheme}.
35
+ */
36
+ async apply(defaultTheme) {
37
+ if (defaultTheme === undefined)
38
+ return;
39
+ const fields = { plugin: defaultTheme.plugin, theme: defaultTheme.theme };
40
+ try {
41
+ // Resolved outside the transaction; applyBootstrapUiTheme re-validates it under the locks
42
+ // (assertPlatformDefaultEligible)
43
+ const row = await this.db
44
+ .selectFrom("platform_themes")
45
+ .select("id")
46
+ .where("plugin_name", "=", defaultTheme.plugin)
47
+ .where("name", "=", defaultTheme.theme)
48
+ .where("deleted_at", "is", null)
49
+ .where("owner_org_id", "is", null)
50
+ .executeTakeFirst();
51
+ if (row === undefined) {
52
+ this.log.warn("bootstrap: the default theme is not installed; retried on the next start", fields);
53
+ return;
54
+ }
55
+ const outcome = await this.settings.applyBootstrapUiTheme(row.id);
56
+ if (outcome === "applied") {
57
+ this.log.info("bootstrap: the default theme is the platform default", fields);
58
+ }
59
+ }
60
+ catch (e) {
61
+ if (e instanceof ApiError && e.code === "theme.not_available") {
62
+ this.log.warn("bootstrap: the default theme cannot be the platform default; retried on the next start", { ...fields, error: e.message });
63
+ return;
64
+ }
65
+ this.log.error("bootstrap: the default theme could not be applied; retried on the next start", {
66
+ ...fields,
67
+ error: errMsg(e),
68
+ });
69
+ }
70
+ }
71
+ };
72
+ BootstrapDefaultsService = __decorate([
73
+ Injectable(),
74
+ __param(0, Inject(KernelDb)),
75
+ __param(1, Inject(SettingsService)),
76
+ __param(2, Inject(KERNEL_LOGGER))
77
+ ], BootstrapDefaultsService);
78
+ export { BootstrapDefaultsService };
@@ -0,0 +1,74 @@
1
+ import { type BootstrapEntry, type BootstrapExtraManifest, type BootstrapExtraMarketplace, type BootstrapGitEntry, type BootstrapManifest, type Logger } from "@capybara-hq/plugin-sdk";
2
+ /**
3
+ * The built-in bootstrap manifest merged with the extra one (spec 2026-11-20-bootstrap-extra-manifest
4
+ * §3): ONE manifest, built-in entries first, hashed as a whole by `bootstrapManifestSha256`. `extra`
5
+ * is absent without an extra manifest, so the object (and its sha256) is the built-in manifest's.
6
+ */
7
+ export type MergedBootstrapManifest = Omit<BootstrapManifest, "plugins"> & {
8
+ plugins: MergedBootstrapEntry[];
9
+ extra?: {
10
+ marketplaces: BootstrapExtraMarketplace[];
11
+ /** The names of the entries that came from the extra manifest (flagged `extra` in a run's results). */
12
+ plugins: string[];
13
+ defaultTheme?: {
14
+ plugin: string;
15
+ theme: string;
16
+ };
17
+ };
18
+ };
19
+ /**
20
+ * What an extra manifest left in the deployment: the config-managed marketplaces and the entries
21
+ * the last completed bootstrap run took from an extra manifest (flagged `extra` in its results).
22
+ * A process without an extra manifest that finds any is configured differently from the ones that
23
+ * wrote them ({@link missingExtraManifestMessage}).
24
+ */
25
+ export interface ExtraManifestTraces {
26
+ marketplaces: string[];
27
+ plugins: string[];
28
+ }
29
+ /** Whether `t` names anything: then a process without an extra manifest must not sync or run. */
30
+ export declare const hasExtraManifestTraces: (t: ExtraManifestTraces) => boolean;
31
+ /** A git entry of the merged manifest: `required` defaults to false, as for an npm extra entry. */
32
+ export type BootstrapGitRunEntry = BootstrapGitEntry & {
33
+ required: boolean;
34
+ };
35
+ /** One entry of the merged manifest. */
36
+ export type MergedBootstrapEntry = BootstrapEntry | BootstrapGitRunEntry;
37
+ /** What the bootstrap step runs: the merged manifest. */
38
+ export type LoadedBootstrapManifest = MergedBootstrapManifest;
39
+ /** Reads and parses an extra manifest; every problem (also a missing file) is `bootstrap.extra_invalid`. */
40
+ export declare function readBootstrapExtraManifest(file: string): Promise<BootstrapExtraManifest>;
41
+ /** Built-in entries first, then the extra ones; a name in both is `bootstrap.extra_conflict`. */
42
+ export declare function mergeBootstrapManifests(builtin: BootstrapManifest, extra: BootstrapExtraManifest | undefined): MergedBootstrapManifest;
43
+ /** Loads the built-in manifest (a given one, else the file) and merges the extra file into it. */
44
+ export declare function loadBootstrapManifest(o: {
45
+ manifestFile?: string;
46
+ builtin?: BootstrapManifest;
47
+ extraManifest?: string;
48
+ }): Promise<LoadedBootstrapManifest>;
49
+ /**
50
+ * A process without an extra manifest found what one left (`t`): another service of the deployment
51
+ * runs with an extra manifest, or an earlier `capybara bootstrap` ran with one. Bootstrapping or
52
+ * syncing here would demote its marketplaces and strip the extra entries' `required` / `builtin`
53
+ * under the built-in manifest's sha, which the correctly configured services then take as done.
54
+ */
55
+ export declare function missingExtraManifestMessage(t: ExtraManifestTraces): string;
56
+ /**
57
+ * The bootstrap step refused under its lock: the manifest has no extra manifest while an extra
58
+ * manifest left traces (`traces`; rulings R16, R17). A replica that checked before another
59
+ * replica's sync committed gets here instead of stripping the extra entries' required / builtin.
60
+ * Nothing was written.
61
+ */
62
+ export declare class BootstrapExtraMismatchError extends Error {
63
+ readonly traces: ExtraManifestTraces;
64
+ constructor(traces: ExtraManifestTraces);
65
+ }
66
+ /**
67
+ * Runs `syncExtraFromConfig`: a deadlock or serialization failure is retried once; a failure that
68
+ * remains is logged and does not stop the start (another replica writes the same rows).
69
+ * A configuration error is not contention and is thrown. The marketplaces it demoted (their
70
+ * names left the extra manifest) are logged as a warning.
71
+ */
72
+ export declare function syncExtraMarketplaces(sync: (marketplaces: readonly BootstrapExtraMarketplace[] | undefined) => Promise<readonly string[]>,
73
+ /** The extra manifest's marketplaces; undefined: no extra manifest (nothing is demoted). */
74
+ marketplaces: readonly BootstrapExtraMarketplace[] | undefined, log: Pick<Logger, "warn">): Promise<void>;