veryfront 0.1.236 → 0.1.240

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/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.236",
3
+ "version": "0.1.240",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "workspace": [
@@ -0,0 +1,37 @@
1
+ import { type ConversationAgentRunUsage, type ConversationRunProjection } from "./durable.js";
2
+ import { type InvokeAgentChildRunProgressEvent, type InvokeAgentChildRunProgressInput } from "./invoke-agent-child-runs.js";
3
+ import type { HostedChildLifecycleAdapter } from "./hosted-child-lifecycle.js";
4
+ import type { HostedLifecycleAdapter, HostedLifecycleTerminalState } from "./hosted-lifecycle.js";
5
+ export interface ConversationHostedLifecycleFinalizeInput {
6
+ model: string;
7
+ provider: string;
8
+ usage?: ConversationAgentRunUsage;
9
+ terminalErrorCode?: string | null;
10
+ terminalErrorMessage?: string | null;
11
+ }
12
+ export interface CreateConversationHostedLifecycleAdapterOptions<TChunk> {
13
+ authToken: string;
14
+ apiUrl: string;
15
+ startRun: (input: {
16
+ abortSignal: AbortSignal;
17
+ }) => Promise<ConversationRunProjection> | ConversationRunProjection;
18
+ mapChunkToEvents?: (chunk: TChunk, run: ConversationRunProjection) => Promise<readonly unknown[] | unknown[]> | readonly unknown[] | unknown[];
19
+ resolveFinalizeInput: (input: {
20
+ run: ConversationRunProjection;
21
+ terminalState: HostedLifecycleTerminalState;
22
+ }) => Promise<ConversationHostedLifecycleFinalizeInput> | ConversationHostedLifecycleFinalizeInput;
23
+ }
24
+ export declare function createConversationHostedLifecycleAdapter<TChunk>(options: CreateConversationHostedLifecycleAdapterOptions<TChunk>): HostedLifecycleAdapter<ConversationRunProjection, TChunk>;
25
+ export interface ConversationChildLifecycleContext {
26
+ authToken: string;
27
+ apiUrl: string;
28
+ parentConversationId: string;
29
+ parentRunId: string;
30
+ projectId?: string | null;
31
+ publishParentRunEvents?: (events: InvokeAgentChildRunProgressEvent[]) => Promise<void> | void;
32
+ progress: Omit<InvokeAgentChildRunProgressInput, "status">;
33
+ model: string;
34
+ provider: string;
35
+ }
36
+ export declare function createConversationChildLifecycleAdapter(ctx: ConversationChildLifecycleContext): HostedChildLifecycleAdapter;
37
+ //# sourceMappingURL=conversation-hosted-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-hosted-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/src/agent/conversation-hosted-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAE/B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,gCAAgC,EACrC,KAAK,gCAAgC,EAEtC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,2BAA2B,EAE5B,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAElG,MAAM,WAAW,wCAAwC;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,yBAAyB,CAAC;IAClC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,+CAA+C,CAAC,MAAM;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,CACR,KAAK,EAAE;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE,KAChC,OAAO,CAAC,yBAAyB,CAAC,GAAG,yBAAyB,CAAC;IACpE,gBAAgB,CAAC,EAAE,CACjB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,yBAAyB,KAC3B,OAAO,CAAC,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,GAAG,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;IAC9E,oBAAoB,EAAE,CAAC,KAAK,EAAE;QAC5B,GAAG,EAAE,yBAAyB,CAAC;QAC/B,aAAa,EAAE,4BAA4B,CAAC;KAC7C,KACG,OAAO,CAAC,wCAAwC,CAAC,GACjD,wCAAwC,CAAC;CAC9C;AAED,wBAAgB,wCAAwC,CAAC,MAAM,EAC7D,OAAO,EAAE,+CAA+C,CAAC,MAAM,CAAC,GAC/D,sBAAsB,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAuD3D;AAED,MAAM,WAAW,iCAAiC;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB,EAAE,MAAM,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE,gCAAgC,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC9F,QAAQ,EAAE,IAAI,CAAC,gCAAgC,EAAE,QAAQ,CAAC,CAAC;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAkCD,wBAAgB,uCAAuC,CACrD,GAAG,EAAE,iCAAiC,GACrC,2BAA2B,CAkD7B"}
@@ -0,0 +1,131 @@
1
+ import { appendConversationRunEvents, finalizeConversationAgentRun, } from "./durable.js";
2
+ import { publishInvokeAgentChildRunProgress, } from "./invoke-agent-child-runs.js";
3
+ export function createConversationHostedLifecycleAdapter(options) {
4
+ return {
5
+ startRun: options.startRun,
6
+ appendEvents: options.mapChunkToEvents
7
+ ? async (run, chunk) => {
8
+ const events = [...await options.mapChunkToEvents(chunk, run)];
9
+ if (events.length === 0) {
10
+ return;
11
+ }
12
+ const appended = await appendConversationRunEvents({
13
+ authToken: options.authToken,
14
+ apiUrl: options.apiUrl,
15
+ conversationId: run.conversationId,
16
+ runId: run.runId,
17
+ expectedPreviousEventId: run.latestEventId,
18
+ expectedPreviousExternalEventSequence: run.latestExternalEventSequence,
19
+ events,
20
+ });
21
+ run.latestEventId = appended.latestEventId;
22
+ run.latestExternalEventSequence = appended.latestExternalEventSequence;
23
+ }
24
+ : undefined,
25
+ finalizeRun: async (run, terminalState) => {
26
+ const finalizeInput = await options.resolveFinalizeInput({ run, terminalState });
27
+ await finalizeConversationAgentRun({
28
+ authToken: options.authToken,
29
+ apiUrl: options.apiUrl,
30
+ conversationId: run.conversationId,
31
+ runId: run.runId,
32
+ status: terminalState.status,
33
+ model: finalizeInput.model,
34
+ provider: finalizeInput.provider,
35
+ usage: finalizeInput.usage,
36
+ terminalErrorCode: finalizeInput.terminalErrorCode,
37
+ terminalErrorMessage: finalizeInput.terminalErrorMessage,
38
+ });
39
+ },
40
+ cancelRun: async (run, terminalState) => {
41
+ const finalizeInput = await options.resolveFinalizeInput({ run, terminalState });
42
+ await finalizeConversationAgentRun({
43
+ authToken: options.authToken,
44
+ apiUrl: options.apiUrl,
45
+ conversationId: run.conversationId,
46
+ runId: run.runId,
47
+ status: "cancelled",
48
+ model: finalizeInput.model,
49
+ provider: finalizeInput.provider,
50
+ usage: finalizeInput.usage,
51
+ terminalErrorCode: finalizeInput.terminalErrorCode,
52
+ terminalErrorMessage: finalizeInput.terminalErrorMessage,
53
+ });
54
+ },
55
+ };
56
+ }
57
+ function toConversationChildUsage(usage) {
58
+ if (!usage) {
59
+ return undefined;
60
+ }
61
+ const inputTokens = usage.inputTokens ?? 0;
62
+ const outputTokens = usage.outputTokens ?? 0;
63
+ return {
64
+ inputTokens,
65
+ outputTokens,
66
+ totalTokens: usage.totalTokens ?? inputTokens + outputTokens,
67
+ };
68
+ }
69
+ async function publishConversationChildProgress(ctx, status) {
70
+ await publishInvokeAgentChildRunProgress({
71
+ authToken: ctx.authToken,
72
+ apiUrl: ctx.apiUrl,
73
+ conversationId: ctx.parentConversationId,
74
+ runId: ctx.parentRunId,
75
+ ...(ctx.projectId !== undefined ? { projectId: ctx.projectId } : {}),
76
+ ...ctx.progress,
77
+ status,
78
+ ...(ctx.publishParentRunEvents ? { publishParentRunEvents: ctx.publishParentRunEvents } : {}),
79
+ });
80
+ }
81
+ export function createConversationChildLifecycleAdapter(ctx) {
82
+ return {
83
+ pending: () => publishConversationChildProgress(ctx, "pending"),
84
+ running: () => publishConversationChildProgress(ctx, "running"),
85
+ completed: async (terminalState) => {
86
+ await finalizeConversationAgentRun({
87
+ authToken: ctx.authToken,
88
+ apiUrl: ctx.apiUrl,
89
+ conversationId: ctx.progress.childConversationId,
90
+ runId: ctx.progress.childRunId,
91
+ status: "completed",
92
+ model: ctx.model,
93
+ provider: ctx.provider,
94
+ usage: toConversationChildUsage(terminalState.usage),
95
+ terminalErrorCode: null,
96
+ terminalErrorMessage: null,
97
+ });
98
+ await publishConversationChildProgress(ctx, "completed");
99
+ },
100
+ failed: async (terminalState) => {
101
+ await finalizeConversationAgentRun({
102
+ authToken: ctx.authToken,
103
+ apiUrl: ctx.apiUrl,
104
+ conversationId: ctx.progress.childConversationId,
105
+ runId: ctx.progress.childRunId,
106
+ status: "failed",
107
+ model: ctx.model,
108
+ provider: ctx.provider,
109
+ usage: toConversationChildUsage(terminalState.usage),
110
+ terminalErrorCode: terminalState.terminalErrorCode ?? "FAILED",
111
+ terminalErrorMessage: terminalState.terminalErrorMessage ?? "Unknown error",
112
+ });
113
+ await publishConversationChildProgress(ctx, "failed");
114
+ },
115
+ cancelled: async (terminalState) => {
116
+ await finalizeConversationAgentRun({
117
+ authToken: ctx.authToken,
118
+ apiUrl: ctx.apiUrl,
119
+ conversationId: ctx.progress.childConversationId,
120
+ runId: ctx.progress.childRunId,
121
+ status: "cancelled",
122
+ model: ctx.model,
123
+ provider: ctx.provider,
124
+ usage: toConversationChildUsage(terminalState.usage),
125
+ terminalErrorCode: terminalState.terminalErrorCode ?? "CANCELLED",
126
+ terminalErrorMessage: terminalState.terminalErrorMessage ?? "Child run cancelled",
127
+ });
128
+ await publishConversationChildProgress(ctx, "cancelled");
129
+ },
130
+ };
131
+ }
@@ -0,0 +1,26 @@
1
+ import type { ConversationRunProjection } from "./durable.js";
2
+ export interface ConversationRunContext {
3
+ run: ConversationRunProjection | null;
4
+ effectiveParentRunId?: string;
5
+ effectiveParentMessageId?: string;
6
+ publishParentRunEvents?: (events: unknown[]) => Promise<void> | void;
7
+ }
8
+ export declare function createConversationRunContext(input: {
9
+ run: ConversationRunProjection | null;
10
+ parentRunId?: string;
11
+ parentMessageId?: string;
12
+ publishParentRunEvents?: ((events: unknown[]) => Promise<void> | void) | undefined;
13
+ }): {
14
+ run: {
15
+ runId: string;
16
+ conversationId: string;
17
+ messageId: string;
18
+ latestEventId: number;
19
+ latestExternalEventSequence: number;
20
+ status: "failed" | "pending" | "completed" | "running" | "cancelled" | "waiting_for_tool";
21
+ } | null;
22
+ effectiveParentRunId: string | undefined;
23
+ effectiveParentMessageId: string | undefined;
24
+ publishParentRunEvents: ((events: unknown[]) => Promise<void> | void) | undefined;
25
+ };
26
+ //# sourceMappingURL=conversation-run-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-run-context.d.ts","sourceRoot":"","sources":["../../../src/src/agent/conversation-run-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,yBAAyB,GAAG,IAAI,CAAC;IACtC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACtE;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE;IAClD,GAAG,EAAE,yBAAyB,GAAG,IAAI,CAAC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sBAAsB,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;CACpF;;;;;;;;;;;sCADoC,OAAO,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;EAQtE"}
@@ -0,0 +1,8 @@
1
+ export function createConversationRunContext(input) {
2
+ return {
3
+ run: input.run,
4
+ effectiveParentRunId: input.run?.runId ?? input.parentRunId,
5
+ effectiveParentMessageId: input.run?.messageId ?? input.parentMessageId,
6
+ publishParentRunEvents: input.publishParentRunEvents,
7
+ };
8
+ }
@@ -89,7 +89,9 @@ export { type AgUiRuntimeContextItem, AgUiRuntimeContextItemSchema, type AgUiRun
89
89
  export { normalizeAgUiRuntimeMessages } from "./ag-ui-runtime-support.js";
90
90
  export { type AgUiBrowserEncodedEvent, type AgUiBrowserEncoderState, type AgUiBrowserRunFinishedMetadata, type AgUiRuntimeStreamEvent, buildAgUiBrowserFinalizeResponse, createAgUiBrowserEncoderState, finalizeAgUiBrowserEvents, mapRuntimeStreamEventToAgUiBrowserEvents, } from "./ag-ui-browser-encoder.js";
91
91
  export { type AgUiBrowserResponseEncoder, type AgUiBrowserResponseExecution, type AgUiBrowserResponseRequestState, createAgUiBrowserResponseStream, type CreateAgUiBrowserResponseStreamInput, } from "./ag-ui-browser-response-stream.js";
92
+ export { type ConversationRunContext, createConversationRunContext, } from "./conversation-run-context.js";
92
93
  export { bootstrapConversationAgentRun, type BootstrapConversationAgentRunResult, type ConversationMessageRecord, ConversationMessageRecordSchema, type ConversationRecord, ConversationRecordSchema, createConversationMessage, createConversationRecord, ensureConversationProjectLink, fetchConversationRecord, } from "./conversation-bootstrap.js";
94
+ export { type ConversationChildLifecycleContext, type ConversationHostedLifecycleFinalizeInput, createConversationChildLifecycleAdapter, createConversationHostedLifecycleAdapter, type CreateConversationHostedLifecycleAdapterOptions, } from "./conversation-hosted-lifecycle.js";
93
95
  export { type ActiveConversationRunStatus, appendConversationRunEvents, AppendConversationRunEventsError, type AppendConversationRunEventsResponse, AppendConversationRunEventsResponseSchema, CompleteConversationRunResponseSchema, type ConversationAgentRunUsage, type ConversationRunProjection, ConversationRunProjectionSchema, ConversationRunStatusSchema, type ConversationRunTargets, ConversationRunTargetsSchema, ConversationRunTerminalStateError, createConversationAgentRun, finalizeConversationAgentRun, getConversationRun, isActiveConversationRunStatus, isCursorMismatchConversationRunAppendError, isIgnorableConversationRunAppendError, monitorConversationRunStatus, parseAppendConversationRunEventsErrorBody, resolveConversationRunTargets, type TerminalConversationRunStatus, } from "./durable.js";
94
96
  export { buildInvokeAgentChildRunLifecycleCustomEvent, buildInvokeAgentChildRunProgressEvents, buildInvokeAgentChildRunStateDelta, type InvokeAgentChildRunLifecycleCustomEvent, InvokeAgentChildRunLifecycleCustomEventSchema, type InvokeAgentChildRunLifecycleValue, InvokeAgentChildRunLifecycleValueSchema, type InvokeAgentChildRunProgressEvent, type InvokeAgentChildRunProgressInput, type InvokeAgentChildRunStateDelta, InvokeAgentChildRunStateDeltaSchema, publishInvokeAgentChildRunProgress, } from "./invoke-agent-child-runs.js";
95
97
  export { type HostedChildLifecycleAdapter, type HostedChildLifecycleRunnerOptions, type HostedChildLifecycleRunResult, type HostedChildLifecycleTerminalState, runHostedChildLifecycle, } from "./hosted-child-lifecycle.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,OAAO,yBAAyB,CAAC;AAGjC,YAAY,EACV,KAAK,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,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tB,KAAK,wBAAwB,EAC7B,8BAA8B,EAC9B,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,4BAA4B,EAC5B,iBAAiB,EACjB,KAAK,wBAAwB,GAC9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,OAAO,yBAAyB,CAAC;AAGjC,YAAY,EACV,KAAK,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,OAAO,IAAI,YAAY,EACvB,WAAW,EACX,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,E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BAA4B,EAC5B,iBAAiB,EACjB,KAAK,wBAAwB,GAC9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC"}
@@ -88,7 +88,9 @@ export { AgUiRuntimeContextItemSchema, AgUiRuntimeInjectedToolSchema, AgUiRuntim
88
88
  export { normalizeAgUiRuntimeMessages } from "./ag-ui-runtime-support.js";
89
89
  export { buildAgUiBrowserFinalizeResponse, createAgUiBrowserEncoderState, finalizeAgUiBrowserEvents, mapRuntimeStreamEventToAgUiBrowserEvents, } from "./ag-ui-browser-encoder.js";
90
90
  export { createAgUiBrowserResponseStream, } from "./ag-ui-browser-response-stream.js";
91
+ export { createConversationRunContext, } from "./conversation-run-context.js";
91
92
  export { bootstrapConversationAgentRun, ConversationMessageRecordSchema, ConversationRecordSchema, createConversationMessage, createConversationRecord, ensureConversationProjectLink, fetchConversationRecord, } from "./conversation-bootstrap.js";
93
+ export { createConversationChildLifecycleAdapter, createConversationHostedLifecycleAdapter, } from "./conversation-hosted-lifecycle.js";
92
94
  export { appendConversationRunEvents, AppendConversationRunEventsError, AppendConversationRunEventsResponseSchema, CompleteConversationRunResponseSchema, ConversationRunProjectionSchema, ConversationRunStatusSchema, ConversationRunTargetsSchema, ConversationRunTerminalStateError, createConversationAgentRun, finalizeConversationAgentRun, getConversationRun, isActiveConversationRunStatus, isCursorMismatchConversationRunAppendError, isIgnorableConversationRunAppendError, monitorConversationRunStatus, parseAppendConversationRunEventsErrorBody, resolveConversationRunTargets, } from "./durable.js";
93
95
  export { buildInvokeAgentChildRunLifecycleCustomEvent, buildInvokeAgentChildRunProgressEvents, buildInvokeAgentChildRunStateDelta, InvokeAgentChildRunLifecycleCustomEventSchema, InvokeAgentChildRunLifecycleValueSchema, InvokeAgentChildRunStateDeltaSchema, publishInvokeAgentChildRunProgress, } from "./invoke-agent-child-runs.js";
94
96
  export { runHostedChildLifecycle, } from "./hosted-child-lifecycle.js";
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.1.236";
1
+ export declare const VERSION = "0.1.240";
2
2
  //# sourceMappingURL=version-constant.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
- export const VERSION = "0.1.236";
3
+ export const VERSION = "0.1.240";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.1.236",
3
+ "version": "0.1.240",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",
package/src/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.236",
3
+ "version": "0.1.240",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "workspace": [
@@ -0,0 +1,199 @@
1
+ import {
2
+ appendConversationRunEvents,
3
+ type ConversationAgentRunUsage,
4
+ type ConversationRunProjection,
5
+ finalizeConversationAgentRun,
6
+ } from "./durable.js";
7
+ import {
8
+ type InvokeAgentChildRunProgressEvent,
9
+ type InvokeAgentChildRunProgressInput,
10
+ publishInvokeAgentChildRunProgress,
11
+ } from "./invoke-agent-child-runs.js";
12
+ import type {
13
+ HostedChildLifecycleAdapter,
14
+ HostedChildLifecycleTerminalState,
15
+ } from "./hosted-child-lifecycle.js";
16
+ import type { HostedLifecycleAdapter, HostedLifecycleTerminalState } from "./hosted-lifecycle.js";
17
+
18
+ export interface ConversationHostedLifecycleFinalizeInput {
19
+ model: string;
20
+ provider: string;
21
+ usage?: ConversationAgentRunUsage;
22
+ terminalErrorCode?: string | null;
23
+ terminalErrorMessage?: string | null;
24
+ }
25
+
26
+ export interface CreateConversationHostedLifecycleAdapterOptions<TChunk> {
27
+ authToken: string;
28
+ apiUrl: string;
29
+ startRun: (
30
+ input: { abortSignal: AbortSignal },
31
+ ) => Promise<ConversationRunProjection> | ConversationRunProjection;
32
+ mapChunkToEvents?: (
33
+ chunk: TChunk,
34
+ run: ConversationRunProjection,
35
+ ) => Promise<readonly unknown[] | unknown[]> | readonly unknown[] | unknown[];
36
+ resolveFinalizeInput: (input: {
37
+ run: ConversationRunProjection;
38
+ terminalState: HostedLifecycleTerminalState;
39
+ }) =>
40
+ | Promise<ConversationHostedLifecycleFinalizeInput>
41
+ | ConversationHostedLifecycleFinalizeInput;
42
+ }
43
+
44
+ export function createConversationHostedLifecycleAdapter<TChunk>(
45
+ options: CreateConversationHostedLifecycleAdapterOptions<TChunk>,
46
+ ): HostedLifecycleAdapter<ConversationRunProjection, TChunk> {
47
+ return {
48
+ startRun: options.startRun,
49
+ appendEvents: options.mapChunkToEvents
50
+ ? async (run, chunk) => {
51
+ const events = [...await options.mapChunkToEvents!(chunk, run)];
52
+ if (events.length === 0) {
53
+ return;
54
+ }
55
+
56
+ const appended = await appendConversationRunEvents({
57
+ authToken: options.authToken,
58
+ apiUrl: options.apiUrl,
59
+ conversationId: run.conversationId,
60
+ runId: run.runId,
61
+ expectedPreviousEventId: run.latestEventId,
62
+ expectedPreviousExternalEventSequence: run.latestExternalEventSequence,
63
+ events,
64
+ });
65
+
66
+ run.latestEventId = appended.latestEventId;
67
+ run.latestExternalEventSequence = appended.latestExternalEventSequence;
68
+ }
69
+ : undefined,
70
+ finalizeRun: async (run, terminalState) => {
71
+ const finalizeInput = await options.resolveFinalizeInput({ run, terminalState });
72
+ await finalizeConversationAgentRun({
73
+ authToken: options.authToken,
74
+ apiUrl: options.apiUrl,
75
+ conversationId: run.conversationId,
76
+ runId: run.runId,
77
+ status: terminalState.status,
78
+ model: finalizeInput.model,
79
+ provider: finalizeInput.provider,
80
+ usage: finalizeInput.usage,
81
+ terminalErrorCode: finalizeInput.terminalErrorCode,
82
+ terminalErrorMessage: finalizeInput.terminalErrorMessage,
83
+ });
84
+ },
85
+ cancelRun: async (run, terminalState) => {
86
+ const finalizeInput = await options.resolveFinalizeInput({ run, terminalState });
87
+ await finalizeConversationAgentRun({
88
+ authToken: options.authToken,
89
+ apiUrl: options.apiUrl,
90
+ conversationId: run.conversationId,
91
+ runId: run.runId,
92
+ status: "cancelled",
93
+ model: finalizeInput.model,
94
+ provider: finalizeInput.provider,
95
+ usage: finalizeInput.usage,
96
+ terminalErrorCode: finalizeInput.terminalErrorCode,
97
+ terminalErrorMessage: finalizeInput.terminalErrorMessage,
98
+ });
99
+ },
100
+ };
101
+ }
102
+
103
+ export interface ConversationChildLifecycleContext {
104
+ authToken: string;
105
+ apiUrl: string;
106
+ parentConversationId: string;
107
+ parentRunId: string;
108
+ projectId?: string | null;
109
+ publishParentRunEvents?: (events: InvokeAgentChildRunProgressEvent[]) => Promise<void> | void;
110
+ progress: Omit<InvokeAgentChildRunProgressInput, "status">;
111
+ model: string;
112
+ provider: string;
113
+ }
114
+
115
+ function toConversationChildUsage(
116
+ usage: HostedChildLifecycleTerminalState["usage"],
117
+ ): ConversationAgentRunUsage | undefined {
118
+ if (!usage) {
119
+ return undefined;
120
+ }
121
+
122
+ const inputTokens = usage.inputTokens ?? 0;
123
+ const outputTokens = usage.outputTokens ?? 0;
124
+ return {
125
+ inputTokens,
126
+ outputTokens,
127
+ totalTokens: usage.totalTokens ?? inputTokens + outputTokens,
128
+ };
129
+ }
130
+
131
+ async function publishConversationChildProgress(
132
+ ctx: ConversationChildLifecycleContext,
133
+ status: InvokeAgentChildRunProgressInput["status"],
134
+ ): Promise<void> {
135
+ await publishInvokeAgentChildRunProgress({
136
+ authToken: ctx.authToken,
137
+ apiUrl: ctx.apiUrl,
138
+ conversationId: ctx.parentConversationId,
139
+ runId: ctx.parentRunId,
140
+ ...(ctx.projectId !== undefined ? { projectId: ctx.projectId } : {}),
141
+ ...ctx.progress,
142
+ status,
143
+ ...(ctx.publishParentRunEvents ? { publishParentRunEvents: ctx.publishParentRunEvents } : {}),
144
+ });
145
+ }
146
+
147
+ export function createConversationChildLifecycleAdapter(
148
+ ctx: ConversationChildLifecycleContext,
149
+ ): HostedChildLifecycleAdapter {
150
+ return {
151
+ pending: () => publishConversationChildProgress(ctx, "pending"),
152
+ running: () => publishConversationChildProgress(ctx, "running"),
153
+ completed: async (terminalState) => {
154
+ await finalizeConversationAgentRun({
155
+ authToken: ctx.authToken,
156
+ apiUrl: ctx.apiUrl,
157
+ conversationId: ctx.progress.childConversationId,
158
+ runId: ctx.progress.childRunId,
159
+ status: "completed",
160
+ model: ctx.model,
161
+ provider: ctx.provider,
162
+ usage: toConversationChildUsage(terminalState.usage),
163
+ terminalErrorCode: null,
164
+ terminalErrorMessage: null,
165
+ });
166
+ await publishConversationChildProgress(ctx, "completed");
167
+ },
168
+ failed: async (terminalState) => {
169
+ await finalizeConversationAgentRun({
170
+ authToken: ctx.authToken,
171
+ apiUrl: ctx.apiUrl,
172
+ conversationId: ctx.progress.childConversationId,
173
+ runId: ctx.progress.childRunId,
174
+ status: "failed",
175
+ model: ctx.model,
176
+ provider: ctx.provider,
177
+ usage: toConversationChildUsage(terminalState.usage),
178
+ terminalErrorCode: terminalState.terminalErrorCode ?? "FAILED",
179
+ terminalErrorMessage: terminalState.terminalErrorMessage ?? "Unknown error",
180
+ });
181
+ await publishConversationChildProgress(ctx, "failed");
182
+ },
183
+ cancelled: async (terminalState) => {
184
+ await finalizeConversationAgentRun({
185
+ authToken: ctx.authToken,
186
+ apiUrl: ctx.apiUrl,
187
+ conversationId: ctx.progress.childConversationId,
188
+ runId: ctx.progress.childRunId,
189
+ status: "cancelled",
190
+ model: ctx.model,
191
+ provider: ctx.provider,
192
+ usage: toConversationChildUsage(terminalState.usage),
193
+ terminalErrorCode: terminalState.terminalErrorCode ?? "CANCELLED",
194
+ terminalErrorMessage: terminalState.terminalErrorMessage ?? "Child run cancelled",
195
+ });
196
+ await publishConversationChildProgress(ctx, "cancelled");
197
+ },
198
+ };
199
+ }
@@ -0,0 +1,22 @@
1
+ import type { ConversationRunProjection } from "./durable.js";
2
+
3
+ export interface ConversationRunContext {
4
+ run: ConversationRunProjection | null;
5
+ effectiveParentRunId?: string;
6
+ effectiveParentMessageId?: string;
7
+ publishParentRunEvents?: (events: unknown[]) => Promise<void> | void;
8
+ }
9
+
10
+ export function createConversationRunContext(input: {
11
+ run: ConversationRunProjection | null;
12
+ parentRunId?: string;
13
+ parentMessageId?: string;
14
+ publishParentRunEvents?: ((events: unknown[]) => Promise<void> | void) | undefined;
15
+ }) {
16
+ return {
17
+ run: input.run,
18
+ effectiveParentRunId: input.run?.runId ?? input.parentRunId,
19
+ effectiveParentMessageId: input.run?.messageId ?? input.parentMessageId,
20
+ publishParentRunEvents: input.publishParentRunEvents,
21
+ };
22
+ }
@@ -180,6 +180,10 @@ export {
180
180
  createAgUiBrowserResponseStream,
181
181
  type CreateAgUiBrowserResponseStreamInput,
182
182
  } from "./ag-ui-browser-response-stream.js";
183
+ export {
184
+ type ConversationRunContext,
185
+ createConversationRunContext,
186
+ } from "./conversation-run-context.js";
183
187
  export {
184
188
  bootstrapConversationAgentRun,
185
189
  type BootstrapConversationAgentRunResult,
@@ -192,6 +196,13 @@ export {
192
196
  ensureConversationProjectLink,
193
197
  fetchConversationRecord,
194
198
  } from "./conversation-bootstrap.js";
199
+ export {
200
+ type ConversationChildLifecycleContext,
201
+ type ConversationHostedLifecycleFinalizeInput,
202
+ createConversationChildLifecycleAdapter,
203
+ createConversationHostedLifecycleAdapter,
204
+ type CreateConversationHostedLifecycleAdapterOptions,
205
+ } from "./conversation-hosted-lifecycle.js";
195
206
  export {
196
207
  type ActiveConversationRunStatus,
197
208
  appendConversationRunEvents,
@@ -1,3 +1,3 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
- export const VERSION = "0.1.236";
3
+ export const VERSION = "0.1.240";