@superblocksteam/shared 0.9620.3 → 0.9622.0

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 (150) hide show
  1. package/dist/errors/http.d.ts +11 -0
  2. package/dist/errors/http.d.ts.map +1 -1
  3. package/dist/errors/http.js +11 -0
  4. package/dist/errors/http.js.map +1 -1
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +1 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/jwt/verifier-timeout.test.d.ts +2 -0
  10. package/dist/jwt/verifier-timeout.test.d.ts.map +1 -0
  11. package/dist/jwt/verifier-timeout.test.js +120 -0
  12. package/dist/jwt/verifier-timeout.test.js.map +1 -0
  13. package/dist/jwt/verifier.d.ts +3 -0
  14. package/dist/jwt/verifier.d.ts.map +1 -1
  15. package/dist/jwt/verifier.js +4 -1
  16. package/dist/jwt/verifier.js.map +1 -1
  17. package/dist/socket/protocol.d.ts +37 -0
  18. package/dist/socket/protocol.d.ts.map +1 -1
  19. package/dist/socket/socket.d.ts +2 -0
  20. package/dist/socket/socket.d.ts.map +1 -1
  21. package/dist/socket/socket.js +6 -1
  22. package/dist/socket/socket.js.map +1 -1
  23. package/dist/socket/socket.test.js +35 -0
  24. package/dist/socket/socket.test.js.map +1 -1
  25. package/dist/types/ai/chat-changed-elsewhere.d.ts +8 -0
  26. package/dist/types/ai/chat-changed-elsewhere.d.ts.map +1 -0
  27. package/dist/types/ai/chat-changed-elsewhere.js +12 -0
  28. package/dist/types/ai/chat-changed-elsewhere.js.map +1 -0
  29. package/dist/types/ai/editor-restart-required.d.ts +8 -0
  30. package/dist/types/ai/editor-restart-required.d.ts.map +1 -0
  31. package/dist/types/ai/editor-restart-required.js +12 -0
  32. package/dist/types/ai/editor-restart-required.js.map +1 -0
  33. package/dist/types/ai/index.d.ts +2 -0
  34. package/dist/types/ai/index.d.ts.map +1 -1
  35. package/dist/types/ai/index.js +2 -0
  36. package/dist/types/ai/index.js.map +1 -1
  37. package/dist/types/ai/native-builder-model.d.ts +29 -5
  38. package/dist/types/ai/native-builder-model.d.ts.map +1 -1
  39. package/dist/types/ai/native-builder-model.js +13 -3
  40. package/dist/types/ai/native-builder-model.js.map +1 -1
  41. package/dist/types/ai/native-builder-model.test.js +6 -3
  42. package/dist/types/ai/native-builder-model.test.js.map +1 -1
  43. package/dist/types/application/index.js +1 -1
  44. package/dist/types/application/index.js.map +1 -1
  45. package/dist/types/audit/ocsf.d.ts.map +1 -1
  46. package/dist/types/audit/ocsf.js +37 -0
  47. package/dist/types/audit/ocsf.js.map +1 -1
  48. package/dist/types/branch/index.d.ts +4 -5
  49. package/dist/types/branch/index.d.ts.map +1 -1
  50. package/dist/types/deployedAgents.d.ts +31 -0
  51. package/dist/types/deployedAgents.d.ts.map +1 -0
  52. package/dist/types/deployedAgents.js +2 -0
  53. package/dist/types/deployedAgents.js.map +1 -0
  54. package/dist/types/deployment/currentPublish.d.ts +33 -0
  55. package/dist/types/deployment/currentPublish.d.ts.map +1 -0
  56. package/dist/types/deployment/currentPublish.js +2 -0
  57. package/dist/types/deployment/currentPublish.js.map +1 -0
  58. package/dist/types/deployment/index.d.ts +1 -0
  59. package/dist/types/deployment/index.d.ts.map +1 -1
  60. package/dist/types/git/index.js +1 -1
  61. package/dist/types/git/index.js.map +1 -1
  62. package/dist/types/git/index.test.js +5 -0
  63. package/dist/types/git/index.test.js.map +1 -1
  64. package/dist/types/policyGate/errors.d.ts +6 -0
  65. package/dist/types/policyGate/errors.d.ts.map +1 -1
  66. package/dist/types/policyGate/errors.js +3 -0
  67. package/dist/types/policyGate/errors.js.map +1 -1
  68. package/dist/types/policyGate/index.d.ts +10 -2
  69. package/dist/types/policyGate/index.d.ts.map +1 -1
  70. package/dist/types/policyGate/index.js.map +1 -1
  71. package/dist/types/rbac/index.d.ts +8 -0
  72. package/dist/types/rbac/index.d.ts.map +1 -1
  73. package/dist/types/rbac/index.js +8 -0
  74. package/dist/types/rbac/index.js.map +1 -1
  75. package/dist/types/reviewPolicy/index.d.ts +5 -2
  76. package/dist/types/reviewPolicy/index.d.ts.map +1 -1
  77. package/dist/types/reviewPolicy/index.js +10 -2
  78. package/dist/types/reviewPolicy/index.js.map +1 -1
  79. package/dist/types/userToken/index.d.ts +1 -0
  80. package/dist/types/userToken/index.d.ts.map +1 -1
  81. package/dist/utils/builderHarnessAvailability.d.ts +25 -0
  82. package/dist/utils/builderHarnessAvailability.d.ts.map +1 -0
  83. package/dist/utils/builderHarnessAvailability.js +34 -0
  84. package/dist/utils/builderHarnessAvailability.js.map +1 -0
  85. package/dist/utils/builderHarnessAvailability.test.d.ts +2 -0
  86. package/dist/utils/builderHarnessAvailability.test.d.ts.map +1 -0
  87. package/dist/utils/builderHarnessAvailability.test.js +31 -0
  88. package/dist/utils/builderHarnessAvailability.test.js.map +1 -0
  89. package/dist/utils/index.d.ts +2 -0
  90. package/dist/utils/index.d.ts.map +1 -1
  91. package/dist/utils/index.js +2 -0
  92. package/dist/utils/index.js.map +1 -1
  93. package/dist/utils/localNativeBuilderFlags.d.ts +2 -1
  94. package/dist/utils/localNativeBuilderFlags.d.ts.map +1 -1
  95. package/dist/utils/localNativeBuilderFlags.js +2 -1
  96. package/dist/utils/localNativeBuilderFlags.js.map +1 -1
  97. package/dist/utils/localNativeBuilderFlags.test.js +8 -8
  98. package/dist/utils/localNativeBuilderFlags.test.js.map +1 -1
  99. package/dist/utils/native-attachment-budget.d.ts +16 -0
  100. package/dist/utils/native-attachment-budget.d.ts.map +1 -0
  101. package/dist/utils/native-attachment-budget.js +32 -0
  102. package/dist/utils/native-attachment-budget.js.map +1 -0
  103. package/dist/utils/native-attachment-budget.test.d.ts +2 -0
  104. package/dist/utils/native-attachment-budget.test.d.ts.map +1 -0
  105. package/dist/utils/native-attachment-budget.test.js +21 -0
  106. package/dist/utils/native-attachment-budget.test.js.map +1 -0
  107. package/dist/utils/pageFixtures/v4/container.d.ts +45 -45
  108. package/dist/utils/pageFixtures/v4/container.d.ts.map +1 -1
  109. package/dist/utils/pageFixtures/v4/form.d.ts +1 -1
  110. package/dist/utils/pageFixtures/v6/nested_modal.d.ts +4 -4
  111. package/dist/utils/pageFixtures/v6/with_main_canvas_children.d.ts +12 -12
  112. package/dist/utils/pageFixtures/v7/grids_and_forms.d.ts +9 -9
  113. package/dist/utils/platform-mcp-server-routes.d.ts +1 -1
  114. package/dist/utils/platform-mcp-server-routes.d.ts.map +1 -1
  115. package/dist/utils/platform-mcp-server-routes.js +12 -0
  116. package/dist/utils/platform-mcp-server-routes.js.map +1 -1
  117. package/package.json +1 -1
  118. package/src/errors/http.ts +13 -0
  119. package/src/index.ts +1 -0
  120. package/src/jwt/verifier-timeout.test.ts +62 -0
  121. package/src/jwt/verifier.ts +5 -1
  122. package/src/socket/protocol.ts +38 -2
  123. package/src/socket/socket.test.ts +43 -0
  124. package/src/socket/socket.ts +8 -1
  125. package/src/types/ai/chat-changed-elsewhere.ts +13 -0
  126. package/src/types/ai/editor-restart-required.ts +13 -0
  127. package/src/types/ai/index.ts +2 -0
  128. package/src/types/ai/native-builder-model.test.ts +7 -3
  129. package/src/types/ai/native-builder-model.ts +18 -3
  130. package/src/types/application/index.ts +1 -1
  131. package/src/types/audit/ocsf.ts +37 -0
  132. package/src/types/branch/index.ts +4 -2
  133. package/src/types/deployedAgents.ts +19 -0
  134. package/src/types/deployment/currentPublish.ts +28 -0
  135. package/src/types/deployment/index.ts +1 -0
  136. package/src/types/git/index.test.ts +8 -0
  137. package/src/types/git/index.ts +1 -1
  138. package/src/types/policyGate/errors.ts +4 -0
  139. package/src/types/policyGate/index.ts +17 -2
  140. package/src/types/rbac/index.ts +8 -0
  141. package/src/types/reviewPolicy/index.ts +12 -2
  142. package/src/types/userToken/index.ts +2 -0
  143. package/src/utils/builderHarnessAvailability.test.ts +33 -0
  144. package/src/utils/builderHarnessAvailability.ts +43 -0
  145. package/src/utils/index.ts +2 -0
  146. package/src/utils/localNativeBuilderFlags.test.ts +8 -8
  147. package/src/utils/localNativeBuilderFlags.ts +4 -3
  148. package/src/utils/native-attachment-budget.test.ts +23 -0
  149. package/src/utils/native-attachment-budget.ts +39 -0
  150. package/src/utils/platform-mcp-server-routes.ts +12 -0
