@adea-ai/runtime-sdk 1.23.0 → 1.24.0

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.
package/README.md CHANGED
@@ -1,13 +1,11 @@
1
1
  # @control-plane/runtime-sdk
2
2
 
3
3
  SDK for building runtimes that plug into the Control Plane: implement the
4
- adapter interface, declare capabilities, pass conformance, and speak the
5
- gateway protocol — without touching Control Plane internals.
4
+ adapter interface, declare capabilities, and pass conformance — without
5
+ touching Control Plane internals.
6
6
 
7
7
  Depends only on [`@adea-ai/contracts`](https://www.npmjs.com/package/@adea-ai/contracts)
8
- and Zod. Pair it with
9
- [`@adea-ai/runtime-gateway-protocol`](https://www.npmjs.com/package/@adea-ai/runtime-gateway-protocol)
10
- for the wire protocol and [`@adea-ai/contracts`](https://www.npmjs.com/package/@adea-ai/contracts)
8
+ and Zod. Pair it with [`@adea-ai/contracts`](https://www.npmjs.com/package/@adea-ai/contracts)
11
9
  for the service boundary.
12
10
 
13
11
  ## What's inside
@@ -20,8 +18,8 @@ for the service boundary.
20
18
  - **Conformance & compatibility** — versioned conformance suites and
21
19
  compatibility checks for runtime implementations.
22
20
  - **Sessions & routing** — external session types and routing decisions.
23
- - **Transport** — transport ports with deterministic in-memory doubles
24
- (`mock.ts`, `fixtures.ts`) for testing adapters without a live gateway.
21
+ - **Transport** — the co-located transport port with deterministic in-memory
22
+ doubles (`mock.ts`, `fixtures.ts`) for testing adapters.
25
23
 
26
24
  Runtime usage accounting distinguishes HQ-funded API usage (`hq_managed`),
27
25
  user-funded API usage (`byo_api`), and external subscriptions
package/dist/adapter.d.ts CHANGED
@@ -12,7 +12,6 @@ export declare const RuntimeAdapterMetadataSchema: z.ZodObject<{
12
12
  harnessVersion: z.ZodString;
13
13
  transportKind: z.ZodOptional<z.ZodEnum<{
14
14
  "direct-local": "direct-local";
15
- "remote-gateway": "remote-gateway";
16
15
  }>>;
17
16
  }, z.core.$strict>;
18
17
  export declare const RuntimeAdapterInspectionSchema: z.ZodObject<{
@@ -28,7 +27,6 @@ export declare const RuntimeAdapterInspectionSchema: z.ZodObject<{
28
27
  harnessVersion: z.ZodString;
29
28
  transportKind: z.ZodOptional<z.ZodEnum<{
30
29
  "direct-local": "direct-local";
31
- "remote-gateway": "remote-gateway";
32
30
  }>>;
33
31
  }, z.core.$strict>;
34
32
  health: z.ZodEnum<{
package/dist/adapter.js CHANGED
@@ -23,7 +23,7 @@ export const RuntimeAdapterMetadataSchema = z
23
23
  .regex(/^[a-z][a-z0-9-]*$/),
24
24
  driverVersion: SemanticVersionSchema,
25
25
  harnessVersion: SemanticVersionSchema,
26
- transportKind: z.enum(['direct-local', 'remote-gateway']).optional(),
26
+ transportKind: z.enum(['direct-local']).optional(),
27
27
  })
28
28
  .strict();
29
29
  const CapabilityEvaluationSchema = z
@@ -13,10 +13,6 @@ export declare const RuntimeChannelOwnershipSchema: z.ZodObject<{
13
13
  lastHeartbeatAt: z.ZodISODateTime;
14
14
  }, z.core.$strict>;
15
15
  export type RuntimeChannelOwnership = z.output<typeof RuntimeChannelOwnershipSchema>;
16
- export interface RuntimeChannelOwnershipCredentialFence {
17
- readonly credentialId: string;
18
- readonly revocationVersion: number;
19
- }
20
16
  export declare const RuntimeChannelSequenceRequestSchema: z.ZodObject<{
21
17
  channel: z.ZodObject<{
22
18
  nodeId: z.ZodString;
@@ -38,12 +34,3 @@ export type RuntimeChannelSequenceRequest = z.output<typeof RuntimeChannelSequen
38
34
  export interface RuntimeChannelSequenceRepository {
39
35
  reserve(request: RuntimeChannelSequenceRequest): Promise<number>;
40
36
  }
41
- export interface RuntimeChannelOwnershipRepository {
42
- claim(record: RuntimeChannelOwnership, credentialFence?: RuntimeChannelOwnershipCredentialFence): Promise<{
43
- accepted: boolean;
44
- previous?: RuntimeChannelOwnership;
45
- }>;
46
- lookup(nodeId: string): Promise<RuntimeChannelOwnership | undefined>;
47
- heartbeat(record: RuntimeChannelOwnership, credentialFence?: RuntimeChannelOwnershipCredentialFence): Promise<boolean>;
48
- release(record: RuntimeChannelOwnership): Promise<boolean>;
49
- }
@@ -78,7 +78,6 @@ export declare const RuntimeCertificationSchema: z.ZodObject<{
78
78
  "direct-local-transport-integration": "direct-local-transport-integration";
79
79
  "hosted-runtime-integration": "hosted-runtime-integration";
80
80
  "runtime-adapter-conformance": "runtime-adapter-conformance";
81
- "runtime-gateway-integration": "runtime-gateway-integration";
82
81
  }>;
83
82
  source: z.ZodString;
84
83
  command: z.ZodString;
@@ -166,7 +165,6 @@ export declare const RuntimeCompatibilityMatrixSchema: z.ZodObject<{
166
165
  "direct-local-transport-integration": "direct-local-transport-integration";
167
166
  "hosted-runtime-integration": "hosted-runtime-integration";
168
167
  "runtime-adapter-conformance": "runtime-adapter-conformance";
169
- "runtime-gateway-integration": "runtime-gateway-integration";
170
168
  }>;
171
169
  source: z.ZodString;
172
170
  command: z.ZodString;
@@ -54,7 +54,6 @@ export const RuntimeCertificationSchema = z
54
54
  suite: z.enum([
55
55
  'runtime-adapter-conformance',
56
56
  'direct-local-transport-integration',
57
- 'runtime-gateway-integration',
58
57
  'hosted-runtime-integration',
59
58
  ]),
60
59
  source: z
@@ -73,7 +72,8 @@ export const RuntimeCertificationSchema = z
73
72
  .superRefine((certification, context) => {
74
73
  if (certification.classification === 'supported' &&
75
74
  (!certification.evidence.some((entry) => entry.suite === 'runtime-adapter-conformance') ||
76
- !certification.evidence.some((entry) => ['direct-local-transport-integration', 'runtime-gateway-integration'].includes(entry.suite) || entry.suite === 'hosted-runtime-integration'))) {
75
+ !certification.evidence.some((entry) => entry.suite === 'direct-local-transport-integration' ||
76
+ entry.suite === 'hosted-runtime-integration'))) {
77
77
  context.addIssue({
78
78
  code: 'custom',
79
79
  path: ['evidence'],
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './adapter.js';
2
2
  export * from './pi-durable-lead.js';
3
3
  export * from './pi-durable-questions.js';
4
+ export * from './pi-durable-approvals.js';
4
5
  export * from './agent-plugins.js';
5
6
  export * from './channel-ownership.js';
6
7
  export * from './capabilities.js';
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './adapter.js';
2
2
  export * from './pi-durable-lead.js';
3
3
  export * from './pi-durable-questions.js';
4
+ export * from './pi-durable-approvals.js';
4
5
  export * from './agent-plugins.js';
5
6
  export * from './channel-ownership.js';
6
7
  export * from './capabilities.js';
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+ import { IdentifierSchemas } from '@adea-ai/contracts';
3
+ export declare const PiDurableApprovalEffectDigestSchema: z.ZodString;
4
+ export declare const PiDurableApprovalDecisionIdSchema: z.ZodString;
5
+ export declare const PiDurableApprovalAnswerSchema: z.ZodObject<{
6
+ dispatchId: z.ZodString;
7
+ approvalId: typeof IdentifierSchemas.interactionId;
8
+ effectDigest: z.ZodString;
9
+ decision: z.ZodEnum<{
10
+ approve: "approve";
11
+ deny: "deny";
12
+ }>;
13
+ decisionId: z.ZodString;
14
+ }, z.core.$strict>;
15
+ export declare const PiDurableApprovalAttestationSchema: z.ZodObject<{
16
+ decidedBy: z.ZodString;
17
+ senderKeyId: z.ZodString;
18
+ keyringRevision: z.ZodNumber;
19
+ }, z.core.$strict>;
20
+ export declare const PiDurableApprovalDecisionSchema: z.ZodObject<{
21
+ decidedBy: z.ZodString;
22
+ senderKeyId: z.ZodString;
23
+ keyringRevision: z.ZodNumber;
24
+ schemaVersion: z.ZodLiteral<"pi-lead-approval-decision/v1">;
25
+ workspaceId: typeof IdentifierSchemas.workspaceId;
26
+ dispatchId: z.ZodString;
27
+ executionId: typeof IdentifierSchemas.executionId;
28
+ attemptId: typeof IdentifierSchemas.attemptId;
29
+ approvalId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"interaction ID">, string>>;
30
+ effectDigest: z.ZodString;
31
+ decision: z.ZodEnum<{
32
+ approve: "approve";
33
+ deny: "deny";
34
+ }>;
35
+ decisionId: z.ZodString;
36
+ decidedAt: z.ZodISODateTime;
37
+ deadlineAt: z.ZodISODateTime;
38
+ }, z.core.$strict>;
39
+ export type PiDurableApprovalAnswer = z.output<typeof PiDurableApprovalAnswerSchema>;
40
+ export type PiDurableApprovalAttestation = z.output<typeof PiDurableApprovalAttestationSchema>;
41
+ export type PiDurableApprovalDecision = z.output<typeof PiDurableApprovalDecisionSchema>;
42
+ export interface PiDurableApprovalDecisionAuthority {
43
+ readonly principalId: string;
44
+ authorize(decision: PiDurableApprovalDecision): Promise<boolean>;
45
+ publish?(decision: PiDurableApprovalDecision): Promise<void>;
46
+ }
47
+ export declare function samePiDurableApprovalDecision(left: PiDurableApprovalDecision, right: PiDurableApprovalDecision): boolean;
@@ -0,0 +1,40 @@
1
+ import { z } from 'zod';
2
+ import { canonicalJsonStringify, IdentifierSchemas } from '@adea-ai/contracts';
3
+ export const PiDurableApprovalEffectDigestSchema = z.string().regex(/^sha256:[a-f0-9]{64}$/);
4
+ export const PiDurableApprovalDecisionIdSchema = z.string().regex(/^pi-decision:[a-f0-9]{32}$/);
5
+ const Reference = z
6
+ .string()
7
+ .min(1)
8
+ .max(256)
9
+ .regex(/^[A-Za-z0-9._:-]+$/);
10
+ export const PiDurableApprovalAnswerSchema = z.strictObject({
11
+ dispatchId: z.string().regex(/^dispatch_[a-f0-9]{32}$/),
12
+ approvalId: IdentifierSchemas.interactionId,
13
+ effectDigest: PiDurableApprovalEffectDigestSchema,
14
+ decision: z.enum(['approve', 'deny']),
15
+ decisionId: PiDurableApprovalDecisionIdSchema,
16
+ });
17
+ export const PiDurableApprovalAttestationSchema = z.strictObject({
18
+ decidedBy: Reference,
19
+ senderKeyId: Reference,
20
+ keyringRevision: z.number().int().min(1),
21
+ });
22
+ export const PiDurableApprovalDecisionSchema = z.strictObject({
23
+ schemaVersion: z.literal('pi-lead-approval-decision/v1'),
24
+ workspaceId: IdentifierSchemas.workspaceId,
25
+ dispatchId: PiDurableApprovalAnswerSchema.shape.dispatchId,
26
+ executionId: IdentifierSchemas.executionId,
27
+ attemptId: IdentifierSchemas.attemptId,
28
+ approvalId: PiDurableApprovalAnswerSchema.shape.approvalId,
29
+ effectDigest: PiDurableApprovalEffectDigestSchema,
30
+ decision: PiDurableApprovalAnswerSchema.shape.decision,
31
+ decisionId: PiDurableApprovalDecisionIdSchema,
32
+ ...PiDurableApprovalAttestationSchema.shape,
33
+ decidedAt: z.iso.datetime(),
34
+ deadlineAt: z.iso.datetime(),
35
+ });
36
+ export function samePiDurableApprovalDecision(left, right) {
37
+ const { decidedAt: _left, ...a } = left;
38
+ const { decidedAt: _right, ...b } = right;
39
+ return canonicalJsonStringify(a) === canonicalJsonStringify(b);
40
+ }
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { PiDurableQuestionAnswersSchema, PiDurableQuestionRequestIdSchema } from './pi-durable-questions.js';
3
+ import { PiDurableApprovalAnswerSchema, PiDurableApprovalAttestationSchema } from './pi-durable-approvals.js';
3
4
  import { IdentifierSchemas, ModelSelectionRefSchema } from '@adea-ai/contracts';
4
5
  import { RuntimeExecutionProgressSchema, RuntimeExecutionStatusSchema, RuntimeExecutionStateSchema, RuntimeObservedGenerationSchema } from './adapter.js';
5
6
  declare const IntentId: z.ZodUUID;
@@ -159,6 +160,7 @@ export declare const PiDurableLeadProgressRequestSchema: z.ZodObject<{
159
160
  export declare const PI_DURABLE_LEAD_EVENTS_CONTRACT_VERSION = 1;
160
161
  export declare const PI_DURABLE_LEAD_EVENTS_MAX_PAGE = 256;
161
162
  export declare const PI_DURABLE_LEAD_EVENTS_MAX_WAIT_MS = 8000;
163
+ export declare const PiDurableSessionIdSchema: z.ZodString;
162
164
  export declare const PiDurableLeadEventsRequestSchema: z.ZodObject<{
163
165
  contractVersion: z.ZodObject<{
164
166
  major: z.ZodNumber;
@@ -182,7 +184,7 @@ export declare const PiDurableLeadEventsRequestSchema: z.ZodObject<{
182
184
  export declare const PiDurableLeadTurnEventSchema: z.ZodObject<{
183
185
  schemaVersion: z.ZodLiteral<1>;
184
186
  eventId: z.ZodString;
185
- runtimeSessionId: z.ZodString;
187
+ runtimeSessionId: typeof PiDurableSessionIdSchema;
186
188
  harnessRunId: z.ZodString;
187
189
  generation: z.ZodLiteral<1>;
188
190
  seq: z.ZodString;
@@ -229,6 +231,44 @@ export declare const PiDurableLeadChildrenRequestSchema: z.ZodObject<{
229
231
  limit: z.ZodOptional<z.ZodNumber>;
230
232
  }, z.core.$strict>;
231
233
  }, z.core.$strict>;
234
+ export declare const PI_DURABLE_SESSIONS_MAX_PAGE = 256;
235
+ export declare const PiDurableSessionsRequestSchema: z.ZodObject<{
236
+ contractVersion: z.ZodObject<{
237
+ major: z.ZodNumber;
238
+ minor: z.ZodNumber;
239
+ }, z.core.$strict>;
240
+ requestId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"request ID">, string>>;
241
+ workspaceId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"workspace ID">, string>>;
242
+ projectId: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"project ID">, string>>>;
243
+ requestedAt: z.ZodISODateTime;
244
+ caller: typeof Caller;
245
+ correlation: typeof Correlation;
246
+ operation: z.ZodLiteral<"pi-durable.lead.sessions">;
247
+ parameters: z.ZodObject<{
248
+ runtimeSessionId: z.ZodOptional<typeof PiDurableSessionIdSchema>;
249
+ after: z.ZodOptional<typeof PiDurableSessionIdSchema>;
250
+ limit: z.ZodOptional<z.ZodNumber>;
251
+ }, z.core.$strict>;
252
+ }, z.core.$strict>;
253
+ export declare const PiDurableSessionEventsRequestSchema: z.ZodObject<{
254
+ contractVersion: z.ZodObject<{
255
+ major: z.ZodNumber;
256
+ minor: z.ZodNumber;
257
+ }, z.core.$strict>;
258
+ requestId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"request ID">, string>>;
259
+ workspaceId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"workspace ID">, string>>;
260
+ projectId: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"project ID">, string>>>;
261
+ requestedAt: z.ZodISODateTime;
262
+ caller: typeof Caller;
263
+ correlation: typeof Correlation;
264
+ operation: z.ZodLiteral<"pi-durable.lead.session-events">;
265
+ parameters: z.ZodObject<{
266
+ runtimeSessionId: typeof PiDurableSessionIdSchema;
267
+ afterSeq: z.ZodNumber;
268
+ waitMs: z.ZodNumber;
269
+ limit: z.ZodOptional<z.ZodNumber>;
270
+ }, z.core.$strict>;
271
+ }, z.core.$strict>;
232
272
  export declare const PiDurableLeadChildTargetRequestSchema: z.ZodObject<{
233
273
  contractVersion: z.ZodObject<{
234
274
  major: z.ZodNumber;
@@ -286,6 +326,23 @@ export declare const PiDurableLeadQuestionAnswerRequestSchema: z.ZodObject<{
286
326
  answers: typeof PiDurableQuestionAnswersSchema;
287
327
  }, z.core.$strict>;
288
328
  }, z.core.$strict>;
329
+ export declare const PiDurableLeadApprovalAnswerRequestSchema: z.ZodObject<{
330
+ contractVersion: z.ZodObject<{
331
+ major: z.ZodNumber;
332
+ minor: z.ZodNumber;
333
+ }, z.core.$strict>;
334
+ requestId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"request ID">, string>>;
335
+ workspaceId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"workspace ID">, string>>;
336
+ projectId: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"project ID">, string>>>;
337
+ commandId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"command ID">, string>>;
338
+ idempotencyKey: z.ZodString;
339
+ payloadHash: z.ZodString;
340
+ issuedAt: z.ZodISODateTime;
341
+ caller: typeof Caller;
342
+ correlation: typeof Correlation;
343
+ operation: z.ZodLiteral<"pi-durable.lead.approval-answer">;
344
+ payload: z.ZodObject<typeof PiDurableApprovalAnswerSchema.shape & typeof PiDurableApprovalAttestationSchema.shape, z.core.$strict>;
345
+ }, z.core.$strict>;
289
346
  export declare const PiDurableLeadChildCancelRequestSchema: z.ZodObject<{
290
347
  contractVersion: z.ZodObject<{
291
348
  major: z.ZodNumber;
@@ -560,6 +617,42 @@ export declare const PiDurableLeadQuestionAnswerResponseSchema: z.ZodObject<{
560
617
  status: typeof RuntimeExecutionStatusSchema;
561
618
  }, z.core.$strict>;
562
619
  }, z.core.$strict>;
620
+ export declare const PiDurableLeadApprovalAnswerResponseSchema: z.ZodObject<{
621
+ contractVersion: z.ZodObject<{
622
+ major: z.ZodNumber;
623
+ minor: z.ZodNumber;
624
+ }, z.core.$strict>;
625
+ requestId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"request ID">, string>>;
626
+ correlation: z.ZodObject<{
627
+ traceId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"trace ID">, string>>;
628
+ causationCommandId: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"command ID">, string>>>;
629
+ parentEventId: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"event ID">, string>>>;
630
+ }, z.core.$strict>;
631
+ data: z.ZodObject<{
632
+ schemaVersion: z.ZodLiteral<"pi-lead-dispatch/v1">;
633
+ dispatchId: typeof DispatchId;
634
+ intentId: typeof IntentId;
635
+ executionId: typeof IdentifierSchemas.executionId;
636
+ attemptId: typeof IdentifierSchemas.attemptId;
637
+ runtimeSessionId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"external-session ID">, string>>;
638
+ requestedTarget: z.ZodOptional<typeof PiDurableLeadRequestedTargetSchema>;
639
+ observedTarget: z.ZodOptional<typeof PiDurableLeadObservedTargetSchema>;
640
+ approvalSchemaVersion: z.ZodLiteral<"pi-lead-approval-answer/v1">;
641
+ approvalId: typeof IdentifierSchemas.interactionId;
642
+ decisionId: z.ZodString;
643
+ requestEventId: z.ZodString;
644
+ decision: z.ZodEnum<{
645
+ approve: "approve";
646
+ deny: "deny";
647
+ }>;
648
+ outcome: z.ZodEnum<{
649
+ already_decided: "already_decided";
650
+ decided: "decided";
651
+ }>;
652
+ state: typeof RuntimeExecutionStateSchema;
653
+ status: typeof RuntimeExecutionStatusSchema;
654
+ }, z.core.$strict>;
655
+ }, z.core.$strict>;
563
656
  export declare const PiDurableLeadEventsResponseSchema: z.ZodObject<{
564
657
  contractVersion: z.ZodObject<{
565
658
  major: z.ZodNumber;
@@ -573,6 +666,56 @@ export declare const PiDurableLeadEventsResponseSchema: z.ZodObject<{
573
666
  }, z.core.$strict>;
574
667
  data: typeof PiDurableLeadEventsDataSchema;
575
668
  }, z.core.$strict>;
669
+ export declare const PiDurableSessionSchema: z.ZodObject<{
670
+ runtimeSessionId: typeof PiDurableSessionIdSchema;
671
+ role: z.ZodEnum<{
672
+ child: "child";
673
+ lead: "lead";
674
+ }>;
675
+ dispatchId: typeof DispatchId;
676
+ intentId: typeof IntentId;
677
+ delegationId: z.ZodOptional<typeof IdentifierSchemas.delegationId>;
678
+ executionId: typeof IdentifierSchemas.executionId;
679
+ attemptId: typeof IdentifierSchemas.attemptId;
680
+ state: typeof RuntimeExecutionStateSchema;
681
+ startedAt: z.ZodISODateTime;
682
+ updatedAt: z.ZodISODateTime;
683
+ }, z.core.$strict>;
684
+ export declare const PiDurableSessionsResponseSchema: z.ZodObject<{
685
+ contractVersion: z.ZodObject<{
686
+ major: z.ZodNumber;
687
+ minor: z.ZodNumber;
688
+ }, z.core.$strict>;
689
+ requestId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"request ID">, string>>;
690
+ correlation: z.ZodObject<{
691
+ traceId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"trace ID">, string>>;
692
+ causationCommandId: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"command ID">, string>>>;
693
+ parentEventId: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"event ID">, string>>>;
694
+ }, z.core.$strict>;
695
+ data: z.ZodObject<{
696
+ sessions: z.ZodArray<typeof PiDurableSessionSchema>;
697
+ next: z.ZodOptional<typeof PiDurableSessionIdSchema>;
698
+ }, z.core.$strict>;
699
+ }, z.core.$strict>;
700
+ export declare const PiDurableSessionEventsResponseSchema: z.ZodObject<{
701
+ contractVersion: z.ZodObject<{
702
+ major: z.ZodNumber;
703
+ minor: z.ZodNumber;
704
+ }, z.core.$strict>;
705
+ requestId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"request ID">, string>>;
706
+ correlation: z.ZodObject<{
707
+ traceId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"trace ID">, string>>;
708
+ causationCommandId: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"command ID">, string>>>;
709
+ parentEventId: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"event ID">, string>>>;
710
+ }, z.core.$strict>;
711
+ data: z.ZodObject<{
712
+ contractVersion: z.ZodLiteral<1>;
713
+ runtimeSessionId: typeof PiDurableSessionIdSchema;
714
+ events: z.ZodArray<typeof PiDurableLeadTurnEventSchema>;
715
+ nextSeq: z.ZodNumber;
716
+ complete: z.ZodBoolean;
717
+ }, z.core.$strict>;
718
+ }, z.core.$strict>;
576
719
  declare const ChildReference: z.ZodString;
577
720
  export declare const PiDurableLeadChildOutcomeSchema: z.ZodObject<{
578
721
  state: z.ZodEnum<{
@@ -598,6 +741,7 @@ export declare const PiDurableLeadChildSchema: z.ZodObject<{
598
741
  delegationId: typeof IdentifierSchemas.delegationId;
599
742
  childExecutionId: typeof IdentifierSchemas.executionId;
600
743
  childAttemptId: z.ZodOptional<typeof IdentifierSchemas.attemptId>;
744
+ runtimeSessionId: z.ZodOptional<typeof IdentifierSchemas.externalSessionId>;
601
745
  role: typeof ChildReference;
602
746
  state: z.ZodEnum<{
603
747
  awaiting_input: "awaiting_input";
@@ -810,6 +954,20 @@ export declare const PiDurableLeadHttpContract: Readonly<{
810
954
  requestSchema: typeof PiDurableLeadChildTargetRequestSchema;
811
955
  responseSchema: typeof PiDurableLeadChildTargetResponseSchema;
812
956
  }>;
957
+ sessions: Readonly<{
958
+ route: "sessions";
959
+ operation: "pi-durable.lead.sessions";
960
+ scope: "execution:read";
961
+ requestSchema: typeof PiDurableSessionsRequestSchema;
962
+ responseSchema: typeof PiDurableSessionsResponseSchema;
963
+ }>;
964
+ sessionEvents: Readonly<{
965
+ route: "session-events";
966
+ operation: "pi-durable.lead.session-events";
967
+ scope: "execution:read";
968
+ requestSchema: typeof PiDurableSessionEventsRequestSchema;
969
+ responseSchema: typeof PiDurableSessionEventsResponseSchema;
970
+ }>;
813
971
  cancel: Readonly<{
814
972
  route: "cancel";
815
973
  operation: "pi-durable.lead.cancel";
@@ -824,6 +982,13 @@ export declare const PiDurableLeadHttpContract: Readonly<{
824
982
  requestSchema: typeof PiDurableLeadQuestionAnswerRequestSchema;
825
983
  responseSchema: typeof PiDurableLeadQuestionAnswerResponseSchema;
826
984
  }>;
985
+ approvalAnswer: Readonly<{
986
+ route: "approvals/answer";
987
+ operation: "pi-durable.lead.approval-answer";
988
+ scope: "execution:write";
989
+ requestSchema: typeof PiDurableLeadApprovalAnswerRequestSchema;
990
+ responseSchema: typeof PiDurableLeadApprovalAnswerResponseSchema;
991
+ }>;
827
992
  childCancel: Readonly<{
828
993
  route: "child-cancel";
829
994
  operation: "pi-durable.lead.child-cancel";
@@ -848,12 +1013,19 @@ export type PiDurableLeadEventsRequest = z.output<typeof PiDurableLeadEventsRequ
848
1013
  export type PiDurableLeadEventsResponse = z.output<typeof PiDurableLeadEventsResponseSchema>;
849
1014
  export type PiDurableLeadTurnEvent = z.output<typeof PiDurableLeadTurnEventSchema>;
850
1015
  export type PiDurableLeadChildrenRequest = z.output<typeof PiDurableLeadChildrenRequestSchema>;
1016
+ export type PiDurableSession = z.output<typeof PiDurableSessionSchema>;
1017
+ export type PiDurableSessionsRequest = z.output<typeof PiDurableSessionsRequestSchema>;
1018
+ export type PiDurableSessionsResponse = z.output<typeof PiDurableSessionsResponseSchema>;
1019
+ export type PiDurableSessionEventsRequest = z.output<typeof PiDurableSessionEventsRequestSchema>;
1020
+ export type PiDurableSessionEventsResponse = z.output<typeof PiDurableSessionEventsResponseSchema>;
851
1021
  export type PiDurableLeadChildrenResponse = z.output<typeof PiDurableLeadChildrenResponseSchema>;
852
1022
  export type PiDurableLeadChild = z.output<typeof PiDurableLeadChildSchema>;
853
1023
  export type PiDurableLeadCancelRequest = z.output<typeof PiDurableLeadCancelRequestSchema>;
854
1024
  export type PiDurableLeadCancelResponse = z.output<typeof PiDurableLeadCancelResponseSchema>;
855
1025
  export type PiDurableLeadQuestionAnswerRequest = z.output<typeof PiDurableLeadQuestionAnswerRequestSchema>;
856
1026
  export type PiDurableLeadQuestionAnswerResponse = z.output<typeof PiDurableLeadQuestionAnswerResponseSchema>;
1027
+ export type PiDurableLeadApprovalAnswerRequest = z.output<typeof PiDurableLeadApprovalAnswerRequestSchema>;
1028
+ export type PiDurableLeadApprovalAnswerResponse = z.output<typeof PiDurableLeadApprovalAnswerResponseSchema>;
857
1029
  export type PiDurableLeadChildCancelRequest = z.output<typeof PiDurableLeadChildCancelRequestSchema>;
858
1030
  export type PiDurableLeadChildCancelResponse = z.output<typeof PiDurableLeadChildCancelResponseSchema>;
859
1031
  export type PiDurableLeadChildTargetRequest = z.output<typeof PiDurableLeadChildTargetRequestSchema>;
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { PiDurableQuestionAnswersSchema, PiDurableQuestionRequestIdSchema, } from './pi-durable-questions.js';
3
+ import { PiDurableApprovalAnswerSchema, PiDurableApprovalAttestationSchema, PiDurableApprovalDecisionIdSchema, } from './pi-durable-approvals.js';
3
4
  import { ContractVersionSchema, IdentifierSchemas, ModelSelectionFundingViewSchema, ModelSelectionRefSchema, PublicContractManifest, ReadRequestEnvelopeSchema, StateChangingCommandEnvelopeSchema, SuccessResponseEnvelopeSchema, negotiateContractVersion, } from '@adea-ai/contracts';
4
5
  import { RuntimeExecutionHandleSchema, RuntimeExecutionProgressSchema, RuntimeExecutionStatusSchema, RuntimeExecutionStateSchema, RuntimeObservedGenerationSchema, } from './adapter.js';
5
6
  const IntentId = z.uuid();
@@ -106,6 +107,9 @@ export const PI_DURABLE_LEAD_EVENTS_CONTRACT_VERSION = 1;
106
107
  export const PI_DURABLE_LEAD_EVENTS_MAX_PAGE = 256;
107
108
  export const PI_DURABLE_LEAD_EVENTS_MAX_WAIT_MS = 8000;
108
109
  const LeadEventSeq = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
110
+ export const PiDurableSessionIdSchema = z
111
+ .string()
112
+ .regex(/^(?:pi-lead:dispatch_[a-f0-9]{32}|ses_[0-9A-HJKMNP-TV-Z]{26})$/);
109
113
  export const PiDurableLeadEventsRequestSchema = PiDurableLeadReadEnvelopeSchema.extend({
110
114
  operation: z.literal('pi-durable.lead.events'),
111
115
  parameters: z
@@ -126,7 +130,7 @@ export const PiDurableLeadTurnEventSchema = z
126
130
  .object({
127
131
  schemaVersion: z.literal(1),
128
132
  eventId: z.string().min(1).max(256),
129
- runtimeSessionId: z.string().regex(/^pi-lead:dispatch_[a-f0-9]{32}$/),
133
+ runtimeSessionId: PiDurableSessionIdSchema,
130
134
  harnessRunId: z.string().min(1).max(256),
131
135
  generation: z.literal(1),
132
136
  seq: z.string().regex(/^[1-9]\d*$/),
@@ -180,6 +184,28 @@ export const PiDurableLeadChildrenRequestSchema = PiDurableLeadReadEnvelopeSchem
180
184
  })
181
185
  .strict(),
182
186
  });
187
+ export const PI_DURABLE_SESSIONS_MAX_PAGE = 256;
188
+ export const PiDurableSessionsRequestSchema = PiDurableLeadReadEnvelopeSchema.extend({
189
+ operation: z.literal('pi-durable.lead.sessions'),
190
+ parameters: z
191
+ .object({
192
+ runtimeSessionId: PiDurableSessionIdSchema.optional(),
193
+ after: PiDurableSessionIdSchema.optional(),
194
+ limit: z.number().int().min(1).max(PI_DURABLE_SESSIONS_MAX_PAGE).optional(),
195
+ })
196
+ .strict(),
197
+ });
198
+ export const PiDurableSessionEventsRequestSchema = PiDurableLeadReadEnvelopeSchema.extend({
199
+ operation: z.literal('pi-durable.lead.session-events'),
200
+ parameters: z
201
+ .object({
202
+ runtimeSessionId: PiDurableSessionIdSchema,
203
+ afterSeq: LeadEventSeq,
204
+ waitMs: z.number().int().min(0).max(PI_DURABLE_LEAD_EVENTS_MAX_WAIT_MS),
205
+ limit: z.number().int().min(1).max(PI_DURABLE_LEAD_EVENTS_MAX_PAGE).optional(),
206
+ })
207
+ .strict(),
208
+ });
183
209
  export const PiDurableLeadChildTargetRequestSchema = PiDurableLeadReadEnvelopeSchema.extend({
184
210
  operation: z.literal('pi-durable.lead.child-target'),
185
211
  parameters: z
@@ -203,6 +229,10 @@ export const PiDurableLeadQuestionAnswerRequestSchema = PiDurableLeadCommandEnve
203
229
  })
204
230
  .strict(),
205
231
  });
232
+ export const PiDurableLeadApprovalAnswerRequestSchema = PiDurableLeadCommandEnvelopeSchema.extend({
233
+ operation: z.literal('pi-durable.lead.approval-answer'),
234
+ payload: PiDurableApprovalAnswerSchema.extend(PiDurableApprovalAttestationSchema.shape),
235
+ });
206
236
  export const PiDurableLeadChildCancelRequestSchema = PiDurableLeadCommandEnvelopeSchema.extend({
207
237
  operation: z.literal('pi-durable.lead.child-cancel'),
208
238
  payload: z
@@ -340,9 +370,96 @@ export const PiDurableLeadQuestionAnswerResponseSchema = response.extend({
340
370
  status: RuntimeExecutionStatusSchema,
341
371
  }),
342
372
  });
373
+ export const PiDurableLeadApprovalAnswerResponseSchema = response.extend({
374
+ data: PiDurableLeadReceiptResponseSchema.extend({
375
+ approvalSchemaVersion: z.literal('pi-lead-approval-answer/v1'),
376
+ approvalId: IdentifierSchemas.interactionId,
377
+ decisionId: PiDurableApprovalDecisionIdSchema,
378
+ requestEventId: z.string().min(1).max(256),
379
+ decision: z.enum(['approve', 'deny']),
380
+ outcome: z.enum(['decided', 'already_decided']),
381
+ state: RuntimeExecutionStateSchema,
382
+ status: RuntimeExecutionStatusSchema,
383
+ }),
384
+ });
343
385
  export const PiDurableLeadEventsResponseSchema = response.extend({
344
386
  data: PiDurableLeadEventsDataSchema,
345
387
  });
388
+ export const PiDurableSessionSchema = z
389
+ .object({
390
+ runtimeSessionId: PiDurableSessionIdSchema,
391
+ role: z.enum(['lead', 'child']),
392
+ dispatchId: DispatchId,
393
+ intentId: IntentId,
394
+ delegationId: IdentifierSchemas.delegationId.optional(),
395
+ executionId: IdentifierSchemas.executionId,
396
+ attemptId: IdentifierSchemas.attemptId,
397
+ state: RuntimeExecutionStateSchema,
398
+ startedAt: z.iso.datetime(),
399
+ updatedAt: z.iso.datetime(),
400
+ })
401
+ .strict()
402
+ .superRefine((value, context) => {
403
+ const lead = value.runtimeSessionId === `pi-lead:${value.dispatchId}`;
404
+ if ((value.role === 'lead') !== lead ||
405
+ (value.role === 'lead') !== (value.delegationId === undefined))
406
+ context.addIssue({
407
+ code: 'custom',
408
+ message: 'A lead session is its dispatch; a child session names its delegation',
409
+ });
410
+ });
411
+ export const PiDurableSessionsResponseSchema = response.extend({
412
+ data: z
413
+ .object({
414
+ sessions: z.array(PiDurableSessionSchema).max(PI_DURABLE_SESSIONS_MAX_PAGE),
415
+ next: PiDurableSessionIdSchema.optional(),
416
+ })
417
+ .strict()
418
+ .superRefine((value, context) => {
419
+ value.sessions.forEach((session, index) => {
420
+ const previous = value.sessions[index - 1];
421
+ if (previous && previous.runtimeSessionId >= session.runtimeSessionId)
422
+ context.addIssue({
423
+ code: 'custom',
424
+ path: ['sessions', index],
425
+ message: 'Sessions are unique and sorted by runtimeSessionId',
426
+ });
427
+ });
428
+ if (value.next !== undefined && value.next !== value.sessions.at(-1)?.runtimeSessionId)
429
+ context.addIssue({ code: 'custom', path: ['next'], message: 'next is the last session' });
430
+ }),
431
+ });
432
+ export const PiDurableSessionEventsResponseSchema = response.extend({
433
+ data: z
434
+ .object({
435
+ contractVersion: z.literal(PI_DURABLE_LEAD_EVENTS_CONTRACT_VERSION),
436
+ runtimeSessionId: PiDurableSessionIdSchema,
437
+ events: z
438
+ .array(PiDurableLeadTurnEventSchema)
439
+ .max(PI_DURABLE_LEAD_EVENTS_MAX_PAGE),
440
+ nextSeq: LeadEventSeq,
441
+ complete: z.boolean(),
442
+ })
443
+ .strict()
444
+ .superRefine((value, context) => {
445
+ const first = value.nextSeq - value.events.length + 1;
446
+ value.events.forEach((event, index) => {
447
+ if (event.seq !== String(first + index) ||
448
+ event.runtimeSessionId !== value.runtimeSessionId)
449
+ context.addIssue({
450
+ code: 'custom',
451
+ path: ['events', index],
452
+ message: 'Events must be the contiguous seqs of this session ending at nextSeq',
453
+ });
454
+ });
455
+ if (first < 1)
456
+ context.addIssue({
457
+ code: 'custom',
458
+ path: ['nextSeq'],
459
+ message: 'nextSeq precedes the page',
460
+ });
461
+ }),
462
+ });
346
463
  const ChildReference = z
347
464
  .string()
348
465
  .trim()
@@ -367,6 +484,7 @@ export const PiDurableLeadChildSchema = z
367
484
  delegationId: IdentifierSchemas.delegationId,
368
485
  childExecutionId: IdentifierSchemas.executionId,
369
486
  childAttemptId: IdentifierSchemas.attemptId.optional(),
487
+ runtimeSessionId: IdentifierSchemas.externalSessionId.optional(),
370
488
  role: ChildReference,
371
489
  state: z.enum([
372
490
  'requested',
@@ -566,6 +684,20 @@ export const PiDurableLeadHttpContract = Object.freeze({
566
684
  requestSchema: PiDurableLeadChildTargetRequestSchema,
567
685
  responseSchema: PiDurableLeadChildTargetResponseSchema,
568
686
  }),
687
+ sessions: Object.freeze({
688
+ route: 'sessions',
689
+ operation: 'pi-durable.lead.sessions',
690
+ scope: 'execution:read',
691
+ requestSchema: PiDurableSessionsRequestSchema,
692
+ responseSchema: PiDurableSessionsResponseSchema,
693
+ }),
694
+ sessionEvents: Object.freeze({
695
+ route: 'session-events',
696
+ operation: 'pi-durable.lead.session-events',
697
+ scope: 'execution:read',
698
+ requestSchema: PiDurableSessionEventsRequestSchema,
699
+ responseSchema: PiDurableSessionEventsResponseSchema,
700
+ }),
569
701
  cancel: Object.freeze({
570
702
  route: 'cancel',
571
703
  operation: 'pi-durable.lead.cancel',
@@ -580,6 +712,13 @@ export const PiDurableLeadHttpContract = Object.freeze({
580
712
  requestSchema: PiDurableLeadQuestionAnswerRequestSchema,
581
713
  responseSchema: PiDurableLeadQuestionAnswerResponseSchema,
582
714
  }),
715
+ approvalAnswer: Object.freeze({
716
+ route: 'approvals/answer',
717
+ operation: 'pi-durable.lead.approval-answer',
718
+ scope: 'execution:write',
719
+ requestSchema: PiDurableLeadApprovalAnswerRequestSchema,
720
+ responseSchema: PiDurableLeadApprovalAnswerResponseSchema,
721
+ }),
583
722
  childCancel: Object.freeze({
584
723
  route: 'child-cancel',
585
724
  operation: 'pi-durable.lead.child-cancel',
@@ -1,5 +1,5 @@
1
1
  import type { RuntimeAdapter, RuntimeAdapterInspection, RuntimeApprovalRequest, RuntimeCancelRequest, RuntimeExecutionHandle, RuntimeExecutionProgress, RuntimeExecutionStatus, RuntimeInputRequest, RuntimeProgressOptions, RuntimeSessionOperation, RuntimeSessionResult, RuntimeStartRequest } from './adapter.js';
2
- export type RuntimeTransportKind = 'direct-local' | 'remote-gateway';
2
+ export type RuntimeTransportKind = 'direct-local';
3
3
  export type RuntimeDriver = RuntimeAdapter;
4
4
  export interface RuntimeTransport extends RuntimeAdapter {
5
5
  readonly kind: RuntimeTransportKind;
@@ -34,7 +34,4 @@ export declare class TransportedRuntimeAdapter extends DelegatingRuntimeAdapter
34
34
  export declare class DirectLocalRuntimeTransport extends DelegatingRuntimeTransport {
35
35
  readonly kind: 'direct-local';
36
36
  }
37
- export declare class RemoteRuntimeGatewayTransport extends DelegatingRuntimeTransport {
38
- readonly kind: 'remote-gateway';
39
- }
40
37
  export {};
package/dist/transport.js CHANGED
@@ -61,6 +61,3 @@ export class TransportedRuntimeAdapter extends DelegatingRuntimeAdapter {
61
61
  export class DirectLocalRuntimeTransport extends DelegatingRuntimeTransport {
62
62
  kind = 'direct-local';
63
63
  }
64
- export class RemoteRuntimeGatewayTransport extends DelegatingRuntimeTransport {
65
- kind = 'remote-gateway';
66
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adea-ai/runtime-sdk",
3
- "version": "1.23.0",
3
+ "version": "1.24.0",
4
4
  "description": "SDK for building Control Plane runtimes: adapters, capabilities, conformance, discovery, eligibility, health, sessions, transport, and routing.",
5
5
  "keywords": [
6
6
  "adapter",
@@ -31,8 +31,7 @@
31
31
  }
32
32
  },
33
33
  "publishConfig": {
34
- "access": "public",
35
- "provenance": true
34
+ "access": "public"
36
35
  },
37
36
  "scripts": {
38
37
  "build": "tsc -p tsconfig.json",
@@ -43,7 +42,7 @@
43
42
  "test": "bun test src"
44
43
  },
45
44
  "dependencies": {
46
- "@adea-ai/contracts": "^3.0.0",
45
+ "@adea-ai/contracts": "^3.1.0",
47
46
  "zod": "4.6.6"
48
47
  },
49
48
  "engines": {