@sequenceholdings/managed-functions 0.4.0 → 0.4.2

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 (92) hide show
  1. package/README.md +444 -2
  2. package/dist/abrigo-contract.d.ts +92 -0
  3. package/dist/abrigo-contract.js +55 -0
  4. package/dist/abrigo-response.d.ts +6 -0
  5. package/dist/abrigo-response.js +27 -0
  6. package/dist/abrigo.d.ts +14 -0
  7. package/dist/abrigo.js +150 -0
  8. package/dist/agent-evidence.d.ts +9 -0
  9. package/dist/agent-evidence.js +84 -0
  10. package/dist/agent-source-evidence-contract.d.ts +1197 -0
  11. package/dist/agent-source-evidence-contract.js +96 -0
  12. package/dist/agents-contract.d.ts +99 -0
  13. package/dist/agents-contract.js +69 -0
  14. package/dist/agents.d.ts +15 -0
  15. package/dist/agents.js +121 -0
  16. package/dist/capabilities.d.ts +165 -0
  17. package/dist/capabilities.js +61 -1
  18. package/dist/config.d.ts +18 -2
  19. package/dist/config.js +62 -1
  20. package/dist/deployed-policy.js +102 -0
  21. package/dist/directory-config.d.ts +23 -0
  22. package/dist/directory-config.js +22 -0
  23. package/dist/directory-contract.d.ts +68 -0
  24. package/dist/directory-contract.js +57 -0
  25. package/dist/directory-manifest.d.ts +5 -0
  26. package/dist/directory-manifest.js +10 -0
  27. package/dist/directory.d.ts +15 -0
  28. package/dist/directory.js +65 -0
  29. package/dist/http-tracing.js +3 -0
  30. package/dist/immutable-release-contract.d.ts +3 -0
  31. package/dist/immutable-release-contract.js +12 -0
  32. package/dist/index.d.ts +40 -1
  33. package/dist/index.js +75 -1
  34. package/dist/invocation-client.d.ts +45 -0
  35. package/dist/invocation-client.js +90 -0
  36. package/dist/invocation-contract.d.ts +36 -0
  37. package/dist/invocation-contract.js +48 -0
  38. package/dist/invocation.d.ts +8 -0
  39. package/dist/invocation.js +134 -0
  40. package/dist/lattice-capability.d.ts +5 -0
  41. package/dist/lattice-capability.js +16 -0
  42. package/dist/lattice-provenance-contract.d.ts +519 -0
  43. package/dist/lattice-provenance-contract.js +148 -0
  44. package/dist/lattice-provenance.d.ts +16 -0
  45. package/dist/lattice-provenance.js +167 -0
  46. package/dist/monitoring-annotations.d.ts +53 -0
  47. package/dist/monitoring-annotations.js +54 -0
  48. package/dist/monitoring-contract.d.ts +463 -0
  49. package/dist/monitoring-contract.js +89 -0
  50. package/dist/monitoring-events.d.ts +257 -0
  51. package/dist/monitoring-events.js +136 -0
  52. package/dist/monitoring.d.ts +14 -0
  53. package/dist/monitoring.js +78 -0
  54. package/dist/orm-contract.d.ts +1 -0
  55. package/dist/orm-contract.js +4 -0
  56. package/dist/orm.d.ts +19 -3
  57. package/dist/orm.js +93 -13
  58. package/dist/preflight-abrigo.d.ts +10 -0
  59. package/dist/preflight-abrigo.js +26 -0
  60. package/dist/preflight-agents.d.ts +10 -0
  61. package/dist/preflight-agents.js +51 -0
  62. package/dist/preflight-directory.d.ts +10 -0
  63. package/dist/preflight-directory.js +36 -0
  64. package/dist/preflight-immutable-release.d.ts +10 -0
  65. package/dist/preflight-immutable-release.js +34 -0
  66. package/dist/preflight-invocation.d.ts +10 -0
  67. package/dist/preflight-invocation.js +40 -0
  68. package/dist/preflight-lattice.d.ts +10 -0
  69. package/dist/preflight-lattice.js +40 -0
  70. package/dist/preflight-monitoring.d.ts +10 -0
  71. package/dist/preflight-monitoring.js +46 -0
  72. package/dist/preflight-service-directory.d.ts +10 -0
  73. package/dist/preflight-service-directory.js +26 -0
  74. package/dist/preflight-workflows.d.ts +10 -0
  75. package/dist/preflight-workflows.js +38 -0
  76. package/dist/preflight.js +50 -2
  77. package/dist/processes-contract.d.ts +20 -0
  78. package/dist/processes-contract.js +8 -1
  79. package/dist/processes.d.ts +4 -8
  80. package/dist/processes.js +52 -83
  81. package/dist/runtime.cjs +3387 -259
  82. package/dist/sdk-range.d.ts +1 -0
  83. package/dist/sdk-range.js +25 -0
  84. package/dist/service-directory.d.ts +12 -0
  85. package/dist/service-directory.js +72 -0
  86. package/dist/workflow-scopes-contract.d.ts +8 -0
  87. package/dist/workflow-scopes-contract.js +29 -0
  88. package/dist/workflow-source-contract.d.ts +524 -0
  89. package/dist/workflow-source-contract.js +59 -0
  90. package/dist/workflow-source.d.ts +12 -0
  91. package/dist/workflow-source.js +93 -0
  92. package/package.json +2 -2
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.functionImmutableReleaseSchema = void 0;
4
+ exports.readFunctionImmutableRelease = readFunctionImmutableRelease;
5
+ const zod_1 = require("zod");
6
+ exports.functionImmutableReleaseSchema = zod_1.z.boolean();
7
+ function readFunctionImmutableRelease(manifest) {
8
+ if (typeof manifest !== 'object' || manifest === null)
9
+ return false;
10
+ const fn = Reflect.get(manifest, 'function');
11
+ return typeof fn === 'object' && fn !== null && Reflect.get(fn, 'immutable_release') === true;
12
+ }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,42 @@
1
+ export { createFunctionDirectoryClient, FunctionDirectoryReadError } from './directory';
2
+ export type { FunctionDirectoryClient, FunctionDirectoryOptions, FunctionDirectoryMembers, FunctionDirectoryMembersQuery } from './directory';
3
+ export type { FunctionInvocationClientOptions } from './invocation-client';
4
+ export { functionLatticeContextCapabilitySchema, readFunctionLatticeContextCapability } from './lattice-capability';
5
+ export { createFunctionLatticeClient } from './lattice-provenance';
6
+ export { functionLatticeParallelSnapshotSchema, functionLatticeParallelSnapshotQuerySchema } from './lattice-provenance-contract';
7
+ export type { FunctionLatticeParallelSnapshot, FunctionLatticeParallelSnapshotQuery } from './lattice-provenance-contract';
8
+ export { functionLatticeStartProvenanceSchema } from './lattice-provenance-contract';
9
+ export type { FunctionLatticeStartProvenance } from './lattice-provenance-contract';
10
+ export * from './invocation-contract';
11
+ export * from './abrigo';
12
+ export { createFunctionInvocationClient } from './invocation';
13
+ export type { FunctionInvocationClient } from './invocation';
14
+ export { FUNCTION_LATTICE_CONTEXT_PATH, FUNCTION_LATTICE_EXECUTION_TOKEN_HEADER, FunctionLatticeContextError, functionLatticeContextRequestSchema, functionLatticeExecutionContextSchema, functionLatticeHumanCompletionQuerySchema, functionLatticeHumanCompletionSchema } from './lattice-provenance-contract';
15
+ export type { FunctionLatticeClient, FunctionLatticeClientOptions } from './lattice-provenance';
16
+ export { functionLatticeHumanCompletionsQuerySchema, functionLatticeHumanCompletionsPageSchema } from './lattice-provenance-contract';
17
+ export type { FunctionLatticeHumanCompletionsQuery, FunctionLatticeHumanCompletionsPage } from './lattice-provenance-contract';
18
+ export type { FunctionLatticeContextRequest, FunctionLatticeExecutionContext, FunctionLatticeHumanCompletion, FunctionLatticeHumanCompletionQuery } from './lattice-provenance-contract';
1
19
  export { createFunctionServiceProcessesClient, FunctionProcessReadError } from './processes';