@@ -3,8 +3,12 @@ import { describe, expect, it } from 'vitest';
3
3
  import { NativeBuilderModel, NATIVE_BUILDER_MODELS } from './native-builder-model.js';
4
4
 
5
5
  describe('NativeBuilderModel', () => {
6
+ it.each(['gpt-6.1-sol', 'gpt-6-astra', 'gpt-6.1-terra', 'gpt-6-luna'])('resolves the selected Codex model %s', (model) => {
7
+ expect(NativeBuilderModel.resolve('codex', model)).toBe(model);
8
+ });
9
+
6
10
  it.each([
7
- ['codex', 'gpt-5.5'],
11
+ ['codex', 'gpt-6.1-sol'],
8
12
  ['claude_code', 'claude-opus-5-5'],
9
13
  ['clark', undefined]
10
14
  ] as const)('keeps the default for %s', (harness, expected) => {
@@ -20,13 +24,13 @@ describe('NativeBuilderModel', () => {
20
24
  });
21
25
 
22
26
  it.each([
23
- ['codex', 'claude-sonnet-4-6'],
27
+ ['codex', 'claude-sonnet-5-5'],
24
28
  ['claude_code', 'gpt-5.5'],
25
29
  ['claude_code', 'sonnet'],
26
30
  ['claude_code', ''],
27
31
  ['claude_code', null],
28
32
  ['claude_code', {}],
29
- ['clark', 'claude-opus-4-6']
33
+ ['clark', 'claude-opus-5-5']
30
34
  ] as const)('rejects %s model selection %j', (harness, model) => {
31
35
  expect(() => NativeBuilderModel.resolve(harness, model)).toThrow('Unsupported builder model');
32
36
  });
@@ -1,19 +1,34 @@
1
+ /** Defines selectable native builder models and their shared provider capabilities. */
1
2
  import { BadRequestError } from '../../errors/http.js';
2
3
 
4
+ /** Total input tokens above which OpenAI Standard long-context rates apply. */
5
+ const OPENAI_LONG_CONTEXT_THRESHOLD = 272_000;
6
+
7
+ /** Ordered picker choices; the first model of each harness is its default. */
3
8
  export const NATIVE_BUILDER_MODELS = {
4
- codex: [{ id: 'gpt-5.5', label: 'GPT-5.5' }],
9
+ codex: [
10
+ { id: 'gpt-6.1-sol', label: 'GPT-6.1 Sol', bedrockRegion: 'us-east-1', longContextThreshold: OPENAI_LONG_CONTEXT_THRESHOLD },
11
+ { id: 'gpt-6-astra', label: 'GPT-6 Astra', bedrockRegion: 'us-west-2', longContextThreshold: OPENAI_LONG_CONTEXT_THRESHOLD },
12
+ { id: 'gpt-6.1-terra', label: 'GPT-6.1 Terra', bedrockRegion: 'us-east-1', longContextThreshold: OPENAI_LONG_CONTEXT_THRESHOLD },
13
+ { id: 'gpt-6-luna', label: 'GPT-6 Luna', bedrockRegion: 'us-east-1', longContextThreshold: OPENAI_LONG_CONTEXT_THRESHOLD },
14
+ { id: 'gpt-5.5', label: 'GPT-5.5', bedrockRegion: undefined, longContextThreshold: OPENAI_LONG_CONTEXT_THRESHOLD }
15
+ ] as const satisfies readonly { id: string; label: string; bedrockRegion: string | undefined; longContextThreshold: number }[],
5
16
  claude_code: [
6
17
  { id: 'claude-opus-5-5', label: 'Opus 5.5' },
7
- { id: 'claude-opus-4-6', label: 'Opus 4.6' },
8
- { id: 'claude-sonnet-4-6', label: 'Sonnet 4.6' }
18
+ { id: 'claude-sonnet-5-5', label: 'Sonnet 5.5' }
9
19
  ]
10
20
  } as const;
11
21
 
22
+ /** Model identifiers accepted by a native builder harness. */
12
23
  export type NativeBuilderModelId =
13
24
  | (typeof NATIVE_BUILDER_MODELS.codex)[number]['id']
14
25
  | (typeof NATIVE_BUILDER_MODELS.claude_code)[number]['id'];
15
26
 
27
+ /** Resolves defaults and validates explicit native model selections. */
16
28
  export class NativeBuilderModel {
29
+ /** Preserves an explicit selection or returns the harness default; a native harness always resolves to a model. */
30
+ static resolve(harness: keyof typeof NATIVE_BUILDER_MODELS, preferredModel?: unknown): NativeBuilderModelId;
31
+ static resolve(harness: keyof typeof NATIVE_BUILDER_MODELS | 'clark', preferredModel?: unknown): NativeBuilderModelId | undefined;
17
32
  static resolve(harness: keyof typeof NATIVE_BUILDER_MODELS | 'clark', preferredModel?: unknown): NativeBuilderModelId | undefined {
18
33
  if (harness === 'clark') {
19
34
  if (preferredModel !== undefined) throw new BadRequestError('Unsupported builder model for Clark');
@@ -683,7 +683,7 @@ export type CheckpointSkipReason = 'draft-autosave' | 'no-changes' | 'no-op-sour
683
683
  *
684
684
  * Must stay in sync with the `sdkApi` field in packages/demo-apps/config.json.
685
685
  */
686
- const SDK_API_TEMPLATES = new Set(['app-fullstack']);
686
+ const SDK_API_TEMPLATES = new Set(['app-fullstack', 'project-starter']);
687
687
 
688
688
  export function isSdkApiTemplate(templateName: string | null | undefined): boolean {
689
689
  if (!templateName) return false;
@@ -163,6 +163,12 @@ export const AUDIT_EVENT_TYPE_CATALOG: AuditEventTypeEntry[] = [
163
163
  category_name: 'APPLICATION_ACTIVITY',
164
164
  resource_type: 'Application',
165
165
  operations: [
166
+ 'application.branch.create',
167
+ 'application.branch.delete',
168
+ 'application.branch.enable',
169
+ 'application.branch.merge',
170
+ 'application.branch.pull',
171
+ 'application.branch.switch',
166
172
  'application.clone',
167
173
  'application.create',
168
174
  'application.create_from_template',
@@ -259,6 +265,7 @@ export const AUDIT_EVENT_TYPE_CATALOG: AuditEventTypeEntry[] = [
259
265
  resource_type: 'Organization',
260
266
  operations: [
261
267
  'organization.mcp_allowed_clients.update',
268
+ 'organization.mcp_client_approval.update',
262
269
  'organization.npm_allow_install_scripts_changed',
263
270
  'organization.npm_registry.create',
264
271
  'organization.npm_registry.delete',
@@ -304,6 +311,36 @@ export const AUDIT_EVENT_TYPE_CATALOG: AuditEventTypeEntry[] = [
304
311
  'reviewpolicy.enable'
305
312
  ]
306
313
  },
314
+ {
315
+ class_uid: OCSFClassUid.ENTITY_MANAGEMENT,
316
+ class_name: 'ENTITY_MANAGEMENT',
317
+ category_uid: OCSFCategoryUid.APPLICATION_ACTIVITY,
318
+ category_name: 'APPLICATION_ACTIVITY',
319
+ resource_type: 'Skill',
320
+ operations: [
321
+ 'skill.archive',
322
+ 'skill.create',
323
+ 'skill.draft.import',
324
+ 'skill.draft.submit',
325
+ 'skill.draft.update',
326
+ 'skill.import',
327
+ 'skill.scope.update',
328
+ 'skill.tags.update',
329
+ 'skill.version.approve',
330
+ 'skill.version.approve_despite_findings',
331
+ 'skill.version.deprecate',
332
+ 'skill.version.reject',
333
+ 'skill.version.revoke'
334
+ ]
335
+ },
336
+ {
337
+ class_uid: OCSFClassUid.ENTITY_MANAGEMENT,
338
+ class_name: 'ENTITY_MANAGEMENT',
339
+ category_uid: OCSFCategoryUid.APPLICATION_ACTIVITY,
340
+ category_name: 'APPLICATION_ACTIVITY',
341
+ resource_type: 'SkillSource',
342
+ operations: ['skillsource.create', 'skillsource.sync']
343
+ },
307
344
  {
308
345
  class_uid: OCSFClassUid.ENTITY_MANAGEMENT,
309
346
  class_name: 'ENTITY_MANAGEMENT',
@@ -27,6 +27,8 @@ export type BranchStatus = {
27
27
  behind: number;
28
28
  /** The commits counted in behind, newest first, at most 10. */
29
29
  behindCommits: BranchStatusCommit[];
30
+ /** Main's commits the branch lacks. A publish needs them. Equals behind when main is the upstream. */
31
+ behindMain: number;
30
32
  /** A merge with conflicts waits for the checkpoint that resolves it. */
31
33
  pendingMerge: boolean;
32
34
  /** The number of conflict paths in the open merge. 0 when none is open. */
@@ -36,8 +38,8 @@ export type BranchStatus = {
36
38
  /** The branch lands on its merge target by itself when that checkpoint is saved. */
37
39
  landPending: boolean;
38
40
  hasUncommittedChanges: boolean;
39
- /** Another user's publish going out for this app. Publishing waits until it finishes. */
40
- otherPublish?: { userId: string; userName: string | null } | null;
41
+ /** Merge targets whose head already contains this branch head. Empty when the live edit has uncommitted changes */
42
+ upToDateTargets: string[];
41
43
  /** The app's user branches. A branch with a holder is locked to that user until they leave. */
42
44
  branches?: UserBranchSummary[];
43
45
  };
@@ -0,0 +1,19 @@
1
+ export type DeployedAgentStreamEvent =
2
+ | { type: 'text_delta'; text: string }
3
+ | { type: 'tool_start'; name: string; toolUseId?: string }
4
+ | { type: 'tool_result'; name: string; toolUseId?: string; content: string; failed?: boolean }
5
+ | { type: 'done' }
6
+ | { type: 'error'; message: string };
7
+
8
+ export interface DeployedAgentToolCall {
9
+ name: string;
10
+ toolUseId?: string;
11
+ status: 'running' | 'complete' | 'failed';
12
+ content?: string;
13
+ }
14
+
15
+ export interface DeployedAgentMessage {
16
+ role: 'user' | 'assistant';
17
+ content: string;
18
+ toolCalls?: DeployedAgentToolCall[];
19
+ }
@@ -0,0 +1,28 @@
1
+ import type { DeployQueueStatus } from './deployQueueStatus.js';
2
+
3
+ /** A publish of the app. `branch` is the user branch its commit was made on. */
4
+ export type PublishSummary = {
5
+ commitId: string;
6
+ branch: string | null;
7
+ commitMessage: string | null;
8
+ /** The git commit, for an app connected to git. */
9
+ gitSha: string | null;
10
+ /** The commit that holds the version's screenshot: the checkpoint it was minted from, else the commit itself. */
11
+ screenshotCommitId: string;
12
+ userId: string | null;
13
+ userName: string | null;
14
+ /** ISO time the publish started (active) or deployed (last). */
15
+ at: string;
16
+ };
17
+
18
+ export type ActivePublish = { commitId: string; userId: string; userName: string | null };
19
+
20
+ /** `checking`: the policy checks still run, before the publish enters the deploy queue. */
21
+ export type ActivePublishStatus = 'checking' | DeployQueueStatus.QUEUED | DeployQueueStatus.DEPLOYING | DeployQueueStatus.AWAITING_ACK;
22
+
23
+ /** The publish going out for the app now, from any branch, and the last publish that deployed. */
24
+ export type CurrentPublish = {
25
+ active: (PublishSummary & { status: ActivePublishStatus }) | null;
26
+ /** `isLive` is false when the live version is no longer this commit. */
27
+ last: (PublishSummary & { isLive: boolean }) | null;
28
+ };
@@ -7,6 +7,7 @@ export {
7
7
  type LifecycleStageState,
8
8
  type LifecycleStageTargetProgress
9
9
  } from './deployQueueStatus.js';
10
+ export type { ActivePublish, ActivePublishStatus, CurrentPublish, PublishSummary } from './currentPublish.js';
10
11
 
11
12
  export interface DeploymentDto {
12
13
  commitId: string | null;
@@ -12,4 +12,12 @@ describe('isGitAuthErrorMessage', () => {
12
12
  it('matches password authentication is not supported errors', () => {
13
13
  expect(isGitAuthErrorMessage(new Error('fatal: Password authentication is not supported for Git operations.'))).toBe(true);
14
14
  });
15
+
16
+ it('matches HTTP 401 authentication errors without matching 401 in a URL or revision', () => {
17
+ expect(isGitAuthErrorMessage('fatal: unable to access https://example.com/repo: The requested URL returned error: 401')).toBe(true);
18
+ expect(isGitAuthErrorMessage('fatal: unable to access https://example.com/repo-401: The requested URL returned error: 403')).toBe(
19
+ false
20
+ );
21
+ expect(isGitAuthErrorMessage("fatal: ambiguous argument '401-missing': unknown revision")).toBe(false);
22
+ });
15
23
  });
@@ -21,7 +21,7 @@ export const GIT_AUTH_ERROR_PATTERNS: readonly string[] = [
21
21
  'invalid username or token',
22
22
  'bad credentials',
23
23
  'password authentication is not supported',
24
- '401'
24
+ 'the requested url returned error: 401'
25
25
  ];
26
26
 
27
27
  /**
@@ -1,3 +1,4 @@
1
+ /** Defines policy review failure classifications and lifecycle time budgets. */
1
2
  export type PolicyGateErrorCategory = 'configuration' | 'platform_error' | 'platform_transient' | 'provider_transient' | 'user_action';
2
3
 
3
4
  export type PolicyGateErrorSpec = {
@@ -10,6 +11,8 @@ export const DEFAULT_POLICY_GATE_ERROR_SPEC: PolicyGateErrorSpec = {
10
11
 
11
12
  export const MAX_POLICY_GATE_RUN_ATTEMPTS = 3;
12
13
  export const POLICY_GATE_MAX_TOTAL_TIME_MS = 15 * 60 * 1000;
14
+ /** Maximum transport time for a review-state callback to the control plane. */
15
+ export const POLICY_GATE_CALLBACK_TIMEOUT_MS = 30_000;
13
16
  // Independent of POLICY_GATE_MAX_TOTAL_TIME_MS: bounds how long the agent can
14
17
  // go without producing a single stream part, so a connection that stalls
15
18
  // without ever erroring (APPS-5642) still fails closed instead of leaving the
@@ -45,6 +48,7 @@ export const POLICY_GATE_ERROR_CODES = {
45
48
  dependency_scan_stalled: { category: 'platform_transient' }, // The in-process dependency scan never completed.
46
49
  dev_server_unreachable: { category: 'platform_transient' }, // The dev server did not finish the run.
47
50
  dispatch_failed: { category: 'platform_transient' }, // The server could not start the run.
51
+ skill_scan_stalled: { category: 'platform_transient' }, // The in-process Skill Scan never completed.
48
52
 
49
53
  // Legacy code from dev servers that predate this registry.
50
54
  execution_failed: { category: 'platform_transient' }, // An old dev server reported a generic failure.
@@ -64,6 +64,8 @@ export type PolicyGateScanProgress = {
64
64
 
65
65
  export type PolicyGateReadinessItem = {
66
66
  actions: PolicyGateReadinessAction[];
67
+ /** Agent run of the latest review; live agent steps carry it. */
68
+ aiAgentRunId?: string;
67
69
  displayName?: string;
68
70
  findings?: PolicyGateReadinessFinding[];
69
71
  /** Optional provider/scanner logo (data URI or URL) shown next to the item. */
@@ -233,8 +235,9 @@ export type ScanScopePriorFinding = {
233
235
  title: string;
234
236
  };
235
237
 
236
- export type ScanScopeJson = {
237
- baseApplicationCommitId: string;
238
+ // What changed since the scan baseline and what the baseline's run already found. Shared by every
239
+ // review subject; each subject's scan scope adds the identity of its baseline.
240
+ type ScanScopeChanges = {
238
241
  changedFiles: ScanScopeChangedFile[];
239
242
  diffTruncated: boolean;
240
243
  priorAiAgentRunId?: string;
@@ -243,6 +246,18 @@ export type ScanScopeJson = {
243
246
  unifiedDiff: string;
244
247
  };
245
248
 
249
+ export type ScanScopeJson = ScanScopeChanges & {
250
+ baseApplicationCommitId: string;
251
+ };
252
+
253
+ // Scan scope for a Skill Scan. The files are the Skill Bundle of `skillVersionId`, diffed against
254
+ // the previous Approved Skill Version. With no baseline (`baseSkillVersionId` null), every file in
255
+ // the bundle is `added`.
256
+ export type SkillBundleScanScopeJson = ScanScopeChanges & {
257
+ baseSkillVersionId: string | null;
258
+ skillVersionId: string;
259
+ };
260
+
246
261
  export function countFailedPolicyGateRuns(item: Pick<PolicyGateReadinessItem, 'runs'>): number {
247
262
  return (item.runs ?? []).filter((run) => run.status === 'failed' && run.errorCode !== 'canceled').length;
248
263
  }
@@ -145,6 +145,7 @@ export enum ResourceTypeEnum {
145
145
  // ORGANIZATION_REQUESTS = 'org.requests',
146
146
  ORGANIZATION_USERS = 'org.users',
147
147
  ORG_KNOWLEDGE = 'org_knowledge',
148
+ ORG_SKILLS = 'org_skills',
148
149
  POLICIES = 'policies',
149
150
  PROFILES = 'profiles',
150
151
  REPOSITORIES = 'repos',
@@ -168,10 +169,12 @@ export enum RoleTypeEnum {
168
169
  }
169
170
 
170
171
  export enum ActionTypeEnum {
172
+ APPROVE = 'approve',
171
173
  BUILD = 'build',
172
174
  CREATE = 'create',
173
175
  DELETE = 'delete',
174
176
  DEPLOY = 'deploy',
177
+ DRAFT = 'draft',
175
178
  MANAGE = 'manage',
176
179
  MANAGE_ENVIRONMENTS = 'manage_environments',
177
180
  MANAGE_SCHEDULE = 'manage_schedule',
@@ -303,6 +306,11 @@ export const ActionTypeByResourceType = {
303
306
  CREATE: ActionTypeEnum.CREATE,
304
307
  UPDATE: ActionTypeEnum.UPDATE,
305
308
  DELETE: ActionTypeEnum.DELETE
309
+ },
310
+ ORG_SKILLS: {
311
+ DRAFT: ActionTypeEnum.DRAFT,
312
+ APPROVE: ActionTypeEnum.APPROVE,
313
+ MANAGE: ActionTypeEnum.MANAGE
306
314
  }
307
315
  } as const;
308
316
 
@@ -16,7 +16,12 @@ export const SUPERBLOCKS_SECURITY_AGENT_NAME = 'Superblocks Security Agent';
16
16
  // runs synchronously against the vulnerability index, so it needs no runner config to enable.
17
17
  export const DEPENDENCY_VULNERABILITY_SCAN_NAME = 'Superblocks Vulnerability Detection';
18
18
 
19
- export const REVIEW_POLICY_TYPES = ['built_in_security_scan', 'security_agent', 'dependency_vulnerability_scan'] as const;
19
+ // Display name of the Superblocks-managed Skill Scan. One per organization that submits a Skill
20
+ // Version, whatever its plan; it is not configurable.
21
+ export const SKILL_SCAN_NAME = 'Superblocks Skill Scan';
22
+
23
+ // `skill_scan` is the Superblocks-managed Skill Scan: its review subject is a Skill Version, not an app.
24
+ export const REVIEW_POLICY_TYPES = ['built_in_security_scan', 'security_agent', 'dependency_vulnerability_scan', 'skill_scan'] as const;
20
25
  export const REVIEW_POLICY_SOURCES = ['admin_configured', 'superblocks_managed'] as const;
21
26
  export const REVIEW_POLICY_TRIGGERS = ['before_deploy', 'after_checkpoint', 'manual'] as const;
22
27
  export const REVIEW_POLICY_EXECUTION_CONTEXTS = [
@@ -24,8 +29,12 @@ export const REVIEW_POLICY_EXECUTION_CONTEXTS = [
24
29
  'superblocks_sabs_built_assets',
25
30
  'superblocks_sabs_dependency_metadata',
26
31
  'superblocks_sabs_source_snapshot',
27
- 'dependency_manifest'
32
+ 'dependency_manifest',
33
+ 'skill_bundle'
28
34
  ] as const;
35
+ // What a review run and its findings are about. An `application` subject is one saved app commit;
36
+ // a `skill_version` subject is one Skill Version in the Skills Registry.
37
+ export const REVIEW_SUBJECT_TYPES = ['application', 'skill_version'] as const;
29
38
  // `superblocks_server` runs in-process on the API server (no external runner), for checks like the
30
39
  // dependency vulnerability scan that only need data already indexed at commit time.
31
40
  export const REVIEW_POLICY_RUNTIMES = ['superblocks_dev_server_agent', 'superblocks_sabs', 'superblocks_server'] as const;
@@ -75,6 +84,7 @@ export type ReviewPolicyType = (typeof REVIEW_POLICY_TYPES)[number];
75
84
  export type ReviewPolicySource = (typeof REVIEW_POLICY_SOURCES)[number];
76
85
  export type ReviewPolicyTrigger = (typeof REVIEW_POLICY_TRIGGERS)[number];
77
86
  export type ReviewPolicyExecutionContext = (typeof REVIEW_POLICY_EXECUTION_CONTEXTS)[number];
87
+ export type ReviewSubjectType = (typeof REVIEW_SUBJECT_TYPES)[number];
78
88
  export type ReviewPolicyRuntime = (typeof REVIEW_POLICY_RUNTIMES)[number];
79
89
  export type ReviewPolicyMode = (typeof REVIEW_POLICY_MODES)[number];
80
90
  export type ReviewPolicyRunnerType = (typeof REVIEW_POLICY_RUNNER_TYPES)[number];
@@ -5,6 +5,8 @@ export type PostUserTokenRequestDto = {
5
5
  authType?: AuthType;
6
6
  datasourceId?: string;
7
7
  configurationId?: string;
8
+ // Shared tokens only: write the token only if no saved configuration has configurationId yet.
9
+ createOnly?: boolean;
8
10
  expiresAt?: Date;
9
11
  tokenType?: TokenType;
10
12
  tokenValue: string;
@@ -0,0 +1,33 @@
1
+ /** Verifies the harness availability contract shared by creation and the homepage. */
2
+ import { describe, expect, it } from 'vitest';
3
+
4
+ import { BuilderHarnessAvailability } from './builderHarnessAvailability.js';
5
+
6
+ describe('BuilderHarnessAvailability', () => {
7
+ it('selects the sole enabled harness without offering a picker', () => {
8
+ const availability = new BuilderHarnessAvailability(['codex']);
9
+ expect(availability.select('clark')).toBe('codex');
10
+ expect(availability.showPicker).toBe(false);
11
+ expect(availability.allows('clark')).toBe(false);
12
+ });
13
+ });
14
+
15
+ it('offers only configured supported choices and preserves an enabled selection', () => {
16
+ const availability = new BuilderHarnessAvailability(['codex', 'unknown', 'codex', 'claude_code']);
17
+ expect(availability.harnesses).toEqual(['claude_code', 'codex']);
18
+ expect(availability.showPicker).toBe(true);
19
+ expect(availability.select('codex')).toBe('codex');
20
+ });
21
+ it.each([undefined, null, false, true, 'codex', {}])('defaults malformed configuration %j to Clark', (value) => {
22
+ expect(new BuilderHarnessAvailability(value).harnesses).toEqual(['clark']);
23
+ });
24
+ it('leaves no harness selected for an empty or unsupported allowlist', () => {
25
+ expect(new BuilderHarnessAvailability([]).select('clark')).toBeUndefined();
26
+ expect(new BuilderHarnessAvailability(['unknown']).harnesses).toEqual([]);
27
+ });
28
+ it('withholds native harnesses without the Skills Registry', () => {
29
+ const allowlist = ['clark', 'claude_code', 'codex'];
30
+ expect(new BuilderHarnessAvailability(allowlist).withSkillsRegistry(true).harnesses).toEqual(['clark', 'claude_code', 'codex']);
31
+ expect(new BuilderHarnessAvailability(allowlist).withSkillsRegistry(false).harnesses).toEqual(['clark']);
32
+ expect(new BuilderHarnessAvailability(['codex']).withSkillsRegistry(false).select('codex')).toBeUndefined();
33
+ });
@@ -0,0 +1,43 @@
1
+ /** Normalizes rollout configuration and resolves available builder harness choices. */
2
+ import type { AiBuilderBinding } from '../types/ai/index.js';
3
+
4
+ /** Shared availability policy for new builder applications. */
5
+ export class BuilderHarnessAvailability {
6
+ /** Choices used when the availability flag has not been configured. */
7
+ static readonly defaults: readonly AiBuilderBinding['harness'][] = ['clark'];
8
+
9
+ /** Supported harnesses in display order. */
10
+ static readonly supported: readonly AiBuilderBinding['harness'][] = ['clark', 'claude_code', 'codex'];
11
+
12
+ /** Validated, deduplicated harnesses in display order. */
13
+ readonly harnesses: readonly AiBuilderBinding['harness'][];
14
+
15
+ /** Accepts a JSON allowlist, falling back to Clark when configuration is absent or malformed. */
16
+ constructor(value: unknown) {
17
+ const configured: readonly unknown[] = Array.isArray(value) ? value : BuilderHarnessAvailability.defaults;
18
+ this.harnesses = BuilderHarnessAvailability.supported.filter((harness) => configured.includes(harness));
19
+ }
20
+
21
+ /**
22
+ * Withholds Codex and Claude Code unless the Skills Registry is enabled: they take their app-building guidance from
23
+ * registry Skills instead of a built-in prompt. Clark needs no registry.
24
+ */
25
+ withSkillsRegistry(enabled: boolean): BuilderHarnessAvailability {
26
+ return enabled ? this : new BuilderHarnessAvailability(this.harnesses.filter((harness) => harness === 'clark'));
27
+ }
28
+
29
+ /** Whether the user has multiple available choices. */
30
+ get showPicker(): boolean {
31
+ return this.harnesses.length > 1;
32
+ }
33
+
34
+ /** Whether a harness can be used for a new application. */
35
+ allows(harness: AiBuilderBinding['harness']): boolean {
36
+ return this.harnesses.includes(harness);
37
+ }
38
+
39
+ /** Keeps an enabled selection, otherwise selects the first available harness. */
40
+ select(preferred: AiBuilderBinding['harness']): AiBuilderBinding['harness'] | undefined {
41
+ return this.allows(preferred) ? preferred : this.harnesses[0];
42
+ }
43
+ }
@@ -4,12 +4,14 @@ export * from './attachment-delivery.js';
4
4
  export * from './attachment-upload.js';
5
5
  export * from './attachment-validation.js';
6
6
  export * from './bytestring.js';
7
+ export * from './builderHarnessAvailability.js';
7
8
  export * from './configuration.js';
8
9
  export * from './env.js';
9
10
  export * from './environment.js';
10
11
  export * from './git-url.js';
11
12
  export * from './launchDarkly.js';
12
13
  export * from './maskCredential.js';
14
+ export * from './native-attachment-budget.js';
13
15
  export * from './normalize.js';
14
16
  export * from './normalizeRoleName.js';
15
17
  export * from './openApiSpecRef.js';
@@ -4,25 +4,25 @@ import { LocalNativeBuilderFlags } from './localNativeBuilderFlags.js';
4
4
 
5
5
  describe('LocalNativeBuilderFlags', () => {
6
6
  it.each(['localhost', '127.0.0.1', '[::1]', 'slot1.superblocks.local'])('supports the explicit local option on %s', (host) => {
7
- expect(LocalNativeBuilderFlags.forBrowser(true, host).valueFor('ui.ai-harness-picker.enabled')).toBe(true);
8
- expect(LocalNativeBuilderFlags.forBrowser(false, host).valueFor('ui.ai-harness-picker.enabled')).toBeUndefined();
7
+ expect(LocalNativeBuilderFlags.forBrowser(true, host).valueFor('ui.ai-harnesses.available')).toEqual(['clark', 'claude_code', 'codex']);
8
+ expect(LocalNativeBuilderFlags.forBrowser(false, host).valueFor('ui.ai-harnesses.available')).toBeUndefined();
9
9
  });
10
10
 
11
11
  it.each(['app.superblocks.com', 'localhost.example.com', 'superblocks.local.evil.test'])('ignores the local option on %s', (host) => {
12
- expect(LocalNativeBuilderFlags.forBrowser(true, host).valueFor('ui.ai-harness-picker.enabled')).toBeUndefined();
12
+ expect(LocalNativeBuilderFlags.forBrowser(true, host).valueFor('ui.ai-harnesses.available')).toBeUndefined();
13
13
  });
14
14
 
15
15
  it('preserves unrelated values and does not mutate the normal flag set', () => {
16
- const flags = { 'ui.ai-harness-picker.enabled': false, unrelated: { value: ['normal'] } };
16
+ const flags = { 'ui.ai-harnesses.available': ['clark'], unrelated: { value: ['normal'] } };
17
17
  const native = new LocalNativeBuilderFlags(true);
18
18
  expect(native.overlay(flags)).toEqual({
19
19
  ...flags,
20
- 'ui.ai-harness-picker.enabled': true,
20
+ 'ui.ai-harnesses.available': ['clark', 'claude_code', 'codex'],
21
21
  'clark.sdk-api.enabled': true,
22
22
  'superblocks.ai-workspace.agentcore.enabled': true,
23
23
  'ui.homepage-app.mode': 'only-3'
24
24
  });
25
- expect(flags['ui.ai-harness-picker.enabled']).toBe(false);
25
+ expect(flags['ui.ai-harnesses.available']).toEqual(['clark']);
26
26
  expect(native.overlay(flags).unrelated).toBe(flags.unrelated);
27
27
  expect(native.valueFor('superblocks.ai-workspace.agentcore.enabled')).toBe(true);
28
28
  expect(native.valueFor('unrelated')).toBeUndefined();
@@ -31,9 +31,9 @@ describe('LocalNativeBuilderFlags', () => {
31
31
 
32
32
  it('leaves every flag unchanged when disabled', () => {
33
33
  const native = new LocalNativeBuilderFlags(false);
34
- const flags = { 'ui.ai-harness-picker.enabled': false };
34
+ const flags = { 'ui.ai-harnesses.available': ['clark'] };
35
35
  expect(native.overlay(flags)).toBe(flags);
36
36
  expect(native.valueFor('superblocks.ai-workspace.agentcore.enabled')).toBeUndefined();
37
- expect(native.valueFor('ui.ai-harness-picker.enabled')).toBeUndefined();
37
+ expect(native.valueFor('ui.ai-harnesses.available')).toBeUndefined();
38
38
  });
39
39
  });
@@ -1,10 +1,11 @@
1
+ /** Opt-in native harness configuration for local development. */
1
2
  export class LocalNativeBuilderFlags {
2
- private readonly values: Record<string, boolean | string>;
3
+ private readonly values: Record<string, boolean | string | readonly string[]>;
3
4
 
4
5
  constructor(readonly enabled: boolean) {
5
6
  this.values = enabled
6
7
  ? {
7
- 'ui.ai-harness-picker.enabled': true,
8
+ 'ui.ai-harnesses.available': ['clark', 'claude_code', 'codex'],
8
9
  'clark.sdk-api.enabled': true,
9
10
  'superblocks.ai-workspace.agentcore.enabled': true,
10
11
  'ui.homepage-app.mode': 'only-3'
@@ -17,7 +18,7 @@ export class LocalNativeBuilderFlags {
17
18
  return new LocalNativeBuilderFlags(enabled && localHost);
18
19
  }
19
20
 
20
- valueFor(key: string): boolean | string | undefined {
21
+ valueFor(key: string): boolean | string | readonly string[] | undefined {
21
22
  return Object.hasOwn(this.values, key) ? this.values[key] : undefined;
22
23
  }
23
24
 
@@ -0,0 +1,23 @@
1
+ import { expect, it } from 'vitest';
2
+
3
+ import { NativeAttachmentBudget } from './native-attachment-budget.js';
4
+
5
+ it('accepts 20 attachments within 32 MiB and rejects additional files or bytes', () => {
6
+ const budget = new NativeAttachmentBudget(20);
7
+ budget.addBytes(16_777_216);
8
+ budget.addBytes(16_777_216);
9
+ expect(budget.sizeBytes).toBe(33_554_432);
10
+ expect(() => budget.addBytes(1)).toThrow('32 MiB');
11
+ expect(budget.sizeBytes).toBe(33_554_432);
12
+ expect(() => new NativeAttachmentBudget(21)).toThrow('20 attachments');
13
+ process.stdout.write(`NATIVE_ATTACHMENT_BUDGET_OBSERVED ${JSON.stringify({ acceptedBytes: budget.sizeBytes })}\n`);
14
+ });
15
+
16
+ it('bounds recovery independently at 100 historical files and 64 MiB', () => {
17
+ const history = new NativeAttachmentBudget(100, 'recovery');
18
+ history.addBytes(33_554_432);
19
+ history.addBytes(33_554_432);
20
+ expect(history.sizeBytes).toBe(67_108_864);
21
+ expect(() => history.addBytes(1)).toThrow('64 MiB');
22
+ expect(() => new NativeAttachmentBudget(101, 'recovery')).toThrow('100 historical attachments');
23
+ });
@@ -0,0 +1,39 @@
1
+ export class NativeAttachmentBudget {
2
+ static readonly maxFiles = 20;
3
+ static readonly maxBytes = 32 * 1024 * 1024;
4
+ static readonly maxRecoveryFiles = 100;
5
+ static readonly maxRecoveryBytes = 64 * 1024 * 1024;
6
+ /** Files one native chat keeps across all its turns, screenshots included. */
7
+ static readonly maxRetainedFiles = 500;
8
+ /** Bytes one native chat keeps across all its turns. */
9
+ static readonly maxRetainedBytes = 512 * 1024 * 1024;
10
+ private bytes = 0;
11
+
12
+ constructor(
13
+ count: number,
14
+ private readonly scope: 'prompt' | 'recovery' = 'prompt'
15
+ ) {
16
+ const maxFiles = scope === 'recovery' ? NativeAttachmentBudget.maxRecoveryFiles : NativeAttachmentBudget.maxFiles;
17
+ if (!Number.isSafeInteger(count) || count < 0 || count > maxFiles)
18
+ throw new Error(
19
+ scope === 'recovery'
20
+ ? `Native chat can restore up to ${maxFiles} historical attachments.`
21
+ : `Native chat supports up to ${maxFiles} attachments per prompt.`
22
+ );
23
+ }
24
+
25
+ addBytes(bytes: number): void {
26
+ const maxBytes = this.scope === 'recovery' ? NativeAttachmentBudget.maxRecoveryBytes : NativeAttachmentBudget.maxBytes;
27
+ if (!Number.isSafeInteger(bytes) || bytes < 0 || this.bytes + bytes > maxBytes)
28
+ throw new Error(
29
+ this.scope === 'recovery'
30
+ ? 'Native chat can restore up to 64 MiB of historical attachments.'
31
+ : 'Native attachments exceed the 32 MiB prompt limit. Remove files or use smaller images.'
32
+ );
33
+ this.bytes += bytes;
34
+ }
35
+
36
+ get sizeBytes(): number {
37
+ return this.bytes;
38
+ }
39
+ }
@@ -14,7 +14,19 @@ export const PLATFORM_MCP_SERVER_ROUTES = [
14
14
  // Publishing with branching on shares the user's branch to main first, like the editor's Publish.
15
15
  'GET /api/v2/applications/*/branch/status',
16
16
  'POST /api/v2/applications/*/branch/land',
17
+ // The branch tools act on the caller's current branch, as the editor's branch menu does.
18
+ 'POST /api/v2/applications/*/branch/update',
19
+ 'POST /api/v2/applications/*/branch/enable',
20
+ 'POST /api/v2/applications/*/branch/create',
21
+ 'DELETE /api/v2/applications/*/branch/*',
22
+ // Versions of the caller's branch, a compare of two of them, and a restore, as the editor's history does.
23
+ 'GET /api/v2/applications/*/branches/*/commits',
24
+ 'GET /api/v2/applications/*/branches/*/commits/compare',
25
+ 'POST /api/v2/applications/*/branches/*/reset',
17
26
  'POST /api/v2/applications/*/deployments',
27
+ // A rollback checks that the version was live before; the current publish is the app-wide publish state.
28
+ 'GET /api/v2/applications/*/deployments',
29
+ 'GET /api/v2/applications/*/current-publish',
18
30
  'GET /api/v2/applications/*/deploy-status/*',
19
31
  'GET /api/v3/applications/*/connect',
20
32
  'GET /api/v3/applications/*/branches/*/connect',