@vertesia/common 1.5.0-dev.20260804.124748Z → 1.5.0-dev.20260807.073259Z

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/Progress.d.ts.map +1 -1
  2. package/lib/Progress.js.map +1 -1
  3. package/lib/access-control-values.d.ts +2 -2
  4. package/lib/access-control-values.d.ts.map +1 -1
  5. package/lib/account-values.d.ts +1 -1
  6. package/lib/account-values.d.ts.map +1 -1
  7. package/lib/api-schemas/access-control.d.ts +19 -19
  8. package/lib/api-schemas/adapter.d.ts +1 -0
  9. package/lib/api-schemas/adapter.d.ts.map +1 -1
  10. package/lib/api-schemas/adapter.js +1 -1
  11. package/lib/api-schemas/adapter.js.map +1 -1
  12. package/lib/api-schemas/agent-runs.d.ts +660 -515
  13. package/lib/api-schemas/agent-runs.d.ts.map +1 -1
  14. package/lib/api-schemas/agent-runs.js +11 -2
  15. package/lib/api-schemas/agent-runs.js.map +1 -1
  16. package/lib/api-schemas/analytics.d.ts +12 -12
  17. package/lib/api-schemas/apikey.d.ts +10 -10
  18. package/lib/api-schemas/app-lifecycle.d.ts +186 -152
  19. package/lib/api-schemas/app-lifecycle.d.ts.map +1 -1
  20. package/lib/api-schemas/app-lifecycle.js +51 -0
  21. package/lib/api-schemas/app-lifecycle.js.map +1 -1
  22. package/lib/api-schemas/app-runtime.d.ts +4493 -2122
  23. package/lib/api-schemas/app-runtime.d.ts.map +1 -1
  24. package/lib/api-schemas/app-runtime.js +93 -1
  25. package/lib/api-schemas/app-runtime.js.map +1 -1
  26. package/lib/api-schemas/apps.d.ts +43 -19
  27. package/lib/api-schemas/apps.d.ts.map +1 -1
  28. package/lib/api-schemas/apps.js +63 -3
  29. package/lib/api-schemas/apps.js.map +1 -1
  30. package/lib/api-schemas/audit-trail.d.ts +129 -129
  31. package/lib/api-schemas/bulk-operation.d.ts +10 -10
  32. package/lib/api-schemas/content.d.ts +542 -398
  33. package/lib/api-schemas/content.d.ts.map +1 -1
  34. package/lib/api-schemas/content.js +12 -0
  35. package/lib/api-schemas/content.js.map +1 -1
  36. package/lib/api-schemas/cost-analytics.d.ts +12 -12
  37. package/lib/api-schemas/dashboard.d.ts +10 -10
  38. package/lib/api-schemas/data-store.d.ts +556 -556
  39. package/lib/api-schemas/document-processing.d.ts +280 -196
  40. package/lib/api-schemas/document-processing.d.ts.map +1 -1
  41. package/lib/api-schemas/embeddings.d.ts +12 -12
  42. package/lib/api-schemas/environment.d.ts +20 -18
  43. package/lib/api-schemas/environment.d.ts.map +1 -1
  44. package/lib/api-schemas/events.d.ts +988 -698
  45. package/lib/api-schemas/events.d.ts.map +1 -1
  46. package/lib/api-schemas/events.js +59 -3
  47. package/lib/api-schemas/events.js.map +1 -1
  48. package/lib/api-schemas/files.d.ts +1 -1
  49. package/lib/api-schemas/group.d.ts +3 -3
  50. package/lib/api-schemas/indexing.d.ts +3 -3
  51. package/lib/api-schemas/integrations.d.ts +4 -4
  52. package/lib/api-schemas/interaction.d.ts +3894 -2752
  53. package/lib/api-schemas/interaction.d.ts.map +1 -1
  54. package/lib/api-schemas/interaction.js +6 -0
  55. package/lib/api-schemas/interaction.js.map +1 -1
  56. package/lib/api-schemas/invites.d.ts +9 -9
  57. package/lib/api-schemas/oauth-server.d.ts +36 -36
  58. package/lib/api-schemas/parameters.js.map +1 -1
  59. package/lib/api-schemas/process.d.ts +47 -47
  60. package/lib/api-schemas/project-configuration.d.ts +944 -664
  61. package/lib/api-schemas/project-configuration.d.ts.map +1 -1
  62. package/lib/api-schemas/project.d.ts +1403 -983
  63. package/lib/api-schemas/project.d.ts.map +1 -1
  64. package/lib/api-schemas/registry.d.ts +19119 -13557
  65. package/lib/api-schemas/registry.d.ts.map +1 -1
  66. package/lib/api-schemas/registry.js +170 -18
  67. package/lib/api-schemas/registry.js.map +1 -1
  68. package/lib/api-schemas/secrets.d.ts +4 -4
  69. package/lib/api-schemas/store.d.ts +4624 -3224
  70. package/lib/api-schemas/store.d.ts.map +1 -1
  71. package/lib/api-schemas/sts.d.ts +46 -36
  72. package/lib/api-schemas/sts.d.ts.map +1 -1
  73. package/lib/api-schemas/sts.js +11 -0
  74. package/lib/api-schemas/sts.js.map +1 -1
  75. package/lib/api-schemas/task.d.ts +30 -30
  76. package/lib/api-schemas/tools.d.ts +9 -9
  77. package/lib/api-schemas/user.d.ts +6 -6
  78. package/lib/api-schemas/view-execution.d.ts +626 -570
  79. package/lib/api-schemas/view-execution.d.ts.map +1 -1
  80. package/lib/api-schemas/views.d.ts +1293 -1125
  81. package/lib/api-schemas/views.d.ts.map +1 -1
  82. package/lib/api-schemas/workflow-runs.d.ts +325 -268
  83. package/lib/api-schemas/workflow-runs.d.ts.map +1 -1
  84. package/lib/apps.d.ts +38 -24
  85. package/lib/apps.d.ts.map +1 -1
  86. package/lib/apps.js +4 -0
  87. package/lib/apps.js.map +1 -1
  88. package/lib/audit-trail.d.ts +3 -3
  89. package/lib/audit-trail.d.ts.map +1 -1
  90. package/lib/data-platform.d.ts +31 -31
  91. package/lib/data-platform.d.ts.map +1 -1
  92. package/lib/environment.d.ts +3 -3
  93. package/lib/index.d.ts +1 -0
  94. package/lib/index.d.ts.map +1 -1
  95. package/lib/index.js +1 -0
  96. package/lib/index.js.map +1 -1
  97. package/lib/platform-event-validation.d.ts.map +1 -1
  98. package/lib/platform-event-validation.js +15 -2
  99. package/lib/platform-event-validation.js.map +1 -1
  100. package/lib/platform-event.d.ts +31 -3
  101. package/lib/platform-event.d.ts.map +1 -1
  102. package/lib/platform-event.js.map +1 -1
  103. package/lib/project.d.ts +1 -1
  104. package/lib/schema-for-extraction.js.map +1 -1
  105. package/lib/store/agent-approval.d.ts +1 -1
  106. package/lib/store/agent-approval.d.ts.map +1 -1
  107. package/lib/store/intake-policy-schema.generated.d.ts.map +1 -1
  108. package/lib/store/intake-policy-schema.generated.js +36 -0
  109. package/lib/store/intake-policy-schema.generated.js.map +1 -1
  110. package/lib/store/process-schema.d.ts +1 -1
  111. package/lib/store/process-schema.d.ts.map +1 -1
  112. package/lib/store/process-validation.js.map +1 -1
  113. package/lib/store/schedule.d.ts +6 -6
  114. package/lib/store/schedule.d.ts.map +1 -1
  115. package/lib/store/store.d.ts +3 -3
  116. package/lib/store/store.d.ts.map +1 -1
  117. package/lib/store/workflow.d.ts +6 -0
  118. package/lib/store/workflow.d.ts.map +1 -1
  119. package/lib/store/workflow.js +8 -0
  120. package/lib/store/workflow.js.map +1 -1
  121. package/lib/sts-errors.d.ts +7 -0
  122. package/lib/sts-errors.d.ts.map +1 -0
  123. package/lib/sts-errors.js +11 -0
  124. package/lib/sts-errors.js.map +1 -0
  125. package/lib/sts-token-types.d.ts +2 -1
  126. package/lib/sts-token-types.d.ts.map +1 -1
  127. package/lib/sts-token-types.js.map +1 -1
  128. package/lib/user.d.ts +1 -1
  129. package/lib/user.d.ts.map +1 -1
  130. package/lib/user.js +1 -1
  131. package/lib/user.js.map +1 -1
  132. package/lib/versions.d.ts +10 -0
  133. package/lib/versions.d.ts.map +1 -1
  134. package/lib/versions.js +10 -0
  135. package/lib/versions.js.map +1 -1
  136. package/lib/vertesia-common.js +3 -3
  137. package/lib/vertesia-common.js.map +1 -1
  138. package/lib/view-configuration-validation.js.map +1 -1
  139. package/lib/view-query-validation.js.map +1 -1
  140. package/lib/view-validation-helpers.d.ts +1 -1
  141. package/lib/view-validation-helpers.d.ts.map +1 -1
  142. package/lib/views-schema.d.ts +51 -51
  143. package/lib/views-schema.d.ts.map +1 -1
  144. package/lib/views-validation.js.map +1 -1
  145. package/lib/views.d.ts +2 -2
  146. package/lib/views.d.ts.map +1 -1
  147. package/lib/workflow-analytics.d.ts +10 -3
  148. package/lib/workflow-analytics.d.ts.map +1 -1
  149. package/package.json +4 -4
  150. package/src/api-schemas/adapter.ts +1 -1
  151. package/src/api-schemas/agent-runs.ts +12 -2
  152. package/src/api-schemas/api-discriminators.test.ts +84 -0
  153. package/src/api-schemas/app-delete-summary.contract.test.ts +67 -0
  154. package/src/api-schemas/app-lifecycle.ts +59 -0
  155. package/src/api-schemas/app-runtime.ts +103 -0
  156. package/src/api-schemas/apps.ts +72 -3
  157. package/src/api-schemas/content.ts +13 -0
  158. package/src/api-schemas/events.ts +63 -3
  159. package/src/api-schemas/interaction.contract.test.ts +27 -0
  160. package/src/api-schemas/interaction.ts +7 -0
  161. package/src/api-schemas/mcp-api-key.contract.test.ts +86 -0
  162. package/src/api-schemas/registry.ts +200 -18
  163. package/src/api-schemas/store.contract.test.ts +21 -0
  164. package/src/api-schemas/sts.contract.test.ts +33 -1
  165. package/src/api-schemas/sts.ts +13 -0
  166. package/src/apps.test.ts +82 -0
  167. package/src/apps.ts +50 -16
  168. package/src/index.ts +1 -0
  169. package/src/platform-event-validation.test.ts +26 -0
  170. package/src/platform-event-validation.ts +15 -2
  171. package/src/platform-event.ts +43 -0
  172. package/src/store/intake-policy-schema.generated.ts +36 -0
  173. package/src/store/workflow.ts +9 -0
  174. package/src/sts-errors.ts +13 -0
  175. package/src/sts-token-types.ts +2 -0
  176. package/src/user.ts +1 -1
  177. package/src/versions.test.ts +13 -0
  178. package/src/versions.ts +12 -0
  179. package/src/workflow-analytics.ts +10 -3
