@adea-ai/contracts 1.5.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 (47) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +39 -0
  3. package/dist/authentication.d.ts +44 -0
  4. package/dist/authentication.d.ts.map +1 -0
  5. package/dist/authentication.js +49 -0
  6. package/dist/authentication.js.map +1 -0
  7. package/dist/context-providers.d.ts +170 -0
  8. package/dist/context-providers.d.ts.map +1 -0
  9. package/dist/context-providers.js +87 -0
  10. package/dist/context-providers.js.map +1 -0
  11. package/dist/control-api.d.ts +591 -0
  12. package/dist/control-api.d.ts.map +1 -0
  13. package/dist/control-api.js +445 -0
  14. package/dist/control-api.js.map +1 -0
  15. package/dist/envelopes.d.ts +296 -0
  16. package/dist/envelopes.d.ts.map +1 -0
  17. package/dist/envelopes.js +164 -0
  18. package/dist/envelopes.js.map +1 -0
  19. package/dist/fixtures.d.ts +142 -0
  20. package/dist/fixtures.d.ts.map +1 -0
  21. package/dist/fixtures.js +95 -0
  22. package/dist/fixtures.js.map +1 -0
  23. package/dist/identifiers.d.ts +77 -0
  24. package/dist/identifiers.d.ts.map +1 -0
  25. package/dist/identifiers.js +43 -0
  26. package/dist/identifiers.js.map +1 -0
  27. package/dist/index.d.ts +12 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +12 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/memory-writeback.d.ts +85 -0
  32. package/dist/memory-writeback.d.ts.map +1 -0
  33. package/dist/memory-writeback.js +74 -0
  34. package/dist/memory-writeback.js.map +1 -0
  35. package/dist/pagination.d.ts +13 -0
  36. package/dist/pagination.d.ts.map +1 -0
  37. package/dist/pagination.js +28 -0
  38. package/dist/pagination.js.map +1 -0
  39. package/dist/runtime-discovery.d.ts +822 -0
  40. package/dist/runtime-discovery.d.ts.map +1 -0
  41. package/dist/runtime-discovery.js +235 -0
  42. package/dist/runtime-discovery.js.map +1 -0
  43. package/dist/versioning.d.ts +38 -0
  44. package/dist/versioning.d.ts.map +1 -0
  45. package/dist/versioning.js +67 -0
  46. package/dist/versioning.js.map +1 -0
  47. package/package.json +50 -0