2
- export type { FunctionServiceProcessesClient, FunctionServiceProcessesOptions, FunctionProcessRunQuery, FunctionProcessRunSummary, FunctionProcessRunStatus, FunctionProcessRunsPage, FunctionProcessRunsPageQuery, FunctionProcessReadRequest } from './processes';
20
+ export { createFunctionServiceAgentsClient, FunctionAgentReadError } from './agents';
21
+ export { createFunctionAgentEvidenceClient } from './agent-evidence';
22
+ export { createFunctionServiceWorkflowsClient, createFunctionWorkflowEvidenceClient } from './workflow-source';
23
+ export type { FunctionServiceWorkflowsClient, FunctionServiceWorkflowsOptions, FunctionWorkflowEvidenceClient, FunctionWorkflowSourceEvidenceInput } from './workflow-source';
24
+ export * from './workflow-source-contract';
25
+ export type { FunctionAgentEvidenceClient, FunctionAgentSourceEvidenceInput, FunctionAgentConversationEvidenceInput } from './agent-evidence';
26
+ export type { FunctionAgentSourceEvidenceCapture, FunctionAgentSourceEvidenceClaims, FunctionAgentSourceEvidenceVerification, FunctionAgentConversationResponse, FunctionAgentConversationEvidenceResponse, FunctionAgentConversationEvidenceCapture, FunctionAgentSourceExecution } from './agent-source-evidence-contract';
27
+ export { functionAgentSourceResponseSchema, functionAgentSourceEvidenceRequestSchema, functionAgentSourceEvidenceCaptureSchema, functionAgentConversationEvidenceResponseSchema, functionAgentConversationEvidenceCaptureSchema, functionAgentConversationEvidenceRequestSchema, functionAgentSourceExecutionSchema } from './agent-source-evidence-contract';
28
+ export { functionSourceJobAdmissionSchema } from './agent-source-evidence-contract';
29
+ export type { FunctionSourceJobAdmission } from './agent-source-evidence-contract';
30
+ export type { FunctionServiceAgentsClient, FunctionServiceAgentsOptions, FunctionAgentCompletedRunQuery, FunctionAgentCompletedRun } from './agents';
31
+ export { createFunctionServiceMonitoringClient } from './monitoring';
32
+ export { FunctionMonitoringError, monitoringPayloadHash } from './monitoring-contract';
33
+ export { monitoringEventsSchema, monitoringPublishSchema } from './monitoring-contract';
34
+ export { functionMonitoringAnnotationSchema } from './monitoring-annotations';
35
+ export type { MonitoringDeltaEvent, MonitoringPublish, MonitoringDeliveryKey, MonitoringDeliveryReceipt } from './monitoring-contract';
36
+ export type { MonitoringCatalogQuery, MonitoringBucketCatalog } from './monitoring-contract';
37
+ export type { FunctionMonitoringAnnotation, MonitoringJson } from './monitoring-annotations';
38
+ export type { FunctionServiceMonitoringClient, FunctionServiceMonitoringOptions } from './monitoring';
39
+ export type { FunctionServiceProcessesClient, FunctionServiceProcessesOptions, FunctionProcessRunQuery, FunctionProcessRunSummary, FunctionProcessRunStatus, FunctionProcessRunsPage, FunctionProcessRunsPageQuery, FunctionProcessReadRequest, FunctionProcessCompletedAgentReferenceQuery, FunctionProcessCompletedAgentReference } from './processes';
3
40
  export { installFunctionTracing, runWithFunctionTracing } from './tracing';