package/src/apps.test.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  import { describe, expect, it } from 'vitest';
2
+ import {
3
+ AppEventHookPayloadSchema,
4
+ AppEventSubscriptionDefinitionSchema,
5
+ AppPackageHooksSchema,
6
+ } from './api-schemas/app-runtime.js';
2
7
  import { APP_ARTIFACT_TYPES, APP_CAPABILITIES, APP_PACKAGE_SCOPES, effectiveAppAccessControl } from './apps.js';
3
8
 
4
9
  describe('app capability contracts', () => {
@@ -6,6 +11,83 @@ describe('app capability contracts', () => {
6
11
  expect(APP_CAPABILITIES).toContain('views');
7
12
  expect(APP_PACKAGE_SCOPES).toContain('views');
8
13
  expect(APP_ARTIFACT_TYPES).toContain('view');
14
+ expect(APP_ARTIFACT_TYPES).toContain('hook');
15
+ expect(APP_ARTIFACT_TYPES).toContain('subscription');
16
+ });
17
+
18
+ it('exposes app hooks as a package query scope', () => {
19
+ expect(APP_PACKAGE_SCOPES).toContain('hooks');
20
+ expect(APP_PACKAGE_SCOPES).toContain('subscriptions');
21
+ });
22
+
23
+ it('accepts app-owned subscriptions without a deployment-specific target', () => {
24
+ expect(
25
+ AppEventSubscriptionDefinitionSchema.parse({
26
+ id: 'content-updated',
27
+ name: 'Content updated',
28
+ hook: 'content-updated',
29
+ filter: { action: ['update'], resource_type: ['content_object'] },
30
+ run_as_role: 'automation',
31
+ }),
32
+ ).toEqual({
33
+ id: 'content-updated',
34
+ name: 'Content updated',
35
+ hook: 'content-updated',
36
+ filter: { action: ['update'], resource_type: ['content_object'] },
37
+ run_as_role: 'automation',
38
+ });
39
+ });
40
+
41
+ it('validates the canonical app event-hook envelope', () => {
42
+ const payload = {
43
+ event: {
44
+ event_id: 'event-1',
45
+ root_event_id: 'event-1',
46
+ hop_count: 0,
47
+ event_category: 'content',
48
+ action: 'update',
49
+ resource_type: 'content_object',
50
+ resource_id: 'object-1',
51
+ account_id: 'account-1',
52
+ project_id: 'project-1',
53
+ tenant_id: 'account-1_project-1',
54
+ timestamp: '2026-08-05T10:00:00.000Z',
55
+ source: 'zeno-server',
56
+ details: { changed: ['title'] },
57
+ },
58
+ delivery: {
59
+ id: 'delivery-1',
60
+ subscription_id: 'subscription-1',
61
+ attempt: 1,
62
+ },
63
+ };
64
+
65
+ expect(AppEventHookPayloadSchema.parse(payload)).toEqual(payload);
66
+ expect(() => AppEventHookPayloadSchema.parse({ event: payload.event })).toThrow();
67
+ });
68
+
69
+ it('accepts lifecycle and event hook package metadata', () => {
70
+ expect(
71
+ AppPackageHooksSchema.parse({
72
+ install: '/api/hooks/install',
73
+ events: [
74
+ {
75
+ name: 'content-updated',
76
+ path: '/api/hooks/content-updated',
77
+ description: 'Processes updated content.',
78
+ },
79
+ ],
80
+ }),
81
+ ).toEqual({
82
+ install: '/api/hooks/install',
83
+ events: [
84
+ {
85
+ name: 'content-updated',
86
+ path: '/api/hooks/content-updated',
87
+ description: 'Processes updated content.',
88
+ },
89
+ ],
90
+ });
9
91
  });
10
92
  });
