@adea-ai/runtime-sdk 1.18.0 → 1.20.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/dist/pi-durable-lead.d.ts +44 -0
- package/dist/pi-durable-lead.js +80 -0
- package/package.json +2 -2
|
@@ -60,6 +60,12 @@ 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;
|
|
68
|
+
export declare function supportsPiDurableRemoteOwnerObservation(consumerVersion: unknown): boolean;
|
|
63
69
|
export declare const PiDurableLeadPrepareRequestSchema: z.ZodObject<{
|
|
64
70
|
contractVersion: z.ZodObject<{
|
|
65
71
|
major: z.ZodNumber;
|
|
@@ -509,6 +515,17 @@ export declare const PiDurableLeadChildTargetSchema: z.ZodObject<{
|
|
|
509
515
|
observedAt: z.ZodISODateTime;
|
|
510
516
|
observedGeneration: z.ZodOptional<typeof RuntimeObservedGenerationSchema>;
|
|
511
517
|
}, z.core.$strict>;
|
|
518
|
+
export declare const PiDurableLeadRemoteSessionReferenceSchema: z.ZodReadonly<z.ZodObject<{
|
|
519
|
+
schemaVersion: z.ZodLiteral<"pi-child-remote-session-reference/v1">;
|
|
520
|
+
source: z.ZodLiteral<"control_plane_reported">;
|
|
521
|
+
basis: z.ZodLiteral<"retained_native_attribution">;
|
|
522
|
+
runtimeConnectionId: typeof IdentifierSchemas.runtimeConnectionId;
|
|
523
|
+
nativeSessionId: typeof IdentifierSchemas.externalSessionId;
|
|
524
|
+
permission: z.ZodLiteral<"none">;
|
|
525
|
+
history: z.ZodLiteral<"adapter_journal_only">;
|
|
526
|
+
attachment: z.ZodLiteral<"unavailable">;
|
|
527
|
+
}, z.core.$strict>>;
|
|
528
|
+
export type PiDurableLeadRemoteSessionReference = z.output<typeof PiDurableLeadRemoteSessionReferenceSchema>;
|
|
512
529
|
export declare const PiDurableLeadChildTargetResponseSchema: z.ZodObject<{
|
|
513
530
|
contractVersion: z.ZodObject<{
|
|
514
531
|
major: z.ZodNumber;
|
|
@@ -544,6 +561,33 @@ export declare const PiDurableLeadChildTargetResponseSchema: z.ZodObject<{
|
|
|
544
561
|
NOT_STARTED: "NOT_STARTED";
|
|
545
562
|
UNAVAILABLE: "UNAVAILABLE";
|
|
546
563
|
}>>;
|
|
564
|
+
remoteSessionReference: z.ZodOptional<z.ZodNullable<z.ZodReadonly<z.ZodObject<{
|
|
565
|
+
schemaVersion: z.ZodLiteral<"pi-child-remote-session-reference/v1">;
|
|
566
|
+
source: z.ZodLiteral<"control_plane_reported">;
|
|
567
|
+
basis: z.ZodLiteral<"retained_native_attribution">;
|
|
568
|
+
runtimeConnectionId: typeof IdentifierSchemas.runtimeConnectionId;
|
|
569
|
+
nativeSessionId: typeof IdentifierSchemas.externalSessionId;
|
|
570
|
+
permission: z.ZodLiteral<"none">;
|
|
571
|
+
history: z.ZodLiteral<"adapter_journal_only">;
|
|
572
|
+
attachment: z.ZodLiteral<"unavailable">;
|
|
573
|
+
}, z.core.$strict>>>>;
|
|
574
|
+
remoteSessionReferenceUnavailableReason: z.ZodOptional<z.ZodEnum<{
|
|
575
|
+
NOT_CONFIGURED: "NOT_CONFIGURED";
|
|
576
|
+
NOT_STARTED: "NOT_STARTED";
|
|
577
|
+
UNAVAILABLE: "UNAVAILABLE";
|
|
578
|
+
}>>;
|
|
579
|
+
remoteOwnerObservation: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
580
|
+
schemaVersion: z.ZodLiteral<"pi-child-owner-observation/v1">;
|
|
581
|
+
runtimeConnectionId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"runtime-connection ID">, string>>;
|
|
582
|
+
nativeSessionId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"external-session ID">, string>>;
|
|
583
|
+
ownerInstanceId: z.ZodUUID;
|
|
584
|
+
permission: z.ZodLiteral<"none">;
|
|
585
|
+
}, z.core.$strict>>>;
|
|
586
|
+
remoteOwnerObservationUnavailableReason: z.ZodOptional<z.ZodEnum<{
|
|
587
|
+
NOT_CONFIGURED: "NOT_CONFIGURED";
|
|
588
|
+
NOT_STARTED: "NOT_STARTED";
|
|
589
|
+
UNAVAILABLE: "UNAVAILABLE";
|
|
590
|
+
}>>;
|
|
547
591
|
}, z.core.$strict>;
|
|
548
592
|
}, z.core.$strict>;
|
|
549
593
|
export declare const PiDurableLeadHttpContract: Readonly<{
|
package/dist/pi-durable-lead.js
CHANGED
|
@@ -39,6 +39,22 @@ 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
|
+
}
|
|
51
|
+
export function supportsPiDurableRemoteOwnerObservation(consumerVersion) {
|
|
52
|
+
const consumer = ContractVersionSchema.safeParse(consumerVersion);
|
|
53
|
+
if (!consumer.success)
|
|
54
|
+
return false;
|
|
55
|
+
const negotiated = negotiateContractVersion([PublicContractManifest.current], [consumer.data]);
|
|
56
|
+
return negotiated?.major === 3 && negotiated.minor >= 3;
|
|
57
|
+
}
|
|
42
58
|
function fenceForeignGeneration(receipt, context) {
|
|
43
59
|
const foreign = (generation) => generation !== undefined && generation.attemptId !== receipt.attemptId;
|
|
44
60
|
if (foreign(receipt.observedTarget?.generation))
|
|
@@ -306,12 +322,76 @@ export const PiDurableLeadChildTargetSchema = z.strictObject({
|
|
|
306
322
|
observedAt: z.iso.datetime(),
|
|
307
323
|
observedGeneration: RuntimeObservedGenerationSchema.optional(),
|
|
308
324
|
});
|
|
325
|
+
export const PiDurableLeadRemoteSessionReferenceSchema = z
|
|
326
|
+
.strictObject({
|
|
327
|
+
schemaVersion: z.literal('pi-child-remote-session-reference/v1'),
|
|
328
|
+
source: z.literal('control_plane_reported'),
|
|
329
|
+
basis: z.literal('retained_native_attribution'),
|
|
330
|
+
runtimeConnectionId: IdentifierSchemas.runtimeConnectionId,
|
|
331
|
+
nativeSessionId: IdentifierSchemas.externalSessionId,
|
|
332
|
+
permission: z.literal('none'),
|
|
333
|
+
history: z.literal('adapter_journal_only'),
|
|
334
|
+
attachment: z.literal('unavailable'),
|
|
335
|
+
})
|
|
336
|
+
.readonly();
|
|
309
337
|
export const PiDurableLeadChildTargetResponseSchema = response.extend({
|
|
310
338
|
data: PiDurableLeadReceiptResponseSchema.extend({
|
|
311
339
|
child: PiDurableLeadChildSchema,
|
|
312
340
|
target: PiDurableLeadChildTargetSchema.nullable(),
|
|
313
341
|
unavailableReason: z.enum(['NOT_STARTED', 'NOT_CONFIGURED', 'UNAVAILABLE']).optional(),
|
|
342
|
+
remoteSessionReference: PiDurableLeadRemoteSessionReferenceSchema.nullable().optional(),
|
|
343
|
+
remoteSessionReferenceUnavailableReason: z
|
|
344
|
+
.enum(['NOT_STARTED', 'NOT_CONFIGURED', 'UNAVAILABLE'])
|
|
345
|
+
.optional(),
|
|
346
|
+
remoteOwnerObservation: z
|
|
347
|
+
.strictObject({
|
|
348
|
+
schemaVersion: z.literal('pi-child-owner-observation/v1'),
|
|
349
|
+
runtimeConnectionId: IdentifierSchemas.runtimeConnectionId,
|
|
350
|
+
nativeSessionId: IdentifierSchemas.externalSessionId,
|
|
351
|
+
ownerInstanceId: z.uuid(),
|
|
352
|
+
permission: z.literal('none'),
|
|
353
|
+
})
|
|
354
|
+
.nullable()
|
|
355
|
+
.optional(),
|
|
356
|
+
remoteOwnerObservationUnavailableReason: z
|
|
357
|
+
.enum(['NOT_STARTED', 'NOT_CONFIGURED', 'UNAVAILABLE'])
|
|
358
|
+
.optional(),
|
|
314
359
|
}).superRefine((value, context) => {
|
|
360
|
+
if ((value.remoteOwnerObservation === null) !==
|
|
361
|
+
(value.remoteOwnerObservationUnavailableReason !== undefined))
|
|
362
|
+
context.addIssue({
|
|
363
|
+
code: 'custom',
|
|
364
|
+
message: 'Unavailable owner observation requires a bounded reason',
|
|
365
|
+
});
|
|
366
|
+
if (value.remoteOwnerObservation &&
|
|
367
|
+
(!value.child.childAttemptId ||
|
|
368
|
+
(value.target !== null &&
|
|
369
|
+
(value.target.runtimeConnectionId !== value.remoteOwnerObservation.runtimeConnectionId ||
|
|
370
|
+
value.target.nativeSessionId !== value.remoteOwnerObservation.nativeSessionId)) ||
|
|
371
|
+
(value.remoteSessionReference &&
|
|
372
|
+
(value.remoteSessionReference.runtimeConnectionId !==
|
|
373
|
+
value.remoteOwnerObservation.runtimeConnectionId ||
|
|
374
|
+
value.remoteSessionReference.nativeSessionId !==
|
|
375
|
+
value.remoteOwnerObservation.nativeSessionId))))
|
|
376
|
+
context.addIssue({
|
|
377
|
+
code: 'custom',
|
|
378
|
+
message: 'Owner observation must bind the selected child reference',
|
|
379
|
+
});
|
|
380
|
+
const reference = value.remoteSessionReference;
|
|
381
|
+
if ((reference === null) !== (value.remoteSessionReferenceUnavailableReason !== undefined))
|
|
382
|
+
context.addIssue({
|
|
383
|
+
code: 'custom',
|
|
384
|
+
message: 'Unavailable remote reference requires a bounded reason',
|
|
385
|
+
});
|
|
386
|
+
if (reference &&
|
|
387
|
+
(value.child.childAttemptId === undefined ||
|
|
388
|
+
(value.target !== null &&
|
|
389
|
+
(reference.runtimeConnectionId !== value.target.runtimeConnectionId ||
|
|
390
|
+
reference.nativeSessionId !== value.target.nativeSessionId))))
|
|
391
|
+
context.addIssue({
|
|
392
|
+
code: 'custom',
|
|
393
|
+
message: 'Remote reference must bind the selected child target',
|
|
394
|
+
});
|
|
315
395
|
if ((value.target === null) !== (value.unavailableReason !== undefined))
|
|
316
396
|
context.addIssue({ code: 'custom', message: 'Unavailable target requires a bounded reason' });
|
|
317
397
|
if (value.target &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adea-ai/runtime-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.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.
|
|
46
|
+
"@adea-ai/contracts": "^1.25.0",
|
|
47
47
|
"zod": "4.6.6"
|
|
48
48
|
},
|
|
49
49
|
"engines": {
|