@opengeni/contracts 2.9.2 → 2.13.0-canary.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 (51) hide show
  1. package/dist/artifacts.d.ts +121 -0
  2. package/dist/atlassian.js +11 -11
  3. package/dist/{chunk-4IVHBXRI.js → chunk-7ABONTXE.js} +42 -2
  4. package/dist/chunk-7ABONTXE.js.map +1 -0
  5. package/dist/{chunk-7RMTKFJW.js → chunk-7Q6HPDY2.js} +8 -8
  6. package/dist/{chunk-AWNGBY5I.js → chunk-DPCCW6U7.js} +7395 -6619
  7. package/dist/chunk-DPCCW6U7.js.map +1 -0
  8. package/dist/{chunk-N6GRVXAJ.js → chunk-NPBM4QSK.js} +2 -2
  9. package/dist/connection-authority.js +11 -11
  10. package/dist/editable-artifact-codec-registry.js +2 -2
  11. package/dist/editable-artifact-live.js +2 -2
  12. package/dist/editable-artifact-serialized-commit.js +3 -3
  13. package/dist/editable-artifacts.js +13 -13
  14. package/dist/github-repository-contracts.d.ts +36 -0
  15. package/dist/github-repository-contracts.js +59 -0
  16. package/dist/github-repository-contracts.js.map +1 -0
  17. package/dist/github-repository.d.ts +14 -0
  18. package/dist/github-repository.js +36 -0
  19. package/dist/github-repository.js.map +1 -0
  20. package/dist/google-drive.js +12 -12
  21. package/dist/index.d.ts +809 -70
  22. package/dist/index.js +299 -135
  23. package/dist/mcp-oauth.d.ts +71 -0
  24. package/dist/model-context-inspector.d.ts +205 -0
  25. package/dist/model-picker-order.d.ts +23 -0
  26. package/dist/model-picker-order.js +42 -0
  27. package/dist/model-picker-order.js.map +1 -0
  28. package/dist/organization-membership-lifecycle.d.ts +17 -0
  29. package/dist/personal-github.js +11 -11
  30. package/dist/session-mcp-projections.d.ts +210 -0
  31. package/dist/session-titles.d.ts +35 -0
  32. package/dist/session-titles.js +9 -3
  33. package/dist/tool-catalog.d.ts +271 -0
  34. package/dist/workspace-learning-policy.d.ts +1 -1
  35. package/package.json +13 -1
  36. package/src/artifacts.ts +111 -1
  37. package/src/github-repository-contracts.ts +85 -0
  38. package/src/github-repository.ts +59 -0
  39. package/src/index.ts +486 -52
  40. package/src/mcp-oauth.ts +68 -0
  41. package/src/model-context-inspector.ts +104 -0
  42. package/src/model-picker-order.ts +87 -0
  43. package/src/organization-membership-lifecycle.ts +20 -0
  44. package/src/session-mcp-projections.ts +268 -0
  45. package/src/session-titles.ts +100 -0
  46. package/src/tool-catalog.ts +136 -0
  47. package/src/workspace-learning-policy.ts +4 -3
  48. package/dist/chunk-4IVHBXRI.js.map +0 -1
  49. package/dist/chunk-AWNGBY5I.js.map +0 -1
  50. /package/dist/{chunk-7RMTKFJW.js.map → chunk-7Q6HPDY2.js.map} +0 -0
  51. /package/dist/{chunk-N6GRVXAJ.js.map → chunk-NPBM4QSK.js.map} +0 -0
@@ -4,14 +4,20 @@ import {
4
4
  SESSION_TITLE_MAX_CHARACTERS,
5
5
  boundAutomaticSessionTitle,
6
6
  containsSensitiveAutomaticSessionTitleValue,
7
- normalizeAutomaticSessionTitle
8
- } from "./chunk-4IVHBXRI.js";
7
+ deriveAutomaticSessionTitlePreview,
8
+ deriveSessionDisplayTitle,
9
+ normalizeAutomaticSessionTitle,
10
+ sessionTitleIsPending
11
+ } from "./chunk-7ABONTXE.js";
9
12
  export {
10
13
  AUTOMATIC_SESSION_TITLE_FALLBACK,
11
14
  AUTOMATIC_SESSION_TITLE_MAX_GRAPHEMES,
12
15
  SESSION_TITLE_MAX_CHARACTERS,
13
16
  boundAutomaticSessionTitle,
14
17
  containsSensitiveAutomaticSessionTitleValue,
15
- normalizeAutomaticSessionTitle
18
+ deriveAutomaticSessionTitlePreview,
19
+ deriveSessionDisplayTitle,
20
+ normalizeAutomaticSessionTitle,
21
+ sessionTitleIsPending
16
22
  };