4
41
  export { createFunctionStorageClient } from './storage';
5
42
  import { type CacheManager } from "./cache";
@@ -13,3 +50,5 @@ export interface ManagedFunctionContext {
13
50
  export declare function createManagedFunctionContext({ env, }?: {
14
51
  env?: NodeJS.ProcessEnv;
15
52
  }): ManagedFunctionContext;
53
+ export * from './directory-contract';
54
+ export { createFunctionServiceDirectoryClient, type FunctionServiceDirectoryOptions, type FunctionServiceDirectoryClient } from './service-directory';
package/dist/index.js CHANGED
@@ -1,10 +1,81 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readCacheConfiguration = exports.cacheManifestSchema = exports.createCacheManager = exports.CacheError = exports.createFunctionStorageClient = exports.runWithFunctionTracing = exports.installFunctionTracing = exports.FunctionProcessReadError = exports.createFunctionServiceProcessesClient = void 0;
17
+ exports.createFunctionServiceDirectoryClient = exports.readCacheConfiguration = exports.cacheManifestSchema = exports.createCacheManager = exports.CacheError = exports.createFunctionStorageClient = exports.runWithFunctionTracing = exports.installFunctionTracing = exports.functionMonitoringAnnotationSchema = exports.monitoringPublishSchema = exports.monitoringEventsSchema = exports.monitoringPayloadHash = exports.FunctionMonitoringError = exports.createFunctionServiceMonitoringClient = exports.functionSourceJobAdmissionSchema = exports.functionAgentSourceExecutionSchema = exports.functionAgentConversationEvidenceRequestSchema = exports.functionAgentConversationEvidenceCaptureSchema = exports.functionAgentConversationEvidenceResponseSchema = exports.functionAgentSourceEvidenceCaptureSchema = exports.functionAgentSourceEvidenceRequestSchema = exports.functionAgentSourceResponseSchema = exports.createFunctionWorkflowEvidenceClient = exports.createFunctionServiceWorkflowsClient = exports.createFunctionAgentEvidenceClient = exports.FunctionAgentReadError = exports.createFunctionServiceAgentsClient = exports.FunctionProcessReadError = exports.createFunctionServiceProcessesClient = exports.functionLatticeHumanCompletionsPageSchema = exports.functionLatticeHumanCompletionsQuerySchema = exports.functionLatticeHumanCompletionSchema = exports.functionLatticeHumanCompletionQuerySchema = exports.functionLatticeExecutionContextSchema = exports.functionLatticeContextRequestSchema = exports.FunctionLatticeContextError = exports.FUNCTION_LATTICE_EXECUTION_TOKEN_HEADER = exports.FUNCTION_LATTICE_CONTEXT_PATH = exports.createFunctionInvocationClient = exports.functionLatticeStartProvenanceSchema = exports.functionLatticeParallelSnapshotQuerySchema = exports.functionLatticeParallelSnapshotSchema = exports.createFunctionLatticeClient = exports.readFunctionLatticeContextCapability = exports.functionLatticeContextCapabilitySchema = exports.FunctionDirectoryReadError = exports.createFunctionDirectoryClient = void 0;
4
18
  exports.createManagedFunctionContext = createManagedFunctionContext;
19
+ var directory_1 = require("./directory");
20
+ Object.defineProperty(exports, "createFunctionDirectoryClient", { enumerable: true, get: function () { return directory_1.createFunctionDirectoryClient; } });
21
+ Object.defineProperty(exports, "FunctionDirectoryReadError", { enumerable: true, get: function () { return directory_1.FunctionDirectoryReadError; } });
22
+ var lattice_capability_1 = require("./lattice-capability");
23
+ Object.defineProperty(exports, "functionLatticeContextCapabilitySchema", { enumerable: true, get: function () { return lattice_capability_1.functionLatticeContextCapabilitySchema; } });
24
+ Object.defineProperty(exports, "readFunctionLatticeContextCapability", { enumerable: true, get: function () { return lattice_capability_1.readFunctionLatticeContextCapability; } });
25
+ var lattice_provenance_1 = require("./lattice-provenance");
26
+ Object.defineProperty(exports, "createFunctionLatticeClient", { enumerable: true, get: function () { return lattice_provenance_1.createFunctionLatticeClient; } });
27
+ var lattice_provenance_contract_1 = require("./lattice-provenance-contract");
28
+ Object.defineProperty(exports, "functionLatticeParallelSnapshotSchema", { enumerable: true, get: function () { return lattice_provenance_contract_1.functionLatticeParallelSnapshotSchema; } });
29
+ Object.defineProperty(exports, "functionLatticeParallelSnapshotQuerySchema", { enumerable: true, get: function () { return lattice_provenance_contract_1.functionLatticeParallelSnapshotQuerySchema; } });
30
+ var lattice_provenance_contract_2 = require("./lattice-provenance-contract");
31
+ Object.defineProperty(exports, "functionLatticeStartProvenanceSchema", { enumerable: true, get: function () { return lattice_provenance_contract_2.functionLatticeStartProvenanceSchema; } });
32
+ __exportStar(require("./invocation-contract"), exports);
33
+ __exportStar(require("./abrigo"), exports);
34
+ var invocation_1 = require("./invocation");
35
+ Object.defineProperty(exports, "createFunctionInvocationClient", { enumerable: true, get: function () { return invocation_1.createFunctionInvocationClient; } });
36
+ var lattice_provenance_contract_3 = require("./lattice-provenance-contract");
37
+ Object.defineProperty(exports, "FUNCTION_LATTICE_CONTEXT_PATH", { enumerable: true, get: function () { return lattice_provenance_contract_3.FUNCTION_LATTICE_CONTEXT_PATH; } });
38
+ Object.defineProperty(exports, "FUNCTION_LATTICE_EXECUTION_TOKEN_HEADER", { enumerable: true, get: function () { return lattice_provenance_contract_3.FUNCTION_LATTICE_EXECUTION_TOKEN_HEADER; } });
39
+ Object.defineProperty(exports, "FunctionLatticeContextError", { enumerable: true, get: function () { return lattice_provenance_contract_3.FunctionLatticeContextError; } });
40
+ Object.defineProperty(exports, "functionLatticeContextRequestSchema", { enumerable: true, get: function () { return lattice_provenance_contract_3.functionLatticeContextRequestSchema; } });
41
+ Object.defineProperty(exports, "functionLatticeExecutionContextSchema", { enumerable: true, get: function () { return lattice_provenance_contract_3.functionLatticeExecutionContextSchema; } });
42
+ Object.defineProperty(exports, "functionLatticeHumanCompletionQuerySchema", { enumerable: true, get: function () { return lattice_provenance_contract_3.functionLatticeHumanCompletionQuerySchema; } });
43
+ Object.defineProperty(exports, "functionLatticeHumanCompletionSchema", { enumerable: true, get: function () { return lattice_provenance_contract_3.functionLatticeHumanCompletionSchema; } });
44
+ var lattice_provenance_contract_4 = require("./lattice-provenance-contract");
45
+ Object.defineProperty(exports, "functionLatticeHumanCompletionsQuerySchema", { enumerable: true, get: function () { return lattice_provenance_contract_4.functionLatticeHumanCompletionsQuerySchema; } });
46
+ Object.defineProperty(exports, "functionLatticeHumanCompletionsPageSchema", { enumerable: true, get: function () { return lattice_provenance_contract_4.functionLatticeHumanCompletionsPageSchema; } });
5
47
  var processes_1 = require("./processes");
6
48
  Object.defineProperty(exports, "createFunctionServiceProcessesClient", { enumerable: true, get: function () { return processes_1.createFunctionServiceProcessesClient; } });
7
49
  Object.defineProperty(exports, "FunctionProcessReadError", { enumerable: true, get: function () { return processes_1.FunctionProcessReadError; } });
50
+ var agents_1 = require("./agents");
51
+ Object.defineProperty(exports, "createFunctionServiceAgentsClient", { enumerable: true, get: function () { return agents_1.createFunctionServiceAgentsClient; } });
52
+ Object.defineProperty(exports, "FunctionAgentReadError", { enumerable: true, get: function () { return agents_1.FunctionAgentReadError; } });
53
+ var agent_evidence_1 = require("./agent-evidence");
54
+ Object.defineProperty(exports, "createFunctionAgentEvidenceClient", { enumerable: true, get: function () { return agent_evidence_1.createFunctionAgentEvidenceClient; } });
55
+ var workflow_source_1 = require("./workflow-source");
56
+ Object.defineProperty(exports, "createFunctionServiceWorkflowsClient", { enumerable: true, get: function () { return workflow_source_1.createFunctionServiceWorkflowsClient; } });
57
+ Object.defineProperty(exports, "createFunctionWorkflowEvidenceClient", { enumerable: true, get: function () { return workflow_source_1.createFunctionWorkflowEvidenceClient; } });
58
+ __exportStar(require("./workflow-source-contract"), exports);
59
+ var agent_source_evidence_contract_1 = require("./agent-source-evidence-contract");
60
+ Object.defineProperty(exports, "functionAgentSourceResponseSchema", { enumerable: true, get: function () { return agent_source_evidence_contract_1.functionAgentSourceResponseSchema; } });
61
+ Object.defineProperty(exports, "functionAgentSourceEvidenceRequestSchema", { enumerable: true, get: function () { return agent_source_evidence_contract_1.functionAgentSourceEvidenceRequestSchema; } });
62
+ Object.defineProperty(exports, "functionAgentSourceEvidenceCaptureSchema", { enumerable: true, get: function () { return agent_source_evidence_contract_1.functionAgentSourceEvidenceCaptureSchema; } });
63
+ Object.defineProperty(exports, "functionAgentConversationEvidenceResponseSchema", { enumerable: true, get: function () { return agent_source_evidence_contract_1.functionAgentConversationEvidenceResponseSchema; } });
64
+ Object.defineProperty(exports, "functionAgentConversationEvidenceCaptureSchema", { enumerable: true, get: function () { return agent_source_evidence_contract_1.functionAgentConversationEvidenceCaptureSchema; } });
65
+ Object.defineProperty(exports, "functionAgentConversationEvidenceRequestSchema", { enumerable: true, get: function () { return agent_source_evidence_contract_1.functionAgentConversationEvidenceRequestSchema; } });
66
+ Object.defineProperty(exports, "functionAgentSourceExecutionSchema", { enumerable: true, get: function () { return agent_source_evidence_contract_1.functionAgentSourceExecutionSchema; } });
67
+ var agent_source_evidence_contract_2 = require("./agent-source-evidence-contract");
68
+ Object.defineProperty(exports, "functionSourceJobAdmissionSchema", { enumerable: true, get: function () { return agent_source_evidence_contract_2.functionSourceJobAdmissionSchema; } });
69
+ var monitoring_1 = require("./monitoring");
70
+ Object.defineProperty(exports, "createFunctionServiceMonitoringClient", { enumerable: true, get: function () { return monitoring_1.createFunctionServiceMonitoringClient; } });
71
+ var monitoring_contract_1 = require("./monitoring-contract");
72
+ Object.defineProperty(exports, "FunctionMonitoringError", { enumerable: true, get: function () { return monitoring_contract_1.FunctionMonitoringError; } });
73
+ Object.defineProperty(exports, "monitoringPayloadHash", { enumerable: true, get: function () { return monitoring_contract_1.monitoringPayloadHash; } });
74
+ var monitoring_contract_2 = require("./monitoring-contract");
75
+ Object.defineProperty(exports, "monitoringEventsSchema", { enumerable: true, get: function () { return monitoring_contract_2.monitoringEventsSchema; } });
76
+ Object.defineProperty(exports, "monitoringPublishSchema", { enumerable: true, get: function () { return monitoring_contract_2.monitoringPublishSchema; } });
77
+ var monitoring_annotations_1 = require("./monitoring-annotations");
78
+ Object.defineProperty(exports, "functionMonitoringAnnotationSchema", { enumerable: true, get: function () { return monitoring_annotations_1.functionMonitoringAnnotationSchema; } });
8
79
  var tracing_1 = require("./tracing");
9
80
  Object.defineProperty(exports, "installFunctionTracing", { enumerable: true, get: function () { return tracing_1.installFunctionTracing; } });
10
81
  Object.defineProperty(exports, "runWithFunctionTracing", { enumerable: true, get: function () { return tracing_1.runWithFunctionTracing; } });
@@ -65,3 +136,6 @@ function lazyValkeyStore(connection, local) {
65
136
  delete: async (key) => (await client()).delete(key),
66
137
  };
67
138
  }
