@sequenceholdings/managed-functions 0.4.2 → 0.4.4

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 (37) hide show
  1. package/README.md +86 -2
  2. package/dist/capabilities.d.ts +28 -0
  3. package/dist/capabilities.js +6 -0
  4. package/dist/config.d.ts +2 -1
  5. package/dist/config.js +5 -2
  6. package/dist/deployed-policy.js +9 -2
  7. package/dist/directory-manifest.d.ts +1 -0
  8. package/dist/directory-manifest.js +3 -1
  9. package/dist/directory-roster-contract.d.ts +22 -0
  10. package/dist/directory-roster-contract.js +24 -0
  11. package/dist/index.d.ts +4 -1
  12. package/dist/index.js +4 -1
  13. package/dist/invocation-contract.d.ts +25 -2
  14. package/dist/invocation-contract.js +21 -6
  15. package/dist/invocation.d.ts +2 -1
  16. package/dist/invocation.js +48 -38
  17. package/dist/lattice-provenance-contract.d.ts +88 -0
  18. package/dist/lattice-provenance-contract.js +10 -1
  19. package/dist/lattice-provenance.d.ts +2 -1
  20. package/dist/lattice-provenance.js +3 -0
  21. package/dist/monitoring-contract.d.ts +2 -2
  22. package/dist/monitoring-contract.js +2 -2
  23. package/dist/orm.d.ts +4 -1
  24. package/dist/preflight-invocation.js +31 -5
  25. package/dist/preflight-service-directory-roster.d.ts +2 -0
  26. package/dist/preflight-service-directory-roster.js +17 -0
  27. package/dist/preflight.js +3 -0
  28. package/dist/processes-contract.d.ts +20 -0
  29. package/dist/processes-contract.js +7 -1
  30. package/dist/processes.d.ts +2 -1
  31. package/dist/processes.js +6 -0
  32. package/dist/runtime.cjs +217 -46
  33. package/dist/service-directory-roster.d.ts +7 -0
  34. package/dist/service-directory-roster.js +25 -0
  35. package/dist/service-directory.d.ts +2 -0
  36. package/dist/service-directory.js +2 -0
  37. package/package.json +3 -3
@@ -54,6 +54,8 @@ export declare const functionLatticeParallelSnapshotQuerySchema: z.ZodObject<{
54
54
  export type FunctionLatticeParallelSnapshotQuery = z.infer<typeof functionLatticeParallelSnapshotQuerySchema>;
55
55
  export declare const functionLatticeContextRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
56
56
  operation: z.ZodLiteral<"getExecutionContext">;
57
+ }, z.core.$strict>, z.ZodObject<{
58
+ operation: z.ZodLiteral<"getRunCreatorAccess">;
57
59
  }, z.core.$strict>, z.ZodObject<{
58
60
  nodeId: z.ZodString;
59
61
  stepId: z.ZodOptional<z.ZodString>;
@@ -69,6 +71,92 @@ export declare const functionLatticeContextRequestSchema: z.ZodDiscriminatedUnio
69
71
  operation: z.ZodLiteral<"getParallelSnapshot">;
70
72
  }, z.core.$strict>], "operation">;
71
73
  export type FunctionLatticeContextRequest = z.infer<typeof functionLatticeContextRequestSchema>;