17
23
  //# sourceMappingURL=session-titles.js.map
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  export declare const ATTEMPT_TOOL_CATALOG_VERSION: 1;
3
+ export declare const TOOL_GATEWAY_CATALOG_VERSION: 1;
3
4
  export declare const ATTEMPT_TOOL_CATALOG_MAX_ENTRIES = 4096;
4
5
  export declare const ATTEMPT_TOOL_CATALOG_MAX_BYTES: number;
5
6
  export declare const ATTEMPT_TOOL_CATALOG_MAX_PATH_SEGMENTS = 8;
@@ -17,6 +18,12 @@ export declare const AttemptToolIdentity: z.ZodObject<{
17
18
  toolName: z.ZodString;
18
19
  }, z.core.$strict>;
19
20
  export type AttemptToolIdentity = z.infer<typeof AttemptToolIdentity>;
21
+ /** Protocol-neutral tool identity shared by MCP, HTTP/SDK, agents, and Codemode. */
22
+ export declare const ToolGatewayIdentity: z.ZodObject<{
23
+ serverId: z.ZodString;
24
+ toolName: z.ZodString;
25
+ }, z.core.$strict>;
26
+ export type ToolGatewayIdentity = AttemptToolIdentity;
20
27
  export declare const AttemptToolCatalogIcon: z.ZodObject<{
21
28
  src: z.ZodString;
22
29
  mimeType: z.ZodOptional<z.ZodString>;
@@ -81,6 +88,110 @@ export declare const AttemptToolCatalogEntry: z.ZodObject<{
81
88
  }>;
82
89
  }, z.core.$strict>;
83
90
  export type AttemptToolCatalogEntry = z.infer<typeof AttemptToolCatalogEntry>;
