@adea-ai/runtime-sdk 1.18.0 → 1.19.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.
@@ -60,6 +60,11 @@ export declare const PI_DURABLE_OBSERVED_GENERATION_CONTRACT_VERSION: {
60
60
  readonly minor: 1;
61
61
  };
62
62
  export declare function supportsPiDurableObservedGeneration(consumerVersion: unknown): boolean;
63
+ export declare const PI_DURABLE_REMOTE_SESSION_REFERENCE_CONTRACT_VERSION: {
64
+ readonly major: 3;
65
+ readonly minor: 2;
66
+ };
67
+ export declare function supportsPiDurableRemoteSessionReference(consumerVersion: unknown): boolean;
63
68
  export declare const PiDurableLeadPrepareRequestSchema: z.ZodObject<{
64
69
  contractVersion: z.ZodObject<{
65
70
  major: z.ZodNumber;
@@ -509,6 +514,17 @@ export declare const PiDurableLeadChildTargetSchema: z.ZodObject<{
509
514
  observedAt: z.ZodISODateTime;
510
515
  observedGeneration: z.ZodOptional<typeof RuntimeObservedGenerationSchema>;
511
516
  }, z.core.$strict>;
517
+ export declare const PiDurableLeadRemoteSessionReferenceSchema: z.ZodReadonly<z.ZodObject<{
518
+ schemaVersion: z.ZodLiteral<"pi-child-remote-session-reference/v1">;
519
+ source: z.ZodLiteral<"control_plane_reported">;
520
+ basis: z.ZodLiteral<"retained_native_attribution">;
521
+ runtimeConnectionId: typeof IdentifierSchemas.runtimeConnectionId;
522
+ nativeSessionId: typeof IdentifierSchemas.externalSessionId;
523
+ permission: z.ZodLiteral<"none">;
524
+ history: z.ZodLiteral<"adapter_journal_only">;
525
+ attachment: z.ZodLiteral<"unavailable">;
526
+ }, z.core.$strict>>;
527
+ export type PiDurableLeadRemoteSessionReference = z.output<typeof PiDurableLeadRemoteSessionReferenceSchema>;
512
528
  export declare const PiDurableLeadChildTargetResponseSchema: z.ZodObject<{
513
529
  contractVersion: z.ZodObject<{
514
530
  major: z.ZodNumber;
@@ -544,6 +560,21 @@ export declare const PiDurableLeadChildTargetResponseSchema: z.ZodObject<{
544
560
  NOT_STARTED: "NOT_STARTED";
545
561
  UNAVAILABLE: "UNAVAILABLE";
546
562
  }>>;
563
+ remoteSessionReference: z.ZodOptional<z.ZodNullable<z.ZodReadonly<z.ZodObject<{
564
+ schemaVersion: z.ZodLiteral<"pi-child-remote-session-reference/v1">;
565
+ source: z.ZodLiteral<"control_plane_reported">;
566
+ basis: z.ZodLiteral<"retained_native_attribution">;
567
+ runtimeConnectionId: typeof IdentifierSchemas.runtimeConnectionId;
568
+ nativeSessionId: typeof IdentifierSchemas.externalSessionId;
569
+ permission: z.ZodLiteral<"none">;
570
+ history: z.ZodLiteral<"adapter_journal_only">;
571
+ attachment: z.ZodLiteral<"unavailable">;
572
+ }, z.core.$strict>>>>;
573
+ remoteSessionReferenceUnavailableReason: z.ZodOptional<z.ZodEnum<{
574
+ NOT_CONFIGURED: "NOT_CONFIGURED";
575
+ NOT_STARTED: "NOT_STARTED";
576
+ UNAVAILABLE: "UNAVAILABLE";
577
+ }>>;
547
578
  }, z.core.$strict>;
548
579
  }, z.core.$strict>;
549
580
  export declare const PiDurableLeadHttpContract: Readonly<{
@@ -39,6 +39,15 @@ export function supportsPiDurableObservedGeneration(consumerVersion) {
39
39
  return (negotiated.major === PI_DURABLE_OBSERVED_GENERATION_CONTRACT_VERSION.major &&
40
40
  negotiated.minor >= PI_DURABLE_OBSERVED_GENERATION_CONTRACT_VERSION.minor);
41
41
  }
42
+ export const PI_DURABLE_REMOTE_SESSION_REFERENCE_CONTRACT_VERSION = { major: 3, minor: 2 };
43
+ export function supportsPiDurableRemoteSessionReference(consumerVersion) {
44
+ const consumer = ContractVersionSchema.safeParse(consumerVersion);
45
+ if (!consumer.success)
46
+ return false;
47
+ const negotiated = negotiateContractVersion([PublicContractManifest.current], [consumer.data]);
48
+ return (negotiated?.major === PI_DURABLE_REMOTE_SESSION_REFERENCE_CONTRACT_VERSION.major &&
49
+ negotiated.minor >= PI_DURABLE_REMOTE_SESSION_REFERENCE_CONTRACT_VERSION.minor);
50
+ }
42
51
  function fenceForeignGeneration(receipt, context) {
43
52
  const foreign = (generation) => generation !== undefined && generation.attemptId !== receipt.attemptId;
44
53
  if (foreign(receipt.observedTarget?.generation))
@@ -306,12 +315,43 @@ export const PiDurableLeadChildTargetSchema = z.strictObject({
306
315
  observedAt: z.iso.datetime(),
307
316
  observedGeneration: RuntimeObservedGenerationSchema.optional(),
308
317
  });
318
+ export const PiDurableLeadRemoteSessionReferenceSchema = z
319
+ .strictObject({
320
+ schemaVersion: z.literal('pi-child-remote-session-reference/v1'),
321
+ source: z.literal('control_plane_reported'),
322
+ basis: z.literal('retained_native_attribution'),
323
+ runtimeConnectionId: IdentifierSchemas.runtimeConnectionId,
324
+ nativeSessionId: IdentifierSchemas.externalSessionId,
325
+ permission: z.literal('none'),
326
+ history: z.literal('adapter_journal_only'),
327
+ attachment: z.literal('unavailable'),
328
+ })
329
+ .readonly();
309
330
  export const PiDurableLeadChildTargetResponseSchema = response.extend({
310
331
  data: PiDurableLeadReceiptResponseSchema.extend({
311
332
  child: PiDurableLeadChildSchema,
312
333
  target: PiDurableLeadChildTargetSchema.nullable(),
313
334
  unavailableReason: z.enum(['NOT_STARTED', 'NOT_CONFIGURED', 'UNAVAILABLE']).optional(),
335
+ remoteSessionReference: PiDurableLeadRemoteSessionReferenceSchema.nullable().optional(),
336
+ remoteSessionReferenceUnavailableReason: z
337
+ .enum(['NOT_STARTED', 'NOT_CONFIGURED', 'UNAVAILABLE'])
338
+ .optional(),
314
339
  }).superRefine((value, context) => {
340
+ const reference = value.remoteSessionReference;
341
+ if ((reference === null) !== (value.remoteSessionReferenceUnavailableReason !== undefined))
342
+ context.addIssue({
343
+ code: 'custom',
344
+ message: 'Unavailable remote reference requires a bounded reason',
345
+ });
346
+ if (reference &&
347
+ (value.child.childAttemptId === undefined ||
348
+ (value.target !== null &&
349
+ (reference.runtimeConnectionId !== value.target.runtimeConnectionId ||
350
+ reference.nativeSessionId !== value.target.nativeSessionId))))
351
+ context.addIssue({
352
+ code: 'custom',
353
+ message: 'Remote reference must bind the selected child target',
354
+ });
315
355
  if ((value.target === null) !== (value.unavailableReason !== undefined))
316
356
  context.addIssue({ code: 'custom', message: 'Unavailable target requires a bounded reason' });
317
357
  if (value.target &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adea-ai/runtime-sdk",
3
- "version": "1.18.0",
3
+ "version": "1.19.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",
@@ -43,7 +43,7 @@
43
43
  "test": "bun test src"
44
44
  },
45
45
  "dependencies": {
46
- "@adea-ai/contracts": "^1.23.1",
46
+ "@adea-ai/contracts": "^1.24.0",
47
47
  "zod": "4.6.6"
48
48
  },
49
49
  "engines": {