11
93
 
package/src/apps.ts CHANGED
@@ -2,9 +2,11 @@ import type { z } from 'zod';
2
2
  import type {
3
3
  AgentToolApprovalClassSchema,
4
4
  AgentToolDefinitionSchema,
5
+ AppApiKeyCollectionParamsSchema,
5
6
  AppBuildProgressSchema,
6
7
  AppBuildProgressStatusSchema,
7
8
  AppBuildTriggerSchema,
9
+ AppDeleteSummarySchema,
8
10
  AppDevelopmentTaskDetailsSchema,
9
11
  AppDevelopmentTaskListSchema,
10
12
  AppDevelopmentTaskSchema,
@@ -40,6 +42,7 @@ import type {
40
42
  AppVersionTargetSchema,
41
43
  AppVersionUrlsSchema,
42
44
  DeleteAppVersionResponseSchema,
45
+ McpApiKeyCredentialSchema,
43
46
  OAuthClientCredentialsSchema,
44
47
  StartAppBuildRequestSchema,
45
48
  StartAppBuildResponseSchema,
@@ -51,11 +54,16 @@ import type {
51
54
  ValidateUrlResponseSchema,
52
55
  } from './api-schemas/app-lifecycle.js';
53
56
  import type {
57
+ AppEventHookDeliverySchema,
58
+ AppEventHookPayloadSchema,
59
+ AppEventSubscriptionDefinitionSchema,
54
60
  AppInstallationListEntrySchema,
55
61
  AppInstallationSchema,
56
62
  AppInstallationWithManifestSchema,
57
63
  AppManifestDataSchema,
58
64
  AppManifestSchema,
65
+ AppPackageEventHookSchema,
66
+ AppPackageHooksSchema,
59
67
  AppPackageSchema,
60
68
  AppWidgetInfoSchema,
61
69
  CompositeAppCardOverridesSchema,
@@ -86,9 +94,11 @@ import type {
86
94
  AppManifestSourceSchema,
87
95
  AppSourceConfigSchema,
88
96
  AppUIConfigSchema,
97
+ MCPApiKeyConfigSchema,
89
98
  MCPOAuthConfigSchema,
90
99
  MCPToolAnnotationsSchema,
91
100
  MCPToolCollectionObjectSchema,
101
+ McpApiKeyStatusSchema,
92
102
  McpOAuthConnectResponseSchema,
93
103
  McpOAuthDisconnectResponseSchema,
94
104
  McpOAuthTokenRequestSchema,
@@ -96,6 +106,7 @@ import type {
96
106
  OAuthAuthorizeResponseSchema,
97
107
  OAuthAuthStatusSchema,
98
108
  OAuthMetadataResponseSchema,
109
+ SetMcpApiKeyRequestSchema,
99
110
  ToolCollectionAuthTypeSchema,
100
111
  ToolCollectionObjectSchema,
101
112
  VertesiaSDKToolCollectionObjectSchema,
@@ -162,6 +173,9 @@ export type ToolCollectionType = 'mcp' | 'vertesia_sdk';
162
173
 
163
174
  export type MCPOAuthConfig = z.infer<typeof MCPOAuthConfigSchema>;
164
175
 
176
+ /** Install-time provisioning blueprint for an `auth: 'api_key'` MCP collection. Never holds the key. */
177
+ export type MCPApiKeyConfig = z.infer<typeof MCPApiKeyConfigSchema>;
178
+
165
179
  export type MCPToolCollectionObject = z.infer<typeof MCPToolCollectionObjectSchema>;
166
180
 
167
181
  export type VertesiaSDKToolCollectionObject = z.infer<typeof VertesiaSDKToolCollectionObjectSchema>;
@@ -296,6 +310,8 @@ export const APP_ARTIFACT_TYPES = [
296
310
  'dashboard',
297
311
  'activity',
298
312
  'tool',
313
+ 'hook',
314
+ 'subscription',
299
315
  ] as const;
300
316
 
301
317
  export type AppArtifactType = (typeof APP_ARTIFACT_TYPES)[number];
@@ -304,7 +320,7 @@ export type AppArtifactType = (typeof APP_ARTIFACT_TYPES)[number];
304
320
  * A single platform artifact the App Solution Architect requires the build to create.
305
321
  * `id` is the app-owned in-code id the implementation must register and reference
306
322
  * (e.g. `app:<name>:main:extract-item` for interactions/agents, `app:<name>:<type>` for
307
- * types, `app:<name>:<process>` for processes).
323
+ * types, `app:<name>:<process>` for processes, and `app:<name>:<local-id>` for hooks/subscriptions).
308
324
  */
309
325
  /**
310
326
  * Build progress for one artifact, maintained by the developer agent as a living checklist:
@@ -337,10 +353,10 @@ export interface AppPlannedArtifact {
337
353
 
338
354
  /**
339
355
  * Structured result the App Solution Architect emits alongside its prose artifacts — the
340
- * machine-readable contract for the build. The implementation MUST create and successfully
341
- * exercise every required artifact before building a deployable version. Persisted into the app repo as
342
- * {@link APP_CAPABILITY_MANIFEST_PATH} so it survives across runs and the version-build
343
- * capability gate can verify against it deterministically. If the builder finds the plan
356
+ * machine-readable contract for the build. The implementation MUST register every required artifact
357
+ * before building a candidate, then successfully exercise it after that candidate is installed and
358
+ * version-pinned. Persisted into the app repo as {@link APP_CAPABILITY_MANIFEST_PATH} so it survives
359
+ * across runs and the package-registration gate can verify it deterministically. If the builder finds the plan
344
360
  * wrong or insufficient, the orchestrator relaunches the architect to revise the manifest;
345
361
  * the gate always checks against the latest committed copy.
346
362
  */
@@ -600,10 +616,17 @@ export const APP_PACKAGE_SCOPES = [
600
616
  'settings',
601
617
  'widgets',
602
618
  'activities',
619
+ 'hooks',
620
+ 'subscriptions',
603
621
  'all',
604
622
  ] as const;
605
623
 
606
624
  export type AppPackageScope = (typeof APP_PACKAGE_SCOPES)[number];
625
+ export type AppPackageEventHook = z.infer<typeof AppPackageEventHookSchema>;
626
+ export type AppPackageHooks = z.infer<typeof AppPackageHooksSchema>;
627
+ export type AppEventHookDelivery = z.infer<typeof AppEventHookDeliverySchema>;
628
+ export type AppEventHookPayload = z.infer<typeof AppEventHookPayloadSchema>;
629
+ export type AppEventSubscriptionDefinition = z.infer<typeof AppEventSubscriptionDefinitionSchema>;
607
630
  export type AppPackage = z.infer<typeof AppPackageSchema>;
608
631
 
609
632
  /**
@@ -663,6 +686,12 @@ export interface OrphanedAppInstallation extends Omit<AppInstallation, 'manifest
663
686
  export type OAuthClientCredentials = z.infer<typeof OAuthClientCredentialsSchema>;
664
687
 
665
688
  export type AppOAuthCollectionParams = z.infer<typeof AppOAuthCollectionParamsSchema>;
689
+
690
+ /** One installer-supplied MCP API key. */
691
+ export type McpApiKeyCredential = z.infer<typeof McpApiKeyCredentialSchema>;
692
+
693
+ /** Installer-supplied MCP API keys, keyed by collection id. */
694
+ export type AppApiKeyCollectionParams = z.infer<typeof AppApiKeyCollectionParamsSchema>;
666
695
  export type AppOAuthProviderParams = z.infer<typeof AppOAuthProviderParamsSchema>;
667
696
 
668
697
  export type AppInstallationPayload = z.infer<typeof AppInstallationPayloadSchema>;
@@ -697,6 +726,15 @@ export interface McpOAuthCollectionRef {
697
726
  collection_id: string;
698
727
  }
699
728
 
729
+ /**
730
+ * Payload for storing the static bearer token of an `auth: 'api_key'` MCP collection.
731
+ * The key is write-only — it is never echoed back by any endpoint.
732
+ */
733
+ export type SetMcpApiKeyRequest = z.infer<typeof SetMcpApiKeyRequestSchema>;
734
+
735
+ /** Whether an `auth: 'api_key'` MCP collection has a key stored, plus a display-only hint. */
736
+ export type McpApiKeyStatus = z.infer<typeof McpApiKeyStatusSchema>;
737
+
700
738
  export type McpOAuthTokenRequest = z.infer<typeof McpOAuthTokenRequestSchema>;
701
739
 
702
740
  export type McpOAuthTokenResponse = z.infer<typeof McpOAuthTokenResponseSchema>;
@@ -873,15 +911,11 @@ export type ValidateUrlResponse = z.infer<typeof ValidateUrlResponseSchema>;
873
911
  * Result of DELETE /api/v1/apps/:id. With `?confirm=true` the cascade runs and
874
912
  * `deleted: true` is set; without it the endpoint returns a dry-run summary so
875
913
  * the UI can show what would be removed.
914
+ *
915
+ * Inferred from the published component rather than hand-written: the endpoint
916
+ * had been declaring `CountResult`, so response validation reported a missing
917
+ * `count` and every field here as unexpected — and in local development, where
918
+ * the check fails closed, that surfaced as a 500 raised AFTER the app was
919
+ * already deleted. Deriving the type is what keeps the two from drifting again.
876
920
  */
877
- export interface AppDeleteSummary {
878
- confirmed: boolean;
879
- app_id: string;
880
- app_name: string;
881
- versions: number;
882
- installations: number;
883
- storage_prefix: string;
884
- git_repo_url?: string;
885
- deleted: boolean;
886
- warnings: string[];
887
- }
921
+ export type AppDeleteSummary = z.infer<typeof AppDeleteSummarySchema>;
package/src/index.ts CHANGED
@@ -75,6 +75,7 @@ export type {
75
75
  ZenoBulkContentObjectExportSplitShardRequest,
76
76
  ZenoBulkContentObjectExportSplitShardResponse,
77
77
  } from './store/store.js';
78
+ export * from './sts-errors.js';
78
79
  export * from './sts-token-types.js';
79
80
  export * from './tenant.js';
80
81
  export * from './tool-execution.js';
@@ -63,6 +63,32 @@ describe('event subscription input validation', () => {
63
63
  expect(result.errors.join(' ')).toContain('timeout_ms');
64
64
  });
65
65
 
66
+ it('accepts a fully resolved app hook target', () => {
67
+ const result = getCreateEventSubscriptionValidationResult(
68
+ validCreate({
69
+ target: {
70
+ type: 'app',
71
+ app_id: 'content-app',
72
+ installation_id: 'installation-1',
73
+ hook: 'content-updated',
74
+ url: 'https://gateway.example/apps/content-app/api/hooks/content-updated',
75
+ },
76
+ }),
77
+ );
78
+ expect(result.valid).toBe(true);
79
+ });
80
+
81
+ it('requires app hook identity and URL fields', () => {
82
+ const result = getCreateEventSubscriptionValidationResult(
83
+ validCreate({ target: { type: 'app', app_id: '', installation_id: '', hook: '', url: '' } }),
84
+ );
85
+ expect(result.valid).toBe(false);
86
+ expect(result.errors.join(' ')).toContain('app_id');
87
+ expect(result.errors.join(' ')).toContain('installation_id');
88
+ expect(result.errors.join(' ')).toContain('hook');
89
+ expect(result.errors.join(' ')).toContain('url');
90
+ });
91
+
66
92
  it('requires endpoint for workflow targets', () => {
67
93
  const result = getCreateEventSubscriptionValidationResult(
68
94
  validCreate({ target: { type: 'workflow' } as never }),
@@ -163,8 +163,8 @@ function validateTarget(target: unknown, errors: string[]): void {
163
163
  return;
164
164
  }
165
165
  const type = target.type;
166
- if (type !== 'workflow' && type !== 'webhook' && type !== 'agent' && type !== 'process') {
167
- errors.push('target.type must be one of workflow, webhook, agent, process');
166
+ if (type !== 'workflow' && type !== 'webhook' && type !== 'app' && type !== 'agent' && type !== 'process') {
167
+ errors.push('target.type must be one of workflow, webhook, app, agent, process');
168
168
  return;
169
169
  }
170
170
  const t = target as EventDeliveryTargetInput;
@@ -204,6 +204,19 @@ function validateTarget(target: unknown, errors: string[]): void {
204
204
  }
205
205
  break;
206
206
  }
207
+ case 'app': {
208
+ for (const field of ['app_id', 'installation_id', 'hook', 'url'] as const) {
209
+ if (typeof t[field] !== 'string' || t[field].length === 0) {
210
+ errors.push(`app target requires a non-empty "${field}"`);
211
+ }
212
+ }
213
+ if (t.timeout_ms !== undefined) {
214
+ if (!Number.isInteger(t.timeout_ms) || t.timeout_ms <= 0 || t.timeout_ms > MAX_WEBHOOK_TIMEOUT_MS) {
215
+ errors.push(`app target.timeout_ms must be an integer between 1 and ${MAX_WEBHOOK_TIMEOUT_MS}`);
216
+ }
217
+ }
218
+ break;
219
+ }
207
220
  case 'process':
208
221
  if ((typeof t.process_ref !== 'string' || t.process_ref.length === 0) && !isRecord(t.process_definition)) {
209
222
  errors.push('process target requires "process_ref" or an inline "process_definition"');
@@ -5,6 +5,10 @@ import type {
5
5
  AgentDeliveryMatchModeSchema,
6
6
  AgentEventDeliveryTargetSchema,
7
7
  AgentSemanticEvaluatorSchema,
8
+ AppEventDeliveryTargetInputSchema,
9
+ AppEventDeliveryTargetSchema,
10
+ CancelEventDeliveryIntentsPayloadSchema,
11
+ CancelEventDeliveryIntentsResponseSchema,
8
12
  CreateEventIngestChannelPayloadSchema,
9
13
  EventDeliveryIntentStatusSchema,
10
14
  EventDeliveryIntentSummarySchema,
@@ -217,6 +221,8 @@ export type WorkflowEventDeliveryTarget = z.infer<typeof WorkflowEventDeliveryTa
217
221
 
218
222
  export type WebhookEventDeliveryTarget = z.infer<typeof WebhookEventDeliveryTargetSchema>;
219
223
 
224
+ export type AppEventDeliveryTarget = z.infer<typeof AppEventDeliveryTargetSchema>;
225
+
220
226
  export const DEFAULT_EVENT_AGENT_INTERACTION_REF = 'sys:GeneralAgent';
221
227
 
222
228
  export type AgentDeliveryMatchMode = z.infer<typeof AgentDeliveryMatchModeSchema>;
@@ -242,6 +248,7 @@ export interface ProcessEventDeliveryTarget {
242
248
  export type EventDeliveryTarget =
243
249
  | WorkflowEventDeliveryTarget
244
250
  | WebhookEventDeliveryTarget
251
+ | AppEventDeliveryTarget
245
252
  | AgentEventDeliveryTarget
246
253
  | ProcessEventDeliveryTarget;
247
254
 
@@ -254,9 +261,12 @@ export type WorkflowEventDeliveryTargetInput = z.infer<typeof WorkflowEventDeliv
254
261
 
255
262
  export type WebhookEventDeliveryTargetInput = z.infer<typeof WebhookEventDeliveryTargetInputSchema>;
256
263
 
264
+ export type AppEventDeliveryTargetInput = z.infer<typeof AppEventDeliveryTargetInputSchema>;
265
+
257
266
  export type EventDeliveryTargetInput =
258
267
  | WorkflowEventDeliveryTargetInput
259
268
  | WebhookEventDeliveryTargetInput
269
+ | AppEventDeliveryTargetInput
260
270
  | AgentEventDeliveryTarget
261
271
  | ProcessEventDeliveryTarget;
262
272
 
@@ -284,6 +294,9 @@ export interface EventSubscription {
284
294
  protected: boolean;
285
295
  enabled: boolean;
286
296
  priority?: EventPriority;
297
+ app_installation_id?: string;
298
+ app_id?: string;
299
+ app_subscription_id?: string;
287
300
  created_by?: string;
288
301
  updated_by?: string;
289
302
  created_at?: string;
@@ -387,6 +400,32 @@ export interface ListEventSubscriptionsQuery {
387
400
  scope?: ('account' | 'project')[];
388
401
  sort_by?: EventSubscriptionSortField;
389
402
  sort_order?: 'asc' | 'desc';
403
+ app_installation_id?: string;
404
+ }
405
+
406
+ /** Trusted Studio -> Zeno request used to provision subscriptions declared by an installed app. */
407
+ export interface ProvisionAppEventSubscriptionsRequest {
408
+ account_id: string;
409
+ project_id: string;
410
+ subscriptions: Array<
411
+ CreateEventSubscriptionPayload & {
412
+ target: AppEventDeliveryTargetInput;
413
+ app_installation_id: string;
414
+ app_id: string;
415
+ app_subscription_id: string;
416
+ }
417
+ >;
418
+ }
419
+
420
+ /** Trusted Studio -> Zeno request used to remove every subscription owned by an app installation. */
421
+ export interface RemoveAppEventSubscriptionsRequest {
422
+ account_id: string;
423
+ project_id: string;
424
+ app_installation_id: string;
425
+ }
426
+
427
+ export interface AppEventSubscriptionsMutationResponse {
428
+ subscription_ids: string[];
390
429
  }
391
430
 
392
431
  export type EventIngestChannelSortField = 'name' | 'source' | 'enabled' | 'updated_at';
@@ -410,6 +449,10 @@ export type EventDeliveryQueueSubscriptionSummary = z.infer<typeof EventDelivery
410
449
 
411
450
  export type EventDeliveryQueueSummaryResponse = z.infer<typeof EventDeliveryQueueSummaryResponseSchema>;
412
451
 
452
+ export type CancelEventDeliveryIntentsPayload = z.infer<typeof CancelEventDeliveryIntentsPayloadSchema>;
453
+
454
+ export type CancelEventDeliveryIntentsResponse = z.infer<typeof CancelEventDeliveryIntentsResponseSchema>;
455
+
413
456
  export interface PublishPlatformEventPayload {
414
457
  event: PlatformEvent;
415
458
  priority?: EventPriority;
@@ -273,6 +273,9 @@ export const ContentTypeIntakePolicySchema: JSONObject = {
273
273
  type: 'string',
274
274
  },
275
275
  },
276
+ include_thoughts: {
277
+ type: 'boolean',
278
+ },
276
279
  },
277
280
  required: ['_option_id'],
278
281
  additionalProperties: false,
@@ -345,6 +348,9 @@ export const ContentTypeIntakePolicySchema: JSONObject = {
345
348
  type: 'string',
346
349
  },
347
350
  },
351
+ include_thoughts: {
352
+ type: 'boolean',
353
+ },
348
354
  },
349
355
  required: ['_option_id'],
350
356
  additionalProperties: false,
@@ -371,6 +377,9 @@ export const ContentTypeIntakePolicySchema: JSONObject = {
371
377
  type: 'string',
372
378
  },
373
379
  },
380
+ include_thoughts: {
381
+ type: 'boolean',
382
+ },
374
383
  },
375
384
  required: ['_option_id'],
376
385
  additionalProperties: false,
@@ -433,6 +442,9 @@ export const ContentTypeIntakePolicySchema: JSONObject = {
433
442
  type: 'string',
434
443
  },
435
444
  },
445
+ include_thoughts: {
446
+ type: 'boolean',
447
+ },
436
448
  },
437
449
  required: ['_option_id'],
438
450
  additionalProperties: false,
@@ -515,6 +527,9 @@ export const ContentTypeIntakePolicySchema: JSONObject = {
515
527
  type: 'string',
516
528
  enum: ['low', 'high', 'auto'],
517
529
  },
530
+ include_thoughts: {
531
+ type: 'boolean',
532
+ },
518
533
  },
519
534
  required: ['_option_id'],
520
535
  additionalProperties: false,
@@ -541,6 +556,9 @@ export const ContentTypeIntakePolicySchema: JSONObject = {
541
556
  type: 'string',
542
557
  },
543
558
  },
559
+ include_thoughts: {
560
+ type: 'boolean',
561
+ },
544
562
  },
545
563
  required: ['_option_id'],
546
564
  additionalProperties: false,
@@ -567,6 +585,9 @@ export const ContentTypeIntakePolicySchema: JSONObject = {
567
585
  type: 'string',
568
586
  },
569
587
  },