91
+ /** One canonical gateway entry. Adapter-specific names are projections, never authority. */
92
+ export declare const ToolGatewayCatalogEntry: z.ZodObject<{
93
+ identity: z.ZodObject<{
94
+ serverId: z.ZodString;
95
+ toolName: z.ZodString;
96
+ }, z.core.$strict>;
97
+ modelName: z.ZodString;
98
+ codemodePath: z.ZodArray<z.ZodString>;
99
+ title: z.ZodOptional<z.ZodString>;
100
+ description: z.ZodOptional<z.ZodString>;
101
+ inputSchema: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
102
+ outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
103
+ annotations: z.ZodOptional<z.ZodObject<{
104
+ title: z.ZodOptional<z.ZodString>;
105
+ readOnlyHint: z.ZodOptional<z.ZodBoolean>;
106
+ destructiveHint: z.ZodOptional<z.ZodBoolean>;
107
+ idempotentHint: z.ZodOptional<z.ZodBoolean>;
108
+ openWorldHint: z.ZodOptional<z.ZodBoolean>;
109
+ }, z.core.$loose>>;
110
+ icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
111
+ src: z.ZodString;
112
+ mimeType: z.ZodOptional<z.ZodString>;
113
+ sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
114
+ theme: z.ZodOptional<z.ZodEnum<{
115
+ dark: "dark";
116
+ light: "light";
117
+ }>>;
118
+ }, z.core.$strict>>>;
119
+ source: z.ZodEnum<{
120
+ codex_apps: "codex_apps";
121
+ docs: "docs";
122
+ files: "files";
123
+ interaction: "interaction";
124
+ mcp: "mcp";
125
+ opengeni: "opengeni";
126
+ }>;
127
+ approval: z.ZodEnum<{
128
+ human: "human";
129
+ none: "none";
130
+ policy: "policy";
131
+ }>;
132
+ }, z.core.$strict>;
133
+ export type ToolGatewayCatalogEntry = AttemptToolCatalogEntry;
134
+ export declare const ToolGatewayCatalog: z.ZodObject<{
135
+ version: z.ZodLiteral<1>;
136
+ accountId: z.ZodString;
137
+ workspaceId: z.ZodString;
138
+ generation: z.ZodNumber;
139
+ digest: z.ZodString;
140
+ createdAt: z.ZodString;
141
+ entries: z.ZodArray<z.ZodObject<{
142
+ identity: z.ZodObject<{
143
+ serverId: z.ZodString;
144
+ toolName: z.ZodString;
145
+ }, z.core.$strict>;
146
+ modelName: z.ZodString;
147
+ codemodePath: z.ZodArray<z.ZodString>;
148
+ title: z.ZodOptional<z.ZodString>;
149
+ description: z.ZodOptional<z.ZodString>;
150
+ inputSchema: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
151
+ outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
152
+ annotations: z.ZodOptional<z.ZodObject<{
153
+ title: z.ZodOptional<z.ZodString>;
154
+ readOnlyHint: z.ZodOptional<z.ZodBoolean>;
155
+ destructiveHint: z.ZodOptional<z.ZodBoolean>;
156
+ idempotentHint: z.ZodOptional<z.ZodBoolean>;
157
+ openWorldHint: z.ZodOptional<z.ZodBoolean>;
158
+ }, z.core.$loose>>;
159
+ icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
160
+ src: z.ZodString;
161
+ mimeType: z.ZodOptional<z.ZodString>;
162
+ sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
163
+ theme: z.ZodOptional<z.ZodEnum<{
164
+ dark: "dark";
165
+ light: "light";
166
+ }>>;
167
+ }, z.core.$strict>>>;
168
+ source: z.ZodEnum<{
169
+ codex_apps: "codex_apps";
170
+ docs: "docs";
171
+ files: "files";
172
+ interaction: "interaction";
173
+ mcp: "mcp";
174
+ opengeni: "opengeni";
175
+ }>;
176
+ approval: z.ZodEnum<{
177
+ human: "human";
178
+ none: "none";
179
+ policy: "policy";
180
+ }>;
181
+ }, z.core.$strict>>;
182
+ }, z.core.$strict>;
183
+ export type ToolGatewayCatalog = z.infer<typeof ToolGatewayCatalog>;
184
+ export declare const ToolGatewayCaller: z.ZodObject<{
185
+ kind: z.ZodEnum<{
186
+ browser: "browser";
187
+ codemode: "codemode";
188
+ http: "http";
189
+ mcp: "mcp";
190
+ model: "model";
191
+ }>;
192
+ subjectId: z.ZodString;
193
+ }, z.core.$strict>;
194
+ export type ToolGatewayCaller = z.infer<typeof ToolGatewayCaller>;
84
195
  export declare const AttemptToolCatalog: z.ZodObject<{
85
196
  version: z.ZodLiteral<1>;
86
197
  accountId: z.ZodString;
@@ -328,6 +439,166 @@ export declare const AttemptToolResult: z.ZodObject<{
328
439
  _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
329
440
  }, z.core.$loose>;
330
441
  export type AttemptToolResult = z.infer<typeof AttemptToolResult>;
442
+ export declare const ToolGatewayResult: z.ZodObject<{
443
+ content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
444
+ type: z.ZodLiteral<"text">;
445
+ text: z.ZodString;
446
+ annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
447
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
448
+ }, z.core.$loose>, z.ZodObject<{
449
+ type: z.ZodLiteral<"image">;
450
+ data: z.ZodString;
451
+ mimeType: z.ZodString;
452
+ annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
453
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
454
+ }, z.core.$loose>, z.ZodObject<{
455
+ type: z.ZodLiteral<"audio">;
456
+ data: z.ZodString;
457
+ mimeType: z.ZodString;
458
+ annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
459
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
460
+ }, z.core.$loose>, z.ZodObject<{
461
+ type: z.ZodLiteral<"resource_link">;
462
+ name: z.ZodString;
463
+ title: z.ZodOptional<z.ZodString>;
464
+ uri: z.ZodString;
465
+ description: z.ZodOptional<z.ZodString>;
466
+ mimeType: z.ZodOptional<z.ZodString>;
467
+ size: z.ZodOptional<z.ZodNumber>;
468
+ icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
469
+ src: z.ZodString;
470
+ mimeType: z.ZodOptional<z.ZodString>;
471
+ sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
472
+ theme: z.ZodOptional<z.ZodEnum<{
473
+ dark: "dark";
474
+ light: "light";
475
+ }>>;
476
+ }, z.core.$strict>>>;
477
+ annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
478
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
479
+ }, z.core.$loose>, z.ZodObject<{
480
+ type: z.ZodLiteral<"resource">;
481
+ resource: z.ZodUnion<readonly [z.ZodObject<{
482
+ uri: z.ZodString;
483
+ mimeType: z.ZodOptional<z.ZodString>;
484
+ text: z.ZodString;
485
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
486
+ }, z.core.$loose>, z.ZodObject<{
487
+ uri: z.ZodString;
488
+ mimeType: z.ZodOptional<z.ZodString>;
489
+ blob: z.ZodString;
490
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
491
+ }, z.core.$loose>]>;
492
+ annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
493
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
494
+ }, z.core.$loose>], "type">>;
495
+ structuredContent: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
496
+ isError: z.ZodOptional<z.ZodBoolean>;
497
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
498
+ }, z.core.$loose>;
499
+ export type ToolGatewayResult = AttemptToolResult;
500
+ export declare const ToolGatewayCallRequest: z.ZodObject<{
501
+ operationId: z.ZodOptional<z.ZodString>;
502
+ catalogDigest: z.ZodString;
503
+ identity: z.ZodObject<{
504
+ serverId: z.ZodString;
505
+ toolName: z.ZodString;
506
+ }, z.core.$strict>;
507
+ arguments: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
508
+ siteArtifactId: z.ZodOptional<z.ZodString>;
509
+ siteVersionId: z.ZodOptional<z.ZodString>;
510
+ approvalToken: z.ZodOptional<z.ZodString>;
511
+ }, z.core.$strict>;
512
+ export type ToolGatewayCallRequest = z.infer<typeof ToolGatewayCallRequest>;
513
+ export declare const ToolGatewayApprovalRequest: z.ZodObject<{
514
+ operationId: z.ZodString;
515
+ catalogDigest: z.ZodString;
516
+ identity: z.ZodObject<{
517
+ serverId: z.ZodString;
518
+ toolName: z.ZodString;
519
+ }, z.core.$strict>;
520
+ arguments: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
521
+ }, z.core.$strict>;
522
+ export type ToolGatewayApprovalRequest = z.infer<typeof ToolGatewayApprovalRequest>;
523
+ export declare const ToolGatewayApprovalResponse: z.ZodObject<{
524
+ operationId: z.ZodString;
525
+ catalogDigest: z.ZodString;
526
+ identity: z.ZodObject<{
527
+ serverId: z.ZodString;
528
+ toolName: z.ZodString;
529
+ }, z.core.$strict>;
530
+ approvalToken: z.ZodString;
531
+ expiresAt: z.ZodString;
532
+ }, z.core.$strict>;
533
+ export type ToolGatewayApprovalResponse = z.infer<typeof ToolGatewayApprovalResponse>;
534
+ export declare const ToolGatewayCallResponse: z.ZodObject<{
535
+ operationId: z.ZodString;
536
+ catalogDigest: z.ZodString;
537
+ result: z.ZodObject<{
538
+ content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
539
+ type: z.ZodLiteral<"text">;
540
+ text: z.ZodString;
541
+ annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
542
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
543
+ }, z.core.$loose>, z.ZodObject<{
544
+ type: z.ZodLiteral<"image">;
545
+ data: z.ZodString;
546
+ mimeType: z.ZodString;
547
+ annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
548
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
549
+ }, z.core.$loose>, z.ZodObject<{
550
+ type: z.ZodLiteral<"audio">;
551
+ data: z.ZodString;
552
+ mimeType: z.ZodString;
553
+ annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
554
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
555
+ }, z.core.$loose>, z.ZodObject<{
556
+ type: z.ZodLiteral<"resource_link">;
557
+ name: z.ZodString;
558
+ title: z.ZodOptional<z.ZodString>;
559
+ uri: z.ZodString;
560
+ description: z.ZodOptional<z.ZodString>;
561
+ mimeType: z.ZodOptional<z.ZodString>;
562
+ size: z.ZodOptional<z.ZodNumber>;
563
+ icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
564
+ src: z.ZodString;
565
+ mimeType: z.ZodOptional<z.ZodString>;
566
+ sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
567
+ theme: z.ZodOptional<z.ZodEnum<{
568
+ dark: "dark";
569
+ light: "light";
570
+ }>>;
571
+ }, z.core.$strict>>>;
572
+ annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
573
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
574
+ }, z.core.$loose>, z.ZodObject<{
575
+ type: z.ZodLiteral<"resource">;
576
+ resource: z.ZodUnion<readonly [z.ZodObject<{
577
+ uri: z.ZodString;
578
+ mimeType: z.ZodOptional<z.ZodString>;
579
+ text: z.ZodString;
580
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
581
+ }, z.core.$loose>, z.ZodObject<{
582
+ uri: z.ZodString;
583
+ mimeType: z.ZodOptional<z.ZodString>;
584
+ blob: z.ZodString;
585
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
586
+ }, z.core.$loose>]>;
587
+ annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
588
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
589
+ }, z.core.$loose>], "type">>;
590
+ structuredContent: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
591
+ isError: z.ZodOptional<z.ZodBoolean>;
592
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
593
+ }, z.core.$loose>;
594
+ }, z.core.$strict>;
595
+ export type ToolGatewayCallResponse = z.infer<typeof ToolGatewayCallResponse>;
596
+ export declare const ToolGatewayDeclarationsResponse: z.ZodObject<{
597
+ catalogDigest: z.ZodString;
598
+ moduleSpecifier: z.ZodString;
599
+ source: z.ZodString;
600
+ }, z.core.$strict>;
601
+ export type ToolGatewayDeclarationsResponse = z.infer<typeof ToolGatewayDeclarationsResponse>;
331
602
  export declare const CodemodeOperationState: z.ZodEnum<{
332
603
  cancelled: "cancelled";
333
604
  completed: "completed";
@@ -3,7 +3,7 @@ export declare const WORKSPACE_LEARNING_POLICY_MAX_SOURCE_OVERRIDES = 256;
3
3
  export declare const WORKSPACE_LEARNING_POLICY_SOURCE_KIND_MAX_CHARS = 96;
4
4
  export declare const WORKSPACE_LEARNING_POLICY_SOURCE_ID_MAX_CHARS = 1024;
5
5
  export declare const WORKSPACE_LEARNING_POLICY_REASON_MAX_CHARS = 4096;
6
- export declare const WORKSPACE_LEARNING_POLICY_DEFAULT_OFF_REVISION_ID = "workspace-learning-policy:default-off:v1";
6
+ export declare const WORKSPACE_LEARNING_POLICY_DEFAULT_SUGGEST_REVISION_ID = "workspace-learning-policy:default-suggest:v1";
7
7
  export declare const WorkspaceLearningMode: z.ZodEnum<{
8
8
  automatic: "automatic";
9
9
  off: "off";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/contracts",
3
- "version": "2.9.2",
3
+ "version": "2.13.0-canary.0",
4
4
  "description": "Shared zod schemas and wire-contract types for the OpenGeni API.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -34,6 +34,14 @@
34
34
  "types": "./dist/personal-github.d.ts",
35
35
  "import": "./dist/personal-github.js"
36
36
  },
37
+ "./github-repository": {
38
+ "types": "./dist/github-repository.d.ts",
39
+ "import": "./dist/github-repository.js"
40
+ },
41
+ "./github-repository-contracts": {
42
+ "types": "./dist/github-repository-contracts.d.ts",
43
+ "import": "./dist/github-repository-contracts.js"
44
+ },
37
45
  "./atlassian": {
38
46
  "types": "./dist/atlassian.d.ts",
39
47
  "import": "./dist/atlassian.js"
@@ -78,6 +86,10 @@
78
86
  "types": "./dist/xai-provider-account-authority.d.ts",
79
87
  "import": "./dist/xai-provider-account-authority.js"
80
88
  },
89
+ "./model-picker-order": {
90
+ "types": "./dist/model-picker-order.d.ts",
91
+ "import": "./dist/model-picker-order.js"
92
+ },
81
93
  "./editable-artifacts": {
82
94
  "types": "./dist/editable-artifacts.d.ts",
83
95
  "import": "./dist/editable-artifacts.js"
package/src/artifacts.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import { z } from "zod";
2
+ import { ToolGatewayIdentity } from "./tool-catalog";
2
3
 
3
4
  export const WORKSPACE_ARTIFACT_HTML_MAX_UTF8_BYTES = 4 * 1024 * 1024;
5
+ export const WORKSPACE_ARTIFACT_SOURCE_MAX_UTF8_BYTES = 4 * 1024 * 1024;
6
+ export const WORKSPACE_ARTIFACT_SOURCE_MAX_FILES = 128;
7
+ export const WORKSPACE_ARTIFACT_REQUESTED_TOOLS_MAX = 128;
4
8
  export const WORKSPACE_ARTIFACT_TITLE_MAX_CHARS = 120;
5
9
  export const WORKSPACE_ARTIFACT_DESCRIPTION_MAX_CHARS = 2_000;
6
10
  export const WORKSPACE_ARTIFACT_LIST_MAX = 100;
@@ -21,6 +25,84 @@ export type WorkspaceArtifactSlug = z.infer<typeof WorkspaceArtifactSlug>;
21
25
  export const WorkspaceArtifactStatus = z.enum(["active", "archived"]);
22
26
  export type WorkspaceArtifactStatus = z.infer<typeof WorkspaceArtifactStatus>;
23
27
 
28
+ export const WorkspaceArtifactSourcePath = z
29
+ .string()
30
+ .min(1)
31
+ .max(256)
32
+ .regex(/^[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/u)
33
+ .refine(
34
+ (value) =>
35
+ !value
36
+ .split("/")
37
+ .some((segment) => segment === "." || segment === ".." || segment.length === 0),
38
+ { message: "artifact source paths must be relative and traversal-free" },
39
+ );
40
+ export type WorkspaceArtifactSourcePath = z.infer<typeof WorkspaceArtifactSourcePath>;
41
+
42
+ export const WorkspaceArtifactSourceFile = z
43
+ .object({
44
+ path: WorkspaceArtifactSourcePath,
45
+ content: z.string(),
46
+ })
47
+ .strict();
48
+ export type WorkspaceArtifactSourceFile = z.infer<typeof WorkspaceArtifactSourceFile>;
49
+
50
+ /** Retained editable source; the published runtime remains one exact HTML document. */
51
+ export const WorkspaceArtifactSourceBundle = z
52
+ .object({
53
+ entrypoint: WorkspaceArtifactSourcePath,
54
+ files: z.array(WorkspaceArtifactSourceFile).min(1).max(WORKSPACE_ARTIFACT_SOURCE_MAX_FILES),
55
+ })
56
+ .strict()
57
+ .superRefine((value, context) => {
58
+ const paths = new Set<string>();
59
+ for (const [index, file] of value.files.entries()) {
60
+ if (paths.has(file.path)) {
61
+ context.addIssue({
62
+ code: "custom",
63
+ path: ["files", index, "path"],
64
+ message: "artifact source file paths must be unique",
65
+ });
66
+ }
67
+ paths.add(file.path);
68
+ }
69
+ if (!paths.has(value.entrypoint)) {
70
+ context.addIssue({
71
+ code: "custom",
72
+ path: ["entrypoint"],
73
+ message: "artifact source entrypoint must name one retained file",
74
+ });
75
+ }
76
+ if (
77
+ encoder.encode(JSON.stringify(value)).byteLength > WORKSPACE_ARTIFACT_SOURCE_MAX_UTF8_BYTES
78
+ ) {
79
+ context.addIssue({
80
+ code: "custom",
81
+ message: `artifact source exceeds ${WORKSPACE_ARTIFACT_SOURCE_MAX_UTF8_BYTES} UTF-8 bytes`,
82
+ });
83
+ }
84
+ });
85
+ export type WorkspaceArtifactSourceBundle = z.infer<typeof WorkspaceArtifactSourceBundle>;
86
+
87
+ export const WorkspaceArtifactRequestedTools = z
88
+ .array(ToolGatewayIdentity)
89
+ .max(WORKSPACE_ARTIFACT_REQUESTED_TOOLS_MAX)
90
+ .superRefine((tools, context) => {
91
+ const seen = new Set<string>();
92
+ for (const [index, identity] of tools.entries()) {
93
+ const key = `${identity.serverId}\u0000${identity.toolName}`;
94
+ if (seen.has(key)) {
95
+ context.addIssue({
96
+ code: "custom",
97
+ path: [index],
98
+ message: "requested artifact tools must be unique",
99
+ });
100
+ }
101
+ seen.add(key);
102
+ }
103
+ });
104
+ export type WorkspaceArtifactRequestedTools = z.infer<typeof WorkspaceArtifactRequestedTools>;
105
+
24
106
  export const WorkspaceArtifactVersion = z.object({
25
107
  id: z.string().uuid(),
26
108
  accountId: z.string().uuid(),
@@ -30,6 +112,14 @@ export const WorkspaceArtifactVersion = z.object({
30
112
  contentType: z.literal("text/html"),
31
113
  contentSha256: sha256,
32
114
  sizeBytes: z.number().int().positive().max(WORKSPACE_ARTIFACT_HTML_MAX_UTF8_BYTES),
115
+ sourceSha256: sha256.nullable(),
116
+ sourceSizeBytes: z
117
+ .number()
118
+ .int()
119
+ .positive()
120
+ .max(WORKSPACE_ARTIFACT_SOURCE_MAX_UTF8_BYTES)
121
+ .nullable(),
122
+ requestedTools: WorkspaceArtifactRequestedTools,
33
123
  sourceSessionId: z.string().uuid().nullable(),
34
124
  sourceTurnId: z.string().uuid().nullable(),
35
125
  sourceAttemptId: z.string().uuid().nullable(),
@@ -54,7 +144,12 @@ export const WorkspaceArtifact = z.object({
54
144
  });
55
145
  export type WorkspaceArtifact = z.infer<typeof WorkspaceArtifact>;
56
146
 
57
- export const WorkspaceArtifactEventType = z.enum(["published", "rolled_back"]);
147
+ export const WorkspaceArtifactEventType = z.enum([
148
+ "published",
149
+ "rolled_back",
150
+ "archived",
151
+ "restored",
152
+ ]);
58
153
  export type WorkspaceArtifactEventType = z.infer<typeof WorkspaceArtifactEventType>;
59
154
 
60
155
  export const WorkspaceArtifactEvent = z.object({
@@ -83,6 +178,7 @@ export const WorkspaceArtifactListQuery = z.object({
83
178
  .max(WORKSPACE_ARTIFACT_LIST_MAX)
84
179
  .default(WORKSPACE_ARTIFACT_LIST_DEFAULT),
85
180
  cursor: z.string().min(1).max(WORKSPACE_ARTIFACT_CURSOR_MAX_CHARS).optional(),
181
+ status: WorkspaceArtifactStatus.optional(),
86
182
  });
87
183
  export type WorkspaceArtifactListQuery = z.infer<typeof WorkspaceArtifactListQuery>;
88
184
 
@@ -120,6 +216,8 @@ export const CreateWorkspaceArtifactRequest = z.object({
120
216
  title: z.string().trim().min(1).max(WORKSPACE_ARTIFACT_TITLE_MAX_CHARS),
121
217
  description: z.string().max(WORKSPACE_ARTIFACT_DESCRIPTION_MAX_CHARS).nullable().optional(),
122
218
  html: WorkspaceArtifactHtml,
219
+ source: WorkspaceArtifactSourceBundle.optional(),
220
+ requestedTools: WorkspaceArtifactRequestedTools.optional(),
123
221
  idempotencyKey: z.string().trim().min(1).max(200),
124
222
  });
125
223
  export type CreateWorkspaceArtifactRequest = z.infer<typeof CreateWorkspaceArtifactRequest>;
@@ -128,6 +226,8 @@ export const PublishWorkspaceArtifactVersionRequest = z.object({
128
226
  title: z.string().trim().min(1).max(WORKSPACE_ARTIFACT_TITLE_MAX_CHARS).optional(),
129
227
  description: z.string().max(WORKSPACE_ARTIFACT_DESCRIPTION_MAX_CHARS).nullable().optional(),
130
228
  html: WorkspaceArtifactHtml,
229
+ source: WorkspaceArtifactSourceBundle.optional(),
230
+ requestedTools: WorkspaceArtifactRequestedTools.optional(),
131
231
  expectedCurrentVersionId: z.string().uuid(),
132
232
  idempotencyKey: z.string().trim().min(1).max(200),
133
233
  });
@@ -143,6 +243,14 @@ export const RollbackWorkspaceArtifactRequest = z.object({
143
243
  });
144
244
  export type RollbackWorkspaceArtifactRequest = z.infer<typeof RollbackWorkspaceArtifactRequest>;
145
245
 
246
+ export const SetWorkspaceArtifactStatusRequest = z.object({
247
+ status: WorkspaceArtifactStatus,
248
+ expectedCurrentVersionId: z.string().uuid(),
249
+ reason: z.string().trim().min(1).max(4096),
250
+ idempotencyKey: z.string().trim().min(1).max(200),
251
+ });
252
+ export type SetWorkspaceArtifactStatusRequest = z.infer<typeof SetWorkspaceArtifactStatusRequest>;
253
+
146
254
  export const WorkspaceArtifactMutationResponse = z.object({
147
255
  artifact: WorkspaceArtifact,
148
256
  version: WorkspaceArtifactVersion,
@@ -157,6 +265,8 @@ export const WorkspaceArtifactContentResponse = z.object({
157
265
  contentType: z.literal("text/html"),
158
266
  contentSha256: sha256,
159
267
  html: WorkspaceArtifactHtml,
268
+ source: WorkspaceArtifactSourceBundle,
269
+ requestedTools: WorkspaceArtifactRequestedTools,
160
270
  });
161
271
  export type WorkspaceArtifactContentResponse = z.infer<typeof WorkspaceArtifactContentResponse>;
162
272
 
@@ -0,0 +1,85 @@
1
+ import { z } from "zod";
2
+
3
+ export const VerifyPublicGitHubRepositoryRefRequest = z
4
+ .object({
5
+ url: z.string().min(1).max(2048),
6
+ ref: z
7
+ .string()
8
+ .trim()
9
+ .min(1)
10
+ .max(1024)
11
+ .refine((value) => !/[\u0000-\u001f\u007f]/u.test(value), "ref contains control characters"),
12
+ })
13
+ .strict();
14
+ export type VerifyPublicGitHubRepositoryRefRequest = z.infer<
15
+ typeof VerifyPublicGitHubRepositoryRefRequest
16
+ >;
17
+
18
+ export const VerifyPublicGitHubRepositoryRefResponse = z
19
+ .object({
20
+ owner: z.string().min(1).max(39),
21
+ name: z.string().min(1).max(100),
22
+ fullName: z.string().min(3).max(140),
23
+ canonicalUrl: z.string().url(),
24
+ cloneUrl: z.string().url(),
25
+ defaultBranch: z.string().min(1).max(1024),
26
+ ref: z.string().min(1).max(1024),
27
+ commitSha: z.string().regex(/^[0-9a-f]{40}$/u),
28
+ })
29
+ .strict();
30
+ export type VerifyPublicGitHubRepositoryRefResponse = z.infer<
31
+ typeof VerifyPublicGitHubRepositoryRefResponse
32
+ >;
33
+
34
+ export const GITHUB_REPOSITORY_BRANCH_PAGE_MAX = 100 as const;
35
+
36
+ export const ListGitHubRepositoryBranchesQuery = z
37
+ .object({
38
+ cursor: z.coerce.number().int().positive().max(10_000).default(1),
39
+ limit: z.coerce
40
+ .number()
41
+ .int()
42
+ .min(1)
43
+ .max(GITHUB_REPOSITORY_BRANCH_PAGE_MAX)
44
+ .default(GITHUB_REPOSITORY_BRANCH_PAGE_MAX),
45
+ })
46
+ .strict();
47
+ export type ListGitHubRepositoryBranchesQuery = z.infer<typeof ListGitHubRepositoryBranchesQuery>;
48
+
49
+ export const GitHubRepositoryBranch = z
50
+ .object({
51
+ name: z.string().min(1).max(1024),
52
+ isDefault: z.boolean(),
53
+ })
54
+ .strict();
55
+ export type GitHubRepositoryBranch = z.infer<typeof GitHubRepositoryBranch>;
56
+
57
+ export const GitHubRepositoryBranchesResponse = z
58
+ .object({
59
+ branches: z.array(GitHubRepositoryBranch).max(GITHUB_REPOSITORY_BRANCH_PAGE_MAX),
60
+ nextCursor: z.number().int().positive().max(10_000).nullable(),
61
+ })
62
+ .strict()
63
+ .superRefine((response, context) => {
64
+ const names = new Set<string>();
65
+ let defaultCount = 0;
66
+ response.branches.forEach((branch, index) => {
67
+ if (names.has(branch.name)) {
68
+ context.addIssue({
69
+ code: "custom",
70
+ path: ["branches", index, "name"],
71
+ message: "branch names must be unique",
72
+ });
73
+ }
74
+ names.add(branch.name);
75
+ if (branch.isDefault) defaultCount += 1;
76
+ });
77
+ if (defaultCount > 1) {
78
+ context.addIssue({
79
+ code: "custom",
80
+ path: ["branches"],
81
+ message: "at most one branch may be marked as default",
82
+ });
83
+ }
84
+ });
85
+ export type GitHubRepositoryBranchesResponse = z.infer<typeof GitHubRepositoryBranchesResponse>;
@@ -0,0 +1,59 @@
1
+ export type CanonicalGitHubRepository = {
2
+ owner: string;
3
+ name: string;
4
+ fullName: string;
5
+ canonicalUrl: string;
6
+ cloneUrl: string;
7
+ };
8
+
9
+ /**
10
+ * Parse only a canonical public github.com repository URL. This deliberately
11
+ * rejects aliases, credentials, ports, query/fragment state, encoded paths,
12
+ * and repository subpaths so callers cannot accidentally verify one target
13
+ * and attach another.
14
+ */
15
+ export function parseCanonicalGitHubRepositoryUrl(value: string): CanonicalGitHubRepository {
16
+ if (!value.startsWith("https://github.com/")) {
17
+ throw new Error("GitHub repository URL must use the exact https://github.com host.");
18
+ }
19
+ let url: URL;
20
+ try {
21
+ url = new URL(value);
22
+ } catch {
23
+ throw new TypeError("GitHub repository URL is invalid.");
24
+ }
25
+ if (
26
+ url.protocol !== "https:" ||
27
+ url.hostname !== "github.com" ||
28
+ url.host !== "github.com" ||
29
+ url.username ||
30
+ url.password ||
31
+ url.search ||
32
+ url.hash ||
33
+ url.pathname.includes("%")
34
+ ) {
35
+ throw new TypeError("Use a canonical https://github.com/owner/repository URL.");
36
+ }
37
+ const match = /^\/([^/]+)\/([^/]+?)\/?$/u.exec(url.pathname);
38
+ if (!match) {
39
+ throw new TypeError("GitHub repository URL must contain exactly owner/repository.");
40
+ }
41
+ const owner = match[1]!;
42
+ const name = match[2]!.replace(/\.git$/iu, "");
43
+ if (
44
+ !/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u.test(owner) ||
45
+ !/^[A-Za-z0-9_.-]{1,100}$/u.test(name) ||
46
+ name === "." ||
47
+ name === ".."
48
+ ) {
49
+ throw new TypeError("GitHub repository owner or name is invalid.");
50
+ }
51
+ const fullName = `${owner}/${name}`;
52
+ return {
53
+ owner,
54
+ name,
55
+ fullName,
56
+ canonicalUrl: `https://github.com/${fullName}`,
57
+ cloneUrl: `https://github.com/${fullName}.git`,
58
+ };
59
+ }