@@ -0,0 +1,95 @@
1
+ const contractVersion = { major: 3, minor: 0 };
2
+ const requestId = 'req_01JABCDEF0123456789ABCDEFG';
3
+ const commandId = 'cmd_01JABCDEF0123456789ABCDEFG';
4
+ const workspaceId = 'wsp_01JABCDEF0123456789ABCDEFG';
5
+ const projectId = 'prj_01JABCDEF0123456789ABCDEFG';
6
+ const traceId = 'trc_01JABCDEF0123456789ABCDEFG';
7
+ const correlation = { traceId };
8
+ const caller = { servicePrincipalId: 'svc_agent-hq' };
9
+ export const PublicContractFixtures = Object.freeze({
10
+ command: {
11
+ caller,
12
+ contractVersion,
13
+ requestId,
14
+ commandId,
15
+ idempotencyKey: 'intent-01JABCDEF0123456789ABCDEFG',
16
+ workspaceId,
17
+ projectId,
18
+ payloadHash: 'a'.repeat(64),
19
+ correlation,
20
+ operation: 'execution.submit',
21
+ issuedAt: '2026-08-23T12:00:00.000Z',
22
+ payload: { objective: 'Validate the public contract' },
23
+ },
24
+ request: {
25
+ caller,
26
+ contractVersion,
27
+ requestId,
28
+ workspaceId,
29
+ projectId,
30
+ correlation,
31
+ operation: 'runtime.list',
32
+ requestedAt: '2026-08-23T12:00:00.000Z',
33
+ parameters: { status: 'available' },
34
+ },
35
+ response: {
36
+ contractVersion,
37
+ requestId,
38
+ correlation,
39
+ data: { accepted: true },
40
+ },
41
+ errorResponse: {
42
+ contractVersion,
43
+ requestId,
44
+ correlation,
45
+ error: {
46
+ class: 'validation',
47
+ code: 'INVALID_REQUEST',
48
+ message: 'The request is invalid',
49
+ retryable: false,
50
+ source: 'client',
51
+ },
52
+ },
53
+ event: {
54
+ contractVersion,
55
+ eventId: 'evt_01JABCDEF0123456789ABCDEFG',
56
+ eventType: 'execution.accepted',
57
+ occurredAt: '2026-08-23T12:00:00.000Z',
58
+ workspaceId,
59
+ projectId,
60
+ correlation: { ...correlation, causationCommandId: commandId },
61
+ data: { executionId: 'exe_01JABCDEF0123456789ABCDEFG' },
62
+ },
63
+ usage: {
64
+ contractVersion,
65
+ requestId,
66
+ workspaceId,
67
+ executionId: 'exe_01JABCDEF0123456789ABCDEFG',
68
+ recordedAt: '2026-08-23T12:00:01.000Z',
69
+ correlation,
70
+ usage: {
71
+ inputTokens: 100,
72
+ outputTokens: 40,
73
+ durationMs: 1_200,
74
+ cost: { amount: '0.0042', currency: 'USD' },
75
+ },
76
+ },
77
+ artifact: {
78
+ contractVersion,
79
+ artifactId: 'art_01JABCDEF0123456789ABCDEFG',
80
+ version: 1,
81
+ mediaType: 'application/json',
82
+ digest: `sha256:${'b'.repeat(64)}`,
83
+ sizeBytes: 128,
84
+ locator: 'artifact://art_01JABCDEF0123456789ABCDEFG/1',
85
+ },
86
+ runtime: {
87
+ contractVersion,
88
+ runtimeNodeRefId: 'rnr_01JABCDEF0123456789ABCDEFG',
89
+ runtimeConnectionId: 'rtc_01JABCDEF0123456789ABCDEFG',
90
+ status: 'available',
91
+ observedAt: '2026-08-23T12:00:00.000Z',
92
+ readModel: { location: 'local', healthy: true },
93
+ },
94
+ });
95
+ //# sourceMappingURL=fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../src/fixtures.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAW,CAAA;AACvD,MAAM,SAAS,GAAG,gCAAgC,CAAA;AAClD,MAAM,SAAS,GAAG,gCAAgC,CAAA;AAClD,MAAM,WAAW,GAAG,gCAAgC,CAAA;AACpD,MAAM,SAAS,GAAG,gCAAgC,CAAA;AAClD,MAAM,OAAO,GAAG,gCAAgC,CAAA;AAChD,MAAM,WAAW,GAAG,EAAE,OAAO,EAAE,CAAA;AAC/B,MAAM,MAAM,GAAG,EAAE,kBAAkB,EAAE,cAA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AK,EAAE;YACL,WAAW,EAAE,GAAG;YAChB,YAAY,EAAE,EAAE;YAChB,UAAU,EAAE,KAAK;YACjB,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE;SAC5C;KACF;IACD,QAAQ,EAAE;QACR,eAAe;QACf,UAAU,EAAE,gCAAgC;QAC5C,OAAO,EAAE,CAAC;QACV,SAAS,EAAE,kBAAkB;QAC7B,MAAM,EAAE,UAAU,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;QAClC,SAAS,EAAE,GAAG;QACd,OAAO,EAAE,6CAA6C;KACvD;IACD,OAAO,EAAE;QACP,eAAe;QACf,gBAAgB,EAAE,gCAAgC;QAClD,mBAAmB,EAAE,gCAAgC;QACrD,MAAM,EAAE,WAAW;QACnB,UAAU,EAAE,0BAA0B;QACtC,SAAS,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;KAChD;CACF,CAAC,CAAA"}
@@ -0,0 +1,77 @@
1
+ import { z } from 'zod';
2
+ export type OpaqueIdentifier<Kind extends string> = string & {
3
+ readonly __identifierKind: Kind;
4
+ };
5
+ export declare const IdentifierSchemas: {
6
+ readonly requestId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"request ID">, string>>;
7
+ readonly commandId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"command ID">, string>>;
8
+ readonly workspaceId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"workspace ID">, string>>;
9
+ readonly projectId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"project ID">, string>>;
10
+ readonly taskId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"task ID">, string>>;
11
+ readonly agentId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"Agent ID">, string>>;
12
+ readonly profileId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"profile ID">, string>>;
13
+ readonly profileVersionId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"profile-version ID">, string>>;
14
+ readonly skillId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"Skill ID">, string>>;
15
+ readonly skillVersionId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"skill-version ID">, string>>;
16
+ readonly executionId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"execution ID">, string>>;
17
+ readonly delegationId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"delegation ID">, string>>;
18
+ readonly delegationGroupId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"delegation-group ID">, string>>;
19
+ readonly attemptId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"attempt ID">, string>>;
20
+ readonly workflowId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"workflow ID">, string>>;
21
+ readonly interactionId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"interaction ID">, string>>;
22
+ readonly runtimeDefinitionId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"runtime-definition ID">, string>>;
23
+ readonly runtimeNodeRefId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"runtime-node reference ID">, string>>;
24
+ readonly runtimeConnectionId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"runtime-connection ID">, string>>;
25
+ readonly externalSessionId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"external-session ID">, string>>;
26
+ readonly projectStateItemId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"ProjectState-item ID">, string>>;
27
+ readonly stateMutationId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"state-mutation ID">, string>>;
28
+ readonly statePromotionProposalId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"state-promotion-proposal ID">, string>>;
29
+ readonly contextPackageId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"ContextPackage ID">, string>>;
30
+ readonly executionPlanId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"ExecutionPlan ID">, string>>;
31
+ readonly artifactId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"Artifact reference ID">, string>>;
32
+ readonly toolDefinitionId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"tool-definition ID">, string>>;
33
+ readonly toolVersionId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"tool-version ID">, string>>;
34
+ readonly toolCallId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"tool-call ID">, string>>;
35
+ readonly credentialId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"credential ID">, string>>;
36
+ readonly credentialLeaseId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"credential-lease ID">, string>>;
37
+ readonly modelCallId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"model-call ID">, string>>;
38
+ readonly memoryWriteProposalId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"memory-write-proposal ID">, string>>;
39
+ readonly eventId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"event ID">, string>>;
40
+ readonly traceId: z.ZodPipe<z.ZodString, z.ZodTransform<OpaqueIdentifier<"trace ID">, string>>;
41
+ };
42
+ export type RequestId = z.output<(typeof IdentifierSchemas)['requestId']>;
43
+ export type CommandId = z.output<(typeof IdentifierSchemas)['commandId']>;
44
+ export type WorkspaceId = z.output<(typeof IdentifierSchemas)['workspaceId']>;
45
+ export type ProjectId = z.output<(typeof IdentifierSchemas)['projectId']>;
46
+ export type TaskId = z.output<(typeof IdentifierSchemas)['taskId']>;
47
+ export type AgentId = z.output<(typeof IdentifierSchemas)['agentId']>;
48
+ export type ProfileId = z.output<(typeof IdentifierSchemas)['profileId']>;
49
+ export type ProfileVersionId = z.output<(typeof IdentifierSchemas)['profileVersionId']>;
50
+ export type SkillId = z.output<(typeof IdentifierSchemas)['skillId']>;
51
+ export type SkillVersionId = z.output<(typeof IdentifierSchemas)['skillVersionId']>;
52
+ export type ExecutionId = z.output<(typeof IdentifierSchemas)['executionId']>;
53
+ export type DelegationId = z.output<(typeof IdentifierSchemas)['delegationId']>;
54
+ export type DelegationGroupId = z.output<(typeof IdentifierSchemas)['delegationGroupId']>;
55
+ export type AttemptId = z.output<(typeof IdentifierSchemas)['attemptId']>;
56
+ export type WorkflowId = z.output<(typeof IdentifierSchemas)['workflowId']>;
57
+ export type InteractionId = z.output<(typeof IdentifierSchemas)['interactionId']>;
58
+ export type RuntimeDefinitionId = z.output<(typeof IdentifierSchemas)['runtimeDefinitionId']>;
59
+ export type RuntimeNodeRefId = z.output<(typeof IdentifierSchemas)['runtimeNodeRefId']>;
60
+ export type RuntimeConnectionId = z.output<(typeof IdentifierSchemas)['runtimeConnectionId']>;
61
+ export type ExternalSessionId = z.output<(typeof IdentifierSchemas)['externalSessionId']>;
62
+ export type ProjectStateItemId = z.output<(typeof IdentifierSchemas)['projectStateItemId']>;
63
+ export type StateMutationId = z.output<(typeof IdentifierSchemas)['stateMutationId']>;
64
+ export type StatePromotionProposalId = z.output<(typeof IdentifierSchemas)['statePromotionProposalId']>;
65
+ export type ContextPackageId = z.output<(typeof IdentifierSchemas)['contextPackageId']>;
66
+ export type ExecutionPlanId = z.output<(typeof IdentifierSchemas)['executionPlanId']>;
67
+ export type ArtifactId = z.output<(typeof IdentifierSchemas)['artifactId']>;
68
+ export type ToolDefinitionId = z.output<(typeof IdentifierSchemas)['toolDefinitionId']>;
69
+ export type ToolVersionId = z.output<(typeof IdentifierSchemas)['toolVersionId']>;
70
+ export type ToolCallId = z.output<(typeof IdentifierSchemas)['toolCallId']>;
71
+ export type CredentialId = z.output<(typeof IdentifierSchemas)['credentialId']>;
72
+ export type CredentialLeaseId = z.output<(typeof IdentifierSchemas)['credentialLeaseId']>;
73
+ export type ModelCallId = z.output<(typeof IdentifierSchemas)['modelCallId']>;
74
+ export type MemoryWriteProposalId = z.output<(typeof IdentifierSchemas)['memoryWriteProposalId']>;
75
+ export type EventId = z.output<(typeof IdentifierSchemas)['eventId']>;
76
+ export type TraceId = z.output<(typeof IdentifierSchemas)['traceId']>;
77
+ //# sourceMappingURL=identifiers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identifiers.d.ts","sourceRoot":"","sources":["../src/identifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,MAAM,gBAAgB,CAAC,IAAI,SAAS,MAAM,IAAI,MAAM,GAAG;IAC3D,QAAQ,CAAC,gBAAgB,EAAE,IAAI,CAAA;CAChC,CAAA;AAQD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCpB,CAAA;AAEV,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,iBAAiB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAA;AACzE,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,iBAAiB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAA;AACzE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,iBAAiB,CAAC,CAAC,aAAa,CAAC,CAAC,CAAA;AAC7E,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,iBAAiB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAA;AACzE,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,iBAAiB,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAA;AACnE,MAAM,MAAM,OA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C,CAAC,CAAA;AACvF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,iBAAiB,CAAC,CAAC,eAAe,CAAC,CAAC,CAAA;AACjF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,iBAAiB,CAAC,CAAC,YAAY,CAAC,CAAC,CAAA;AAC3E,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,iBAAiB,CAAC,CAAC,cAAc,CAAC,CAAC,CAAA;AAC/E,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,iBAAiB,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAA;AACzF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,iBAAiB,CAAC,CAAC,aAAa,CAAC,CAAC,CAAA;AAC7E,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,iBAAiB,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAA;AACjG,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,iBAAiB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;AACrE,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,iBAAiB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA"}
@@ -0,0 +1,43 @@
1
+ import { z } from 'zod';
2
+ const opaqueIdentifier = (prefix, kind) => z
3
+ .string()
4
+ .regex(new RegExp(`^${prefix}_[0-9A-HJKMNP-TV-Z]{26}$`), `Expected a canonical opaque ${kind}`)
5
+ .transform((value) => value);
6
+ export const IdentifierSchemas = {
7
+ requestId: opaqueIdentifier('req', 'request ID'),
8
+ commandId: opaqueIdentifier('cmd', 'command ID'),
9
+ workspaceId: opaqueIdentifier('wsp', 'workspace ID'),
10
+ projectId: opaqueIdentifier('prj', 'project ID'),
11
+ taskId: opaqueIdentifier('tsk', 'task ID'),
12
+ agentId: opaqueIdentifier('agt', 'Agent ID'),
13
+ profileId: opaqueIdentifier('prf', 'profile ID'),
14
+ profileVersionId: opaqueIdentifier('pfv', 'profile-version ID'),
15
+ skillId: opaqueIdentifier('skl', 'Skill ID'),
16
+ skillVersionId: opaqueIdentifier('skv', 'skill-version ID'),
17
+ executionId: opaqueIdentifier('exe', 'execution ID'),
18
+ delegationId: opaqueIdentifier('dlg', 'delegation ID'),
19
+ delegationGroupId: opaqueIdentifier('dgr', 'delegation-group ID'),
20
+ attemptId: opaqueIdentifier('att', 'attempt ID'),
21
+ workflowId: opaqueIdentifier('wfl', 'workflow ID'),
22
+ interactionId: opaqueIdentifier('int', 'interaction ID'),
23
+ runtimeDefinitionId: opaqueIdentifier('rtd', 'runtime-definition ID'),
24
+ runtimeNodeRefId: opaqueIdentifier('rnr', 'runtime-node reference ID'),
25
+ runtimeConnectionId: opaqueIdentifier('rtc', 'runtime-connection ID'),
26
+ externalSessionId: opaqueIdentifier('ses', 'external-session ID'),
27
+ projectStateItemId: opaqueIdentifier('psi', 'ProjectState-item ID'),
28
+ stateMutationId: opaqueIdentifier('stm', 'state-mutation ID'),
29
+ statePromotionProposalId: opaqueIdentifier('spp', 'state-promotion-proposal ID'),
30
+ contextPackageId: opaqueIdentifier('ctx', 'ContextPackage ID'),
31
+ executionPlanId: opaqueIdentifier('pln', 'ExecutionPlan ID'),
32
+ artifactId: opaqueIdentifier('art', 'Artifact reference ID'),
33
+ toolDefinitionId: opaqueIdentifier('tld', 'tool-definition ID'),
34
+ toolVersionId: opaqueIdentifier('tlv', 'tool-version ID'),
35
+ toolCallId: opaqueIdentifier('tlc', 'tool-call ID'),
36
+ credentialId: opaqueIdentifier('crd', 'credential ID'),
37
+ credentialLeaseId: opaqueIdentifier('crl', 'credential-lease ID'),
38
+ modelCallId: opaqueIdentifier('mdc', 'model-call ID'),
39
+ memoryWriteProposalId: opaqueIdentifier('mwp', 'memory-write-proposal ID'),
40
+ eventId: opaqueIdentifier('evt', 'event ID'),
41
+ traceId: opaqueIdentifier('trc', 'trace ID'),
42
+ };
43
+ //# sourceMappingURL=identifiers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identifiers.js","sourceRoot":"","sources":["../src/identifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,MAAM,gBAAgB,GAAG,CAAsB,MAAc,EAAE,IAAU,EAAE,EAAE,CAC3E,CAAC;KACE,MAAM,EAAE;KACR,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,MAAM,0BAA0B,CAAC,EAAE,+BAA+B,IAAI,EAAE,CAAC;KAC9F,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAA+B,CAAC,CAAA;AAE1D,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,SAAS,EAAE,gBAAgB,CAAC,KAAK,EAAE,YAAY,CAAC;IAChD,SAAS,EAAE,gBAAgB,CAAC,KAAK,EAAE,YAAY,CAAC;IAChD,WAAW,EAAE,gBAAgB,CAAC,KAAK,EAAE,cAAc,CAAC;IACpD,SAAS,EAAE,gBAAgB,CAAC,KAAK,EAAE,YAAY,CAAC;IAChD,MAAM,EAAE,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1C,OAAO,EAAE,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC;IAC5C,SAAS,EAAE,gBAAgB,CAAC,KAAK,EAAE,YAAY,CAAC;IAChD,gBAAgB,EAAE,gBAAgB,CAAC,KAAK,EAAE,oBAAoB,CAAC;IAC/D,OAAO,EAAE,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC;IAC5C,cAAc,EAAE,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,CAAC;IAC3D,WAAW,EAAE,gBAAgB,CAAC,KAAK,EAAE,cAAc,CAAC;IACpD,YAAY,EAAE,gB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;IACrD,qBAAqB,EAAE,gBAAgB,CAAC,KAAK,EAAE,0BAA0B,CAAC;IAC1E,OAAO,EAAE,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC;IAC5C,OAAO,EAAE,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC;CACpC,CAAA"}
@@ -0,0 +1,12 @@
1
+ export * from './authentication.js';
2
+ export * from './control-api.js';
3
+ export * from './context-providers.js';
4
+ export * from './envelopes.js';
5
+ export * from './fixtures.js';
6
+ export * from './identifiers.js';
7
+ export * from './memory-writeback.js';
8
+ export * from './pagination.js';
9
+ export * from './runtime-discovery.js';
10
+ export * from './versioning.js';
11
+ export declare const packageName = "contracts";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAE/B,eAAO,MAAM,WAAW,cAAc,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ export * from './authentication.js';
2
+ export * from './control-api.js';
3
+ export * from './context-providers.js';
4
+ export * from './envelopes.js';
5
+ export * from './fixtures.js';
6
+ export * from './identifiers.js';
7
+ export * from './memory-writeback.js';
8
+ export * from './pagination.js';
9
+ export * from './runtime-discovery.js';
10
+ export * from './versioning.js';
11
+ export const packageName = 'contracts';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAE/B,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAA"}
@@ -0,0 +1,85 @@
1
+ import { z } from 'zod';
2
+ export declare const MemoryWritePolicySchema: z.ZodObject<{
3
+ mode: z.ZodDefault<z.ZodEnum<{
4
+ disabled: "disabled";
5
+ proposal_only: "proposal_only";
6
+ approval_required: "approval_required";
7
+ }>>;
8
+ maximumBytes: z.ZodNumber;
9
+ allowedSensitivities: z.ZodArray<z.ZodEnum<{
10
+ internal: "internal";
11
+ public: "public";
12
+ confidential: "confidential";
13
+ restricted: "restricted";
14
+ }>>;
15
+ approvalPrincipalIds: z.ZodArray<z.ZodString>;
16
+ }, z.core.$strip>;
17
+ export declare const MemoryWriteProposalSchema: z.ZodObject<{
18
+ proposalId: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").OpaqueIdentifier<"memory-write-proposal ID">, string>>;
19
+ providerId: z.ZodString;
20
+ connectionId: z.ZodString;
21
+ workspaceId: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").OpaqueIdentifier<"workspace ID">, string>>;
22
+ scopeDigest: z.ZodString;
23
+ memoryType: z.ZodEnum<{
24
+ fact: "fact";
25
+ preference: "preference";
26
+ observation: "observation";
27
+ summary: "summary";
28
+ }>;
29
+ content: z.ZodString;
30
+ retention: z.ZodEnum<{
31
+ session: "session";
32
+ project: "project";
33
+ durable: "durable";
34
+ }>;
35
+ provenance: z.ZodObject<{
36
+ sourceExecutionId: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").OpaqueIdentifier<"execution ID">, string>>;
37
+ sourceAttemptId: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").OpaqueIdentifier<"attempt ID">, string>>;
38
+ confidence: z.ZodNumber;
39
+ importance: z.ZodNumber;
40
+ sensitivity: z.ZodEnum<{
41
+ internal: "internal";
42
+ public: "public";
43
+ confidential: "confidential";
44
+ restricted: "restricted";
45
+ }>;
46
+ expiresAt: z.ZodOptional<z.ZodISODateTime>;
47
+ evidenceRefs: z.ZodArray<z.ZodString>;
48
+ artifactRefs: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").OpaqueIdentifier<"Artifact reference ID">, string>>>;
49
+ }, z.core.$strip>;
50
+ dedupeHint: z.ZodString;
51
+ contentDigest: z.ZodString;
52
+ state: z.ZodEnum<{
53
+ revoked: "revoked";
54
+ failed: "failed";
55
+ reconciliation_required: "reconciliation_required";
56
+ proposed: "proposed";
57
+ awaiting_approval: "awaiting_approval";
58
+ approved: "approved";
59
+ denied: "denied";
60
+ expired: "expired";
61
+ committing: "committing";
62
+ committed: "committed";
63
+ }>;
64
+ version: z.ZodNumber;
65
+ createdAt: z.ZodISODateTime;
66
+ updatedAt: z.ZodISODateTime;
67
+ approvalInteractionId: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").OpaqueIdentifier<"interaction ID">, string>>>;
68
+ outcome: z.ZodOptional<z.ZodObject<{
69
+ code: z.ZodEnum<{
70
+ revoked: "revoked";
71
+ failed: "failed";
72
+ approved: "approved";
73
+ denied: "denied";
74
+ expired: "expired";
75
+ committed: "committed";
76
+ reconciled: "reconciled";
77
+ ambiguous: "ambiguous";
78
+ }>;
79
+ observedAt: z.ZodISODateTime;
80
+ providerMemoryRef: z.ZodOptional<z.ZodString>;
81
+ }, z.core.$strip>>;
82
+ }, z.core.$strip>;
83
+ export type MemoryWritePolicy = z.output<typeof MemoryWritePolicySchema>;
84
+ export type MemoryWriteProposal = z.output<typeof MemoryWriteProposalSchema>;
85
+ //# sourceMappingURL=memory-writeback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-writeback.d.ts","sourceRoot":"","sources":["../src/memory-writeback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAQvB,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;iBAKlC,CAAA;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4DlC,CAAA;AAEJ,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAA;AACxE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,yBAAyB,CAAC,CAAA"}
@@ -0,0 +1,74 @@
1
+ import { z } from 'zod';
2
+ import { IdentifierSchemas } from './identifiers.js';
3
+ const DigestSchema = z.string().regex(/^sha256:[a-f0-9]{64}$/);
4
+ const ProviderIdSchema = z.string().regex(/^ctp_[0-9A-HJKMNP-TV-Z]{26}$/);
5
+ const ConnectionIdSchema = z.string().regex(/^ctc_[0-9A-HJKMNP-TV-Z]{26}$/);
6
+ const TimestampSchema = z.iso.datetime();
7
+ export const MemoryWritePolicySchema = z.object({
8
+ mode: z.enum(['disabled', 'proposal_only', 'approval_required']).default('disabled'),
9
+ maximumBytes: z.number().int().positive().max(65_536),
10
+ allowedSensitivities: z.array(z.enum(['public', 'internal', 'confidential', 'restricted'])),
11
+ approvalPrincipalIds: z.array(z.string().min(3).max(128)).max(64),
12
+ });
13
+ export const MemoryWriteProposalSchema = z
14
+ .object({
15
+ proposalId: IdentifierSchemas.memoryWriteProposalId,
16
+ providerId: ProviderIdSchema,
17
+ connectionId: ConnectionIdSchema,
18
+ workspaceId: IdentifierSchemas.workspaceId,
19
+ scopeDigest: DigestSchema,
20
+ memoryType: z.enum(['fact', 'preference', 'observation', 'summary']),
21
+ content: z.string().min(1).max(65_536),
22
+ retention: z.enum(['session', 'project', 'durable']),
23
+ provenance: z.object({
24
+ sourceExecutionId: IdentifierSchemas.executionId,
25
+ sourceAttemptId: IdentifierSchemas.attemptId,
26
+ confidence: z.number().min(0).max(1),
27
+ importance: z.number().min(0).max(1),
28
+ sensitivity: z.enum(['public', 'internal', 'confidential', 'restricted']),
29
+ expiresAt: TimestampSchema.optional(),
30
+ evidenceRefs: z.array(z.string().min(1).max(1_024)).max(64),
31
+ artifactRefs: z.array(IdentifierSchemas.artifactId).max(64),
32
+ }),
33
+ dedupeHint: z.string().min(1).max(256),
34
+ contentDigest: DigestSchema,
35
+ state: z.enum([
36
+ 'proposed',
37
+ 'awaiting_approval',
38
+ 'approved',
39
+ 'denied',
40
+ 'expired',
41
+ 'revoked',
42
+ 'committing',
43
+ 'committed',
44
+ 'failed',
45
+ 'reconciliation_required',
46
+ ]),
47
+ version: z.number().int().positive(),
48
+ createdAt: TimestampSchema,
49
+ updatedAt: TimestampSchema,
50
+ approvalInteractionId: IdentifierSchemas.interactionId.optional(),
51
+ outcome: z
52
+ .object({
53
+ code: z.enum([
54
+ 'approved',
55
+ 'denied',
56
+ 'expired',
57
+ 'revoked',
58
+ 'failed',
59
+ 'committed',
60
+ 'reconciled',
61
+ 'ambiguous',
62
+ ]),
63
+ observedAt: TimestampSchema,
64
+ providerMemoryRef: z.string().min(1).max(512).optional(),
65
+ })
66
+ .optional(),
67
+ })
68
+ .superRefine((proposal, context) => {
69
+ if (Buffer.byteLength(proposal.content, 'utf8') > 65_536)
70
+ context.addIssue({ code: 'custom', path: ['content'], message: 'Content exceeds byte limit' });
71
+ if (proposal.approvalInteractionId && proposal.state === 'proposed')
72
+ context.addIssue({ code: 'custom', message: 'Proposed state cannot have approval effect' });
73
+ });
74
+ //# sourceMappingURL=memory-writeback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-writeback.js","sourceRoot":"","sources":["../src/memory-writeback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,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export interface CursorPosition {
4
+ readonly sortKey: string;
5
+ readonly id: string;
6
+ }
7
+ export declare function encodeCursor(position: CursorPosition): string;
8
+ export declare function decodeCursor(cursor: string): CursorPosition;
9
+ export declare const PageSchema: z.ZodObject<{
10
+ nextCursor: z.ZodOptional<z.ZodString>;
11
+ }, z.core.$strip>;
12
+ export type Cursor = z.output<typeof CursorSchema>;
13
+ //# sourceMappingURL=pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,YAAY,aAIO,CAAA;AAEhC,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CACpB;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAI7D;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAW3D;AAED,eAAO,MAAM,UAAU;;iBAAoD,CAAA;AAE3E,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,YAAY,CAAC,CAAA"}
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ export const CursorSchema = z
3
+ .string()
4
+ .min(8)
5
+ .max(512)
6
+ .regex(/^cur_[A-Za-z0-9_-]+$/);
7
+ export function encodeCursor(position) {
8
+ if (!position.sortKey || !position.id)
9
+ throw new Error('INVALID_CURSOR_POSITION');
10
+ const payload = JSON.stringify({ id: position.id, sortKey: position.sortKey });
11
+ return `cur_${Buffer.from(payload, 'utf8').toString('base64url')}`;
12
+ }
13
+ export function decodeCursor(cursor) {
14
+ CursorSchema.parse(cursor);
15
+ let value;
16
+ try {
17
+ value = JSON.parse(Buffer.from(cursor.slice(4), 'base64url').toString('utf8'));
18
+ }
19
+ catch {
20
+ throw new Error('INVALID_CURSOR');
21
+ }
22
+ const parsed = z.object({ sortKey: z.string().min(1), id: z.string().min(1) }).safeParse(value);
23
+ if (!parsed.success)
24
+ throw new Error('INVALID_CURSOR');
25
+ return parsed.data;
26
+ }
27
+ export const PageSchema = z.object({ nextCursor: CursorSchema.optional() });
28
+ //# sourceMappingURL=pagination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.js","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC;KAC1B,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,GAAG,CAAC;KACR,KAAK,CAAC,sBAAsB,CAAC,CAAA;AAOhC,MAAM,UAAU,YAAY,CAAC,QAAwB;IACnD,IAAI,CAAC,QAAQ,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IACjF,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IAC9E,OAAO,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAA;AACpE,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC1B,IAAI,KAAc,CAAA;IAClB,IAAI,CAAC;QACH,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;IAChF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