588
+ include_thoughts: {
589
+ type: 'boolean',
590
+ },
570
591
  },
571
592
  required: ['_option_id'],
572
593
  additionalProperties: false,
@@ -1169,6 +1190,12 @@ export const ContentTypeIntakePolicySchema: JSONObject = {
1169
1190
  max_tokens: {
1170
1191
  type: 'number',
1171
1192
  },
1193
+ effort: {
1194
+ $ref: '#/$defs/ReasoningEffort',
1195
+ },
1196
+ reasoning_effort: {
1197
+ $ref: '#/$defs/ReasoningEffort',
1198
+ },
1172
1199
  temperature: {
1173
1200
  type: 'number',
1174
1201
  },
@@ -1191,6 +1218,9 @@ export const ContentTypeIntakePolicySchema: JSONObject = {
1191
1218
  type: 'string',
1192
1219
  enum: ['low', 'high', 'auto'],
1193
1220
  },
1221
+ include_thoughts: {
1222
+ type: 'boolean',
1223
+ },
1194
1224
  },
1195
1225
  required: ['_option_id'],
1196
1226
  additionalProperties: false,
@@ -1221,6 +1251,9 @@ export const ContentTypeIntakePolicySchema: JSONObject = {
1221
1251
  type: 'string',
1222
1252
  enum: ['low', 'high', 'auto'],
1223
1253
  },