139
+ __exportStar(require("./directory-contract"), exports);
140
+ var service_directory_1 = require("./service-directory");
141
+ Object.defineProperty(exports, "createFunctionServiceDirectoryClient", { enumerable: true, get: function () { return service_directory_1.createFunctionServiceDirectoryClient; } });
@@ -0,0 +1,45 @@
1
+ import { z } from 'zod';
2
+ export interface FunctionInvocationClientOptions {
3
+ request: {
4
+ headers: Pick<Headers, 'get'> | Readonly<Record<string, string | readonly string[] | undefined>>;
5
+ };
6
+ baseUrl: string;
7
+ fetchImpl?: typeof globalThis.fetch;
8
+ }
9
+ type ClientErrorFactory = (status: number, code: string, message: string) => Error;
10
+ export declare function readInvocationCredential<T extends {
11
+ exp: number;
12
+ }>({ request, header, maxBytes, claimsSchema, invalidContext, }: Pick<FunctionInvocationClientOptions, 'request'> & {
13
+ header: string;
14
+ maxBytes: number;
15
+ claimsSchema: z.ZodType<T>;
16
+ invalidContext: () => Error;
17
+ }): {
18
+ token: string;
19
+ expiresAt: number;
20
+ };
21
+ export declare function createInvocationReadTransport({ baseUrl, fetchImpl, path, header, credential, additionalCredentials, timeoutMs, error, failure, }: Pick<FunctionInvocationClientOptions, 'baseUrl' | 'fetchImpl'> & {
22
+ path: string;
23
+ header: string;
24
+ credential: {
25
+ token: string;
26
+ expiresAt: number;
27
+ };
28
+ additionalCredentials?: readonly {
29
+ header: string;
30
+ credential: {
31
+ token: string;
32
+ expiresAt: number;
33
+ };
34
+ }[];
35
+ timeoutMs: number;
36
+ error: ClientErrorFactory;
37
+ failure: {
38
+ code: string;
39
+ message: string;
40
+ };
41
+ }): <T>({ body, schema, }: {
42
+ body: unknown;
43
+ schema: z.ZodType<T>;
44
+ }) => Promise<T>;
45
+ export {};
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readInvocationCredential = readInvocationCredential;
4
+ exports.createInvocationReadTransport = createInvocationReadTransport;
5
+ const zod_1 = require("zod");
6
+ function readInvocationCredential({ request, header, maxBytes, claimsSchema, invalidContext, }) {
7
+ const { headers } = request;
8
+ const matches = typeof headers.get === 'function'
9
+ ? [headers.get(header)]
10
+ : Object.entries(headers)
11
+ .filter(([name]) => name.toLowerCase() === header)
12
+ .map(([, value]) => value);
13
+ const token = matches[0];
14
+ if (matches.length !== 1 ||
15
+ typeof token !== 'string' ||
16
+ token.length > maxBytes)
17
+ throw invalidContext();
18
+ const envelope = /^([A-Za-z0-9_-]+)\.([A-Za-z0-9_-]{43})$/.exec(token);
19
+ if (!envelope?.[1])
20
+ throw invalidContext();
21
+ let value;
22
+ try {
23
+ value = JSON.parse(Buffer.from(envelope[1], 'base64url').toString('utf8'));
24
+ }
25
+ catch {
26
+ throw invalidContext();
27
+ }
28
+ const parsed = claimsSchema.safeParse(value);
29
+ if (!parsed.success)
30
+ throw invalidContext();
31
+ return { token, expiresAt: parsed.data.exp };
32
+ }
33
+ function trustedOrigin({ baseUrl, error, }) {
34
+ let url;
35
+ try {
36
+ url = new URL(baseUrl);
37
+ }
38
+ catch {
39
+ throw error(400, 'invalid_configuration', 'Configure a trusted Atlas origin');
40
+ }
41
+ const loopback = url.protocol === 'http:' &&
42
+ ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);
43
+ if ((!loopback && url.protocol !== 'https:') ||
44
+ url.username ||
45
+ url.password ||
46
+ url.pathname !== '/' ||
47
+ url.search ||
48
+ url.hash) {
49
+ throw error(400, 'invalid_configuration', 'Configure an HTTPS Atlas origin without credentials, path, query or fragment');
50
+ }
51
+ return url.origin;
52
+ }
53
+ const errorResponseSchema = zod_1.z.object({
54
+ code: zod_1.z.string().max(128).optional(),
55
+ detail: zod_1.z.string().max(2000).optional(),
56
+ });
57
+ function createInvocationReadTransport({ baseUrl, fetchImpl = globalThis.fetch, path, header, credential, additionalCredentials = [], timeoutMs, error, failure, }) {
58
+ const url = `${trustedOrigin({ baseUrl, error })}${path}`;
59
+ const credentials = [{ header, credential }, ...additionalCredentials];
60
+ const names = credentials.map((value) => value.header.toLowerCase());
61
+ if (new Set(names).size !== names.length || names.includes('content-type')) {
62
+ throw error(400, 'invalid_configuration', 'Credential headers must be distinct');
63
+ }
64
+ return async function read({ body, schema, }) {
65
+ if (credentials.some((value) => value.credential.expiresAt <= Date.now() / 1000)) {
66
+ throw error(401, 'expired_context', 'The invocation credential expired; start a new invocation');
67
+ }
68
+ const response = await fetchImpl(url, {
69
+ method: 'POST',
70
+ headers: {
71
+ 'content-type': 'application/json',
72
+ ...Object.fromEntries(credentials.map((value) => [value.header, value.credential.token])),
73
+ },
74
+ body: JSON.stringify(body),
75
+ redirect: 'error',
76
+ signal: AbortSignal.timeout(timeoutMs),
77
+ });
78
+ const result = await response.json().catch(() => null);
79
+ if (!response.ok) {
80
+ const parsed = errorResponseSchema.safeParse(result);
81
+ throw error(response.status, parsed.success ? (parsed.data.code ?? failure.code) : failure.code, parsed.success
82
+ ? (parsed.data.detail ?? failure.message)
83
+ : failure.message);
84
+ }
85
+ const validated = schema.safeParse(result);
86
+ if (!validated.success)
87
+ throw error(502, 'malformed_response', 'Atlas returned an invalid capability response');
88
+ return validated.data;
89
+ };
90
+ }
@@ -0,0 +1,36 @@
1
+ import { z } from 'zod';
2
+ export declare const FUNCTION_INVOCATION_IDENTITY_TOKEN_HEADER = "x-sequence-invocation-identity-token";
3
+ export declare const FUNCTION_INVOCATION_CONTEXT_PATH = "/api/managed-functions/invocation/context";
4
+ export declare const functionInvocationIdentityCapabilitySchema: z.ZodObject<{
5
+ identity: z.ZodLiteral<true>;
6
+ }, z.core.$strict>;
7
+ export declare function readFunctionInvocationIdentityCapability(manifest: unknown): boolean;
8
+ export declare const functionInvocationContextRequestSchema: z.ZodObject<{
9
+ operation: z.ZodLiteral<"getInvocationContext">;
10
+ }, z.core.$strict>;
11
+ export type FunctionInvocationContextRequest = z.infer<typeof functionInvocationContextRequestSchema>;
12
+ export declare const functionInvocationContextSchema: z.ZodObject<{
13
+ receiver: z.ZodObject<{
14
+ functionId: z.ZodString;
15
+ versionId: z.ZodString;
16
+ invocationId: z.ZodString;
17
+ orgId: z.ZodString;
18
+ serviceAccountId: z.ZodString;
19
+ serviceAccountSub: z.ZodString;
20
+ }, z.core.$strict>;
21
+ caller: z.ZodObject<{
22
+ kind: z.ZodEnum<{
23
+ human: "human";
24
+ service_account: "service_account";
25
+ system: "system";
26
+ }>;
27
+ sub: z.ZodString;
28
+ }, z.core.$strict>;
29
+ }, z.core.$strict>;
30
+ export type FunctionInvocationContext = z.infer<typeof functionInvocationContextSchema>;
31
+ export declare class FunctionInvocationContextError extends Error {
32
+ readonly status: number;
33
+ readonly code: string;
34
+ readonly name = "FunctionInvocationContextError";
35
+ constructor(status: number, code: string, message: string);
36
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FunctionInvocationContextError = exports.functionInvocationContextSchema = exports.functionInvocationContextRequestSchema = exports.functionInvocationIdentityCapabilitySchema = exports.FUNCTION_INVOCATION_CONTEXT_PATH = exports.FUNCTION_INVOCATION_IDENTITY_TOKEN_HEADER = void 0;
4
+ exports.readFunctionInvocationIdentityCapability = readFunctionInvocationIdentityCapability;
5
+ const zod_1 = require("zod");
6
+ exports.FUNCTION_INVOCATION_IDENTITY_TOKEN_HEADER = 'x-sequence-invocation-identity-token';
7
+ exports.FUNCTION_INVOCATION_CONTEXT_PATH = '/api/managed-functions/invocation/context';
8
+ const identifier = zod_1.z.string().min(1).max(255);
9
+ const principal = zod_1.z.string().min(1).max(512);
10
+ exports.functionInvocationIdentityCapabilitySchema = zod_1.z.strictObject({
11
+ identity: zod_1.z.literal(true),
12
+ });
13
+ function readFunctionInvocationIdentityCapability(manifest) {
14
+ if (typeof manifest !== 'object' || manifest === null)
15
+ return false;
16
+ const capabilities = Reflect.get(manifest, 'capabilities');
17
+ if (typeof capabilities !== 'object' || capabilities === null)
18
+ return false;
19
+ return exports.functionInvocationIdentityCapabilitySchema.safeParse(Reflect.get(capabilities, 'invocation')).success;
20
+ }
21
+ exports.functionInvocationContextRequestSchema = zod_1.z.strictObject({
22
+ operation: zod_1.z.literal('getInvocationContext'),
23
+ });
24
+ exports.functionInvocationContextSchema = zod_1.z.strictObject({
25
+ receiver: zod_1.z.strictObject({
26
+ functionId: identifier,
27
+ versionId: identifier,
28
+ invocationId: identifier,
29
+ orgId: identifier,
30
+ serviceAccountId: identifier,
31
+ serviceAccountSub: principal,
32
+ }).refine((value) => value.serviceAccountSub === `service-account|${value.serviceAccountId}`, 'The receiver subject must identify the attached service account'),
33
+ caller: zod_1.z.strictObject({
34
+ kind: zod_1.z.enum(['human', 'service_account', 'system']),
35
+ sub: principal,
36
+ }),
37
+ });
38
+ class FunctionInvocationContextError extends Error {
39
+ status;
40
+ code;
41
+ name = 'FunctionInvocationContextError';
42
+ constructor(status, code, message) {
43
+ super(message);
44
+ this.status = status;
45
+ this.code = code;
46
+ }
47
+ }
48
+ exports.FunctionInvocationContextError = FunctionInvocationContextError;
@@ -0,0 +1,8 @@
1
+ import { type FunctionInvocationContext } from './invocation-contract';
2
+ export * from './invocation-contract';
3
+ import type { FunctionInvocationClientOptions } from './invocation-client';
4
+ export type { FunctionInvocationClientOptions } from './invocation-client';
5
+ export interface FunctionInvocationClient {
6
+ getInvocationContext(): Promise<FunctionInvocationContext>;
7
+ }
8
+ export declare function createFunctionInvocationClient({ request, baseUrl, fetchImpl, }: FunctionInvocationClientOptions): FunctionInvocationClient;
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.createFunctionInvocationClient = createFunctionInvocationClient;
18
+ const zod_1 = require("zod");
19
+ const invocation_contract_1 = require("./invocation-contract");
20
+ __exportStar(require("./invocation-contract"), exports);
21
+ const identifier = zod_1.z.string().min(1).max(255);
22
+ const principal = zod_1.z.string().min(1).max(512);
23
+ const tokenClaimsSchema = zod_1.z.strictObject({
24
+ audience: zod_1.z.literal('atlas-managed-function-invocation-identity'),
25
+ environment: zod_1.z.string().min(1).max(4096),
26
+ functionId: identifier,
27
+ versionId: identifier,
28
+ invocationId: identifier,
29
+ serviceAccountId: identifier,
30
+ org: identifier,
31
+ callerKind: zod_1.z.enum(['human', 'service_account', 'system']),
32
+ callerSub: principal,
33
+ callerAuthenticationMethod: identifier,
34
+ exp: zod_1.z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
35
+ });
36
+ const errorSchema = zod_1.z.strictObject({
37
+ code: zod_1.z.string().min(1).max(128).regex(/^[a-z][a-z0-9_]*$/),
38
+ detail: zod_1.z.string().min(1).max(2000),
39
+ });
40
+ const invalidContext = () => new invocation_contract_1.FunctionInvocationContextError(401, 'invalid_context', 'This invocation has no valid identity credential');
41
+ function readCredential({ request }) {
42
+ const { headers } = request;
43
+ const matches = typeof headers.get === 'function'
44
+ ? [headers.get(invocation_contract_1.FUNCTION_INVOCATION_IDENTITY_TOKEN_HEADER)]
45
+ : Object.entries(headers)
46
+ .filter(([name]) => name.toLowerCase() === invocation_contract_1.FUNCTION_INVOCATION_IDENTITY_TOKEN_HEADER)
47
+ .map(([, value]) => value);
48
+ const token = matches[0];
49
+ if (matches.length !== 1 || typeof token !== 'string' || token.length > 16_384)
50
+ throw invalidContext();
51
+ const envelope = /^([A-Za-z0-9_-]+)\.([A-Za-z0-9_-]{43})$/.exec(token);
52
+ if (!envelope?.[1])
53
+ throw invalidContext();
54
+ let value;
55
+ try {
56
+ const decoded = Buffer.from(envelope[1], 'base64url');
57
+ if (decoded.toString('base64url') !== envelope[1])
58
+ throw invalidContext();
59
+ value = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(decoded));
60
+ }
61
+ catch {
62
+ throw invalidContext();
63
+ }
64
+ const parsed = tokenClaimsSchema.safeParse(value);
65
+ if (!parsed.success)
66
+ throw invalidContext();
67
+ return { token, claims: parsed.data };
68
+ }
69
+ function trustedOrigin(baseUrl) {
70
+ const invalid = () => new invocation_contract_1.FunctionInvocationContextError(400, 'invalid_configuration', 'Configure a trusted HTTPS Atlas origin without credentials, path, query or fragment');
71
+ let url;
72
+ try {
73
+ url = new URL(baseUrl);
74
+ }
75
+ catch {
76
+ throw invalid();
77
+ }
78
+ const loopback = url.protocol === 'http:' &&
79
+ ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);
80
+ if ((!loopback && url.protocol !== 'https:') || url.username || url.password ||
81
+ url.pathname !== '/' || url.search || url.hash)
82
+ throw invalid();
83
+ return url.origin;
84
+ }
85
+ function requireFresh(claims) {
86
+ if (claims.exp <= Date.now() / 1000)
87
+ throw new invocation_contract_1.FunctionInvocationContextError(401, 'expired_context', 'The identity credential expired; start a new invocation');
88
+ }
89
+ function matchesInvocation({ context, claims, }) {
90
+ const { receiver, caller } = context;
91
+ return receiver.functionId === claims.functionId &&
92
+ receiver.versionId === claims.versionId &&
93
+ receiver.invocationId === claims.invocationId &&
94
+ receiver.orgId === claims.org &&
95
+ receiver.serviceAccountId === claims.serviceAccountId &&
96
+ caller.kind === claims.callerKind && caller.sub === claims.callerSub;
97
+ }
98
+ function createFunctionInvocationClient({ request, baseUrl, fetchImpl = globalThis.fetch, }) {
99
+ const url = `${trustedOrigin(baseUrl)}${invocation_contract_1.FUNCTION_INVOCATION_CONTEXT_PATH}`;
100
+ const { token, claims } = readCredential({ request });
101
+ return {
102
+ async getInvocationContext() {
103
+ requireFresh(claims);
104
+ let response;
105
+ try {
106
+ response = await fetchImpl(url, {
107
+ method: 'POST',
108
+ headers: {
109
+ 'content-type': 'application/json',
110
+ [invocation_contract_1.FUNCTION_INVOCATION_IDENTITY_TOKEN_HEADER]: token,
111
+ },
112
+ body: JSON.stringify(invocation_contract_1.functionInvocationContextRequestSchema.parse({ operation: 'getInvocationContext' })),
113
+ redirect: 'error', signal: AbortSignal.timeout(30_000),
114
+ });
115
+ }
116
+ catch {
117
+ throw new invocation_contract_1.FunctionInvocationContextError(502, 'context_request_failed', 'The invocation context request failed');
118
+ }
119
+ if (response.redirected || (response.status >= 300 && response.status < 400))
120
+ throw new invocation_contract_1.FunctionInvocationContextError(502, 'redirect_refused', 'The invocation context request must not redirect');
121
+ const result = await response.json().catch(() => null);
122
+ if (!response.ok) {
123
+ const error = errorSchema.safeParse(result);
124
+ throw new invocation_contract_1.FunctionInvocationContextError(response.status, error.success ? error.data.code : 'context_read_failed', error.success && !error.data.detail.includes(token)
125
+ ? error.data.detail : 'Invocation context read failed');
126
+ }
127
+ requireFresh(claims);
128
+ const parsed = invocation_contract_1.functionInvocationContextSchema.safeParse(result);
129
+ if (!parsed.success || !matchesInvocation({ context: parsed.data, claims }))
130
+ throw new invocation_contract_1.FunctionInvocationContextError(502, 'malformed_response', 'Atlas returned an invalid invocation context response');
131
+ return parsed.data;
132
+ },
133
+ };
134
+ }
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ export declare const functionLatticeContextCapabilitySchema: z.ZodObject<{
3
+ context: z.ZodLiteral<true>;
4
+ }, z.core.$strict>;
5
+ export declare function readFunctionLatticeContextCapability(manifest: unknown): boolean;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.functionLatticeContextCapabilitySchema = void 0;
4
+ exports.readFunctionLatticeContextCapability = readFunctionLatticeContextCapability;
5
+ const zod_1 = require("zod");
6
+ exports.functionLatticeContextCapabilitySchema = zod_1.z.strictObject({
7
+ context: zod_1.z.literal(true),
8
+ });
9
+ function readFunctionLatticeContextCapability(manifest) {
10
+ if (typeof manifest !== 'object' || manifest === null)
11
+ return false;
12
+ const capabilities = Reflect.get(manifest, 'capabilities');
13
+ if (typeof capabilities !== 'object' || capabilities === null)
14
+ return false;
15
+ return exports.functionLatticeContextCapabilitySchema.safeParse(Reflect.get(capabilities, 'lattice')).success;
16
+ }