File size: 1,073 Bytes
4e23b01 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /**
* `sessionInteractionService` — blocking human-in-the-loop request kernel.
* Mirrors `agent-core-v2/human/interaction/interaction.ts`.
*/
import { z } from 'zod';
import { noResult } from '../helpers.js';
import type { ServiceContract } from '../types.js';
export const interactionKindSchema = z.enum(['approval', 'question', 'user_tool']);
export const interactionTagsSchema = z.record(z.string(), z.union([z.string(), z.number()]));
export const interactionSchema = z.object({
id: z.string(),
kind: interactionKindSchema,
payload: z.unknown(),
tags: interactionTagsSchema,
createdAt: z.number(),
});
export const interactionResolutionSchema = z.object({
id: z.string(),
response: z.unknown(),
});
export const sessionInteractionContract = {
listPending: {
input: z.tuple([interactionKindSchema.optional()]),
output: z.array(interactionSchema),
},
respond: { input: z.tuple([z.string(), z.unknown()]), output: noResult },
isRecentlyResolved: { input: z.tuple([z.string()]), output: z.boolean() },
} satisfies ServiceContract;
|