@agentskit/chat-protocol
Advanced tools
+254
-96
@@ -27,2 +27,7 @@ "use strict"; | ||
| ANSWER_PROTOCOL_VERSION: () => ANSWER_PROTOCOL_VERSION, | ||
| ASK_BACKEND_MAX_MESSAGES: () => ASK_BACKEND_MAX_MESSAGES, | ||
| ASK_BACKEND_MAX_MESSAGE_CHARS: () => ASK_BACKEND_MAX_MESSAGE_CHARS, | ||
| ASK_BACKEND_MAX_SOURCES: () => ASK_BACKEND_MAX_SOURCES, | ||
| ASK_BACKEND_PROTOCOL: () => ASK_BACKEND_PROTOCOL, | ||
| ASK_BACKEND_PROTOCOL_VERSION: () => ASK_BACKEND_PROTOCOL_VERSION, | ||
| ASK_EVENT_MAX_BYTES: () => ASK_EVENT_MAX_BYTES, | ||
@@ -40,2 +45,11 @@ ASK_EVENT_MAX_RECORDS: () => ASK_EVENT_MAX_RECORDS, | ||
| AnswerSuggestionSchema: () => AnswerSuggestionSchema, | ||
| AskBackendDiagnosticSchema: () => AskBackendDiagnosticSchema, | ||
| AskBackendMessageSchema: () => AskBackendMessageSchema, | ||
| AskBackendMetricNameSchema: () => AskBackendMetricNameSchema, | ||
| AskBackendMetricSchema: () => AskBackendMetricSchema, | ||
| AskBackendRequestSchema: () => AskBackendRequestSchema, | ||
| AskBackendSessionRecordSchema: () => AskBackendSessionRecordSchema, | ||
| AskBackendSiteConfigSchema: () => AskBackendSiteConfigSchema, | ||
| AskBackendSourceSchema: () => AskBackendSourceSchema, | ||
| AskBackendUsageSchema: () => AskBackendUsageSchema, | ||
| AskEventSchema: () => AskEventSchema, | ||
@@ -98,3 +112,3 @@ AssistantComponentPartSchema: () => AssistantComponentPartSchema, | ||
| var import_memory_validation = require("@agentskit/core/memory-validation"); | ||
| var import_zod3 = require("zod"); | ||
| var import_zod4 = require("zod"); | ||
@@ -111,3 +125,8 @@ // src/ask.ts | ||
| import_zod.z.object({ type: import_zod.z.literal("done"), model: import_zod.z.string().max(256).optional() }).strict(), | ||
| import_zod.z.object({ type: import_zod.z.literal("error"), message: import_zod.z.string().min(1).max(4096) }).strict() | ||
| import_zod.z.object({ | ||
| type: import_zod.z.literal("error"), | ||
| message: import_zod.z.string().min(1).max(4096), | ||
| code: import_zod.z.string().regex(/^[A-Z][A-Z0-9_]{0,127}$/).optional(), | ||
| retryable: import_zod.z.boolean().optional() | ||
| }).strict() | ||
| ]); | ||
@@ -142,2 +161,5 @@ var byteLength = (value) => new TextEncoder().encode(value).byteLength; | ||
| // src/backend.ts | ||
| var import_zod3 = require("zod"); | ||
| // src/deterministic.ts | ||
@@ -413,2 +435,124 @@ var import_sha2 = require("@noble/hashes/sha2.js"); | ||
| // src/backend.ts | ||
| var ASK_BACKEND_PROTOCOL = "agentskit.chat.ask"; | ||
| var ASK_BACKEND_PROTOCOL_VERSION = 1; | ||
| var ASK_BACKEND_MAX_MESSAGES = 64; | ||
| var ASK_BACKEND_MAX_MESSAGE_CHARS = 16384; | ||
| var ASK_BACKEND_MAX_SOURCES = 8; | ||
| var SafeIdentifierSchema2 = import_zod3.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/); | ||
| var SafeLabelSchema = import_zod3.z.string().trim().min(1).max(256); | ||
| var SafeHrefSchema2 = import_zod3.z.string().min(1).max(2048).refine((value) => { | ||
| if (/[\u0000-\u001F\u007F\\]/u.test(value) || value.startsWith("//")) return false; | ||
| if (!/^[A-Za-z][A-Za-z0-9+.-]*:/.test(value)) return /^\/(?!\/)/.test(value); | ||
| try { | ||
| const url = new URL(value); | ||
| return (url.protocol === "http:" || url.protocol === "https:") && url.username === "" && url.password === ""; | ||
| } catch { | ||
| return false; | ||
| } | ||
| }, "Source must use a safe relative, HTTP, or HTTPS URL."); | ||
| var AskBackendMessageSchema = import_zod3.z.object({ | ||
| role: import_zod3.z.enum(["user", "assistant"]), | ||
| content: import_zod3.z.string().max(ASK_BACKEND_MAX_MESSAGE_CHARS) | ||
| }).strict().readonly(); | ||
| var DeterministicEscalationSchema = AnswerResponseSchema.refine( | ||
| (value) => value.outcome === "escalation", | ||
| "Deterministic context must be an escalation." | ||
| ); | ||
| var AskBackendRequestSchema = import_zod3.z.object({ | ||
| protocol: import_zod3.z.literal(ASK_BACKEND_PROTOCOL).optional(), | ||
| version: import_zod3.z.literal(ASK_BACKEND_PROTOCOL_VERSION).optional(), | ||
| sessionId: SafeIdentifierSchema2.optional(), | ||
| messages: import_zod3.z.array(AskBackendMessageSchema).min(1).max(ASK_BACKEND_MAX_MESSAGES).readonly(), | ||
| deterministic: DeterministicEscalationSchema.optional() | ||
| }).strict().readonly(); | ||
| var AskBackendSourceSchema = import_zod3.z.object({ | ||
| id: SafeIdentifierSchema2, | ||
| title: SafeLabelSchema, | ||
| href: SafeHrefSchema2, | ||
| excerpt: import_zod3.z.string().trim().min(1).max(4096) | ||
| }).strict().readonly(); | ||
| var AskBackendSiteConfigSchema = import_zod3.z.object({ | ||
| protocol: import_zod3.z.literal("agentskit.chat.backend-site"), | ||
| version: import_zod3.z.literal(1), | ||
| siteId: SafeIdentifierSchema2, | ||
| assistant: import_zod3.z.object({ | ||
| id: SafeIdentifierSchema2, | ||
| name: SafeLabelSchema, | ||
| suggestions: import_zod3.z.array(SafeLabelSchema).max(8).readonly() | ||
| }).strict().readonly(), | ||
| corpus: import_zod3.z.object({ | ||
| id: SafeIdentifierSchema2, | ||
| mode: import_zod3.z.enum(["local", "federated"]) | ||
| }).strict().readonly(), | ||
| components: import_zod3.z.array(SafeIdentifierSchema2).max(64).readonly(), | ||
| actions: import_zod3.z.array(SafeIdentifierSchema2).max(64).readonly(), | ||
| limits: import_zod3.z.object({ | ||
| requestTimeoutMs: import_zod3.z.number().int().min(100).max(12e4), | ||
| retrievalTimeoutMs: import_zod3.z.number().int().min(100).max(6e4), | ||
| generationTimeoutMs: import_zod3.z.number().int().min(100).max(12e4), | ||
| maxSources: import_zod3.z.number().int().min(1).max(ASK_BACKEND_MAX_SOURCES) | ||
| }).strict().readonly(), | ||
| persistence: import_zod3.z.object({ mode: import_zod3.z.enum(["required", "disabled"]) }).strict().readonly() | ||
| }).strict().readonly(); | ||
| var AskBackendUsageSchema = import_zod3.z.object({ | ||
| inputTokens: import_zod3.z.number().int().nonnegative().optional(), | ||
| outputTokens: import_zod3.z.number().int().nonnegative().optional(), | ||
| totalTokens: import_zod3.z.number().int().nonnegative().optional(), | ||
| costUsd: import_zod3.z.number().nonnegative().finite().optional(), | ||
| model: import_zod3.z.string().trim().min(1).max(256).optional() | ||
| }).strict().readonly(); | ||
| var AskBackendSessionRecordSchema = import_zod3.z.object({ | ||
| revision: import_zod3.z.number().int().nonnegative(), | ||
| messages: import_zod3.z.array(AskBackendMessageSchema).max(ASK_BACKEND_MAX_MESSAGES).readonly() | ||
| }).strict().readonly(); | ||
| var AskBackendDiagnosticSchema = import_zod3.z.object({ | ||
| code: import_zod3.z.enum([ | ||
| "ASK_INVALID_REQUEST", | ||
| "ASK_UNAUTHORIZED", | ||
| "ASK_FORBIDDEN", | ||
| "ASK_RATE_LIMITED", | ||
| "ASK_TIMEOUT", | ||
| "ASK_CANCELLED", | ||
| "ASK_RETRIEVAL_FAILED", | ||
| "ASK_NO_GROUNDED_SOURCES", | ||
| "ASK_GENERATION_FAILED", | ||
| "ASK_PERSISTENCE_CONFLICT", | ||
| "ASK_INTERNAL" | ||
| ]), | ||
| message: import_zod3.z.string().trim().min(1).max(4096), | ||
| retryable: import_zod3.z.boolean() | ||
| }).strict().readonly(); | ||
| var AskBackendMetricNameSchema = import_zod3.z.enum([ | ||
| "request.total_ms", | ||
| "stream.first_event_ms", | ||
| "stream.first_token_ms", | ||
| "stream.bytes", | ||
| "stream.events", | ||
| "stream.snapshots", | ||
| "deterministic.fallback", | ||
| "retrieval.total_ms", | ||
| "retrieval.documents", | ||
| "persistence.total_ms", | ||
| "cancellation.count", | ||
| "conflict.count", | ||
| "error.count", | ||
| "usage.input_tokens", | ||
| "usage.output_tokens", | ||
| "usage.total_tokens", | ||
| "cost.usd" | ||
| ]); | ||
| var AskBackendMetricSchema = import_zod3.z.object({ | ||
| protocol: import_zod3.z.literal("agentskit.chat.backend-metric"), | ||
| version: import_zod3.z.literal(1), | ||
| name: AskBackendMetricNameSchema, | ||
| siteId: SafeIdentifierSchema2, | ||
| corpusId: SafeIdentifierSchema2, | ||
| requestId: SafeIdentifierSchema2, | ||
| value: import_zod3.z.number().finite().nonnegative(), | ||
| unit: import_zod3.z.enum(["ms", "bytes", "count", "tokens", "usd"]), | ||
| outcome: import_zod3.z.enum(["ok", "rejected", "cancelled", "error"]), | ||
| emittedAt: import_zod3.z.string().datetime({ offset: true }) | ||
| }).strict().readonly(); | ||
| // src/index.ts | ||
@@ -450,42 +594,42 @@ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value); | ||
| var ASSISTANT_CONTENT_MAX_RECORDS = 512; | ||
| var ComponentKeySchema = import_zod3.z.string().regex(/^[a-z][a-z0-9-]{0,63}$/); | ||
| var ComponentFallbackSchema = import_zod3.z.object({ | ||
| kind: import_zod3.z.string().min(1).max(64), | ||
| summary: import_zod3.z.string().min(1).max(4096) | ||
| var ComponentKeySchema = import_zod4.z.string().regex(/^[a-z][a-z0-9-]{0,63}$/); | ||
| var ComponentFallbackSchema = import_zod4.z.object({ | ||
| kind: import_zod4.z.string().min(1).max(64), | ||
| summary: import_zod4.z.string().min(1).max(4096) | ||
| }).readonly(); | ||
| var ComponentRenderFrameSchema = import_zod3.z.object({ | ||
| protocol: import_zod3.z.literal(COMPONENT_PROTOCOL), | ||
| version: import_zod3.z.literal(COMPONENT_PROTOCOL_VERSION), | ||
| type: import_zod3.z.literal("render"), | ||
| var ComponentRenderFrameSchema = import_zod4.z.object({ | ||
| protocol: import_zod4.z.literal(COMPONENT_PROTOCOL), | ||
| version: import_zod4.z.literal(COMPONENT_PROTOCOL_VERSION), | ||
| type: import_zod4.z.literal("render"), | ||
| componentKey: ComponentKeySchema, | ||
| instanceId: import_zod3.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| props: import_zod3.z.unknown().refine(isBoundedJsonValue), | ||
| instanceId: import_zod4.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| props: import_zod4.z.unknown().refine(isBoundedJsonValue), | ||
| fallback: ComponentFallbackSchema | ||
| }).readonly(); | ||
| var ComponentSelectionEventSchema = import_zod3.z.object({ | ||
| protocol: import_zod3.z.literal(COMPONENT_PROTOCOL), | ||
| version: import_zod3.z.literal(COMPONENT_PROTOCOL_VERSION), | ||
| type: import_zod3.z.literal("select"), | ||
| var ComponentSelectionEventSchema = import_zod4.z.object({ | ||
| protocol: import_zod4.z.literal(COMPONENT_PROTOCOL), | ||
| version: import_zod4.z.literal(COMPONENT_PROTOCOL_VERSION), | ||
| type: import_zod4.z.literal("select"), | ||
| componentKey: ComponentKeySchema, | ||
| instanceId: import_zod3.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| choiceId: import_zod3.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/) | ||
| instanceId: import_zod4.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| choiceId: import_zod4.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/) | ||
| }).readonly(); | ||
| var ComponentInteractionEventSchema = import_zod3.z.object({ | ||
| protocol: import_zod3.z.literal(COMPONENT_PROTOCOL), | ||
| version: import_zod3.z.literal(COMPONENT_PROTOCOL_VERSION), | ||
| type: import_zod3.z.literal("interact"), | ||
| var ComponentInteractionEventSchema = import_zod4.z.object({ | ||
| protocol: import_zod4.z.literal(COMPONENT_PROTOCOL), | ||
| version: import_zod4.z.literal(COMPONENT_PROTOCOL_VERSION), | ||
| type: import_zod4.z.literal("interact"), | ||
| componentKey: ComponentKeySchema, | ||
| instanceId: import_zod3.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| event: import_zod3.z.string().regex(/^[a-z][a-z0-9-]{0,63}$/), | ||
| value: import_zod3.z.unknown().refine(isBoundedJsonValue).optional() | ||
| instanceId: import_zod4.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| event: import_zod4.z.string().regex(/^[a-z][a-z0-9-]{0,63}$/), | ||
| value: import_zod4.z.unknown().refine(isBoundedJsonValue).optional() | ||
| }).readonly(); | ||
| var AssistantTextPartSchema = import_zod3.z.object({ | ||
| kind: import_zod3.z.literal("text"), | ||
| text: import_zod3.z.string().min(1).max(16384) | ||
| var AssistantTextPartSchema = import_zod4.z.object({ | ||
| kind: import_zod4.z.literal("text"), | ||
| text: import_zod4.z.string().min(1).max(16384) | ||
| }).readonly(); | ||
| var AssistantComponentPartSchema = import_zod3.z.object({ | ||
| kind: import_zod3.z.literal("component"), | ||
| var AssistantComponentPartSchema = import_zod4.z.object({ | ||
| kind: import_zod4.z.literal("component"), | ||
| frame: ComponentRenderFrameSchema | ||
| }).readonly(); | ||
| var AssistantContentPartSchema = import_zod3.z.discriminatedUnion("kind", [AssistantTextPartSchema, AssistantComponentPartSchema]); | ||
| var AssistantContentPartSchema = import_zod4.z.discriminatedUnion("kind", [AssistantTextPartSchema, AssistantComponentPartSchema]); | ||
| var createAssistantContentEncoder = () => { | ||
@@ -612,24 +756,24 @@ let started = false; | ||
| }); | ||
| var TokenUsageSchema = import_zod3.z.object({ | ||
| promptTokens: import_zod3.z.number().int().nonnegative(), | ||
| completionTokens: import_zod3.z.number().int().nonnegative(), | ||
| totalTokens: import_zod3.z.number().int().nonnegative() | ||
| var TokenUsageSchema = import_zod4.z.object({ | ||
| promptTokens: import_zod4.z.number().int().nonnegative(), | ||
| completionTokens: import_zod4.z.number().int().nonnegative(), | ||
| totalTokens: import_zod4.z.number().int().nonnegative() | ||
| }); | ||
| var TurnDiagnosticSchema = import_zod3.z.object({ | ||
| version: import_zod3.z.literal(1), | ||
| code: import_zod3.z.string().regex(/^[A-Z][A-Z0-9_]*$/), | ||
| message: import_zod3.z.string().min(1), | ||
| retryable: import_zod3.z.boolean() | ||
| var TurnDiagnosticSchema = import_zod4.z.object({ | ||
| version: import_zod4.z.literal(1), | ||
| code: import_zod4.z.string().regex(/^[A-Z][A-Z0-9_]*$/), | ||
| message: import_zod4.z.string().min(1), | ||
| retryable: import_zod4.z.boolean() | ||
| }); | ||
| var SafeIdentifierSchema2 = import_zod3.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/); | ||
| var SafeIdentifierSchema3 = import_zod4.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/); | ||
| var EnvelopeFields = { | ||
| protocol: import_zod3.z.literal(TURN_PROTOCOL), | ||
| version: import_zod3.z.literal(TURN_PROTOCOL_VERSION), | ||
| eventId: import_zod3.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| sessionId: import_zod3.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| turnId: import_zod3.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| sequence: import_zod3.z.number().int().nonnegative(), | ||
| emittedAt: import_zod3.z.string().datetime({ offset: true }) | ||
| protocol: import_zod4.z.literal(TURN_PROTOCOL), | ||
| version: import_zod4.z.literal(TURN_PROTOCOL_VERSION), | ||
| eventId: import_zod4.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| sessionId: import_zod4.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| turnId: import_zod4.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| sequence: import_zod4.z.number().int().nonnegative(), | ||
| emittedAt: import_zod4.z.string().datetime({ offset: true }) | ||
| }; | ||
| var MemoryMessagesSchema = import_zod3.z.array(import_zod3.z.unknown()).transform((messages, context) => { | ||
| var MemoryMessagesSchema = import_zod4.z.array(import_zod4.z.unknown()).transform((messages, context) => { | ||
| try { | ||
@@ -639,22 +783,22 @@ return (0, import_memory_validation.validateMemoryRecord)({ version: 1, messages }).messages; | ||
| context.addIssue({ code: "custom", message: "Messages are not a valid AgentsKit memory record." }); | ||
| return import_zod3.z.NEVER; | ||
| return import_zod4.z.NEVER; | ||
| } | ||
| }); | ||
| var TurnLineageSchema = import_zod3.z.discriminatedUnion("operation", [ | ||
| import_zod3.z.object({ operation: import_zod3.z.literal("submit") }), | ||
| import_zod3.z.object({ operation: import_zod3.z.enum(["retry", "edit", "regenerate"]), parentTurnId: SafeIdentifierSchema2, sourceMessageId: SafeIdentifierSchema2 }) | ||
| var TurnLineageSchema = import_zod4.z.discriminatedUnion("operation", [ | ||
| import_zod4.z.object({ operation: import_zod4.z.literal("submit") }), | ||
| import_zod4.z.object({ operation: import_zod4.z.enum(["retry", "edit", "regenerate"]), parentTurnId: SafeIdentifierSchema3, sourceMessageId: SafeIdentifierSchema3 }) | ||
| ]); | ||
| var SubmitEventSchema = import_zod3.z.object({ | ||
| var SubmitEventSchema = import_zod4.z.object({ | ||
| ...EnvelopeFields, | ||
| event: import_zod3.z.literal("client.turn.submit"), | ||
| payload: import_zod3.z.object({ | ||
| input: import_zod3.z.string().min(1).refine((value) => value.trim().length > 0) | ||
| event: import_zod4.z.literal("client.turn.submit"), | ||
| payload: import_zod4.z.object({ | ||
| input: import_zod4.z.string().min(1).refine((value) => value.trim().length > 0) | ||
| }) | ||
| }); | ||
| var SnapshotEventSchema = import_zod3.z.object({ | ||
| var SnapshotEventSchema = import_zod4.z.object({ | ||
| ...EnvelopeFields, | ||
| event: import_zod3.z.literal("server.turn.snapshot"), | ||
| payload: import_zod3.z.object({ | ||
| event: import_zod4.z.literal("server.turn.snapshot"), | ||
| payload: import_zod4.z.object({ | ||
| messages: MemoryMessagesSchema, | ||
| status: import_zod3.z.enum(["idle", "streaming", "complete", "error"]), | ||
| status: import_zod4.z.enum(["idle", "streaming", "complete", "error"]), | ||
| usage: TokenUsageSchema, | ||
@@ -665,8 +809,8 @@ error: TurnDiagnosticSchema.optional(), | ||
| }); | ||
| var DiagnosticEventSchema = import_zod3.z.object({ | ||
| var DiagnosticEventSchema = import_zod4.z.object({ | ||
| ...EnvelopeFields, | ||
| event: import_zod3.z.literal("server.turn.diagnostic"), | ||
| event: import_zod4.z.literal("server.turn.diagnostic"), | ||
| payload: TurnDiagnosticSchema | ||
| }); | ||
| var TurnEventSchema = import_zod3.z.discriminatedUnion("event", [ | ||
| var TurnEventSchema = import_zod4.z.discriminatedUnion("event", [ | ||
| SubmitEventSchema, | ||
@@ -699,3 +843,3 @@ SnapshotEventSchema, | ||
| var createTurnSnapshotCursor = (sessionId) => { | ||
| const expectedSessionId = SafeIdentifierSchema2.parse(sessionId); | ||
| const expectedSessionId = SafeIdentifierSchema3.parse(sessionId); | ||
| let snapshot; | ||
@@ -718,3 +862,3 @@ return { | ||
| if (!isRecord(input)) return void 0; | ||
| const parsed = SafeIdentifierSchema2.safeParse(input.eventId); | ||
| const parsed = SafeIdentifierSchema3.safeParse(input.eventId); | ||
| return parsed.success ? parsed.data : void 0; | ||
@@ -774,18 +918,18 @@ } catch { | ||
| var SESSION_PROTOCOL_VERSION = 1; | ||
| var SessionDecisionSchema = import_zod3.z.object({ | ||
| messageId: SafeIdentifierSchema2, | ||
| input: import_zod3.z.string().max(16384), | ||
| routeId: SafeIdentifierSchema2, | ||
| kind: import_zod3.z.enum(["deterministic", "repaired", "fallback"]), | ||
| content: import_zod3.z.string().max(65536), | ||
| fromState: import_zod3.z.string().min(1).max(128), | ||
| toState: import_zod3.z.string().min(1).max(128) | ||
| var SessionDecisionSchema = import_zod4.z.object({ | ||
| messageId: SafeIdentifierSchema3, | ||
| input: import_zod4.z.string().max(16384), | ||
| routeId: SafeIdentifierSchema3, | ||
| kind: import_zod4.z.enum(["deterministic", "repaired", "fallback"]), | ||
| content: import_zod4.z.string().max(65536), | ||
| fromState: import_zod4.z.string().min(1).max(128), | ||
| toState: import_zod4.z.string().min(1).max(128) | ||
| }).readonly(); | ||
| var SessionConfirmationSchema = import_zod3.z.object({ | ||
| token: SafeIdentifierSchema2, | ||
| action: SafeIdentifierSchema2, | ||
| input: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()).refine(isBoundedJsonValue), | ||
| toolCallId: SafeIdentifierSchema2, | ||
| expiresAt: import_zod3.z.number().int().nonnegative(), | ||
| status: import_zod3.z.enum(["pending", "approving", "rejecting", "expiring", "approved", "rejected", "expired"]) | ||
| var SessionConfirmationSchema = import_zod4.z.object({ | ||
| token: SafeIdentifierSchema3, | ||
| action: SafeIdentifierSchema3, | ||
| input: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.unknown()).refine(isBoundedJsonValue), | ||
| toolCallId: SafeIdentifierSchema3, | ||
| expiresAt: import_zod4.z.number().int().nonnegative(), | ||
| status: import_zod4.z.enum(["pending", "approving", "rejecting", "expiring", "approved", "rejected", "expired"]) | ||
| }).readonly(); | ||
@@ -800,19 +944,19 @@ var uniqueBy = (items, key, context, path) => { | ||
| }; | ||
| var SessionDecisionsSchema = import_zod3.z.array(SessionDecisionSchema).max(1e3).superRefine((items, context) => uniqueBy(items, (item) => item.messageId, context, "messageId")); | ||
| var SessionConfirmationsSchema = import_zod3.z.array(SessionConfirmationSchema).max(1e3).superRefine((items, context) => { | ||
| var SessionDecisionsSchema = import_zod4.z.array(SessionDecisionSchema).max(1e3).superRefine((items, context) => uniqueBy(items, (item) => item.messageId, context, "messageId")); | ||
| var SessionConfirmationsSchema = import_zod4.z.array(SessionConfirmationSchema).max(1e3).superRefine((items, context) => { | ||
| uniqueBy(items, (item) => item.token, context, "token"); | ||
| uniqueBy(items, (item) => item.toolCallId, context, "toolCallId"); | ||
| }); | ||
| var SessionSnapshotObjectSchema = import_zod3.z.object({ | ||
| protocol: import_zod3.z.literal(SESSION_PROTOCOL), | ||
| version: import_zod3.z.literal(SESSION_PROTOCOL_VERSION), | ||
| sessionId: SafeIdentifierSchema2, | ||
| definitionId: SafeIdentifierSchema2, | ||
| definitionRevision: import_zod3.z.number().int().positive(), | ||
| updatedAt: import_zod3.z.string().datetime({ offset: true }), | ||
| cursor: import_zod3.z.number().int().nonnegative(), | ||
| activeTurn: import_zod3.z.object({ turnId: SafeIdentifierSchema2, expiresAt: import_zod3.z.number().int().nonnegative() }).readonly().optional(), | ||
| terminalTurns: import_zod3.z.array(import_zod3.z.object({ turnId: SafeIdentifierSchema2, outcome: import_zod3.z.enum(["completed", "indeterminate"]) }).readonly()).max(64).superRefine((items, context) => uniqueBy(items, (item) => item.turnId, context, "turnId")).readonly().optional(), | ||
| conversation: import_zod3.z.object({ | ||
| state: import_zod3.z.string().min(1).max(128), | ||
| var SessionSnapshotObjectSchema = import_zod4.z.object({ | ||
| protocol: import_zod4.z.literal(SESSION_PROTOCOL), | ||
| version: import_zod4.z.literal(SESSION_PROTOCOL_VERSION), | ||
| sessionId: SafeIdentifierSchema3, | ||
| definitionId: SafeIdentifierSchema3, | ||
| definitionRevision: import_zod4.z.number().int().positive(), | ||
| updatedAt: import_zod4.z.string().datetime({ offset: true }), | ||
| cursor: import_zod4.z.number().int().nonnegative(), | ||
| activeTurn: import_zod4.z.object({ turnId: SafeIdentifierSchema3, expiresAt: import_zod4.z.number().int().nonnegative() }).readonly().optional(), | ||
| terminalTurns: import_zod4.z.array(import_zod4.z.object({ turnId: SafeIdentifierSchema3, outcome: import_zod4.z.enum(["completed", "indeterminate"]) }).readonly()).max(64).superRefine((items, context) => uniqueBy(items, (item) => item.turnId, context, "turnId")).readonly().optional(), | ||
| conversation: import_zod4.z.object({ | ||
| state: import_zod4.z.string().min(1).max(128), | ||
| decisions: SessionDecisionsSchema | ||
@@ -823,3 +967,3 @@ }).readonly().optional(), | ||
| var SessionSnapshotSchema = SessionSnapshotObjectSchema.readonly(); | ||
| var LegacySessionSnapshotSchema = SessionSnapshotObjectSchema.omit({ protocol: true, version: true }).extend({ version: import_zod3.z.literal(0) }); | ||
| var LegacySessionSnapshotSchema = SessionSnapshotObjectSchema.omit({ protocol: true, version: true }).extend({ version: import_zod4.z.literal(0) }); | ||
| var decodeSessionSnapshot = (input) => { | ||
@@ -852,2 +996,7 @@ let candidate = input; | ||
| ANSWER_PROTOCOL_VERSION, | ||
| ASK_BACKEND_MAX_MESSAGES, | ||
| ASK_BACKEND_MAX_MESSAGE_CHARS, | ||
| ASK_BACKEND_MAX_SOURCES, | ||
| ASK_BACKEND_PROTOCOL, | ||
| ASK_BACKEND_PROTOCOL_VERSION, | ||
| ASK_EVENT_MAX_BYTES, | ||
@@ -865,2 +1014,11 @@ ASK_EVENT_MAX_RECORDS, | ||
| AnswerSuggestionSchema, | ||
| AskBackendDiagnosticSchema, | ||
| AskBackendMessageSchema, | ||
| AskBackendMetricNameSchema, | ||
| AskBackendMetricSchema, | ||
| AskBackendRequestSchema, | ||
| AskBackendSessionRecordSchema, | ||
| AskBackendSiteConfigSchema, | ||
| AskBackendSourceSchema, | ||
| AskBackendUsageSchema, | ||
| AskEventSchema, | ||
@@ -867,0 +1025,0 @@ AssistantComponentPartSchema, |
+425
-1
@@ -21,2 +21,4 @@ import { Message, TokenUsage, MemoryRecord } from '@agentskit/core'; | ||
| message: z.ZodString; | ||
| code: z.ZodOptional<z.ZodString>; | ||
| retryable: z.ZodOptional<z.ZodBoolean>; | ||
| }, z.core.$strict>], "type">; | ||
@@ -35,2 +37,424 @@ type AskEvent = z.infer<typeof AskEventSchema>; | ||
| declare const ASK_BACKEND_PROTOCOL: "agentskit.chat.ask"; | ||
| declare const ASK_BACKEND_PROTOCOL_VERSION: 1; | ||
| declare const ASK_BACKEND_MAX_MESSAGES = 64; | ||
| declare const ASK_BACKEND_MAX_MESSAGE_CHARS = 16384; | ||
| declare const ASK_BACKEND_MAX_SOURCES = 8; | ||
| declare const AskBackendMessageSchema: z.ZodReadonly<z.ZodObject<{ | ||
| role: z.ZodEnum<{ | ||
| user: "user"; | ||
| assistant: "assistant"; | ||
| }>; | ||
| content: z.ZodString; | ||
| }, z.core.$strict>>; | ||
| /** Additive v1 request accepted by both hosted and self-hosted Ask handlers. */ | ||
| declare const AskBackendRequestSchema: z.ZodReadonly<z.ZodObject<{ | ||
| protocol: z.ZodOptional<z.ZodLiteral<"agentskit.chat.ask">>; | ||
| version: z.ZodOptional<z.ZodLiteral<1>>; | ||
| sessionId: z.ZodOptional<z.ZodString>; | ||
| messages: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{ | ||
| role: z.ZodEnum<{ | ||
| user: "user"; | ||
| assistant: "assistant"; | ||
| }>; | ||
| content: z.ZodString; | ||
| }, z.core.$strict>>>>; | ||
| deterministic: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{ | ||
| protocol: z.ZodLiteral<"agentskit.chat.answer">; | ||
| version: z.ZodLiteral<1>; | ||
| outcome: z.ZodLiteral<"answer">; | ||
| query: z.ZodString; | ||
| normalizedQuery: z.ZodString; | ||
| answer: z.ZodReadonly<z.ZodObject<{ | ||
| markdown: z.ZodString; | ||
| citations: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{ | ||
| id: z.ZodString; | ||
| title: z.ZodString; | ||
| href: z.ZodString; | ||
| }, z.core.$strip>>>>; | ||
| }, z.core.$strip>>; | ||
| provenance: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{ | ||
| source: z.ZodLiteral<"local">; | ||
| artifactId: z.ZodString; | ||
| contentHash: z.ZodString; | ||
| entryIds: z.ZodReadonly<z.ZodArray<z.ZodString>>; | ||
| }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{ | ||
| source: z.ZodLiteral<"backend">; | ||
| provider: z.ZodOptional<z.ZodString>; | ||
| model: z.ZodOptional<z.ZodString>; | ||
| }, z.core.$strip>>]>; | ||
| confidence: z.ZodReadonly<z.ZodObject<{ | ||
| level: z.ZodEnum<{ | ||
| high: "high"; | ||
| medium: "medium"; | ||
| low: "low"; | ||
| }>; | ||
| basis: z.ZodEnum<{ | ||
| exact: "exact"; | ||
| backend: "backend"; | ||
| ambiguous: "ambiguous"; | ||
| miss: "miss"; | ||
| stale: "stale"; | ||
| corrupt: "corrupt"; | ||
| offline: "offline"; | ||
| }>; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{ | ||
| protocol: z.ZodLiteral<"agentskit.chat.answer">; | ||
| version: z.ZodLiteral<1>; | ||
| outcome: z.ZodLiteral<"choices">; | ||
| query: z.ZodString; | ||
| normalizedQuery: z.ZodString; | ||
| message: z.ZodString; | ||
| suggestions: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{ | ||
| id: z.ZodString; | ||
| label: z.ZodString; | ||
| value: z.ZodString; | ||
| }, z.core.$strip>>>>; | ||
| provenance: z.ZodReadonly<z.ZodObject<{ | ||
| source: z.ZodLiteral<"local">; | ||
| artifactId: z.ZodString; | ||
| contentHash: z.ZodString; | ||
| entryIds: z.ZodReadonly<z.ZodArray<z.ZodString>>; | ||
| }, z.core.$strip>>; | ||
| confidence: z.ZodReadonly<z.ZodObject<{ | ||
| level: z.ZodEnum<{ | ||
| high: "high"; | ||
| medium: "medium"; | ||
| low: "low"; | ||
| }>; | ||
| basis: z.ZodEnum<{ | ||
| exact: "exact"; | ||
| backend: "backend"; | ||
| ambiguous: "ambiguous"; | ||
| miss: "miss"; | ||
| stale: "stale"; | ||
| corrupt: "corrupt"; | ||
| offline: "offline"; | ||
| }>; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{ | ||
| protocol: z.ZodLiteral<"agentskit.chat.answer">; | ||
| version: z.ZodLiteral<1>; | ||
| outcome: z.ZodLiteral<"escalation">; | ||
| query: z.ZodString; | ||
| normalizedQuery: z.ZodString; | ||
| message: z.ZodString; | ||
| reason: z.ZodEnum<{ | ||
| miss: "miss"; | ||
| stale: "stale"; | ||
| corrupt: "corrupt"; | ||
| offline: "offline"; | ||
| }>; | ||
| candidateEntryIds: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>; | ||
| confidence: z.ZodReadonly<z.ZodObject<{ | ||
| level: z.ZodEnum<{ | ||
| high: "high"; | ||
| medium: "medium"; | ||
| low: "low"; | ||
| }>; | ||
| basis: z.ZodEnum<{ | ||
| exact: "exact"; | ||
| backend: "backend"; | ||
| ambiguous: "ambiguous"; | ||
| miss: "miss"; | ||
| stale: "stale"; | ||
| corrupt: "corrupt"; | ||
| offline: "offline"; | ||
| }>; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>>], "outcome"> & z.ZodType<Readonly<{ | ||
| protocol: "agentskit.chat.answer"; | ||
| version: 1; | ||
| outcome: "escalation"; | ||
| query: string; | ||
| normalizedQuery: string; | ||
| message: string; | ||
| reason: "miss" | "stale" | "corrupt" | "offline"; | ||
| confidence: Readonly<{ | ||
| level: "high" | "medium" | "low"; | ||
| basis: "exact" | "backend" | "ambiguous" | "miss" | "stale" | "corrupt" | "offline"; | ||
| }>; | ||
| candidateEntryIds?: readonly string[] | undefined; | ||
| }>, Readonly<{ | ||
| protocol: "agentskit.chat.answer"; | ||
| version: 1; | ||
| outcome: "answer"; | ||
| query: string; | ||
| normalizedQuery: string; | ||
| answer: Readonly<{ | ||
| markdown: string; | ||
| citations: readonly Readonly<{ | ||
| id: string; | ||
| title: string; | ||
| href: string; | ||
| }>[]; | ||
| }>; | ||
| provenance: Readonly<{ | ||
| source: "local"; | ||
| artifactId: string; | ||
| contentHash: string; | ||
| entryIds: readonly string[]; | ||
| }> | Readonly<{ | ||
| source: "backend"; | ||
| provider?: string | undefined; | ||
| model?: string | undefined; | ||
| }>; | ||
| confidence: Readonly<{ | ||
| level: "high" | "medium" | "low"; | ||
| basis: "exact" | "backend" | "ambiguous" | "miss" | "stale" | "corrupt" | "offline"; | ||
| }>; | ||
| }> | Readonly<{ | ||
| protocol: "agentskit.chat.answer"; | ||
| version: 1; | ||
| outcome: "choices"; | ||
| query: string; | ||
| normalizedQuery: string; | ||
| message: string; | ||
| suggestions: readonly Readonly<{ | ||
| id: string; | ||
| label: string; | ||
| value: string; | ||
| }>[]; | ||
| provenance: Readonly<{ | ||
| source: "local"; | ||
| artifactId: string; | ||
| contentHash: string; | ||
| entryIds: readonly string[]; | ||
| }>; | ||
| confidence: Readonly<{ | ||
| level: "high" | "medium" | "low"; | ||
| basis: "exact" | "backend" | "ambiguous" | "miss" | "stale" | "corrupt" | "offline"; | ||
| }>; | ||
| }> | Readonly<{ | ||
| protocol: "agentskit.chat.answer"; | ||
| version: 1; | ||
| outcome: "escalation"; | ||
| query: string; | ||
| normalizedQuery: string; | ||
| message: string; | ||
| reason: "miss" | "stale" | "corrupt" | "offline"; | ||
| confidence: Readonly<{ | ||
| level: "high" | "medium" | "low"; | ||
| basis: "exact" | "backend" | "ambiguous" | "miss" | "stale" | "corrupt" | "offline"; | ||
| }>; | ||
| candidateEntryIds?: readonly string[] | undefined; | ||
| }>, z.core.$ZodTypeInternals<Readonly<{ | ||
| protocol: "agentskit.chat.answer"; | ||
| version: 1; | ||
| outcome: "escalation"; | ||
| query: string; | ||
| normalizedQuery: string; | ||
| message: string; | ||
| reason: "miss" | "stale" | "corrupt" | "offline"; | ||
| confidence: Readonly<{ | ||
| level: "high" | "medium" | "low"; | ||
| basis: "exact" | "backend" | "ambiguous" | "miss" | "stale" | "corrupt" | "offline"; | ||
| }>; | ||
| candidateEntryIds?: readonly string[] | undefined; | ||
| }>, Readonly<{ | ||
| protocol: "agentskit.chat.answer"; | ||
| version: 1; | ||
| outcome: "answer"; | ||
| query: string; | ||
| normalizedQuery: string; | ||
| answer: Readonly<{ | ||
| markdown: string; | ||
| citations: readonly Readonly<{ | ||
| id: string; | ||
| title: string; | ||
| href: string; | ||
| }>[]; | ||
| }>; | ||
| provenance: Readonly<{ | ||
| source: "local"; | ||
| artifactId: string; | ||
| contentHash: string; | ||
| entryIds: readonly string[]; | ||
| }> | Readonly<{ | ||
| source: "backend"; | ||
| provider?: string | undefined; | ||
| model?: string | undefined; | ||
| }>; | ||
| confidence: Readonly<{ | ||
| level: "high" | "medium" | "low"; | ||
| basis: "exact" | "backend" | "ambiguous" | "miss" | "stale" | "corrupt" | "offline"; | ||
| }>; | ||
| }> | Readonly<{ | ||
| protocol: "agentskit.chat.answer"; | ||
| version: 1; | ||
| outcome: "choices"; | ||
| query: string; | ||
| normalizedQuery: string; | ||
| message: string; | ||
| suggestions: readonly Readonly<{ | ||
| id: string; | ||
| label: string; | ||
| value: string; | ||
| }>[]; | ||
| provenance: Readonly<{ | ||
| source: "local"; | ||
| artifactId: string; | ||
| contentHash: string; | ||
| entryIds: readonly string[]; | ||
| }>; | ||
| confidence: Readonly<{ | ||
| level: "high" | "medium" | "low"; | ||
| basis: "exact" | "backend" | "ambiguous" | "miss" | "stale" | "corrupt" | "offline"; | ||
| }>; | ||
| }> | Readonly<{ | ||
| protocol: "agentskit.chat.answer"; | ||
| version: 1; | ||
| outcome: "escalation"; | ||
| query: string; | ||
| normalizedQuery: string; | ||
| message: string; | ||
| reason: "miss" | "stale" | "corrupt" | "offline"; | ||
| confidence: Readonly<{ | ||
| level: "high" | "medium" | "low"; | ||
| basis: "exact" | "backend" | "ambiguous" | "miss" | "stale" | "corrupt" | "offline"; | ||
| }>; | ||
| candidateEntryIds?: readonly string[] | undefined; | ||
| }>>>>; | ||
| }, z.core.$strict>>; | ||
| declare const AskBackendSourceSchema: z.ZodReadonly<z.ZodObject<{ | ||
| id: z.ZodString; | ||
| title: z.ZodString; | ||
| href: z.ZodString; | ||
| excerpt: z.ZodString; | ||
| }, z.core.$strict>>; | ||
| declare const AskBackendSiteConfigSchema: z.ZodReadonly<z.ZodObject<{ | ||
| protocol: z.ZodLiteral<"agentskit.chat.backend-site">; | ||
| version: z.ZodLiteral<1>; | ||
| siteId: z.ZodString; | ||
| assistant: z.ZodReadonly<z.ZodObject<{ | ||
| id: z.ZodString; | ||
| name: z.ZodString; | ||
| suggestions: z.ZodReadonly<z.ZodArray<z.ZodString>>; | ||
| }, z.core.$strict>>; | ||
| corpus: z.ZodReadonly<z.ZodObject<{ | ||
| id: z.ZodString; | ||
| mode: z.ZodEnum<{ | ||
| local: "local"; | ||
| federated: "federated"; | ||
| }>; | ||
| }, z.core.$strict>>; | ||
| components: z.ZodReadonly<z.ZodArray<z.ZodString>>; | ||
| actions: z.ZodReadonly<z.ZodArray<z.ZodString>>; | ||
| limits: z.ZodReadonly<z.ZodObject<{ | ||
| requestTimeoutMs: z.ZodNumber; | ||
| retrievalTimeoutMs: z.ZodNumber; | ||
| generationTimeoutMs: z.ZodNumber; | ||
| maxSources: z.ZodNumber; | ||
| }, z.core.$strict>>; | ||
| persistence: z.ZodReadonly<z.ZodObject<{ | ||
| mode: z.ZodEnum<{ | ||
| disabled: "disabled"; | ||
| required: "required"; | ||
| }>; | ||
| }, z.core.$strict>>; | ||
| }, z.core.$strict>>; | ||
| declare const AskBackendUsageSchema: z.ZodReadonly<z.ZodObject<{ | ||
| inputTokens: z.ZodOptional<z.ZodNumber>; | ||
| outputTokens: z.ZodOptional<z.ZodNumber>; | ||
| totalTokens: z.ZodOptional<z.ZodNumber>; | ||
| costUsd: z.ZodOptional<z.ZodNumber>; | ||
| model: z.ZodOptional<z.ZodString>; | ||
| }, z.core.$strict>>; | ||
| declare const AskBackendSessionRecordSchema: z.ZodReadonly<z.ZodObject<{ | ||
| revision: z.ZodNumber; | ||
| messages: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{ | ||
| role: z.ZodEnum<{ | ||
| user: "user"; | ||
| assistant: "assistant"; | ||
| }>; | ||
| content: z.ZodString; | ||
| }, z.core.$strict>>>>; | ||
| }, z.core.$strict>>; | ||
| declare const AskBackendDiagnosticSchema: z.ZodReadonly<z.ZodObject<{ | ||
| code: z.ZodEnum<{ | ||
| ASK_INVALID_REQUEST: "ASK_INVALID_REQUEST"; | ||
| ASK_UNAUTHORIZED: "ASK_UNAUTHORIZED"; | ||
| ASK_FORBIDDEN: "ASK_FORBIDDEN"; | ||
| ASK_RATE_LIMITED: "ASK_RATE_LIMITED"; | ||
| ASK_TIMEOUT: "ASK_TIMEOUT"; | ||
| ASK_CANCELLED: "ASK_CANCELLED"; | ||
| ASK_RETRIEVAL_FAILED: "ASK_RETRIEVAL_FAILED"; | ||
| ASK_NO_GROUNDED_SOURCES: "ASK_NO_GROUNDED_SOURCES"; | ||
| ASK_GENERATION_FAILED: "ASK_GENERATION_FAILED"; | ||
| ASK_PERSISTENCE_CONFLICT: "ASK_PERSISTENCE_CONFLICT"; | ||
| ASK_INTERNAL: "ASK_INTERNAL"; | ||
| }>; | ||
| message: z.ZodString; | ||
| retryable: z.ZodBoolean; | ||
| }, z.core.$strict>>; | ||
| declare const AskBackendMetricNameSchema: z.ZodEnum<{ | ||
| "request.total_ms": "request.total_ms"; | ||
| "stream.first_event_ms": "stream.first_event_ms"; | ||
| "stream.first_token_ms": "stream.first_token_ms"; | ||
| "stream.bytes": "stream.bytes"; | ||
| "stream.events": "stream.events"; | ||
| "stream.snapshots": "stream.snapshots"; | ||
| "deterministic.fallback": "deterministic.fallback"; | ||
| "retrieval.total_ms": "retrieval.total_ms"; | ||
| "retrieval.documents": "retrieval.documents"; | ||
| "persistence.total_ms": "persistence.total_ms"; | ||
| "cancellation.count": "cancellation.count"; | ||
| "conflict.count": "conflict.count"; | ||
| "error.count": "error.count"; | ||
| "usage.input_tokens": "usage.input_tokens"; | ||
| "usage.output_tokens": "usage.output_tokens"; | ||
| "usage.total_tokens": "usage.total_tokens"; | ||
| "cost.usd": "cost.usd"; | ||
| }>; | ||
| declare const AskBackendMetricSchema: z.ZodReadonly<z.ZodObject<{ | ||
| protocol: z.ZodLiteral<"agentskit.chat.backend-metric">; | ||
| version: z.ZodLiteral<1>; | ||
| name: z.ZodEnum<{ | ||
| "request.total_ms": "request.total_ms"; | ||
| "stream.first_event_ms": "stream.first_event_ms"; | ||
| "stream.first_token_ms": "stream.first_token_ms"; | ||
| "stream.bytes": "stream.bytes"; | ||
| "stream.events": "stream.events"; | ||
| "stream.snapshots": "stream.snapshots"; | ||
| "deterministic.fallback": "deterministic.fallback"; | ||
| "retrieval.total_ms": "retrieval.total_ms"; | ||
| "retrieval.documents": "retrieval.documents"; | ||
| "persistence.total_ms": "persistence.total_ms"; | ||
| "cancellation.count": "cancellation.count"; | ||
| "conflict.count": "conflict.count"; | ||
| "error.count": "error.count"; | ||
| "usage.input_tokens": "usage.input_tokens"; | ||
| "usage.output_tokens": "usage.output_tokens"; | ||
| "usage.total_tokens": "usage.total_tokens"; | ||
| "cost.usd": "cost.usd"; | ||
| }>; | ||
| siteId: z.ZodString; | ||
| corpusId: z.ZodString; | ||
| requestId: z.ZodString; | ||
| value: z.ZodNumber; | ||
| unit: z.ZodEnum<{ | ||
| ms: "ms"; | ||
| bytes: "bytes"; | ||
| count: "count"; | ||
| tokens: "tokens"; | ||
| usd: "usd"; | ||
| }>; | ||
| outcome: z.ZodEnum<{ | ||
| error: "error"; | ||
| rejected: "rejected"; | ||
| ok: "ok"; | ||
| cancelled: "cancelled"; | ||
| }>; | ||
| emittedAt: z.ZodString; | ||
| }, z.core.$strict>>; | ||
| type AskBackendRequest = z.infer<typeof AskBackendRequestSchema>; | ||
| type AskBackendMessage = z.infer<typeof AskBackendMessageSchema>; | ||
| type AskBackendSource = z.infer<typeof AskBackendSourceSchema>; | ||
| type AskBackendSiteConfig = z.infer<typeof AskBackendSiteConfigSchema>; | ||
| type AskBackendUsage = z.infer<typeof AskBackendUsageSchema>; | ||
| type AskBackendSessionRecord = z.infer<typeof AskBackendSessionRecordSchema>; | ||
| type AskBackendDiagnostic = z.infer<typeof AskBackendDiagnosticSchema>; | ||
| type AskBackendMetric = z.infer<typeof AskBackendMetricSchema>; | ||
| declare const DETERMINISTIC_SITE_PROTOCOL: "agentskit.chat.site"; | ||
@@ -699,2 +1123,2 @@ declare const DETERMINISTIC_SITE_PROTOCOL_VERSION: 1; | ||
| export { ANSWER_MAX_CITATIONS, ANSWER_MAX_SUGGESTIONS, ANSWER_PROTOCOL, ANSWER_PROTOCOL_VERSION, ASK_EVENT_MAX_BYTES, ASK_EVENT_MAX_RECORDS, ASK_SERVICE_PROTOCOL_VERSION, ASSISTANT_CONTENT_MAX_BYTES, ASSISTANT_CONTENT_MAX_RECORDS, ASSISTANT_CONTENT_PREFIX, ASSISTANT_CONTENT_PROTOCOL, ASSISTANT_CONTENT_PROTOCOL_VERSION, type AnswerCitation, AnswerCitationSchema, AnswerConfidenceSchema, type AnswerResponse, AnswerResponseSchema, AnswerSuggestionSchema, type AskEvent, type AskEventDecodeResult, AskEventSchema, type AskToolEvent, type AssistantComponentPart, AssistantComponentPartSchema, type AssistantContentDecodeCode, type AssistantContentEncoder, type AssistantContentPart, AssistantContentPartSchema, type AssistantTextPart, AssistantTextPartSchema, COMPONENT_PROTOCOL, COMPONENT_PROTOCOL_VERSION, type ComponentDecodeCode, type ComponentFallback, ComponentFallbackSchema, type ComponentInteractionEvent, ComponentInteractionEventSchema, ComponentKeySchema, type ComponentRenderFrame, ComponentRenderFrameSchema, type ComponentSelectionEvent, ComponentSelectionEventSchema, type CreateSnapshotEventOptions, DETERMINISTIC_ARTIFACT_MAX_BYTES, DETERMINISTIC_ARTIFACT_MAX_ENTRIES, DETERMINISTIC_KNOWLEDGE_PROTOCOL, DETERMINISTIC_KNOWLEDGE_PROTOCOL_VERSION, DETERMINISTIC_MATCH_MAX_VALUES, DETERMINISTIC_QUERY_MAX_CHARS, DETERMINISTIC_SITE_PROTOCOL, DETERMINISTIC_SITE_PROTOCOL_VERSION, type DecodeAssistantContentResult, type DecodeComponentFrameResult, type DecodeLocalKnowledgeArtifactOptions, type DecodeSessionSnapshotResult, type DecodeTurnEventResult, type DeterministicDecodeCode, type DeterministicDecodeResult, type DeterministicKnowledgeEntry, DeterministicKnowledgeEntrySchema, type DeterministicSiteConfig, DeterministicSiteConfigSchema, type DiagnosticTurnEvent, type LocalKnowledgeArtifact, type LocalKnowledgeArtifactHashInput, LocalKnowledgeArtifactSchema, type ProtocolDecodeCode, type ProtocolDecodeDiagnostic, SESSION_PROTOCOL, SESSION_PROTOCOL_VERSION, type SessionConfirmation, SessionConfirmationSchema, type SessionSnapshot, SessionSnapshotSchema, type SnapshotTurnEvent, type SubmitTurnEvent, TURN_PROTOCOL, TURN_PROTOCOL_VERSION, TokenUsageSchema, type TurnDiagnostic, TurnDiagnosticSchema, type TurnEvent, TurnEventSchema, type TurnLineage, type TurnSnapshotCursor, type VerifiedLocalKnowledgeArtifact, type VerifyLocalKnowledgeArtifactOptions, type WireMessage, canonicalizeLocalKnowledgeArtifact, computeLocalKnowledgeArtifactContentHash, createAssistantContentEncoder, createInteractionEvent, createSelectionEvent, createSnapshotEvent, createTurnSnapshotCursor, decodeAnswerResponse, decodeAskEvents, decodeAssistantContent, decodeComponentFrame, decodeDeterministicSiteConfig, decodeLocalKnowledgeArtifact, decodeSessionSnapshot, decodeTurnEvent, encodeTurnEvent, isAssistantContentCandidate, isComponentFrameCandidate, normalizeKnowledgeKey, snapshotMessages, verifyLocalKnowledgeArtifact, verifyLocalKnowledgeArtifactSync }; | ||
| export { ANSWER_MAX_CITATIONS, ANSWER_MAX_SUGGESTIONS, ANSWER_PROTOCOL, ANSWER_PROTOCOL_VERSION, ASK_BACKEND_MAX_MESSAGES, ASK_BACKEND_MAX_MESSAGE_CHARS, ASK_BACKEND_MAX_SOURCES, ASK_BACKEND_PROTOCOL, ASK_BACKEND_PROTOCOL_VERSION, ASK_EVENT_MAX_BYTES, ASK_EVENT_MAX_RECORDS, ASK_SERVICE_PROTOCOL_VERSION, ASSISTANT_CONTENT_MAX_BYTES, ASSISTANT_CONTENT_MAX_RECORDS, ASSISTANT_CONTENT_PREFIX, ASSISTANT_CONTENT_PROTOCOL, ASSISTANT_CONTENT_PROTOCOL_VERSION, type AnswerCitation, AnswerCitationSchema, AnswerConfidenceSchema, type AnswerResponse, AnswerResponseSchema, AnswerSuggestionSchema, type AskBackendDiagnostic, AskBackendDiagnosticSchema, type AskBackendMessage, AskBackendMessageSchema, type AskBackendMetric, AskBackendMetricNameSchema, AskBackendMetricSchema, type AskBackendRequest, AskBackendRequestSchema, type AskBackendSessionRecord, AskBackendSessionRecordSchema, type AskBackendSiteConfig, AskBackendSiteConfigSchema, type AskBackendSource, AskBackendSourceSchema, type AskBackendUsage, AskBackendUsageSchema, type AskEvent, type AskEventDecodeResult, AskEventSchema, type AskToolEvent, type AssistantComponentPart, AssistantComponentPartSchema, type AssistantContentDecodeCode, type AssistantContentEncoder, type AssistantContentPart, AssistantContentPartSchema, type AssistantTextPart, AssistantTextPartSchema, COMPONENT_PROTOCOL, COMPONENT_PROTOCOL_VERSION, type ComponentDecodeCode, type ComponentFallback, ComponentFallbackSchema, type ComponentInteractionEvent, ComponentInteractionEventSchema, ComponentKeySchema, type ComponentRenderFrame, ComponentRenderFrameSchema, type ComponentSelectionEvent, ComponentSelectionEventSchema, type CreateSnapshotEventOptions, DETERMINISTIC_ARTIFACT_MAX_BYTES, DETERMINISTIC_ARTIFACT_MAX_ENTRIES, DETERMINISTIC_KNOWLEDGE_PROTOCOL, DETERMINISTIC_KNOWLEDGE_PROTOCOL_VERSION, DETERMINISTIC_MATCH_MAX_VALUES, DETERMINISTIC_QUERY_MAX_CHARS, DETERMINISTIC_SITE_PROTOCOL, DETERMINISTIC_SITE_PROTOCOL_VERSION, type DecodeAssistantContentResult, type DecodeComponentFrameResult, type DecodeLocalKnowledgeArtifactOptions, type DecodeSessionSnapshotResult, type DecodeTurnEventResult, type DeterministicDecodeCode, type DeterministicDecodeResult, type DeterministicKnowledgeEntry, DeterministicKnowledgeEntrySchema, type DeterministicSiteConfig, DeterministicSiteConfigSchema, type DiagnosticTurnEvent, type LocalKnowledgeArtifact, type LocalKnowledgeArtifactHashInput, LocalKnowledgeArtifactSchema, type ProtocolDecodeCode, type ProtocolDecodeDiagnostic, SESSION_PROTOCOL, SESSION_PROTOCOL_VERSION, type SessionConfirmation, SessionConfirmationSchema, type SessionSnapshot, SessionSnapshotSchema, type SnapshotTurnEvent, type SubmitTurnEvent, TURN_PROTOCOL, TURN_PROTOCOL_VERSION, TokenUsageSchema, type TurnDiagnostic, TurnDiagnosticSchema, type TurnEvent, TurnEventSchema, type TurnLineage, type TurnSnapshotCursor, type VerifiedLocalKnowledgeArtifact, type VerifyLocalKnowledgeArtifactOptions, type WireMessage, canonicalizeLocalKnowledgeArtifact, computeLocalKnowledgeArtifactContentHash, createAssistantContentEncoder, createInteractionEvent, createSelectionEvent, createSnapshotEvent, createTurnSnapshotCursor, decodeAnswerResponse, decodeAskEvents, decodeAssistantContent, decodeComponentFrame, decodeDeterministicSiteConfig, decodeLocalKnowledgeArtifact, decodeSessionSnapshot, decodeTurnEvent, encodeTurnEvent, isAssistantContentCandidate, isComponentFrameCandidate, normalizeKnowledgeKey, snapshotMessages, verifyLocalKnowledgeArtifact, verifyLocalKnowledgeArtifactSync }; |
+425
-1
@@ -21,2 +21,4 @@ import { Message, TokenUsage, MemoryRecord } from '@agentskit/core'; | ||
| message: z.ZodString; | ||
| code: z.ZodOptional<z.ZodString>; | ||
| retryable: z.ZodOptional<z.ZodBoolean>; | ||
| }, z.core.$strict>], "type">; | ||
@@ -35,2 +37,424 @@ type AskEvent = z.infer<typeof AskEventSchema>; | ||
| declare const ASK_BACKEND_PROTOCOL: "agentskit.chat.ask"; | ||
| declare const ASK_BACKEND_PROTOCOL_VERSION: 1; | ||
| declare const ASK_BACKEND_MAX_MESSAGES = 64; | ||
| declare const ASK_BACKEND_MAX_MESSAGE_CHARS = 16384; | ||
| declare const ASK_BACKEND_MAX_SOURCES = 8; | ||
| declare const AskBackendMessageSchema: z.ZodReadonly<z.ZodObject<{ | ||
| role: z.ZodEnum<{ | ||
| user: "user"; | ||
| assistant: "assistant"; | ||
| }>; | ||
| content: z.ZodString; | ||
| }, z.core.$strict>>; | ||
| /** Additive v1 request accepted by both hosted and self-hosted Ask handlers. */ | ||
| declare const AskBackendRequestSchema: z.ZodReadonly<z.ZodObject<{ | ||
| protocol: z.ZodOptional<z.ZodLiteral<"agentskit.chat.ask">>; | ||
| version: z.ZodOptional<z.ZodLiteral<1>>; | ||
| sessionId: z.ZodOptional<z.ZodString>; | ||
| messages: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{ | ||
| role: z.ZodEnum<{ | ||
| user: "user"; | ||
| assistant: "assistant"; | ||
| }>; | ||
| content: z.ZodString; | ||
| }, z.core.$strict>>>>; | ||
| deterministic: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{ | ||
| protocol: z.ZodLiteral<"agentskit.chat.answer">; | ||
| version: z.ZodLiteral<1>; | ||
| outcome: z.ZodLiteral<"answer">; | ||
| query: z.ZodString; | ||
| normalizedQuery: z.ZodString; | ||
| answer: z.ZodReadonly<z.ZodObject<{ | ||
| markdown: z.ZodString; | ||
| citations: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{ | ||
| id: z.ZodString; | ||
| title: z.ZodString; | ||
| href: z.ZodString; | ||
| }, z.core.$strip>>>>; | ||
| }, z.core.$strip>>; | ||
| provenance: z.ZodUnion<readonly [z.ZodReadonly<z.ZodObject<{ | ||
| source: z.ZodLiteral<"local">; | ||
| artifactId: z.ZodString; | ||
| contentHash: z.ZodString; | ||
| entryIds: z.ZodReadonly<z.ZodArray<z.ZodString>>; | ||
| }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{ | ||
| source: z.ZodLiteral<"backend">; | ||
| provider: z.ZodOptional<z.ZodString>; | ||
| model: z.ZodOptional<z.ZodString>; | ||
| }, z.core.$strip>>]>; | ||
| confidence: z.ZodReadonly<z.ZodObject<{ | ||
| level: z.ZodEnum<{ | ||
| high: "high"; | ||
| medium: "medium"; | ||
| low: "low"; | ||
| }>; | ||
| basis: z.ZodEnum<{ | ||
| exact: "exact"; | ||
| backend: "backend"; | ||
| ambiguous: "ambiguous"; | ||
| miss: "miss"; | ||
| stale: "stale"; | ||
| corrupt: "corrupt"; | ||
| offline: "offline"; | ||
| }>; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{ | ||
| protocol: z.ZodLiteral<"agentskit.chat.answer">; | ||
| version: z.ZodLiteral<1>; | ||
| outcome: z.ZodLiteral<"choices">; | ||
| query: z.ZodString; | ||
| normalizedQuery: z.ZodString; | ||
| message: z.ZodString; | ||
| suggestions: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{ | ||
| id: z.ZodString; | ||
| label: z.ZodString; | ||
| value: z.ZodString; | ||
| }, z.core.$strip>>>>; | ||
| provenance: z.ZodReadonly<z.ZodObject<{ | ||
| source: z.ZodLiteral<"local">; | ||
| artifactId: z.ZodString; | ||
| contentHash: z.ZodString; | ||
| entryIds: z.ZodReadonly<z.ZodArray<z.ZodString>>; | ||
| }, z.core.$strip>>; | ||
| confidence: z.ZodReadonly<z.ZodObject<{ | ||
| level: z.ZodEnum<{ | ||
| high: "high"; | ||
| medium: "medium"; | ||
| low: "low"; | ||
| }>; | ||
| basis: z.ZodEnum<{ | ||
| exact: "exact"; | ||
| backend: "backend"; | ||
| ambiguous: "ambiguous"; | ||
| miss: "miss"; | ||
| stale: "stale"; | ||
| corrupt: "corrupt"; | ||
| offline: "offline"; | ||
| }>; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{ | ||
| protocol: z.ZodLiteral<"agentskit.chat.answer">; | ||
| version: z.ZodLiteral<1>; | ||
| outcome: z.ZodLiteral<"escalation">; | ||
| query: z.ZodString; | ||
| normalizedQuery: z.ZodString; | ||
| message: z.ZodString; | ||
| reason: z.ZodEnum<{ | ||
| miss: "miss"; | ||
| stale: "stale"; | ||
| corrupt: "corrupt"; | ||
| offline: "offline"; | ||
| }>; | ||
| candidateEntryIds: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>; | ||
| confidence: z.ZodReadonly<z.ZodObject<{ | ||
| level: z.ZodEnum<{ | ||
| high: "high"; | ||
| medium: "medium"; | ||
| low: "low"; | ||
| }>; | ||
| basis: z.ZodEnum<{ | ||
| exact: "exact"; | ||
| backend: "backend"; | ||
| ambiguous: "ambiguous"; | ||
| miss: "miss"; | ||
| stale: "stale"; | ||
| corrupt: "corrupt"; | ||
| offline: "offline"; | ||
| }>; | ||
| }, z.core.$strip>>; | ||
| }, z.core.$strip>>], "outcome"> & z.ZodType<Readonly<{ | ||
| protocol: "agentskit.chat.answer"; | ||
| version: 1; | ||
| outcome: "escalation"; | ||
| query: string; | ||
| normalizedQuery: string; | ||
| message: string; | ||
| reason: "miss" | "stale" | "corrupt" | "offline"; | ||
| confidence: Readonly<{ | ||
| level: "high" | "medium" | "low"; | ||
| basis: "exact" | "backend" | "ambiguous" | "miss" | "stale" | "corrupt" | "offline"; | ||
| }>; | ||
| candidateEntryIds?: readonly string[] | undefined; | ||
| }>, Readonly<{ | ||
| protocol: "agentskit.chat.answer"; | ||
| version: 1; | ||
| outcome: "answer"; | ||
| query: string; | ||
| normalizedQuery: string; | ||
| answer: Readonly<{ | ||
| markdown: string; | ||
| citations: readonly Readonly<{ | ||
| id: string; | ||
| title: string; | ||
| href: string; | ||
| }>[]; | ||
| }>; | ||
| provenance: Readonly<{ | ||
| source: "local"; | ||
| artifactId: string; | ||
| contentHash: string; | ||
| entryIds: readonly string[]; | ||
| }> | Readonly<{ | ||
| source: "backend"; | ||
| provider?: string | undefined; | ||
| model?: string | undefined; | ||
| }>; | ||
| confidence: Readonly<{ | ||
| level: "high" | "medium" | "low"; | ||
| basis: "exact" | "backend" | "ambiguous" | "miss" | "stale" | "corrupt" | "offline"; | ||
| }>; | ||
| }> | Readonly<{ | ||
| protocol: "agentskit.chat.answer"; | ||
| version: 1; | ||
| outcome: "choices"; | ||
| query: string; | ||
| normalizedQuery: string; | ||
| message: string; | ||
| suggestions: readonly Readonly<{ | ||
| id: string; | ||
| label: string; | ||
| value: string; | ||
| }>[]; | ||
| provenance: Readonly<{ | ||
| source: "local"; | ||
| artifactId: string; | ||
| contentHash: string; | ||
| entryIds: readonly string[]; | ||
| }>; | ||
| confidence: Readonly<{ | ||
| level: "high" | "medium" | "low"; | ||
| basis: "exact" | "backend" | "ambiguous" | "miss" | "stale" | "corrupt" | "offline"; | ||
| }>; | ||
| }> | Readonly<{ | ||
| protocol: "agentskit.chat.answer"; | ||
| version: 1; | ||
| outcome: "escalation"; | ||
| query: string; | ||
| normalizedQuery: string; | ||
| message: string; | ||
| reason: "miss" | "stale" | "corrupt" | "offline"; | ||
| confidence: Readonly<{ | ||
| level: "high" | "medium" | "low"; | ||
| basis: "exact" | "backend" | "ambiguous" | "miss" | "stale" | "corrupt" | "offline"; | ||
| }>; | ||
| candidateEntryIds?: readonly string[] | undefined; | ||
| }>, z.core.$ZodTypeInternals<Readonly<{ | ||
| protocol: "agentskit.chat.answer"; | ||
| version: 1; | ||
| outcome: "escalation"; | ||
| query: string; | ||
| normalizedQuery: string; | ||
| message: string; | ||
| reason: "miss" | "stale" | "corrupt" | "offline"; | ||
| confidence: Readonly<{ | ||
| level: "high" | "medium" | "low"; | ||
| basis: "exact" | "backend" | "ambiguous" | "miss" | "stale" | "corrupt" | "offline"; | ||
| }>; | ||
| candidateEntryIds?: readonly string[] | undefined; | ||
| }>, Readonly<{ | ||
| protocol: "agentskit.chat.answer"; | ||
| version: 1; | ||
| outcome: "answer"; | ||
| query: string; | ||
| normalizedQuery: string; | ||
| answer: Readonly<{ | ||
| markdown: string; | ||
| citations: readonly Readonly<{ | ||
| id: string; | ||
| title: string; | ||
| href: string; | ||
| }>[]; | ||
| }>; | ||
| provenance: Readonly<{ | ||
| source: "local"; | ||
| artifactId: string; | ||
| contentHash: string; | ||
| entryIds: readonly string[]; | ||
| }> | Readonly<{ | ||
| source: "backend"; | ||
| provider?: string | undefined; | ||
| model?: string | undefined; | ||
| }>; | ||
| confidence: Readonly<{ | ||
| level: "high" | "medium" | "low"; | ||
| basis: "exact" | "backend" | "ambiguous" | "miss" | "stale" | "corrupt" | "offline"; | ||
| }>; | ||
| }> | Readonly<{ | ||
| protocol: "agentskit.chat.answer"; | ||
| version: 1; | ||
| outcome: "choices"; | ||
| query: string; | ||
| normalizedQuery: string; | ||
| message: string; | ||
| suggestions: readonly Readonly<{ | ||
| id: string; | ||
| label: string; | ||
| value: string; | ||
| }>[]; | ||
| provenance: Readonly<{ | ||
| source: "local"; | ||
| artifactId: string; | ||
| contentHash: string; | ||
| entryIds: readonly string[]; | ||
| }>; | ||
| confidence: Readonly<{ | ||
| level: "high" | "medium" | "low"; | ||
| basis: "exact" | "backend" | "ambiguous" | "miss" | "stale" | "corrupt" | "offline"; | ||
| }>; | ||
| }> | Readonly<{ | ||
| protocol: "agentskit.chat.answer"; | ||
| version: 1; | ||
| outcome: "escalation"; | ||
| query: string; | ||
| normalizedQuery: string; | ||
| message: string; | ||
| reason: "miss" | "stale" | "corrupt" | "offline"; | ||
| confidence: Readonly<{ | ||
| level: "high" | "medium" | "low"; | ||
| basis: "exact" | "backend" | "ambiguous" | "miss" | "stale" | "corrupt" | "offline"; | ||
| }>; | ||
| candidateEntryIds?: readonly string[] | undefined; | ||
| }>>>>; | ||
| }, z.core.$strict>>; | ||
| declare const AskBackendSourceSchema: z.ZodReadonly<z.ZodObject<{ | ||
| id: z.ZodString; | ||
| title: z.ZodString; | ||
| href: z.ZodString; | ||
| excerpt: z.ZodString; | ||
| }, z.core.$strict>>; | ||
| declare const AskBackendSiteConfigSchema: z.ZodReadonly<z.ZodObject<{ | ||
| protocol: z.ZodLiteral<"agentskit.chat.backend-site">; | ||
| version: z.ZodLiteral<1>; | ||
| siteId: z.ZodString; | ||
| assistant: z.ZodReadonly<z.ZodObject<{ | ||
| id: z.ZodString; | ||
| name: z.ZodString; | ||
| suggestions: z.ZodReadonly<z.ZodArray<z.ZodString>>; | ||
| }, z.core.$strict>>; | ||
| corpus: z.ZodReadonly<z.ZodObject<{ | ||
| id: z.ZodString; | ||
| mode: z.ZodEnum<{ | ||
| local: "local"; | ||
| federated: "federated"; | ||
| }>; | ||
| }, z.core.$strict>>; | ||
| components: z.ZodReadonly<z.ZodArray<z.ZodString>>; | ||
| actions: z.ZodReadonly<z.ZodArray<z.ZodString>>; | ||
| limits: z.ZodReadonly<z.ZodObject<{ | ||
| requestTimeoutMs: z.ZodNumber; | ||
| retrievalTimeoutMs: z.ZodNumber; | ||
| generationTimeoutMs: z.ZodNumber; | ||
| maxSources: z.ZodNumber; | ||
| }, z.core.$strict>>; | ||
| persistence: z.ZodReadonly<z.ZodObject<{ | ||
| mode: z.ZodEnum<{ | ||
| disabled: "disabled"; | ||
| required: "required"; | ||
| }>; | ||
| }, z.core.$strict>>; | ||
| }, z.core.$strict>>; | ||
| declare const AskBackendUsageSchema: z.ZodReadonly<z.ZodObject<{ | ||
| inputTokens: z.ZodOptional<z.ZodNumber>; | ||
| outputTokens: z.ZodOptional<z.ZodNumber>; | ||
| totalTokens: z.ZodOptional<z.ZodNumber>; | ||
| costUsd: z.ZodOptional<z.ZodNumber>; | ||
| model: z.ZodOptional<z.ZodString>; | ||
| }, z.core.$strict>>; | ||
| declare const AskBackendSessionRecordSchema: z.ZodReadonly<z.ZodObject<{ | ||
| revision: z.ZodNumber; | ||
| messages: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{ | ||
| role: z.ZodEnum<{ | ||
| user: "user"; | ||
| assistant: "assistant"; | ||
| }>; | ||
| content: z.ZodString; | ||
| }, z.core.$strict>>>>; | ||
| }, z.core.$strict>>; | ||
| declare const AskBackendDiagnosticSchema: z.ZodReadonly<z.ZodObject<{ | ||
| code: z.ZodEnum<{ | ||
| ASK_INVALID_REQUEST: "ASK_INVALID_REQUEST"; | ||
| ASK_UNAUTHORIZED: "ASK_UNAUTHORIZED"; | ||
| ASK_FORBIDDEN: "ASK_FORBIDDEN"; | ||
| ASK_RATE_LIMITED: "ASK_RATE_LIMITED"; | ||
| ASK_TIMEOUT: "ASK_TIMEOUT"; | ||
| ASK_CANCELLED: "ASK_CANCELLED"; | ||
| ASK_RETRIEVAL_FAILED: "ASK_RETRIEVAL_FAILED"; | ||
| ASK_NO_GROUNDED_SOURCES: "ASK_NO_GROUNDED_SOURCES"; | ||
| ASK_GENERATION_FAILED: "ASK_GENERATION_FAILED"; | ||
| ASK_PERSISTENCE_CONFLICT: "ASK_PERSISTENCE_CONFLICT"; | ||
| ASK_INTERNAL: "ASK_INTERNAL"; | ||
| }>; | ||
| message: z.ZodString; | ||
| retryable: z.ZodBoolean; | ||
| }, z.core.$strict>>; | ||
| declare const AskBackendMetricNameSchema: z.ZodEnum<{ | ||
| "request.total_ms": "request.total_ms"; | ||
| "stream.first_event_ms": "stream.first_event_ms"; | ||
| "stream.first_token_ms": "stream.first_token_ms"; | ||
| "stream.bytes": "stream.bytes"; | ||
| "stream.events": "stream.events"; | ||
| "stream.snapshots": "stream.snapshots"; | ||
| "deterministic.fallback": "deterministic.fallback"; | ||
| "retrieval.total_ms": "retrieval.total_ms"; | ||
| "retrieval.documents": "retrieval.documents"; | ||
| "persistence.total_ms": "persistence.total_ms"; | ||
| "cancellation.count": "cancellation.count"; | ||
| "conflict.count": "conflict.count"; | ||
| "error.count": "error.count"; | ||
| "usage.input_tokens": "usage.input_tokens"; | ||
| "usage.output_tokens": "usage.output_tokens"; | ||
| "usage.total_tokens": "usage.total_tokens"; | ||
| "cost.usd": "cost.usd"; | ||
| }>; | ||
| declare const AskBackendMetricSchema: z.ZodReadonly<z.ZodObject<{ | ||
| protocol: z.ZodLiteral<"agentskit.chat.backend-metric">; | ||
| version: z.ZodLiteral<1>; | ||
| name: z.ZodEnum<{ | ||
| "request.total_ms": "request.total_ms"; | ||
| "stream.first_event_ms": "stream.first_event_ms"; | ||
| "stream.first_token_ms": "stream.first_token_ms"; | ||
| "stream.bytes": "stream.bytes"; | ||
| "stream.events": "stream.events"; | ||
| "stream.snapshots": "stream.snapshots"; | ||
| "deterministic.fallback": "deterministic.fallback"; | ||
| "retrieval.total_ms": "retrieval.total_ms"; | ||
| "retrieval.documents": "retrieval.documents"; | ||
| "persistence.total_ms": "persistence.total_ms"; | ||
| "cancellation.count": "cancellation.count"; | ||
| "conflict.count": "conflict.count"; | ||
| "error.count": "error.count"; | ||
| "usage.input_tokens": "usage.input_tokens"; | ||
| "usage.output_tokens": "usage.output_tokens"; | ||
| "usage.total_tokens": "usage.total_tokens"; | ||
| "cost.usd": "cost.usd"; | ||
| }>; | ||
| siteId: z.ZodString; | ||
| corpusId: z.ZodString; | ||
| requestId: z.ZodString; | ||
| value: z.ZodNumber; | ||
| unit: z.ZodEnum<{ | ||
| ms: "ms"; | ||
| bytes: "bytes"; | ||
| count: "count"; | ||
| tokens: "tokens"; | ||
| usd: "usd"; | ||
| }>; | ||
| outcome: z.ZodEnum<{ | ||
| error: "error"; | ||
| rejected: "rejected"; | ||
| ok: "ok"; | ||
| cancelled: "cancelled"; | ||
| }>; | ||
| emittedAt: z.ZodString; | ||
| }, z.core.$strict>>; | ||
| type AskBackendRequest = z.infer<typeof AskBackendRequestSchema>; | ||
| type AskBackendMessage = z.infer<typeof AskBackendMessageSchema>; | ||
| type AskBackendSource = z.infer<typeof AskBackendSourceSchema>; | ||
| type AskBackendSiteConfig = z.infer<typeof AskBackendSiteConfigSchema>; | ||
| type AskBackendUsage = z.infer<typeof AskBackendUsageSchema>; | ||
| type AskBackendSessionRecord = z.infer<typeof AskBackendSessionRecordSchema>; | ||
| type AskBackendDiagnostic = z.infer<typeof AskBackendDiagnosticSchema>; | ||
| type AskBackendMetric = z.infer<typeof AskBackendMetricSchema>; | ||
| declare const DETERMINISTIC_SITE_PROTOCOL: "agentskit.chat.site"; | ||
@@ -699,2 +1123,2 @@ declare const DETERMINISTIC_SITE_PROTOCOL_VERSION: 1; | ||
| export { ANSWER_MAX_CITATIONS, ANSWER_MAX_SUGGESTIONS, ANSWER_PROTOCOL, ANSWER_PROTOCOL_VERSION, ASK_EVENT_MAX_BYTES, ASK_EVENT_MAX_RECORDS, ASK_SERVICE_PROTOCOL_VERSION, ASSISTANT_CONTENT_MAX_BYTES, ASSISTANT_CONTENT_MAX_RECORDS, ASSISTANT_CONTENT_PREFIX, ASSISTANT_CONTENT_PROTOCOL, ASSISTANT_CONTENT_PROTOCOL_VERSION, type AnswerCitation, AnswerCitationSchema, AnswerConfidenceSchema, type AnswerResponse, AnswerResponseSchema, AnswerSuggestionSchema, type AskEvent, type AskEventDecodeResult, AskEventSchema, type AskToolEvent, type AssistantComponentPart, AssistantComponentPartSchema, type AssistantContentDecodeCode, type AssistantContentEncoder, type AssistantContentPart, AssistantContentPartSchema, type AssistantTextPart, AssistantTextPartSchema, COMPONENT_PROTOCOL, COMPONENT_PROTOCOL_VERSION, type ComponentDecodeCode, type ComponentFallback, ComponentFallbackSchema, type ComponentInteractionEvent, ComponentInteractionEventSchema, ComponentKeySchema, type ComponentRenderFrame, ComponentRenderFrameSchema, type ComponentSelectionEvent, ComponentSelectionEventSchema, type CreateSnapshotEventOptions, DETERMINISTIC_ARTIFACT_MAX_BYTES, DETERMINISTIC_ARTIFACT_MAX_ENTRIES, DETERMINISTIC_KNOWLEDGE_PROTOCOL, DETERMINISTIC_KNOWLEDGE_PROTOCOL_VERSION, DETERMINISTIC_MATCH_MAX_VALUES, DETERMINISTIC_QUERY_MAX_CHARS, DETERMINISTIC_SITE_PROTOCOL, DETERMINISTIC_SITE_PROTOCOL_VERSION, type DecodeAssistantContentResult, type DecodeComponentFrameResult, type DecodeLocalKnowledgeArtifactOptions, type DecodeSessionSnapshotResult, type DecodeTurnEventResult, type DeterministicDecodeCode, type DeterministicDecodeResult, type DeterministicKnowledgeEntry, DeterministicKnowledgeEntrySchema, type DeterministicSiteConfig, DeterministicSiteConfigSchema, type DiagnosticTurnEvent, type LocalKnowledgeArtifact, type LocalKnowledgeArtifactHashInput, LocalKnowledgeArtifactSchema, type ProtocolDecodeCode, type ProtocolDecodeDiagnostic, SESSION_PROTOCOL, SESSION_PROTOCOL_VERSION, type SessionConfirmation, SessionConfirmationSchema, type SessionSnapshot, SessionSnapshotSchema, type SnapshotTurnEvent, type SubmitTurnEvent, TURN_PROTOCOL, TURN_PROTOCOL_VERSION, TokenUsageSchema, type TurnDiagnostic, TurnDiagnosticSchema, type TurnEvent, TurnEventSchema, type TurnLineage, type TurnSnapshotCursor, type VerifiedLocalKnowledgeArtifact, type VerifyLocalKnowledgeArtifactOptions, type WireMessage, canonicalizeLocalKnowledgeArtifact, computeLocalKnowledgeArtifactContentHash, createAssistantContentEncoder, createInteractionEvent, createSelectionEvent, createSnapshotEvent, createTurnSnapshotCursor, decodeAnswerResponse, decodeAskEvents, decodeAssistantContent, decodeComponentFrame, decodeDeterministicSiteConfig, decodeLocalKnowledgeArtifact, decodeSessionSnapshot, decodeTurnEvent, encodeTurnEvent, isAssistantContentCandidate, isComponentFrameCandidate, normalizeKnowledgeKey, snapshotMessages, verifyLocalKnowledgeArtifact, verifyLocalKnowledgeArtifactSync }; | ||
| export { ANSWER_MAX_CITATIONS, ANSWER_MAX_SUGGESTIONS, ANSWER_PROTOCOL, ANSWER_PROTOCOL_VERSION, ASK_BACKEND_MAX_MESSAGES, ASK_BACKEND_MAX_MESSAGE_CHARS, ASK_BACKEND_MAX_SOURCES, ASK_BACKEND_PROTOCOL, ASK_BACKEND_PROTOCOL_VERSION, ASK_EVENT_MAX_BYTES, ASK_EVENT_MAX_RECORDS, ASK_SERVICE_PROTOCOL_VERSION, ASSISTANT_CONTENT_MAX_BYTES, ASSISTANT_CONTENT_MAX_RECORDS, ASSISTANT_CONTENT_PREFIX, ASSISTANT_CONTENT_PROTOCOL, ASSISTANT_CONTENT_PROTOCOL_VERSION, type AnswerCitation, AnswerCitationSchema, AnswerConfidenceSchema, type AnswerResponse, AnswerResponseSchema, AnswerSuggestionSchema, type AskBackendDiagnostic, AskBackendDiagnosticSchema, type AskBackendMessage, AskBackendMessageSchema, type AskBackendMetric, AskBackendMetricNameSchema, AskBackendMetricSchema, type AskBackendRequest, AskBackendRequestSchema, type AskBackendSessionRecord, AskBackendSessionRecordSchema, type AskBackendSiteConfig, AskBackendSiteConfigSchema, type AskBackendSource, AskBackendSourceSchema, type AskBackendUsage, AskBackendUsageSchema, type AskEvent, type AskEventDecodeResult, AskEventSchema, type AskToolEvent, type AssistantComponentPart, AssistantComponentPartSchema, type AssistantContentDecodeCode, type AssistantContentEncoder, type AssistantContentPart, AssistantContentPartSchema, type AssistantTextPart, AssistantTextPartSchema, COMPONENT_PROTOCOL, COMPONENT_PROTOCOL_VERSION, type ComponentDecodeCode, type ComponentFallback, ComponentFallbackSchema, type ComponentInteractionEvent, ComponentInteractionEventSchema, ComponentKeySchema, type ComponentRenderFrame, ComponentRenderFrameSchema, type ComponentSelectionEvent, ComponentSelectionEventSchema, type CreateSnapshotEventOptions, DETERMINISTIC_ARTIFACT_MAX_BYTES, DETERMINISTIC_ARTIFACT_MAX_ENTRIES, DETERMINISTIC_KNOWLEDGE_PROTOCOL, DETERMINISTIC_KNOWLEDGE_PROTOCOL_VERSION, DETERMINISTIC_MATCH_MAX_VALUES, DETERMINISTIC_QUERY_MAX_CHARS, DETERMINISTIC_SITE_PROTOCOL, DETERMINISTIC_SITE_PROTOCOL_VERSION, type DecodeAssistantContentResult, type DecodeComponentFrameResult, type DecodeLocalKnowledgeArtifactOptions, type DecodeSessionSnapshotResult, type DecodeTurnEventResult, type DeterministicDecodeCode, type DeterministicDecodeResult, type DeterministicKnowledgeEntry, DeterministicKnowledgeEntrySchema, type DeterministicSiteConfig, DeterministicSiteConfigSchema, type DiagnosticTurnEvent, type LocalKnowledgeArtifact, type LocalKnowledgeArtifactHashInput, LocalKnowledgeArtifactSchema, type ProtocolDecodeCode, type ProtocolDecodeDiagnostic, SESSION_PROTOCOL, SESSION_PROTOCOL_VERSION, type SessionConfirmation, SessionConfirmationSchema, type SessionSnapshot, SessionSnapshotSchema, type SnapshotTurnEvent, type SubmitTurnEvent, TURN_PROTOCOL, TURN_PROTOCOL_VERSION, TokenUsageSchema, type TurnDiagnostic, TurnDiagnosticSchema, type TurnEvent, TurnEventSchema, type TurnLineage, type TurnSnapshotCursor, type VerifiedLocalKnowledgeArtifact, type VerifyLocalKnowledgeArtifactOptions, type WireMessage, canonicalizeLocalKnowledgeArtifact, computeLocalKnowledgeArtifactContentHash, createAssistantContentEncoder, createInteractionEvent, createSelectionEvent, createSnapshotEvent, createTurnSnapshotCursor, decodeAnswerResponse, decodeAskEvents, decodeAssistantContent, decodeComponentFrame, decodeDeterministicSiteConfig, decodeLocalKnowledgeArtifact, decodeSessionSnapshot, decodeTurnEvent, encodeTurnEvent, isAssistantContentCandidate, isComponentFrameCandidate, normalizeKnowledgeKey, snapshotMessages, verifyLocalKnowledgeArtifact, verifyLocalKnowledgeArtifactSync }; |
+240
-96
| // src/index.ts | ||
| import { deserializeMessages, serializeMessages } from "@agentskit/core"; | ||
| import { validateMemoryRecord } from "@agentskit/core/memory-validation"; | ||
| import { z as z3 } from "zod"; | ||
| import { z as z4 } from "zod"; | ||
@@ -16,3 +16,8 @@ // src/ask.ts | ||
| z.object({ type: z.literal("done"), model: z.string().max(256).optional() }).strict(), | ||
| z.object({ type: z.literal("error"), message: z.string().min(1).max(4096) }).strict() | ||
| z.object({ | ||
| type: z.literal("error"), | ||
| message: z.string().min(1).max(4096), | ||
| code: z.string().regex(/^[A-Z][A-Z0-9_]{0,127}$/).optional(), | ||
| retryable: z.boolean().optional() | ||
| }).strict() | ||
| ]); | ||
@@ -47,2 +52,5 @@ var byteLength = (value) => new TextEncoder().encode(value).byteLength; | ||
| // src/backend.ts | ||
| import { z as z3 } from "zod"; | ||
| // src/deterministic.ts | ||
@@ -318,2 +326,124 @@ import { sha256 } from "@noble/hashes/sha2.js"; | ||
| // src/backend.ts | ||
| var ASK_BACKEND_PROTOCOL = "agentskit.chat.ask"; | ||
| var ASK_BACKEND_PROTOCOL_VERSION = 1; | ||
| var ASK_BACKEND_MAX_MESSAGES = 64; | ||
| var ASK_BACKEND_MAX_MESSAGE_CHARS = 16384; | ||
| var ASK_BACKEND_MAX_SOURCES = 8; | ||
| var SafeIdentifierSchema2 = z3.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/); | ||
| var SafeLabelSchema = z3.string().trim().min(1).max(256); | ||
| var SafeHrefSchema2 = z3.string().min(1).max(2048).refine((value) => { | ||
| if (/[\u0000-\u001F\u007F\\]/u.test(value) || value.startsWith("//")) return false; | ||
| if (!/^[A-Za-z][A-Za-z0-9+.-]*:/.test(value)) return /^\/(?!\/)/.test(value); | ||
| try { | ||
| const url = new URL(value); | ||
| return (url.protocol === "http:" || url.protocol === "https:") && url.username === "" && url.password === ""; | ||
| } catch { | ||
| return false; | ||
| } | ||
| }, "Source must use a safe relative, HTTP, or HTTPS URL."); | ||
| var AskBackendMessageSchema = z3.object({ | ||
| role: z3.enum(["user", "assistant"]), | ||
| content: z3.string().max(ASK_BACKEND_MAX_MESSAGE_CHARS) | ||
| }).strict().readonly(); | ||
| var DeterministicEscalationSchema = AnswerResponseSchema.refine( | ||
| (value) => value.outcome === "escalation", | ||
| "Deterministic context must be an escalation." | ||
| ); | ||
| var AskBackendRequestSchema = z3.object({ | ||
| protocol: z3.literal(ASK_BACKEND_PROTOCOL).optional(), | ||
| version: z3.literal(ASK_BACKEND_PROTOCOL_VERSION).optional(), | ||
| sessionId: SafeIdentifierSchema2.optional(), | ||
| messages: z3.array(AskBackendMessageSchema).min(1).max(ASK_BACKEND_MAX_MESSAGES).readonly(), | ||
| deterministic: DeterministicEscalationSchema.optional() | ||
| }).strict().readonly(); | ||
| var AskBackendSourceSchema = z3.object({ | ||
| id: SafeIdentifierSchema2, | ||
| title: SafeLabelSchema, | ||
| href: SafeHrefSchema2, | ||
| excerpt: z3.string().trim().min(1).max(4096) | ||
| }).strict().readonly(); | ||
| var AskBackendSiteConfigSchema = z3.object({ | ||
| protocol: z3.literal("agentskit.chat.backend-site"), | ||
| version: z3.literal(1), | ||
| siteId: SafeIdentifierSchema2, | ||
| assistant: z3.object({ | ||
| id: SafeIdentifierSchema2, | ||
| name: SafeLabelSchema, | ||
| suggestions: z3.array(SafeLabelSchema).max(8).readonly() | ||
| }).strict().readonly(), | ||
| corpus: z3.object({ | ||
| id: SafeIdentifierSchema2, | ||
| mode: z3.enum(["local", "federated"]) | ||
| }).strict().readonly(), | ||
| components: z3.array(SafeIdentifierSchema2).max(64).readonly(), | ||
| actions: z3.array(SafeIdentifierSchema2).max(64).readonly(), | ||
| limits: z3.object({ | ||
| requestTimeoutMs: z3.number().int().min(100).max(12e4), | ||
| retrievalTimeoutMs: z3.number().int().min(100).max(6e4), | ||
| generationTimeoutMs: z3.number().int().min(100).max(12e4), | ||
| maxSources: z3.number().int().min(1).max(ASK_BACKEND_MAX_SOURCES) | ||
| }).strict().readonly(), | ||
| persistence: z3.object({ mode: z3.enum(["required", "disabled"]) }).strict().readonly() | ||
| }).strict().readonly(); | ||
| var AskBackendUsageSchema = z3.object({ | ||
| inputTokens: z3.number().int().nonnegative().optional(), | ||
| outputTokens: z3.number().int().nonnegative().optional(), | ||
| totalTokens: z3.number().int().nonnegative().optional(), | ||
| costUsd: z3.number().nonnegative().finite().optional(), | ||
| model: z3.string().trim().min(1).max(256).optional() | ||
| }).strict().readonly(); | ||
| var AskBackendSessionRecordSchema = z3.object({ | ||
| revision: z3.number().int().nonnegative(), | ||
| messages: z3.array(AskBackendMessageSchema).max(ASK_BACKEND_MAX_MESSAGES).readonly() | ||
| }).strict().readonly(); | ||
| var AskBackendDiagnosticSchema = z3.object({ | ||
| code: z3.enum([ | ||
| "ASK_INVALID_REQUEST", | ||
| "ASK_UNAUTHORIZED", | ||
| "ASK_FORBIDDEN", | ||
| "ASK_RATE_LIMITED", | ||
| "ASK_TIMEOUT", | ||
| "ASK_CANCELLED", | ||
| "ASK_RETRIEVAL_FAILED", | ||
| "ASK_NO_GROUNDED_SOURCES", | ||
| "ASK_GENERATION_FAILED", | ||
| "ASK_PERSISTENCE_CONFLICT", | ||
| "ASK_INTERNAL" | ||
| ]), | ||
| message: z3.string().trim().min(1).max(4096), | ||
| retryable: z3.boolean() | ||
| }).strict().readonly(); | ||
| var AskBackendMetricNameSchema = z3.enum([ | ||
| "request.total_ms", | ||
| "stream.first_event_ms", | ||
| "stream.first_token_ms", | ||
| "stream.bytes", | ||
| "stream.events", | ||
| "stream.snapshots", | ||
| "deterministic.fallback", | ||
| "retrieval.total_ms", | ||
| "retrieval.documents", | ||
| "persistence.total_ms", | ||
| "cancellation.count", | ||
| "conflict.count", | ||
| "error.count", | ||
| "usage.input_tokens", | ||
| "usage.output_tokens", | ||
| "usage.total_tokens", | ||
| "cost.usd" | ||
| ]); | ||
| var AskBackendMetricSchema = z3.object({ | ||
| protocol: z3.literal("agentskit.chat.backend-metric"), | ||
| version: z3.literal(1), | ||
| name: AskBackendMetricNameSchema, | ||
| siteId: SafeIdentifierSchema2, | ||
| corpusId: SafeIdentifierSchema2, | ||
| requestId: SafeIdentifierSchema2, | ||
| value: z3.number().finite().nonnegative(), | ||
| unit: z3.enum(["ms", "bytes", "count", "tokens", "usd"]), | ||
| outcome: z3.enum(["ok", "rejected", "cancelled", "error"]), | ||
| emittedAt: z3.string().datetime({ offset: true }) | ||
| }).strict().readonly(); | ||
| // src/index.ts | ||
@@ -355,42 +485,42 @@ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value); | ||
| var ASSISTANT_CONTENT_MAX_RECORDS = 512; | ||
| var ComponentKeySchema = z3.string().regex(/^[a-z][a-z0-9-]{0,63}$/); | ||
| var ComponentFallbackSchema = z3.object({ | ||
| kind: z3.string().min(1).max(64), | ||
| summary: z3.string().min(1).max(4096) | ||
| var ComponentKeySchema = z4.string().regex(/^[a-z][a-z0-9-]{0,63}$/); | ||
| var ComponentFallbackSchema = z4.object({ | ||
| kind: z4.string().min(1).max(64), | ||
| summary: z4.string().min(1).max(4096) | ||
| }).readonly(); | ||
| var ComponentRenderFrameSchema = z3.object({ | ||
| protocol: z3.literal(COMPONENT_PROTOCOL), | ||
| version: z3.literal(COMPONENT_PROTOCOL_VERSION), | ||
| type: z3.literal("render"), | ||
| var ComponentRenderFrameSchema = z4.object({ | ||
| protocol: z4.literal(COMPONENT_PROTOCOL), | ||
| version: z4.literal(COMPONENT_PROTOCOL_VERSION), | ||
| type: z4.literal("render"), | ||
| componentKey: ComponentKeySchema, | ||
| instanceId: z3.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| props: z3.unknown().refine(isBoundedJsonValue), | ||
| instanceId: z4.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| props: z4.unknown().refine(isBoundedJsonValue), | ||
| fallback: ComponentFallbackSchema | ||
| }).readonly(); | ||
| var ComponentSelectionEventSchema = z3.object({ | ||
| protocol: z3.literal(COMPONENT_PROTOCOL), | ||
| version: z3.literal(COMPONENT_PROTOCOL_VERSION), | ||
| type: z3.literal("select"), | ||
| var ComponentSelectionEventSchema = z4.object({ | ||
| protocol: z4.literal(COMPONENT_PROTOCOL), | ||
| version: z4.literal(COMPONENT_PROTOCOL_VERSION), | ||
| type: z4.literal("select"), | ||
| componentKey: ComponentKeySchema, | ||
| instanceId: z3.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| choiceId: z3.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/) | ||
| instanceId: z4.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| choiceId: z4.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/) | ||
| }).readonly(); | ||
| var ComponentInteractionEventSchema = z3.object({ | ||
| protocol: z3.literal(COMPONENT_PROTOCOL), | ||
| version: z3.literal(COMPONENT_PROTOCOL_VERSION), | ||
| type: z3.literal("interact"), | ||
| var ComponentInteractionEventSchema = z4.object({ | ||
| protocol: z4.literal(COMPONENT_PROTOCOL), | ||
| version: z4.literal(COMPONENT_PROTOCOL_VERSION), | ||
| type: z4.literal("interact"), | ||
| componentKey: ComponentKeySchema, | ||
| instanceId: z3.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| event: z3.string().regex(/^[a-z][a-z0-9-]{0,63}$/), | ||
| value: z3.unknown().refine(isBoundedJsonValue).optional() | ||
| instanceId: z4.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| event: z4.string().regex(/^[a-z][a-z0-9-]{0,63}$/), | ||
| value: z4.unknown().refine(isBoundedJsonValue).optional() | ||
| }).readonly(); | ||
| var AssistantTextPartSchema = z3.object({ | ||
| kind: z3.literal("text"), | ||
| text: z3.string().min(1).max(16384) | ||
| var AssistantTextPartSchema = z4.object({ | ||
| kind: z4.literal("text"), | ||
| text: z4.string().min(1).max(16384) | ||
| }).readonly(); | ||
| var AssistantComponentPartSchema = z3.object({ | ||
| kind: z3.literal("component"), | ||
| var AssistantComponentPartSchema = z4.object({ | ||
| kind: z4.literal("component"), | ||
| frame: ComponentRenderFrameSchema | ||
| }).readonly(); | ||
| var AssistantContentPartSchema = z3.discriminatedUnion("kind", [AssistantTextPartSchema, AssistantComponentPartSchema]); | ||
| var AssistantContentPartSchema = z4.discriminatedUnion("kind", [AssistantTextPartSchema, AssistantComponentPartSchema]); | ||
| var createAssistantContentEncoder = () => { | ||
@@ -517,24 +647,24 @@ let started = false; | ||
| }); | ||
| var TokenUsageSchema = z3.object({ | ||
| promptTokens: z3.number().int().nonnegative(), | ||
| completionTokens: z3.number().int().nonnegative(), | ||
| totalTokens: z3.number().int().nonnegative() | ||
| var TokenUsageSchema = z4.object({ | ||
| promptTokens: z4.number().int().nonnegative(), | ||
| completionTokens: z4.number().int().nonnegative(), | ||
| totalTokens: z4.number().int().nonnegative() | ||
| }); | ||
| var TurnDiagnosticSchema = z3.object({ | ||
| version: z3.literal(1), | ||
| code: z3.string().regex(/^[A-Z][A-Z0-9_]*$/), | ||
| message: z3.string().min(1), | ||
| retryable: z3.boolean() | ||
| var TurnDiagnosticSchema = z4.object({ | ||
| version: z4.literal(1), | ||
| code: z4.string().regex(/^[A-Z][A-Z0-9_]*$/), | ||
| message: z4.string().min(1), | ||
| retryable: z4.boolean() | ||
| }); | ||
| var SafeIdentifierSchema2 = z3.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/); | ||
| var SafeIdentifierSchema3 = z4.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/); | ||
| var EnvelopeFields = { | ||
| protocol: z3.literal(TURN_PROTOCOL), | ||
| version: z3.literal(TURN_PROTOCOL_VERSION), | ||
| eventId: z3.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| sessionId: z3.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| turnId: z3.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| sequence: z3.number().int().nonnegative(), | ||
| emittedAt: z3.string().datetime({ offset: true }) | ||
| protocol: z4.literal(TURN_PROTOCOL), | ||
| version: z4.literal(TURN_PROTOCOL_VERSION), | ||
| eventId: z4.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| sessionId: z4.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| turnId: z4.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/), | ||
| sequence: z4.number().int().nonnegative(), | ||
| emittedAt: z4.string().datetime({ offset: true }) | ||
| }; | ||
| var MemoryMessagesSchema = z3.array(z3.unknown()).transform((messages, context) => { | ||
| var MemoryMessagesSchema = z4.array(z4.unknown()).transform((messages, context) => { | ||
| try { | ||
@@ -544,22 +674,22 @@ return validateMemoryRecord({ version: 1, messages }).messages; | ||
| context.addIssue({ code: "custom", message: "Messages are not a valid AgentsKit memory record." }); | ||
| return z3.NEVER; | ||
| return z4.NEVER; | ||
| } | ||
| }); | ||
| var TurnLineageSchema = z3.discriminatedUnion("operation", [ | ||
| z3.object({ operation: z3.literal("submit") }), | ||
| z3.object({ operation: z3.enum(["retry", "edit", "regenerate"]), parentTurnId: SafeIdentifierSchema2, sourceMessageId: SafeIdentifierSchema2 }) | ||
| var TurnLineageSchema = z4.discriminatedUnion("operation", [ | ||
| z4.object({ operation: z4.literal("submit") }), | ||
| z4.object({ operation: z4.enum(["retry", "edit", "regenerate"]), parentTurnId: SafeIdentifierSchema3, sourceMessageId: SafeIdentifierSchema3 }) | ||
| ]); | ||
| var SubmitEventSchema = z3.object({ | ||
| var SubmitEventSchema = z4.object({ | ||
| ...EnvelopeFields, | ||
| event: z3.literal("client.turn.submit"), | ||
| payload: z3.object({ | ||
| input: z3.string().min(1).refine((value) => value.trim().length > 0) | ||
| event: z4.literal("client.turn.submit"), | ||
| payload: z4.object({ | ||
| input: z4.string().min(1).refine((value) => value.trim().length > 0) | ||
| }) | ||
| }); | ||
| var SnapshotEventSchema = z3.object({ | ||
| var SnapshotEventSchema = z4.object({ | ||
| ...EnvelopeFields, | ||
| event: z3.literal("server.turn.snapshot"), | ||
| payload: z3.object({ | ||
| event: z4.literal("server.turn.snapshot"), | ||
| payload: z4.object({ | ||
| messages: MemoryMessagesSchema, | ||
| status: z3.enum(["idle", "streaming", "complete", "error"]), | ||
| status: z4.enum(["idle", "streaming", "complete", "error"]), | ||
| usage: TokenUsageSchema, | ||
@@ -570,8 +700,8 @@ error: TurnDiagnosticSchema.optional(), | ||
| }); | ||
| var DiagnosticEventSchema = z3.object({ | ||
| var DiagnosticEventSchema = z4.object({ | ||
| ...EnvelopeFields, | ||
| event: z3.literal("server.turn.diagnostic"), | ||
| event: z4.literal("server.turn.diagnostic"), | ||
| payload: TurnDiagnosticSchema | ||
| }); | ||
| var TurnEventSchema = z3.discriminatedUnion("event", [ | ||
| var TurnEventSchema = z4.discriminatedUnion("event", [ | ||
| SubmitEventSchema, | ||
@@ -604,3 +734,3 @@ SnapshotEventSchema, | ||
| var createTurnSnapshotCursor = (sessionId) => { | ||
| const expectedSessionId = SafeIdentifierSchema2.parse(sessionId); | ||
| const expectedSessionId = SafeIdentifierSchema3.parse(sessionId); | ||
| let snapshot; | ||
@@ -623,3 +753,3 @@ return { | ||
| if (!isRecord(input)) return void 0; | ||
| const parsed = SafeIdentifierSchema2.safeParse(input.eventId); | ||
| const parsed = SafeIdentifierSchema3.safeParse(input.eventId); | ||
| return parsed.success ? parsed.data : void 0; | ||
@@ -679,18 +809,18 @@ } catch { | ||
| var SESSION_PROTOCOL_VERSION = 1; | ||
| var SessionDecisionSchema = z3.object({ | ||
| messageId: SafeIdentifierSchema2, | ||
| input: z3.string().max(16384), | ||
| routeId: SafeIdentifierSchema2, | ||
| kind: z3.enum(["deterministic", "repaired", "fallback"]), | ||
| content: z3.string().max(65536), | ||
| fromState: z3.string().min(1).max(128), | ||
| toState: z3.string().min(1).max(128) | ||
| var SessionDecisionSchema = z4.object({ | ||
| messageId: SafeIdentifierSchema3, | ||
| input: z4.string().max(16384), | ||
| routeId: SafeIdentifierSchema3, | ||
| kind: z4.enum(["deterministic", "repaired", "fallback"]), | ||
| content: z4.string().max(65536), | ||
| fromState: z4.string().min(1).max(128), | ||
| toState: z4.string().min(1).max(128) | ||
| }).readonly(); | ||
| var SessionConfirmationSchema = z3.object({ | ||
| token: SafeIdentifierSchema2, | ||
| action: SafeIdentifierSchema2, | ||
| input: z3.record(z3.string(), z3.unknown()).refine(isBoundedJsonValue), | ||
| toolCallId: SafeIdentifierSchema2, | ||
| expiresAt: z3.number().int().nonnegative(), | ||
| status: z3.enum(["pending", "approving", "rejecting", "expiring", "approved", "rejected", "expired"]) | ||
| var SessionConfirmationSchema = z4.object({ | ||
| token: SafeIdentifierSchema3, | ||
| action: SafeIdentifierSchema3, | ||
| input: z4.record(z4.string(), z4.unknown()).refine(isBoundedJsonValue), | ||
| toolCallId: SafeIdentifierSchema3, | ||
| expiresAt: z4.number().int().nonnegative(), | ||
| status: z4.enum(["pending", "approving", "rejecting", "expiring", "approved", "rejected", "expired"]) | ||
| }).readonly(); | ||
@@ -705,19 +835,19 @@ var uniqueBy = (items, key, context, path) => { | ||
| }; | ||
| var SessionDecisionsSchema = z3.array(SessionDecisionSchema).max(1e3).superRefine((items, context) => uniqueBy(items, (item) => item.messageId, context, "messageId")); | ||
| var SessionConfirmationsSchema = z3.array(SessionConfirmationSchema).max(1e3).superRefine((items, context) => { | ||
| var SessionDecisionsSchema = z4.array(SessionDecisionSchema).max(1e3).superRefine((items, context) => uniqueBy(items, (item) => item.messageId, context, "messageId")); | ||
| var SessionConfirmationsSchema = z4.array(SessionConfirmationSchema).max(1e3).superRefine((items, context) => { | ||
| uniqueBy(items, (item) => item.token, context, "token"); | ||
| uniqueBy(items, (item) => item.toolCallId, context, "toolCallId"); | ||
| }); | ||
| var SessionSnapshotObjectSchema = z3.object({ | ||
| protocol: z3.literal(SESSION_PROTOCOL), | ||
| version: z3.literal(SESSION_PROTOCOL_VERSION), | ||
| sessionId: SafeIdentifierSchema2, | ||
| definitionId: SafeIdentifierSchema2, | ||
| definitionRevision: z3.number().int().positive(), | ||
| updatedAt: z3.string().datetime({ offset: true }), | ||
| cursor: z3.number().int().nonnegative(), | ||
| activeTurn: z3.object({ turnId: SafeIdentifierSchema2, expiresAt: z3.number().int().nonnegative() }).readonly().optional(), | ||
| terminalTurns: z3.array(z3.object({ turnId: SafeIdentifierSchema2, outcome: z3.enum(["completed", "indeterminate"]) }).readonly()).max(64).superRefine((items, context) => uniqueBy(items, (item) => item.turnId, context, "turnId")).readonly().optional(), | ||
| conversation: z3.object({ | ||
| state: z3.string().min(1).max(128), | ||
| var SessionSnapshotObjectSchema = z4.object({ | ||
| protocol: z4.literal(SESSION_PROTOCOL), | ||
| version: z4.literal(SESSION_PROTOCOL_VERSION), | ||
| sessionId: SafeIdentifierSchema3, | ||
| definitionId: SafeIdentifierSchema3, | ||
| definitionRevision: z4.number().int().positive(), | ||
| updatedAt: z4.string().datetime({ offset: true }), | ||
| cursor: z4.number().int().nonnegative(), | ||
| activeTurn: z4.object({ turnId: SafeIdentifierSchema3, expiresAt: z4.number().int().nonnegative() }).readonly().optional(), | ||
| terminalTurns: z4.array(z4.object({ turnId: SafeIdentifierSchema3, outcome: z4.enum(["completed", "indeterminate"]) }).readonly()).max(64).superRefine((items, context) => uniqueBy(items, (item) => item.turnId, context, "turnId")).readonly().optional(), | ||
| conversation: z4.object({ | ||
| state: z4.string().min(1).max(128), | ||
| decisions: SessionDecisionsSchema | ||
@@ -728,3 +858,3 @@ }).readonly().optional(), | ||
| var SessionSnapshotSchema = SessionSnapshotObjectSchema.readonly(); | ||
| var LegacySessionSnapshotSchema = SessionSnapshotObjectSchema.omit({ protocol: true, version: true }).extend({ version: z3.literal(0) }); | ||
| var LegacySessionSnapshotSchema = SessionSnapshotObjectSchema.omit({ protocol: true, version: true }).extend({ version: z4.literal(0) }); | ||
| var decodeSessionSnapshot = (input) => { | ||
@@ -756,2 +886,7 @@ let candidate = input; | ||
| ANSWER_PROTOCOL_VERSION, | ||
| ASK_BACKEND_MAX_MESSAGES, | ||
| ASK_BACKEND_MAX_MESSAGE_CHARS, | ||
| ASK_BACKEND_MAX_SOURCES, | ||
| ASK_BACKEND_PROTOCOL, | ||
| ASK_BACKEND_PROTOCOL_VERSION, | ||
| ASK_EVENT_MAX_BYTES, | ||
@@ -769,2 +904,11 @@ ASK_EVENT_MAX_RECORDS, | ||
| AnswerSuggestionSchema, | ||
| AskBackendDiagnosticSchema, | ||
| AskBackendMessageSchema, | ||
| AskBackendMetricNameSchema, | ||
| AskBackendMetricSchema, | ||
| AskBackendRequestSchema, | ||
| AskBackendSessionRecordSchema, | ||
| AskBackendSiteConfigSchema, | ||
| AskBackendSourceSchema, | ||
| AskBackendUsageSchema, | ||
| AskEventSchema, | ||
@@ -771,0 +915,0 @@ AssistantComponentPartSchema, |
+1
-1
| { | ||
| "name": "@agentskit/chat-protocol", | ||
| "version": "0.1.0", | ||
| "version": "0.2.0", | ||
| "description": "Versioned turn protocol for AgentsKit Chat.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
+5
-0
@@ -16,2 +16,7 @@ # @agentskit/chat-protocol | ||
| The package also validates the additive Ask request, trusted backend site | ||
| configuration, grounded sources, CAS session records, typed diagnostics, | ||
| usage, and privacy-safe metrics used by `createAskServiceHandler`. See the | ||
| [backend guide](../../docs/backend.md). | ||
| For one canonical assistant message containing both streamed prose and registered application components, use `createAssistantContentEncoder` and decode with `decodeAssistantContent`. Every text chunk must pass through the encoder; raw model output must never be appended to the envelope. See the [v1 protocol guide](../../docs/protocol/v1.md#ordered-assistant-content). |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
274246
19.37%4746
18%22
29.41%