1254
+ include_thoughts: {
1255
+ type: 'boolean',
1256
+ },
1224
1257
  },
1225
1258
  required: ['_option_id'],
1226
1259
  additionalProperties: false,
@@ -1264,6 +1297,9 @@ export const ContentTypeIntakePolicySchema: JSONObject = {
1264
1297
  type: 'string',
1265
1298
  },
1266
1299
  },
1300
+ include_thoughts: {
1301
+ type: 'boolean',
1302
+ },
1267
1303
  },
1268
1304
  required: ['_option_id'],
1269
1305
  additionalProperties: false,
@@ -737,6 +737,15 @@ export enum FileProcessingStatus {
737
737
 
738
738
  export type ConversationFile = z.infer<typeof ConversationFileSchema>;
739
739
 
740
+ /**
741
+ * A file is deliverable when it is ready and has not yet been delivered to the agent as part
742
+ * of a user message. Deliverable files get attached to the next message; consumed ones stay
743
+ * reachable to tools via artifact_path/md_path but are not re-attached.
744
+ */
745
+ export function isDeliverableFile(file: ConversationFile): boolean {
746
+ return file.status === FileProcessingStatus.READY && !file.consumed_at;
747
+ }
748
+
740
749
  /**
741
750
  * Details for file processing SYSTEM messages.
742
751
  * Used when type is AgentMessageType.SYSTEM with system_type: 'file_processing'.
@@ -0,0 +1,13 @@
1
+ export const REQUESTED_SCOPE_UNAVAILABLE_ERROR_CODE = 'requested_scope_unavailable';
2
+ export const NO_ACCESSIBLE_ACCOUNT_ERROR_CODE = 'no_accessible_account';
3
+ export const RESTRICTED_ENVIRONMENT_ERROR_CODE = 'restricted_environment';
4
+ export const TOKEN_ISSUANCE_FORBIDDEN_ERROR_CODE = 'token_issuance_forbidden';
5
+
6
+ export const ISSUE_TOKEN_FORBIDDEN_ERROR_CODES = [
7
+ REQUESTED_SCOPE_UNAVAILABLE_ERROR_CODE,
8
+ NO_ACCESSIBLE_ACCOUNT_ERROR_CODE,
9
+ RESTRICTED_ENVIRONMENT_ERROR_CODE,
10
+ TOKEN_ISSUANCE_FORBIDDEN_ERROR_CODE,
11
+ ] as const;
12
+
13
+ export type IssueTokenForbiddenErrorCode = (typeof ISSUE_TOKEN_FORBIDDEN_ERROR_CODES)[number];
@@ -7,6 +7,7 @@ import type {
7
7
  AgentTokenRequestSchema,
8
8
  ApiKeyTokenRequestSchema,
9
9
  EnvironmentTokenRequestSchema,
10
+ IssueTokenForbiddenResponseSchema,
10
11
  IssueTokenRequestSchema,
11
12
  IssueTokenResponseSchema,
12
13
  ProjectTokenRequestSchema,
@@ -91,6 +92,7 @@ export interface TokenResponse {
91
92
  }
92
93
 
93
94
  export type IssueTokenResponse = z.infer<typeof IssueTokenResponseSchema>;
95
+ export type IssueTokenForbiddenResponse = z.infer<typeof IssueTokenForbiddenResponseSchema>;
94
96
 
95
97
  export interface ValidateTokenResponse {
96
98
  valid: boolean;
package/src/user.ts CHANGED
@@ -59,7 +59,7 @@ export const EARLY_ACCESS_ANNOTATION = 'early-access';
59
59
  * restricted (`preview`/`preprod`) environment because they lack the {@link EARLY_ACCESS_ANNOTATION}
60
60
  * annotation. The UI keys its dedicated rejection screen off this code.
61
61
  */
62
- export const RESTRICTED_ENVIRONMENT_ERROR_CODE = 'restricted_environment';
62
+ export { RESTRICTED_ENVIRONMENT_ERROR_CODE } from './sts-errors.js';
63
63
 
64
64
  /**
65
65
  * The account as it crosses the wire.
@@ -0,0 +1,13 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { ApiVersions, CURRENT_API_VERSION, CURRENT_API_VERSION_HEADER_VALUE } from './versions.js';
3
+
4
+ describe('API versions', () => {
5
+ it('keeps the current API version aligned with the latest milestone', () => {
6
+ const milestones = Object.values(ApiVersions).filter(
7
+ (version): version is number => typeof version === 'number',
8
+ );
9
+
10
+ expect(CURRENT_API_VERSION).toBe(Math.max(...milestones));
11
+ expect(CURRENT_API_VERSION_HEADER_VALUE).toBe(String(CURRENT_API_VERSION));
12
+ });
13
+ });
package/src/versions.ts CHANGED
@@ -27,3 +27,15 @@ export enum ApiVersions {
27
27
  */
28
28
  REQUEST_CONTRACT_ENFORCEMENT_V1 = 20260803,
29
29
  }
