@vertesia/common 1.5.0 → 1.6.0-dev.20260918.061604Z

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 (179) hide show
  1. package/lib/access-control-values.d.ts +13 -0
  2. package/lib/access-control-values.d.ts.map +1 -1
  3. package/lib/access-control-values.js +24 -0
  4. package/lib/access-control-values.js.map +1 -1
  5. package/lib/api-contract/components.generated.json +4446 -2194
  6. package/lib/api-schemas/account.d.ts +3 -10
  7. package/lib/api-schemas/account.d.ts.map +1 -1
  8. package/lib/api-schemas/account.js +5 -9
  9. package/lib/api-schemas/account.js.map +1 -1
  10. package/lib/api-schemas/adapter.d.ts.map +1 -1
  11. package/lib/api-schemas/adapter.js +8 -1
  12. package/lib/api-schemas/adapter.js.map +1 -1
  13. package/lib/api-schemas/agent-communication.d.ts +1 -0
  14. package/lib/api-schemas/agent-communication.d.ts.map +1 -1
  15. package/lib/api-schemas/agent-communication.js +6 -0
  16. package/lib/api-schemas/agent-communication.js.map +1 -1
  17. package/lib/api-schemas/agent-runs.d.ts +5286 -903
  18. package/lib/api-schemas/agent-runs.d.ts.map +1 -1
  19. package/lib/api-schemas/agent-runs.js +366 -1
  20. package/lib/api-schemas/agent-runs.js.map +1 -1
  21. package/lib/api-schemas/apikey.d.ts +55 -0
  22. package/lib/api-schemas/apikey.d.ts.map +1 -1
  23. package/lib/api-schemas/apikey.js +30 -0
  24. package/lib/api-schemas/apikey.js.map +1 -1
  25. package/lib/api-schemas/app-runtime.d.ts +1240 -22
  26. package/lib/api-schemas/app-runtime.d.ts.map +1 -1
  27. package/lib/api-schemas/content.d.ts +435 -0
  28. package/lib/api-schemas/content.d.ts.map +1 -1
  29. package/lib/api-schemas/delegation.d.ts +35 -0
  30. package/lib/api-schemas/delegation.d.ts.map +1 -0
  31. package/lib/api-schemas/delegation.js +21 -0
  32. package/lib/api-schemas/delegation.js.map +1 -0
  33. package/lib/api-schemas/document-processing.d.ts +261 -0
  34. package/lib/api-schemas/document-processing.d.ts.map +1 -1
  35. package/lib/api-schemas/emit-json-schema.d.ts +5 -0
  36. package/lib/api-schemas/emit-json-schema.d.ts.map +1 -0
  37. package/lib/api-schemas/emit-json-schema.js +37 -0
  38. package/lib/api-schemas/emit-json-schema.js.map +1 -0
  39. package/lib/api-schemas/environment.d.ts +18 -0
  40. package/lib/api-schemas/environment.d.ts.map +1 -1
  41. package/lib/api-schemas/events.d.ts +783 -0
  42. package/lib/api-schemas/events.d.ts.map +1 -1
  43. package/lib/api-schemas/index.d.ts +1 -0
  44. package/lib/api-schemas/index.d.ts.map +1 -1
  45. package/lib/api-schemas/index.js +1 -0
  46. package/lib/api-schemas/index.js.map +1 -1
  47. package/lib/api-schemas/interaction.d.ts +3939 -91
  48. package/lib/api-schemas/interaction.d.ts.map +1 -1
  49. package/lib/api-schemas/interaction.js +14 -3
  50. package/lib/api-schemas/interaction.js.map +1 -1
  51. package/lib/api-schemas/oauth-server.d.ts +1 -0
  52. package/lib/api-schemas/oauth-server.d.ts.map +1 -1
  53. package/lib/api-schemas/oauth-server.js +3 -0
  54. package/lib/api-schemas/oauth-server.js.map +1 -1
  55. package/lib/api-schemas/process-agent-policy.d.ts +69 -0
  56. package/lib/api-schemas/process-agent-policy.d.ts.map +1 -0
  57. package/lib/api-schemas/process-agent-policy.js +154 -0
  58. package/lib/api-schemas/process-agent-policy.js.map +1 -0
  59. package/lib/api-schemas/process.d.ts +1260 -0
  60. package/lib/api-schemas/process.d.ts.map +1 -1
  61. package/lib/api-schemas/process.js +29 -1
  62. package/lib/api-schemas/process.js.map +1 -1
  63. package/lib/api-schemas/project-configuration.d.ts +883 -8
  64. package/lib/api-schemas/project-configuration.d.ts.map +1 -1
  65. package/lib/api-schemas/project-configuration.js +3 -2
  66. package/lib/api-schemas/project-configuration.js.map +1 -1
  67. package/lib/api-schemas/project.d.ts +1330 -22
  68. package/lib/api-schemas/project.d.ts.map +1 -1
  69. package/lib/api-schemas/registry.d.ts +24347 -5694
  70. package/lib/api-schemas/registry.d.ts.map +1 -1
  71. package/lib/api-schemas/registry.js +50 -8
  72. package/lib/api-schemas/registry.js.map +1 -1
  73. package/lib/api-schemas/store.d.ts +4427 -77
  74. package/lib/api-schemas/store.d.ts.map +1 -1
  75. package/lib/api-schemas/sts.d.ts +6 -0
  76. package/lib/api-schemas/sts.d.ts.map +1 -1
  77. package/lib/api-schemas/sts.js +3 -0
  78. package/lib/api-schemas/sts.js.map +1 -1
  79. package/lib/api-schemas/workflow-runs.d.ts +189 -0
  80. package/lib/api-schemas/workflow-runs.d.ts.map +1 -1
  81. package/lib/api-schemas/workflow-runs.js +14 -0
  82. package/lib/api-schemas/workflow-runs.js.map +1 -1
  83. package/lib/apikey.d.ts +8 -0
  84. package/lib/apikey.d.ts.map +1 -1
  85. package/lib/apikey.js.map +1 -1
  86. package/lib/delegation.d.ts +13 -0
  87. package/lib/delegation.d.ts.map +1 -0
  88. package/lib/delegation.js +2 -0
  89. package/lib/delegation.js.map +1 -0
  90. package/lib/environment.d.ts +1 -0
  91. package/lib/environment.d.ts.map +1 -1
  92. package/lib/index.d.ts +1 -0
  93. package/lib/index.d.ts.map +1 -1
  94. package/lib/index.js.map +1 -1
  95. package/lib/oauth-scopes.d.ts.map +1 -1
  96. package/lib/oauth-scopes.js +3 -1
  97. package/lib/oauth-scopes.js.map +1 -1
  98. package/lib/project-values.d.ts +1 -0
  99. package/lib/project-values.d.ts.map +1 -1
  100. package/lib/project-values.js +1 -0
  101. package/lib/project-values.js.map +1 -1
  102. package/lib/store/agent-run-values.d.ts +25 -0
  103. package/lib/store/agent-run-values.d.ts.map +1 -0
  104. package/lib/store/agent-run-values.js +25 -0
  105. package/lib/store/agent-run-values.js.map +1 -0
  106. package/lib/store/agent-run.d.ts +22 -2
  107. package/lib/store/agent-run.d.ts.map +1 -1
  108. package/lib/store/agent-run.js +1 -1
  109. package/lib/store/agent-run.js.map +1 -1
  110. package/lib/store/conversation-state.d.ts +1 -1
  111. package/lib/store/conversation-state.d.ts.map +1 -1
  112. package/lib/store/intake-policy-schema.generated.d.ts.map +1 -1
  113. package/lib/store/intake-policy-schema.generated.js +124 -0
  114. package/lib/store/intake-policy-schema.generated.js.map +1 -1
  115. package/lib/store/process.d.ts +17 -0
  116. package/lib/store/process.d.ts.map +1 -1
  117. package/lib/store/process.js.map +1 -1
  118. package/lib/store/schedule.d.ts +62 -25
  119. package/lib/store/schedule.d.ts.map +1 -1
  120. package/lib/store/schedule.js +2 -2
  121. package/lib/store/schedule.js.map +1 -1
  122. package/lib/store/workflow.d.ts +2 -0
  123. package/lib/store/workflow.d.ts.map +1 -1
  124. package/lib/store/workflow.js.map +1 -1
  125. package/lib/vertesia-common.js +2 -2
  126. package/lib/vertesia-common.js.map +1 -1
  127. package/lib/workflow-analytics.d.ts +230 -2
  128. package/lib/workflow-analytics.d.ts.map +1 -1
  129. package/lib/workflow-analytics.js +8 -0
  130. package/lib/workflow-analytics.js.map +1 -1
  131. package/package.json +8 -8
  132. package/src/access-control-values.ts +26 -0
  133. package/src/api-contract/components.contract.test.ts +2 -2
  134. package/src/api-contract/components.generated.json +4446 -2194
  135. package/src/api-schemas/account-apikey.test.ts +60 -0
  136. package/src/api-schemas/account.contract.test.ts +2 -1
  137. package/src/api-schemas/account.ts +5 -9
  138. package/src/api-schemas/adapter-edge-cases.test.ts +19 -0
  139. package/src/api-schemas/adapter.ts +8 -1
  140. package/src/api-schemas/agent-communication.ts +6 -0
  141. package/src/api-schemas/agent-history.contract.test.ts +42 -0
  142. package/src/api-schemas/agent-runs.contract.test.ts +240 -0
  143. package/src/api-schemas/agent-runs.ts +399 -0
  144. package/src/api-schemas/apikey.ts +31 -0
  145. package/src/api-schemas/bundle-isolation.test.ts +5 -41
  146. package/src/api-schemas/delegation.ts +21 -0
  147. package/src/api-schemas/emit-json-schema.test.ts +36 -0
  148. package/src/api-schemas/emit-json-schema.ts +40 -0
  149. package/src/api-schemas/environment.contract.test.ts +3 -0
  150. package/src/api-schemas/index.ts +1 -0
  151. package/src/api-schemas/interaction.contract.test.ts +23 -0
  152. package/src/api-schemas/interaction.ts +15 -3
  153. package/src/api-schemas/llumiverse.contract.test.ts +3 -9
  154. package/src/api-schemas/oauth-server.ts +4 -0
  155. package/src/api-schemas/process-agent-policy.ts +167 -0
  156. package/src/api-schemas/process.contract.test.ts +115 -0
  157. package/src/api-schemas/process.ts +31 -1
  158. package/src/api-schemas/project-configuration.ts +3 -2
  159. package/src/api-schemas/project.contract.test.ts +15 -0
  160. package/src/api-schemas/registry.ts +59 -10
  161. package/src/api-schemas/store.contract.test.ts +4 -126
  162. package/src/api-schemas/sts.ts +3 -0
  163. package/src/api-schemas/workflow-runs.ts +16 -0
  164. package/src/api-schemas/zeno-response-contracts.test.ts +36 -0
  165. package/src/apikey.ts +13 -0
  166. package/src/delegation.ts +18 -0
  167. package/src/index.ts +6 -0
  168. package/src/oauth-scopes.ts +3 -1
  169. package/src/project-values.ts +1 -0
  170. package/src/roles.test.ts +1 -0
  171. package/src/store/agent-run-values.ts +27 -0
  172. package/src/store/agent-run.ts +36 -0
  173. package/src/store/conversation-state.ts +1 -1
  174. package/src/store/intake-policy-schema.generated.ts +125 -0
  175. package/src/store/process.ts +22 -0
  176. package/src/store/schedule.test.ts +59 -0
  177. package/src/store/schedule.ts +91 -27
  178. package/src/store/workflow.ts +2 -0
  179. package/src/workflow-analytics.ts +274 -1