74
+ export declare const functionLatticeRunCreatorAccessSchema: z.ZodObject<{
75
+ receiverFunctionOrgId: z.ZodString;
76
+ parent: z.ZodOptional<z.ZodNullable<z.ZodObject<{
77
+ runId: z.ZodString;
78
+ processId: z.ZodString;
79
+ processVersion: z.ZodString;
80
+ bundleHash: z.ZodString;
81
+ stepId: z.ZodString;
82
+ nodeId: z.ZodString;
83
+ attempt: z.ZodNumber;
84
+ input: z.ZodUnknown;
85
+ branch: z.ZodNullable<z.ZodObject<{
86
+ id: z.ZodString;
87
+ index: z.ZodNumber;
88
+ item: z.ZodUnknown;
89
+ }, z.core.$strip>>;
90
+ }, z.core.$strip>>>;
91
+ run: z.ZodObject<{
92
+ id: z.ZodString;
93
+ processId: z.ZodString;
94
+ processVersion: z.ZodString;
95
+ bundleHash: z.ZodString;
96
+ entity: z.ZodNullable<z.ZodObject<{
97
+ type: z.ZodString;
98
+ id: z.ZodString;
99
+ }, z.core.$strip>>;
100
+ startProvenance: z.ZodOptional<z.ZodNullable<z.ZodObject<{
101
+ version: z.ZodLiteral<1>;
102
+ issuer: z.ZodString;
103
+ runId: z.ZodString;
104
+ processId: z.ZodString;
105
+ processVersion: z.ZodString;
106
+ bundleHash: z.ZodString;
107
+ actorSub: z.ZodString;
108
+ startedBy: z.ZodNullable<z.ZodString>;
109
+ mode: z.ZodEnum<{
110
+ system: "system";
111
+ manual: "manual";
112
+ trigger: "trigger";
113
+ schedule: "schedule";
114
+ subprocess: "subprocess";
115
+ intervention: "intervention";
116
+ }>;
117
+ basis: z.ZodEnum<{
118
+ fga_invoker: "fga_invoker";
119
+ trusted_trigger: "trusted_trigger";
120
+ schedule_author: "schedule_author";
121
+ schedule_no_author: "schedule_no_author";
122
+ trusted_service: "trusted_service";
123
+ subprocess_spawn_gate: "subprocess_spawn_gate";
124
+ subprocess_parent_starter: "subprocess_parent_starter";
125
+ subprocess_existing_child: "subprocess_existing_child";
126
+ intervention_actor: "intervention_actor";
127
+ }>;
128
+ authorizedAt: z.ZodISODateTime;
129
+ schedule: z.ZodNullable<z.ZodObject<{
130
+ scheduleId: z.ZodString;
131
+ scheduledAt: z.ZodISODateTime;
132
+ }, z.core.$strict>>;
133
+ }, z.core.$strict>>>;
134
+ }, z.core.$strip>;
135
+ step: z.ZodObject<{
136
+ id: z.ZodString;
137
+ nodeId: z.ZodString;
138
+ attempt: z.ZodNumber;
139
+ runAsServiceAccount: z.ZodNullable<z.ZodString>;
140
+ }, z.core.$strip>;
141
+ receiver: z.ZodObject<{
142
+ functionId: z.ZodString;
143
+ versionId: z.ZodString;
144
+ invocationId: z.ZodString;
145
+ invoker: z.ZodObject<{
146
+ sub: z.ZodString;
147
+ kind: z.ZodString;
148
+ authenticationMethod: z.ZodString;
149
+ }, z.core.$strip>;
150
+ attachedServiceAccountSub: z.ZodString;
151
+ }, z.core.$strip>;
152
+ creator: z.ZodNullable<z.ZodObject<{
153
+ sub: z.ZodString;
154
+ tenant: z.ZodNullable<z.ZodString>;
155
+ platformOperator: z.ZodBoolean;
156
+ }, z.core.$strict>>;
157
+ observedAt: z.ZodISODateTime;
158
+ }, z.core.$strip>;
159
+ export type FunctionLatticeRunCreatorAccess = z.infer<typeof functionLatticeRunCreatorAccessSchema>;
72
160
  export declare const functionLatticeExecutionContextSchema: z.ZodObject<{
73
161
  receiverFunctionOrgId: z.ZodString;
74
162
  parent: z.ZodOptional<z.ZodNullable<z.ZodObject<{
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FunctionLatticeContextError = exports.functionLatticeParallelSnapshotSchema = exports.functionLatticeHumanCompletionsPageSchema = exports.functionLatticeHumanCompletionSchema = exports.functionLatticeExecutionContextSchema = exports.functionLatticeContextRequestSchema = exports.functionLatticeParallelSnapshotQuerySchema = exports.functionLatticeHumanCompletionsQuerySchema = exports.functionLatticeHumanCompletionQuerySchema = exports.functionLatticeStartProvenanceSchema = exports.FUNCTION_LATTICE_CONTEXT_PATH = exports.FUNCTION_LATTICE_EXECUTION_TOKEN_HEADER = void 0;
3
+ exports.FunctionLatticeContextError = exports.functionLatticeParallelSnapshotSchema = exports.functionLatticeHumanCompletionsPageSchema = exports.functionLatticeHumanCompletionSchema = exports.functionLatticeExecutionContextSchema = exports.functionLatticeRunCreatorAccessSchema = exports.functionLatticeContextRequestSchema = exports.functionLatticeParallelSnapshotQuerySchema = exports.functionLatticeHumanCompletionsQuerySchema = exports.functionLatticeHumanCompletionQuerySchema = exports.functionLatticeStartProvenanceSchema = exports.FUNCTION_LATTICE_CONTEXT_PATH = exports.FUNCTION_LATTICE_EXECUTION_TOKEN_HEADER = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.FUNCTION_LATTICE_EXECUTION_TOKEN_HEADER = 'x-sequence-lattice-execution-token';
6
6
  exports.FUNCTION_LATTICE_CONTEXT_PATH = '/api/managed-functions/lattice/context';
@@ -29,6 +29,7 @@ exports.functionLatticeHumanCompletionsQuerySchema = exports.functionLatticeHuma
29
29
  exports.functionLatticeParallelSnapshotQuerySchema = zod_1.z.strictObject({ nodeId: identifier, ancestorNodeId: identifier });
30
30
  exports.functionLatticeContextRequestSchema = zod_1.z.discriminatedUnion('operation', [
31
31
  zod_1.z.strictObject({ operation: zod_1.z.literal('getExecutionContext') }),
32
+ zod_1.z.strictObject({ operation: zod_1.z.literal('getRunCreatorAccess') }),
32
33
  exports.functionLatticeHumanCompletionQuerySchema.extend({
33
34
  operation: zod_1.z.literal('getHumanCompletion'),
34
35
  }),
@@ -62,6 +63,14 @@ const executionIdentity = zod_1.z.object({
62
63
  attachedServiceAccountSub: principal,
63
64
  }),
64
65
  });
66
+ exports.functionLatticeRunCreatorAccessSchema = executionIdentity.extend({
67
+ creator: zod_1.z.strictObject({
68
+ sub: principal,
69
+ tenant: zod_1.z.string().min(1).max(64).nullable(),
70
+ platformOperator: zod_1.z.boolean(),
71
+ }).nullable(),
72
+ observedAt: zod_1.z.iso.datetime({ offset: true }),
73
+ });
65
74
  exports.functionLatticeExecutionContextSchema = executionIdentity.extend({
66
75
  input: zod_1.z.unknown(),
67
76
  ctxSnapshot: zod_1.z.object({
@@ -1,4 +1,4 @@
1
- import { type FunctionLatticeExecutionContext, type FunctionLatticeHumanCompletion, type FunctionLatticeHumanCompletionQuery, type FunctionLatticeHumanCompletionsQuery, type FunctionLatticeHumanCompletionsPage, type FunctionLatticeParallelSnapshot, type FunctionLatticeParallelSnapshotQuery } from './lattice-provenance-contract';
1
+ import { type FunctionLatticeRunCreatorAccess, type FunctionLatticeExecutionContext, type FunctionLatticeHumanCompletion, type FunctionLatticeHumanCompletionQuery, type FunctionLatticeHumanCompletionsQuery, type FunctionLatticeHumanCompletionsPage, type FunctionLatticeParallelSnapshot, type FunctionLatticeParallelSnapshotQuery } from './lattice-provenance-contract';
2
2
  export * from './lattice-provenance-contract';
3
3
  export interface FunctionLatticeClientOptions {
4
4
  request: {
@@ -9,6 +9,7 @@ export interface FunctionLatticeClientOptions {
9
9
  }
10
10
  export interface FunctionLatticeClient {
11
11
  getExecutionContext(): Promise<FunctionLatticeExecutionContext>;
12
+ getRunCreatorAccess(): Promise<FunctionLatticeRunCreatorAccess>;
12
13
  getHumanCompletion(query: FunctionLatticeHumanCompletionQuery): Promise<FunctionLatticeHumanCompletion>;
13
14
  getHumanCompletions(query: FunctionLatticeHumanCompletionsQuery): Promise<FunctionLatticeHumanCompletionsPage>;
14
15
  getParallelSnapshot(query: FunctionLatticeParallelSnapshotQuery): Promise<FunctionLatticeParallelSnapshot>;
@@ -139,6 +139,9 @@ function createFunctionLatticeClient({ request, baseUrl, fetchImpl = globalThis.
139
139
  getExecutionContext() {
140
140
  return read({ body: { operation: 'getExecutionContext' }, schema: lattice_provenance_contract_1.functionLatticeExecutionContextSchema, executions: (value) => [value] });
141
141
  },
142
+ getRunCreatorAccess() {
143
+ return read({ body: { operation: 'getRunCreatorAccess' }, schema: lattice_provenance_contract_1.functionLatticeRunCreatorAccessSchema, executions: value => [value] });
144
+ },
142
145
  async getHumanCompletion(query) {
143
146
  const completion = await read({
144
147
  body: { ...query, operation: 'getHumanCompletion' },
@@ -3,8 +3,8 @@ import { functionMonitoringAnnotationSchema } from './monitoring-annotations';
3
3
  export type { DeltaEventInput as MonitoringDeltaEvent } from './monitoring-events';
4
4
  export declare const FUNCTION_MONITORING_TOKEN_HEADER = "x-sequence-monitoring-service-token";
5
5
  export declare const FUNCTION_MONITORING_DELIVERIES_PATH = "/api/managed-functions/monitoring/deliveries";
6
- export declare const MONITORING_PRODUCER_CAPABILITY = "emit_monitoring";
7
- export declare const MONITORING_CATALOG_CAPABILITY = "read_monitoring_catalog";
6
+ export declare const MONITORING_PRODUCER_CAPABILITY = "emit-monitoring";
7
+ export declare const MONITORING_CATALOG_CAPABILITY = "read-monitoring-catalog";
8
8
  export declare const MAX_MONITORING_DELIVERY_BYTES: number;
9
9
  export declare const functionMonitoringScopesSchema: z.ZodObject<{
10
10
  producers: z.ZodArray<z.ZodString>;
@@ -9,8 +9,8 @@ const monitoring_events_1 = require("./monitoring-events");
9
9
  const monitoring_annotations_1 = require("./monitoring-annotations");
10
10
  exports.FUNCTION_MONITORING_TOKEN_HEADER = 'x-sequence-monitoring-service-token';
11
11
  exports.FUNCTION_MONITORING_DELIVERIES_PATH = '/api/managed-functions/monitoring/deliveries';
12
- exports.MONITORING_PRODUCER_CAPABILITY = 'emit_monitoring';
13
- exports.MONITORING_CATALOG_CAPABILITY = 'read_monitoring_catalog';
12
+ exports.MONITORING_PRODUCER_CAPABILITY = 'emit-monitoring';
13
+ exports.MONITORING_CATALOG_CAPABILITY = 'read-monitoring-catalog';
14
14
  exports.MAX_MONITORING_DELIVERY_BYTES = 512 * 1024;
15
15
  const producer = zod_1.z.string().min(1).max(41).regex(/^[a-z][a-z0-9_]{0,40}$/);
16
16
  exports.functionMonitoringScopesSchema = zod_1.z.strictObject({
package/dist/orm.d.ts CHANGED
@@ -29,13 +29,16 @@ type SqlQueryVariables = {
29
29
  sql: string;
30
30
  parameters?: Record<string, SqlQueryParameter>;
31
31
  };
32
+ type SqlQueryCell = string | number | boolean | null | SqlQueryCell[] | {
33
+ [key: string]: SqlQueryCell;
34
+ };
32
35
  interface SqlQueryResult {
33
36
  columns: Array<{
34
37
  name: string;
35
38
  type: string;
36
39
  nullable: boolean;
37
40
  }>;
38
- rows: Array<Array<string | number | boolean | null>>;
41
+ rows: Array<Array<SqlQueryCell>>;
39
42
  truncated: boolean;
40
43
  }
41
44
 
@@ -12,20 +12,45 @@ function checkInvocationIdentity({ manifest, capabilities, tooling, cliVersion,
12
12
  const deployed = capabilities?.features.invocation_identity;
13
13
  const feature = deployed ?? capabilities_1.MANAGED_FUNCTION_CAPABILITIES.features.invocation_identity;
14
14
  const details = {
15
- limit: feature.limit, tooling, requiredCli: feature.min_cli,
16
- requiredSdk: feature.min_sdk, cliVersion, sdkVersion,
15
+ limit: feature.limit,
16
+ tooling,
17
+ requiredCli: feature.min_cli,
18
+ requiredSdk: feature.min_sdk,
19
+ cliVersion,
20
+ sdkVersion,
17
21
  };
18
22
  const parsed = invocation_contract_1.functionInvocationIdentityCapabilitySchema.safeParse(invocation);
19
23
  if (!parsed.success) {
20
24
  issues.push((0, preflight_issue_1.createPreflightIssue)({
21
- ...details, field: 'capabilities.invocation',
25
+ ...details,
26
+ field: 'capabilities.invocation',
22
27
  problem: (0, capabilities_1.formatValidationDetail)(parsed.error.issues),
23
28
  }));
24
29
  return;
25
30
  }
31
+ if (parsed.data.caller_capabilities) {
32
+ const observed = capabilities?.features.invocation_caller_capabilities;
33
+ const required = capabilities_1.MANAGED_FUNCTION_CAPABILITIES.features.invocation_caller_capabilities;
34
+ if ((checkDeployment && observed?.supported !== true) ||
35
+ (0, capabilities_1.versionIsOlder)(cliVersion, required.min_cli) ||
36
+ !sdkVersion ||
37
+ (0, sdk_range_1.sdkConstraintIsOlder)(sdkVersion, required.min_sdk)) {
38
+ issues.push((0, preflight_issue_1.createPreflightIssue)({
39
+ limit: required.limit,
40
+ tooling,
41
+ requiredCli: required.min_cli,
42
+ requiredSdk: required.min_sdk,
43
+ cliVersion,
44
+ sdkVersion,
45
+ field: required.field,
46
+ problem: 'Current caller capability reads require deployed support and compatible tooling',
47
+ }));
48
+ }
49
+ }
26
50
  if (checkDeployment && deployed?.supported !== true) {
27
51
  issues.push((0, preflight_issue_1.createPreflightIssue)({
28
- ...details, field: feature.field,
52
+ ...details,
53
+ field: feature.field,
29
54
  problem: 'Invocation identity reads are not supported by this deployment',
30
55
  }));
31
56
  return;
@@ -33,7 +58,8 @@ function checkInvocationIdentity({ manifest, capabilities, tooling, cliVersion,
33
58
  if ((0, capabilities_1.versionIsOlder)(cliVersion, feature.min_cli) ||
34
59
  (sdkVersion && (0, sdk_range_1.sdkConstraintIsOlder)(sdkVersion, feature.min_sdk))) {
35
60
  issues.push((0, preflight_issue_1.createPreflightIssue)({
36
- ...details, field: feature.field,
61
+ ...details,
62
+ field: feature.field,
37
63
  problem: 'the installed tooling does not support managed function invocation identity reads',
38
64
  }));
39
65
  }
@@ -0,0 +1,2 @@
1
+ import type { checkDirectory } from './preflight-service-directory';
2
+ export declare function checkDirectoryRosters({ capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues }: Parameters<typeof checkDirectory>[0]): void;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkDirectoryRosters = checkDirectoryRosters;
4
+ const capabilities_1 = require("./capabilities");
5
+ const preflight_issue_1 = require("./preflight-issue");
6
+ const sdk_range_1 = require("./sdk-range");
7
+ function checkDirectoryRosters({ capabilities, tooling, cliVersion, sdkVersion, checkDeployment, issues }) {
8
+ const deployed = capabilities?.features.directory_rosters;
9
+ const feature = deployed ?? capabilities_1.MANAGED_FUNCTION_CAPABILITIES.features.directory_rosters;
10
+ const details = { field: feature.field, limit: feature.limit, tooling, requiredCli: feature.min_cli, requiredSdk: feature.min_sdk, cliVersion, sdkVersion };
11
+ if (checkDeployment && deployed?.supported !== true) {
12
+ issues.push((0, preflight_issue_1.createPreflightIssue)({ ...details, problem: 'scoped service group rosters are not supported by this deployment' }));
13
+ return;
14
+ }
15
+ if ((0, capabilities_1.versionIsOlder)(cliVersion, feature.min_cli) || (sdkVersion && (0, sdk_range_1.sdkConstraintIsOlder)(sdkVersion, feature.min_sdk)))
16
+ issues.push((0, preflight_issue_1.createPreflightIssue)({ ...details, problem: 'the installed tooling does not support scoped service group rosters' }));
17
+ }
package/dist/preflight.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.preflightManagedFunction = preflightManagedFunction;
4
+ const preflight_service_directory_roster_1 = require("./preflight-service-directory-roster");
4
5
  const capabilities_1 = require("./capabilities");
5
6
  const sdk_range_1 = require("./sdk-range");
6
7
  const preflight_issue_1 = require("./preflight-issue");
@@ -206,6 +207,8 @@ function checkDirectoryDeclarations(args) {
206
207
  return;
207
208
  }
208
209
  const scoped = (directory) => ({ ...args, manifest: { ...args.manifest, capabilities: { ...args.manifest.capabilities, directory } } });
210
+ if (parsed.data.rosters)
211
+ (0, preflight_service_directory_roster_1.checkDirectoryRosters)(args);
209
212
  if (parsed.data.groups)
210
213
  (0, preflight_directory_1.checkDirectory)(scoped({ groups: parsed.data.groups }));
211
214
  if (parsed.data.resolve)
@@ -55,6 +55,21 @@ export declare const functionProcessRunsPageQuerySchema: z.ZodObject<{
55
55
  archived: z.ZodOptional<z.ZodBoolean>;
56
56
  }, z.core.$strict>;
57
57
  export type FunctionProcessRunQuery = z.infer<typeof functionProcessRunQuerySchema>;
58
+ export declare const functionProcessCompletedNodeQuerySchema: z.ZodObject<{
59
+ process: z.ZodString;
60
+ runId: z.ZodString;
61
+ nodeId: z.ZodString;
62
+ }, z.core.$strict>;
63
+ export type FunctionProcessCompletedNodeQuery = z.infer<typeof functionProcessCompletedNodeQuerySchema>;
64
+ export declare const functionProcessCompletedNodeSchema: z.ZodObject<{
65
+ runId: z.ZodString;
66
+ processId: z.ZodString;
67
+ processVersion: z.ZodString;
68
+ nodeId: z.ZodString;
69
+ stepId: z.ZodString;
70
+ completedAt: z.ZodISODateTime;
71
+ }, z.core.$strict>;
72
+ export type FunctionProcessCompletedNode = z.infer<typeof functionProcessCompletedNodeSchema>;
58
73
  export declare const functionProcessCompletedAgentReferenceQuerySchema: z.ZodObject<{
59
74
  process: z.ZodString;
60
75
  runId: z.ZodString;
@@ -95,6 +110,11 @@ export declare const functionProcessReadRequestSchema: z.ZodDiscriminatedUnion<[
95
110
  process: z.ZodString;
96
111
  runId: z.ZodString;
97
112
  operation: z.ZodLiteral<"getRun">;
113
+ }, z.core.$strict>, z.ZodObject<{
114
+ process: z.ZodString;
115
+ runId: z.ZodString;
116
+ nodeId: z.ZodString;
117
+ operation: z.ZodLiteral<"getCompletedNode">;
98
118
  }, z.core.$strict>, z.ZodObject<{
99
119
  process: z.ZodString;
100
120
  runId: z.ZodString;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FunctionProcessReadError = exports.functionProcessReadRequestSchema = exports.functionProcessRunsPageSchema = exports.functionProcessCompletedAgentReferenceSchema = exports.functionProcessCompletedAgentReferenceQuerySchema = exports.functionProcessRunsPageQuerySchema = exports.functionProcessRunQuerySchema = exports.functionProcessRunSummarySchema = exports.functionProcessRunStatusSchema = exports.functionProcessReadScopesSchema = exports.FUNCTION_PROCESS_READ_PATH = exports.FUNCTION_PROCESS_TOKEN_HEADER = void 0;
3
+ exports.FunctionProcessReadError = exports.functionProcessReadRequestSchema = exports.functionProcessRunsPageSchema = exports.functionProcessCompletedAgentReferenceSchema = exports.functionProcessCompletedAgentReferenceQuerySchema = exports.functionProcessCompletedNodeSchema = exports.functionProcessCompletedNodeQuerySchema = exports.functionProcessRunsPageQuerySchema = exports.functionProcessRunQuerySchema = exports.functionProcessRunSummarySchema = exports.functionProcessRunStatusSchema = exports.functionProcessReadScopesSchema = exports.FUNCTION_PROCESS_READ_PATH = exports.FUNCTION_PROCESS_TOKEN_HEADER = void 0;
4
4
  exports.readFunctionProcessScopes = readFunctionProcessScopes;
5
5
  const zod_1 = require("zod");
6
6
  exports.FUNCTION_PROCESS_TOKEN_HEADER = 'x-sequence-process-service-token';
@@ -66,6 +66,11 @@ exports.functionProcessRunsPageQuerySchema = zod_1.z.strictObject({
66
66
  cursor: zod_1.z.string().min(1).max(8192).optional(),
67
67
  archived: zod_1.z.boolean().optional(),
68
68
  });
69
+ exports.functionProcessCompletedNodeQuerySchema = exports.functionProcessRunQuerySchema.extend({ nodeId: entityId });
70
+ exports.functionProcessCompletedNodeSchema = zod_1.z.strictObject({
71
+ runId: entityId, processId, processVersion: entityId, nodeId: entityId, stepId: entityId,
72
+ completedAt: zod_1.z.iso.datetime({ offset: true }),
73
+ });
69
74
  exports.functionProcessCompletedAgentReferenceQuerySchema = exports.functionProcessRunQuerySchema.extend({ nodeId: entityId });
70
75
  exports.functionProcessCompletedAgentReferenceSchema = zod_1.z.strictObject({
71
76
  stepId: entityId, attempt: zod_1.z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
@@ -78,6 +83,7 @@ exports.functionProcessRunsPageSchema = zod_1.z.object({
78
83
  });
79
84
  exports.functionProcessReadRequestSchema = zod_1.z.discriminatedUnion('operation', [
80
85
  exports.functionProcessRunQuerySchema.extend({ operation: zod_1.z.literal('getRun') }),
86
+ exports.functionProcessCompletedNodeQuerySchema.extend({ operation: zod_1.z.literal('getCompletedNode') }),
81
87
  exports.functionProcessCompletedAgentReferenceQuerySchema.extend({ operation: zod_1.z.literal('getCompletedAgentReference') }),
82
88
  exports.functionProcessRunsPageQuerySchema.extend({
83
89
  operation: zod_1.z.literal('listRunsPage'),
@@ -1,8 +1,9 @@
1
- import { type FunctionProcessCompletedAgentReference, type FunctionProcessCompletedAgentReferenceQuery, type FunctionProcessRunQuery, type FunctionProcessRunSummary, type FunctionProcessRunsPage, type FunctionProcessRunsPageQuery } from './processes-contract';
1
+ import { type FunctionProcessCompletedNode, type FunctionProcessCompletedNodeQuery, type FunctionProcessCompletedAgentReference, type FunctionProcessCompletedAgentReferenceQuery, type FunctionProcessRunQuery, type FunctionProcessRunSummary, type FunctionProcessRunsPage, type FunctionProcessRunsPageQuery } from './processes-contract';
2
2
  import { type FunctionInvocationClientOptions } from './invocation-client';
3
3
  export * from './processes-contract';
4
4
  export type FunctionServiceProcessesOptions = FunctionInvocationClientOptions;
5
5
  export interface FunctionServiceProcessesClient {
6
+ getCompletedNode(query: FunctionProcessCompletedNodeQuery): Promise<FunctionProcessCompletedNode>;
6
7
  getCompletedAgentReference(query: FunctionProcessCompletedAgentReferenceQuery): Promise<FunctionProcessCompletedAgentReference>;
7
8
  getRun(query: FunctionProcessRunQuery): Promise<FunctionProcessRunSummary>;
8
9
  listRunsPage(query: FunctionProcessRunsPageQuery): Promise<FunctionProcessRunsPage>;
package/dist/processes.js CHANGED
@@ -70,6 +70,12 @@ function createFunctionServiceProcessesClient({ request, baseUrl, fetchImpl = gl
70
70
  });
71
71
  const read = ({ body, schema }) => transport({ body: processes_contract_1.functionProcessReadRequestSchema.parse(body), schema });
72
72
  return {
73
+ async getCompletedNode(query) {
74
+ const proof = await read({ body: { ...query, operation: 'getCompletedNode' }, schema: processes_contract_1.functionProcessCompletedNodeSchema });
75
+ if (proof.runId !== query.runId || proof.processId !== query.process || proof.nodeId !== query.nodeId)
76
+ throw new processes_contract_1.FunctionProcessReadError(502, 'malformed_response', 'Atlas returned a different completed node');
77
+ return proof;
78
+ },
73
79
  async getCompletedAgentReference(query) {
74
80
  const agent = readAgentCredential({ request });
75
81
  const readReference = (0, invocation_client_1.createInvocationReadTransport)({