30
+
31
+ /**
32
+ * The API version used by current clients and published as the current OpenAPI shape.
33
+ *
34
+ * Keep this explicit rather than deriving it at runtime: promoting a milestone to the client
35
+ * default is a deliberate compatibility decision. The versions test ensures this alias is
36
+ * reconsidered whenever a newer milestone is added.
37
+ */
38
+ export const CURRENT_API_VERSION = ApiVersions.REQUEST_CONTRACT_ENFORCEMENT_V1;
39
+
40
+ /** The current API version formatted for the {@link VERSION_HEADER} wire value. */
41
+ export const CURRENT_API_VERSION_HEADER_VALUE = String(CURRENT_API_VERSION);
@@ -114,11 +114,18 @@ export interface AgentRunCompletedEvent extends BaseAgentEvent {
114
114
  totalToolCalls: number;
115
115
  /** Total LLM calls made */
116
116
  totalLlmCalls: number;
117
- /** Cumulative token usage */
118
- totalTokens?: {
117
+ /**
118
+ * Cumulative token usage breakdown for the run.
119
+ *
120
+ * No `totalTokens` (and no `total` here): an input+output sum mixes
121
+ * differently-priced quantities and nothing consumes it — token analytics
122
+ * aggregate the per-call LlmCallEvent fields. This also keeps
123
+ * `$.totalTokens` scalar-only in the telemetry `event_data` column
124
+ * (LlmCallEvent is the only current producer of that path).
125
+ */
126
+ tokenUsage?: {
119
127
  input: number;
120
128
  output: number;
121
- total: number;
122
129
  };
123
130
  /** If conversation was ended via end_conversation tool */
124
131
  endConversation?: {