@@ -31,7 +31,7 @@ import {
31
31
  ToolUseSchema,
32
32
  VideoResultSchema,
33
33
  } from '@llumiverse/common/schemas';
34
- import { z } from 'zod';
34
+ import type { z } from 'zod';
35
35
  import type {
36
36
  CreateEventSubscriptionPayload,
37
37
  EventDeliveryTarget,
@@ -90,6 +90,9 @@ import {
90
90
  TimeResolutionSchema,
91
91
  } from './analytics.js';
92
92
  import {
93
+ AccountApiKeyArraySchema,
94
+ AccountApiKeySchema,
95
+ AccountApiKeyWithValueSchema,
93
96
  ApiKeyArraySchema,
94
97
  ApiKeyListQuerySchema,
95
98
  ApiKeyReadQuerySchema,
@@ -97,9 +100,11 @@ import {
97
100
  ApiKeySchema,
98
101
  ApiKeyWithValueSchema,
99
102
  AuthTokenResponseSchema,
103
+ CreateAccountApiKeyPayloadSchema,
100
104
  CreateApiKeyPayloadSchema,
101
105
  DeleteOperationResultSchema,
102
106
  ProjectRefArraySchema,
107
+ UpdateAccountApiKeyPayloadSchema,
103
108
  UpdateApiKeyPayloadSchema,
104
109
  } from './apikey.js';
105
110
  import {
@@ -343,6 +348,7 @@ import {
343
348
  SemanticColumnTypeSchema,
344
349
  UpdateSchemaPayloadSchema,
345
350
  } from './data-store.js';
351
+ import { CreateDelegationGrantPayloadSchema, DelegationGrantArraySchema, DelegationGrantSchema } from './delegation.js';
346
352
  import {
347
353
  DocAnalyzeRunStatusResponseSchema,
348
354
  DocAnalyzerProgressSchema,
@@ -374,6 +380,7 @@ import {
374
380
  EmbeddingsStatusResponseSchema,
375
381
  ProjectConfigurationEmbeddingEnablePayloadSchema,
376
382
  } from './embeddings.js';
383
+ import { emitJsonSchema } from './emit-json-schema.js';
377
384
  import {
378
385
  EnableEnvironmentModelPayloadSchema,
379
386
  ExecutionEnvironmentArraySchema,
@@ -839,6 +846,12 @@ const IAM_AND_ACCOUNT_SCHEMAS = {
839
846
  ApiKey: ApiKeySchema,
840
847
  ApiKeyArray: ApiKeyArraySchema,
841
848
  ApiKeyWithValue: ApiKeyWithValueSchema,
849
+ AccountApiKey: AccountApiKeySchema,
850
+ AccountApiKeyWithValue: AccountApiKeyWithValueSchema,
851
+ AccountApiKeyArray: AccountApiKeyArraySchema,
852
+ CreateAccountApiKeyPayload: CreateAccountApiKeyPayloadSchema,
853
+ UpdateAccountApiKeyPayload: UpdateAccountApiKeyPayloadSchema,
854
+
842
855
  ApiKeyReadResponse: ApiKeyReadResponseSchema,
843
856
  ApiKeyReadQuery: ApiKeyReadQuerySchema,
844
857
  CreateApiKeyPayload: CreateApiKeyPayloadSchema,
@@ -875,8 +888,8 @@ const PROJECT_AND_APP_SCHEMAS = {
875
888
  ProjectConfigurationEmbedding: ProjectConfigurationEmbeddingSchema,
876
889
  BrowserUseProjectConfiguration: BrowserUseProjectConfigurationSchema,
877
890
  ProjectIntakeSniffConfiguration: ProjectIntakeSniffConfigurationSchema,
878
- // Leaves of the Project closure. `ModelOptions` hoists its
879
- // twenty-five driver option sets and four enums; `JSONSchema` hoists `JSONSchemaProperties`.
891
+ // Leaves of the Project closure. `ModelOptions` hoists its driver option sets and shared enums;
892
+ // `JSONSchema` hoists `JSONSchemaProperties`.
880
893
  JSONSchema: JSONSchemaSchema,
881
894
  ModelOptions: ModelOptionsSchema,
882
895
  HttpTimeoutOptions: HttpTimeoutOptionsSchema,
@@ -1786,6 +1799,25 @@ const AGENT_RUN_SCHEMAS = {
1786
1799
  SearchAgentRunsQuery: AgentRunSchemas.SearchAgentRunsQuerySchema,
1787
1800
  StreamAgentRunQuery: AgentRunSchemas.StreamAgentRunQuerySchema,
1788
1801
  UpdateAgentRunStatusPayload: AgentRunSchemas.UpdateAgentRunStatusPayloadSchema,
1802
+ AgentRunFeedbackRating: AgentRunSchemas.AgentRunFeedbackRatingSchema,
1803
+ AgentRunFeedbackReasonCode: AgentRunSchemas.AgentRunFeedbackReasonCodeSchema,
1804
+ AgentRunFeedbackPayload: AgentRunSchemas.AgentRunFeedbackPayloadSchema,
1805
+ AgentRunFeedbackStatus: AgentRunSchemas.AgentRunFeedbackStatusSchema,
1806
+ AgentRunFeedbackCounts: AgentRunSchemas.AgentRunFeedbackCountsSchema,
1807
+ AgentRunFeedbackResponse: AgentRunSchemas.AgentRunFeedbackResponseSchema,
1808
+ AgentRunFeedbackEntry: AgentRunSchemas.AgentRunFeedbackEntrySchema,
1809
+ AgentRunEvaluationRollup: AgentRunSchemas.AgentRunEvaluationRollupSchema,
1810
+ AgentRunJudgeResult: AgentRunSchemas.AgentRunJudgeResultSchema,
1811
+ AgentRunContradictionReason: AgentRunSchemas.AgentRunContradictionReasonSchema,
1812
+ AgentRunEvaluation: AgentRunSchemas.AgentRunEvaluationSchema,
1813
+ TurnTerminalType: AgentRunSchemas.TurnTerminalTypeSchema,
1814
+ EvaluationSeverity: AgentRunSchemas.EvaluationSeveritySchema,
1815
+ TurnEvaluationFlag: AgentRunSchemas.TurnEvaluationFlagSchema,
1816
+ ToolErrorClass: AgentRunSchemas.ToolErrorClassSchema,
1817
+ JudgeGateReason: AgentRunSchemas.JudgeGateReasonSchema,
1818
+ JudgeOutcome: AgentRunSchemas.JudgeOutcomeSchema,
1819
+ JudgeVerdict: AgentRunSchemas.JudgeVerdictSchema,
1820
+ ListAgentRunsEvaluationSeverity: AgentRunSchemas.ListAgentRunsEvaluationSeveritySchema,
1789
1821
  AgentEvent: AgentRunSchemas.AgentEventSchema,
1790
1822
  IngestAgentEventsPayload: AgentRunSchemas.IngestAgentEventsPayloadSchema,
1791
1823
  IngestAgentEventsResponse: AgentRunSchemas.IngestAgentEventsResponseSchema,
@@ -2246,7 +2278,13 @@ const CONTENT_QUERY_SCHEMAS = {
2246
2278
  ContentQueryResult: ContentQuerySchemas.ContentQueryResultSchema,
2247
2279
  } as const satisfies Record<string, z.ZodType>;
2248
2280
 
2281
+ const DELEGATION_SCHEMAS = {
2282
+ CreateDelegationGrantPayload: CreateDelegationGrantPayloadSchema,
2283
+ DelegationGrant: DelegationGrantSchema,
2284
+ DelegationGrantArray: DelegationGrantArraySchema,
2285
+ };
2249
2286
  const API_SCHEMA_GROUPS = [
2287
+ DELEGATION_SCHEMAS,
2250
2288
  IAM_AND_ACCOUNT_SCHEMAS,
2251
2289
  PROJECT_AND_APP_SCHEMAS,
2252
2290
  OAUTH_SCHEMAS,
@@ -2309,7 +2347,8 @@ const API_SCHEMA_GROUPS = [
2309
2347
  * have inferred to. `mergeComponentGroups` rejects a name declared by two groups, so no key is ever
2310
2348
  * intersected with a second schema.
2311
2349
  */
2312
- type ApiSchemaMap = typeof IAM_AND_ACCOUNT_SCHEMAS &
2350
+ type ApiSchemaMap = typeof DELEGATION_SCHEMAS &
2351
+ typeof IAM_AND_ACCOUNT_SCHEMAS &
2313
2352
  typeof PROJECT_AND_APP_SCHEMAS &
2314
2353
  typeof OAUTH_SCHEMAS &
2315
2354
  typeof ENVIRONMENT_SCHEMAS &
@@ -2380,6 +2419,13 @@ const API_SCHEMAS: Readonly<Record<ApiComponentName, z.ZodType>> = mergeComponen
2380
2419
  * objects, so a body carrying an undeclared property is rejected rather than quietly accepted.
2381
2420
  */
2382
2421
  const STRICT_COMPONENTS: ReadonlySet<string> = new Set<string>([
2422
+ 'AccountApiKey',
2423
+ 'AccountApiKeyWithValue',
2424
+ 'CreateAccountApiKeyPayload',
2425
+ 'UpdateAccountApiKeyPayload',
2426
+
2427
+ 'CreateDelegationGrantPayload',
2428
+ 'DelegationGrant',
2383
2429
  // Process Test Lab request, fixture, and result contracts.
2384
2430
  'ProcessTestVirtualActor',
2385
2431
  'ProcessTestFixtureResult',
@@ -2580,6 +2626,7 @@ const STRICT_COMPONENTS: ReadonlySet<string> = new Set<string>([
2580
2626
  'BedrockMantleClaudeOptions',
2581
2627
  'OpenAiThinkingOptions',
2582
2628
  'OpenAiTextOptions',
2629
+ 'OpenRouterTextOptions',
2583
2630
  'OpenAiDalleOptions',
2584
2631
  'OpenAiGptImageOptions',
2585
2632
  'XAIGrokImageOptions',
@@ -2778,6 +2825,13 @@ const STRICT_COMPONENTS: ReadonlySet<string> = new Set<string>([
2778
2825
  'UpdateAgentArtifactContentResponse',
2779
2826
  'UpdateAgentArtifactContentPayload',
2780
2827
  'TerminateAgentRunResponse',
2828
+ 'AgentRunFeedbackPayload',
2829
+ 'AgentRunFeedbackResponse',
2830
+ 'AgentRunFeedbackCounts',
2831
+ 'AgentRunFeedbackEntry',
2832
+ 'AgentRunEvaluationRollup',
2833
+ 'AgentRunJudgeResult',
2834
+ 'AgentRunEvaluation',
2781
2835
  'StartContentObjectExportResponse',
2782
2836
  'ExportContentObjectsIncludeOptions',
2783
2837
  'ExportContentObjectsFilter',
@@ -3385,12 +3439,7 @@ const STRICT_COMPONENTS: ReadonlySet<string> = new Set<string>([
3385
3439
  * not be used to express contract rules — they would be invisible to both the spec and AJV.
3386
3440
  */
3387
3441
  function emitRawSchemas(): Record<string, unknown> {
3388
- return Object.fromEntries(
3389
- Object.entries(API_SCHEMAS).map(([name, schema]) => [
3390
- name,
3391
- z.toJSONSchema(schema, { target: 'draft-2020-12', io: 'input' }),
3392
- ]),
3393
- );
3442
+ return Object.fromEntries(Object.entries(API_SCHEMAS).map(([name, schema]) => [name, emitJsonSchema(schema)]));
3394
3443
  }
3395
3444
 
3396
3445
  /**
@@ -1,5 +1,3 @@
1
- import { readFileSync } from 'node:fs';
2
- import { fileURLToPath } from 'node:url';
3
1
  import { Ajv } from 'ajv';
4
2
  import { describe, expect, it } from 'vitest';
5
3
  import { ContentTypeIntakePolicySchema as GeneratedIntakePolicySchema } from '../store/intake-policy-schema.generated.js';
@@ -14,9 +12,9 @@ function assertType<T extends true>(_ok: T): void {}
14
12
 
15
13
  /**
16
14
  * The intake policy is now stated once, in Zod, and reaches its consumers three ways: as the
17
- * published OpenAPI component, as the checked-in JSON artifact that zeno-server / the workflow tool /
18
- * the web editor compiles, and as the TypeScript type. This file is the gate that keeps all three
19
- * the same statement.
15
+ * canonical component, as the checked-in JSON artifact consumers compile, and as the TypeScript
16
+ * type. This file keeps those package-owned contracts aligned. Downstream consumers test their
17
+ * published API documents and generated-client fixtures separately.
20
18
  *
21
19
  * It also pins the behaviour changes the conversion makes, because the schema it replaced was
22
20
  * hand-written and disagreed with the contract in both directions. Each is asserted rather than
@@ -30,101 +28,13 @@ function errors(): string {
30
28
  return ajv.errorsText(validate.errors, { separator: '\n' });
31
29
  }
32
30
 
33
- /**
34
- * Reads a file from the studio repository this package is a submodule of.
35
- *
36
- * `undefined` when it is not there, which is the normal state in this repository's own CI: it clones
37
- * composableai alone, so nothing above the submodule root exists. Two of the gates below compare
38
- * against the published document and the generated-client fixture, both of which live up there — so
39
- * they are skipped when they cannot be read rather than failing the whole file at import time, which
40
- * is what used to happen and what left this suite red on every commit.
41
- *
42
- * They still run where they are the actual gate: a checkout of the parent repository, which is what
43
- * the migration's own verification and the studio CI use.
44
- */
45
- function readFromStudioRepo(relativePath: string): unknown {
46
- try {
47
- return JSON.parse(readFileSync(fileURLToPath(new URL(relativePath, import.meta.url)), 'utf8'));
48
- } catch (error) {
49
- if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;
50
- throw error;
51
- }
52
- }
53
-
54
- const publishedDocument = readFromStudioRepo('../../../../../packages/api-specs/vertesia-openapi.json') as
55
- | { components: { schemas: Record<string, Record<string, unknown>> } }
56
- | undefined;
57
- const published = publishedDocument?.components.schemas ?? {};
58
-
59
- /**
60
- * The published component minus the OpenAPI-only discriminator hint the bundler drops.
61
- *
62
- * Written out here rather than imported from the registry on purpose: reusing the production
63
- * function to check the production function would make the comparison below pass by construction.
64
- * The rule is small enough to state twice, and stating it twice is what makes it a gate.
65
- */
66
- function withoutDiscriminatorHints(value: unknown): unknown {
67
- if (Array.isArray(value)) return value.map(withoutDiscriminatorHints);
68
- if (!value || typeof value !== 'object') return value;
69
- const node = value as Record<string, unknown>;
70
- const restated = node.discriminator !== undefined && node.properties === undefined;
71
- return Object.fromEntries(
72
- Object.entries(node)
73
- .filter(([key]) => key !== 'discriminator' && !(restated && (key === 'type' || key === 'required')))
74
- .map(([key, item]) => [key, withoutDiscriminatorHints(item)]),
75
- );
76
- }
77
-
78
- function $defsOf(schema: unknown): unknown {
79
- return (schema as { $defs: unknown }).$defs;
80
- }
81
-
82
- describe.skipIf(!publishedDocument)('gate — generated artifact = canonical component = published component', () => {
31
+ describe('generated artifact and canonical component', () => {
83
32
  it('is the exact bundle the registry emits, so the artifact is compiled output', () => {
84
33
  // Deep equality, not a spot check: the file is generated by `pnpm run gen:schemas` from this
85
34
  // same function, so any difference means someone hand-edited it or forgot to regenerate.
86
35
  expect(GeneratedIntakePolicySchema).toEqual(bundleCanonicalComponent('ContentTypeIntakePolicy'));
87
36
  });
88
37
 
89
- it('describes the same shape as the component the OpenAPI document publishes', () => {
90
- // The artifact re-roots `#/components/schemas/X` to `#/$defs/X` so AJV and Monaco can compile
91
- // it standalone. Undoing that is what makes the two directly comparable.
92
- const { $defs, ...body } = GeneratedIntakePolicySchema as { $defs: Record<string, unknown> };
93
- const rerooted = JSON.parse(JSON.stringify(body).replaceAll('#/$defs/', '#/components/schemas/'));
94
- expect(rerooted).toEqual(withoutDiscriminatorHints(published.ContentTypeIntakePolicy));
95
-
96
- // ...and every definition it carries is the published component of that name, so the bundle
97
- // cannot describe a private variant of a shared type.
98
- for (const [name, definition] of Object.entries($defs)) {
99
- const asComponent = JSON.parse(JSON.stringify(definition).replaceAll('#/$defs/', '#/components/schemas/'));
100
- expect(asComponent, `$defs.${name} disagrees with the published component`).toEqual(
101
- withoutDiscriminatorHints(published[name]),
102
- );
103
- }
104
- });
105
-
106
- it('drops the discriminator hint the published component keeps, and only that', () => {
107
- // The one place the artifact and the component are allowed to differ, pinned from both sides
108
- // so neither can move alone. `synthesizeDiscriminator` restates `type` and `required` on the
109
- // union node for the generated Java/Go clients; the node has no `properties`, and Gemini
110
- // rejects the whole tool schema over it ("requires unspecified property '_option_id'") when
111
- // the artifact reaches Vertex inside `create_or_update_type`'s input schema.
112
- expect(published.ModelOptions).toMatchObject({
113
- discriminator: { propertyName: '_option_id' },
114
- type: 'object',
115
- required: ['_option_id'],
116
- });
117
-
118
- const bundled = ($defsOf(GeneratedIntakePolicySchema) as Record<string, Record<string, unknown>>).ModelOptions;
119
- expect(bundled.discriminator).toBeUndefined();
120
- expect(bundled.required).toBeUndefined();
121
- expect(bundled.type).toBeUndefined();
122
- // The branches are what carried the contract all along, so nothing was validated away.
123
- expect((bundled.oneOf as unknown[]).length).toBe(
124
- ((published.ModelOptions as { oneOf: unknown[] }).oneOf ?? []).length,
125
- );
126
- });
127
-
128
38
  it('registers the component the alias claims, under the id the alias name requires', () => {
129
39
  expect(Object.keys(ApiSchemaComponents)).toContain('ContentTypeIntakePolicy');
130
40
  assertType<Equals<ContentTypeIntakePolicy, (typeof ContentTypeIntakePolicySchema)['_zod']['output']>>(true);
@@ -230,38 +140,6 @@ describe('gate — the artifact accepts exactly what the Zod schema accepts', ()
230
140
  });
231
141
  });
232
142
 
233
- describe.skipIf(!publishedDocument)('the fixture the generated Java and Go clients deserialize', () => {
234
- // `openapi/fixtures/content-type-intake-policy.json` is read by
235
- // `openapi/java/src/test/.../ContentTypeIntakePolicyDeserializationTest.java` and by
236
- // `openapi/go/tests/intake_policy_deserialization_test.go`. Asserting it HERE is what stops it
237
- // going stale: a schema change that the fixture no longer satisfies fails in this package,
238
- // beside the schema, rather than in a client harness that only CI runs.
239
- const fixture = readFromStudioRepo('../../../../../openapi/fixtures/content-type-intake-policy.json') ?? {};
240
-
241
- it('is a policy the canonical schema and the generated artifact both accept', () => {
242
- expect(ContentTypeIntakePolicySchema.safeParse(fixture).success).toBe(true);
243
- expect(validate(fixture), errors()).toBe(true);
244
- });
245
-
246
- it('exercises the shapes the number -> integer correction changed', () => {
247
- // The fields whose generated Java type moved from Double to Integer and whose Go type moved
248
- // from float32 to int32. A fixture that omitted them would let the clients compile and
249
- // deserialize while proving nothing about the change this batch makes.
250
- const policy = fixture as ContentTypeIntakePolicy;
251
- expect(policy.extraction?.max_pages).toBe(6);
252
- expect(policy.extraction?.page_ranges).toEqual([
253
- [1, 2],
254
- [-1, -1],
255
- ]);
256
- expect(policy.text_conversion?.render_dpi).toBe(150);
257
- expect(policy.extraction?.vision?.max_image_tokens).toBe(9000);
258
- expect(policy.extraction?.grounding?.window_pages).toBe(4);
259
- // ...and the discriminated union, which is what a Go oneOf decoder gets wrong when the
260
- // discriminator is missing from the document.
261
- expect(policy.extraction?.config?.model_options?._option_id).toBe('vertexai-claude');
262
- });
263
- });
264
-
265
143
  describe('the TypeScript type says what the schema says', () => {
266
144
  it('widens page ranges to number[][], which is what the component has always described', () => {
267
145
  // `[number, number][]` is what the interface used to claim. The published component is
@@ -59,6 +59,9 @@ export const EnvironmentTokenRequestSchema = z
59
59
  export const AgentTokenRequestSchema = z
60
60
  .strictObject({
61
61
  type: z.literal('agent'),
62
+ delegation_grant_id: z.string().optional(),
63
+ delegation_policy_hash: z.string().optional(),
64
+ continuation_token: z.string().optional(),
62
65
  ...baseTokenRequestShape,
63
66
  account_id: z.string(),
64
67
  project_id: z.string(),
@@ -223,11 +223,13 @@ export const PendingActivitySchema = z
223
223
  maximumAttempts: z.number(),
224
224
  lastFailure: z.string().optional(),
225
225
  lastStartedTime: nullableStringSchema,
226
+ lastHeartbeatTime: nullableStringSchema.optional(),
226
227
  })
227
228
  .meta({ id: 'PendingActivity' });
228
229
 
229
230
  export const AgentTaskSchema = z
230
231
  .strictObject({
232
+ history_id: z.string().meta({ description: 'Stable observability row identity across refreshes.' }).optional(),
231
233
  taskType: z
232
234
  .enum(['tool_call', 'llm_call', 'input', 'timer', 'subagent', 'processing', 'signal'])
233
235
  .meta({ description: 'Type discriminator for future task types' }),
@@ -575,6 +577,20 @@ export const WorkflowHistorySchema = z
575
577
  }),
576
578
  z.strictObject({
577
579
  type: z.literal('agent'),
580
+ mode: z
581
+ .enum(['snapshot', 'delta'])
582
+ .meta({
583
+ description:
584
+ 'Snapshot replaces all history; delta replaces returned rows by history_id and retains other rows.',
585
+ })
586
+ .optional(),
587
+ next_from: z
588
+ .string()
589
+ .meta({
590
+ description:
591
+ 'Pass as from on the next refresh with the same options. Absence disables incremental refresh.',
592
+ })
593
+ .optional(),
578
594
  agentTasks: z.array(AgentTaskSchema),
579
595
  }),
580
596
  ])
@@ -341,4 +341,40 @@ describe('Zeno read-side response contracts', () => {
341
341
  ]).valid,
342
342
  ).toBe(true);
343
343
  });
344
+
345
+ it('publishes agent-node launch and execution policy', () => {
346
+ expect(
347
+ validateApiRequest('CreateProcessDefinitionPayload', {
348
+ name: 'App development process',
349
+ definition: {
350
+ format_version: 1,
351
+ process: 'app_development',
352
+ initial: 'implement',
353
+ context: { schema: {}, initial: {} },
354
+ nodes: {
355
+ implement: {
356
+ type: 'agent',
357
+ interaction: 'sys:AppDeveloper',
358
+ inherit_context: false,
359
+ initial_skills: ['app_quick_fix'],
360
+ excluded_tools: ['learn_app_development'],
361
+ agent_policy: {
362
+ phases: [
363
+ {
364
+ id: 'saved',
365
+ tools: ['app_workspace_save'],
366
+ tool_input_contains: [{ field: 'mode', contains: 'commit' }],
367
+ recovery_prompt: 'Save before finishing.',
368
+ },
369
+ ],
370
+ phase_resets: [{ tools: ['app_workspace_edit'], to_phase: 'saved' }],
371
+ defer_result_schema_until_complete: true,
372
+ completion_prompt: 'Return the structured result now.',
373
+ },
374
+ },
375
+ },
376
+ },
377
+ }).valid,
378
+ ).toBe(true);
379
+ });
344
380
  });
package/src/apikey.ts CHANGED
@@ -80,6 +80,9 @@ export type ApiKeyListQuery = z.infer<typeof ApiKeyListQuerySchema>;
80
80
  export type ApiKeyReadQuery = z.infer<typeof ApiKeyReadQuerySchema>;
81
81
 
82
82
  export interface AuthTokenPayload {
83
+ credential_scope?: 'project' | 'account';
84
+ credential_profile?: 'account_admin_v1';
85
+ delegation?: import('./delegation.js').DelegationTokenClaim;
83
86
  sub: string;
84
87
  name: string;
85
88
  email?: string;
@@ -193,3 +196,13 @@ export enum PrincipalType {
193
196
  Agent = 'agent',
194
197
  Schedule = 'schedule',
195
198
  }
199
+
200
+ export type AccountApiKey = z.infer<typeof import('./api-schemas/apikey.js').AccountApiKeySchema>;
201
+ export type AccountApiKeyWithValue = z.infer<typeof import('./api-schemas/apikey.js').AccountApiKeyWithValueSchema>;
202
+ export type AccountApiKeyArray = z.infer<typeof import('./api-schemas/apikey.js').AccountApiKeyArraySchema>;
203
+ export type CreateAccountApiKeyPayload = z.infer<
204
+ typeof import('./api-schemas/apikey.js').CreateAccountApiKeyPayloadSchema
205
+ >;
206
+ export type UpdateAccountApiKeyPayload = z.infer<
207
+ typeof import('./api-schemas/apikey.js').UpdateAccountApiKeyPayloadSchema
208
+ >;
@@ -0,0 +1,18 @@
1
+ import type { z } from 'zod';
2
+ import type {
3
+ CreateDelegationGrantPayloadSchema,
4
+ DelegationGrantArraySchema,
5
+ DelegationGrantSchema,
6
+ } from './api-schemas/delegation.js';
7
+
8
+ export type CreateDelegationGrantPayload = z.infer<typeof CreateDelegationGrantPayloadSchema>;
9
+ export type DelegationGrant = z.infer<typeof DelegationGrantSchema>;
10
+ export type DelegationGrantArray = z.infer<typeof DelegationGrantArraySchema>;
11
+
12
+ export interface DelegationTokenClaim {
13
+ grant_id: string;
14
+ subject: string;
15
+ schedule_id: string;
16
+ output_collection_id: string;
17
+ policy_hash: string;
18
+ }
package/src/index.ts CHANGED
@@ -22,6 +22,12 @@ export * from './common.js';
22
22
  export * from './content-query.js';
23
23
  export * from './cost-analytics.js';
24
24
  export * from './data-platform.js';
25
+ export type {
26
+ CreateDelegationGrantPayload,
27
+ DelegationGrant,
28
+ DelegationGrantArray,
29
+ DelegationTokenClaim,
30
+ } from './delegation.js';
25
31
  export * from './email.js';
26
32
  export * from './embeddings.js';
27
33
  export * from './environment.js';
@@ -1,4 +1,4 @@
1
- import { Permission } from './access-control-values.js';
1
+ import { ACCOUNT_SCOPED_PERMISSIONS, Permission } from './access-control-values.js';
2
2
 
3
3
  export const OAUTH_SCOPE_OPENID = 'openid';
4
4
  export const OAUTH_SCOPE_PROFILE = 'profile';
@@ -12,6 +12,8 @@ export const OAUTH_STANDARD_SCOPES = [OAUTH_SCOPE_OPENID, OAUTH_SCOPE_PROFILE, O
12
12
  * hand out secret material, or are internal to the platform's own consoles.
13
13
  */
14
14
  const NON_OAUTH_PERMISSION_SCOPES = new Set<Permission>([
15
+ ...ACCOUNT_SCOPED_PERMISSIONS,
16
+ Permission.schedule_delegate,
15
17
  Permission.api_key_create,
16
18
  Permission.api_key_update,
17
19
  Permission.api_key_delete,
@@ -24,6 +24,7 @@ export enum ResourceVisibility {
24
24
  export enum SystemRoles {
25
25
  owner = 'owner', // all permissions
26
26
  admin = 'admin', // all permissions
27
+ app_admin = 'app_admin', // all permissions but studio:access — admin driving a custom admin UI
27
28
  manager = 'manager', // all permissions but manage_account, manage_billing
28
29
  developer = 'developer', // all permissions but manage_account, manage_billing, manage_roles, delete
29
30
  application = 'application', // executor + request_pk
package/src/roles.test.ts CHANGED
@@ -7,6 +7,7 @@ describe('shared role vocabulary', () => {
7
7
  expect(Object.values(SystemRoles).sort()).toEqual(
8
8
  [
9
9
  'admin',
10
+ 'app_admin',
10
11
  'app_member',
11
12
  'application',
12
13
  'auditor',
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Runtime values the agent-run API schemas build on.
3
+ *
4
+ * Split out of `agent-run.ts` for the reason `account-values.ts` was split out of `user.ts`: the
5
+ * schema module in `api-schemas/` needs these at runtime, while `agent-run.ts` must stay a
6
+ * type-only module so importing it never pulls Zod into a consumer's bundle. Both sides import
7
+ * from here, and `agent-run.ts` re-exports it so the constants are nameable from the package root.
8
+ */
9
+
10
+ /**
11
+ * Bound on `AgentRunFeedbackPayload.comment`, in characters.
12
+ *
13
+ * Published so a client can stop the user at the limit instead of letting the server reject the
14
+ * whole rating over the tail of a comment.
15
+ */
16
+ export const AGENT_RUN_FEEDBACK_COMMENT_MAX_LENGTH = 2000;
17
+
18
+ /**
19
+ * Bound on `AgentRunFeedbackPayload.feedback_id`, in characters. A UUID fits comfortably.
20
+ */
21
+ export const AGENT_RUN_FEEDBACK_ID_MAX_LENGTH = 64;
22
+
23
+ /**
24
+ * How many feedback entries a run retains. Counters are computed over the retained entries;
25
+ * replaced entries are evicted first, then the oldest.
26
+ */
27
+ export const AGENT_RUN_FEEDBACK_MAX_ENTRIES = 50;
@@ -21,7 +21,18 @@ import type {
21
21
  AgentRunArtifactQuerySchema,
22
22
  AgentRunArtifactsQuerySchema,
23
23
  AgentRunArtifactUploadHeadersSchema,
24
+ AgentRunContradictionReasonSchema,
24
25
  AgentRunDetailsQuerySchema,
26
+ AgentRunEvaluationRollupSchema,
27
+ AgentRunEvaluationSchema,
28
+ AgentRunFeedbackCountsSchema,
29
+ AgentRunFeedbackEntrySchema,
30
+ AgentRunFeedbackPayloadSchema,
31
+ AgentRunFeedbackRatingSchema,
32
+ AgentRunFeedbackReasonCodeSchema,
33
+ AgentRunFeedbackResponseSchema,
34
+ AgentRunFeedbackStatusSchema,
35
+ AgentRunJudgeResultSchema,
25
36
  AgentRunSchema,
26
37
  AgentRunUpdatesQuerySchema,
27
38
  AgentRunUpdatesResponseSchema,
@@ -31,6 +42,7 @@ import type {
31
42
  CreateRunPayloadSchema,
32
43
  IngestAgentEventsPayloadSchema,
33
44
  IngestAgentEventsResponseSchema,
45
+ ListAgentRunsEvaluationSeveritySchema,
34
46
  ListAgentRunsQuerySchema,
35
47
  PostAgentRunUpdatePayloadSchema,
36
48
  PostAgentRunUpdateResponseSchema,
@@ -64,6 +76,8 @@ import type {
64
76
  WorkflowRunEvent,
65
77
  } from './workflow.js';
66
78
 
79
+ export * from './agent-run-values.js';
80
+
67
81
  export type AgentRunStatus = z.infer<typeof AgentRunStatusSchema>;
68
82
 
69
83
  export type AgentRunArchiveState = z.infer<typeof AgentRunArchiveStateSchema>;
@@ -263,6 +277,8 @@ export interface RecordProcessRunPayload<TData = Record<string, unknown>, TSourc
263
277
  RecordRunWorkflowPayload {
264
278
  run_kind: 'process';
265
279
  run_type?: ProcessRunType;
280
+ schedule_id?: string;
281
+ type?: AgentRunType;
266
282
  }
267
283
 
268
284
  export type RecordRunPayload<TData = Record<string, unknown>, TSource = RunSource> =
@@ -277,6 +293,18 @@ export type BindRunWorkflowPayload = z.infer<typeof BindRunWorkflowPayloadSchema
277
293
 
278
294
  export type TerminateAgentRunResponse = z.infer<typeof TerminateAgentRunResponseSchema>;
279
295
 
296
+ export type AgentRunFeedbackRating = z.infer<typeof AgentRunFeedbackRatingSchema>;
297
+ export type AgentRunFeedbackReasonCode = z.infer<typeof AgentRunFeedbackReasonCodeSchema>;
298
+ export type AgentRunFeedbackPayload = z.infer<typeof AgentRunFeedbackPayloadSchema>;
299
+ export type AgentRunFeedbackStatus = z.infer<typeof AgentRunFeedbackStatusSchema>;
300
+ export type AgentRunFeedbackCounts = z.infer<typeof AgentRunFeedbackCountsSchema>;
301
+ export type AgentRunFeedbackResponse = z.infer<typeof AgentRunFeedbackResponseSchema>;
302
+ export type AgentRunFeedbackEntry = z.infer<typeof AgentRunFeedbackEntrySchema>;
303
+ export type AgentRunEvaluationRollup = z.infer<typeof AgentRunEvaluationRollupSchema>;
304
+ export type AgentRunJudgeResult = z.infer<typeof AgentRunJudgeResultSchema>;
305
+ export type AgentRunContradictionReason = z.infer<typeof AgentRunContradictionReasonSchema>;
306
+ export type AgentRunEvaluation = z.infer<typeof AgentRunEvaluationSchema>;
307
+
280
308
  /**
281
309
  * Payload for updating an AgentRun's lifecycle and derived metadata.
282
310
  */
@@ -308,6 +336,11 @@ export interface UpdateAgentRunStatusPayload {
308
336
  last_archive_error?: string;
309
337
  sequence?: number;
310
338
  process_state?: ProcessState;
339
+ /**
340
+ * Fold of the run's turn evaluations, written by the conversation workflow. The server applies
341
+ * it atomically and ignores a rollup whose `seq` is not newer than the one it holds.
342
+ */
343
+ evaluation_rollup?: AgentRunEvaluationRollup;
311
344
  }
312
345
 
313
346
  // The wire contract is deliberately open because signal payloads are selected by `signalName`.
@@ -388,6 +421,9 @@ export type AgentRunDetailsStreamEvent =
388
421
  | { type: 'control'; data: AgentRunDetailsControlStreamEvent }
389
422
  | { type: 'error'; data: AgentRunDetailsErrorStreamEvent };
390
423
 
424
+ /** Evaluation severity filter values; `unrated` selects runs without an evaluation. */
425
+ export type ListAgentRunsEvaluationSeverity = z.infer<typeof ListAgentRunsEvaluationSeveritySchema>;
426
+
391
427
  /**
392
428
  * Filters for listing agent runs.
393
429
  */
@@ -66,7 +66,7 @@ export interface ConversationState {
66
66
  /** Run-scoped, exact-target grants created by "allow this action for this run". */
67
67
  tool_approval_grants?: Record<string, ToolApprovalGrant>;
68
68
 
69
- /** Buffered tool results held while approval denial pauses until the next user message. */
69
+ /** Buffered tool results held across an interactive pause until the next user message. */
70
70
  pending_tool_approval_results?: PendingToolApprovalResults;
71
71
 
72
72
  /** Compact, redacted latest user intent for reviewer-style system interactions. */