veryfront 0.1.232 → 0.1.233

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.d.ts CHANGED
@@ -17,6 +17,7 @@ declare namespace _default {
17
17
  "./markdown": string;
18
18
  "./mdx": string;
19
19
  "./agent": string;
20
+ "./agent/conversation-bootstrap": string;
20
21
  "./agent/durable": string;
21
22
  "./channels/control-plane": string;
22
23
  "./channels/invoke": string;
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.232",
3
+ "version": "0.1.233",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "workspace": [
@@ -30,6 +30,7 @@ export default {
30
30
  "./markdown": "./src/markdown/index.ts",
31
31
  "./mdx": "./src/mdx/index.ts",
32
32
  "./agent": "./src/agent/index.ts",
33
+ "./agent/conversation-bootstrap": "./src/agent/conversation-bootstrap.ts",
33
34
  "./agent/durable": "./src/agent/durable.ts",
34
35
  "./channels/control-plane": "./src/channels/control-plane.ts",
35
36
  "./channels/invoke": "./src/channels/invoke.ts",
@@ -0,0 +1,61 @@
1
+ import "../../_dnt.polyfills.js";
2
+ import { z } from "zod";
3
+ import { type ConversationRunProjection } from "./durable.js";
4
+ export declare const ConversationRecordSchema: z.ZodPipe<z.ZodObject<{
5
+ id: z.ZodString;
6
+ projectId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
7
+ project_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8
+ }, z.core.$loose>, z.ZodTransform<{
9
+ id: string;
10
+ projectId: string | null;
11
+ }, {
12
+ [x: string]: unknown;
13
+ id: string;
14
+ projectId?: string | null | undefined;
15
+ project_id?: string | null | undefined;
16
+ }>>;
17
+ export declare const ConversationMessageRecordSchema: z.ZodObject<{
18
+ id: z.ZodString;
19
+ }, z.core.$strip>;
20
+ export type ConversationRecord = z.infer<typeof ConversationRecordSchema>;
21
+ export type ConversationMessageRecord = z.infer<typeof ConversationMessageRecordSchema>;
22
+ export declare function fetchConversationRecord(input: {
23
+ authToken: string;
24
+ apiUrl: string;
25
+ conversationId: string;
26
+ }): Promise<ConversationRecord>;
27
+ export declare function ensureConversationProjectLink(input: {
28
+ authToken: string;
29
+ apiUrl: string;
30
+ conversationId: string;
31
+ projectId: string;
32
+ }): Promise<void>;
33
+ export declare function createConversationRecord(input: {
34
+ authToken: string;
35
+ apiUrl: string;
36
+ body: unknown;
37
+ }): Promise<ConversationRecord>;
38
+ export declare function createConversationMessage(input: {
39
+ authToken: string;
40
+ apiUrl: string;
41
+ conversationId: string;
42
+ body: unknown;
43
+ }): Promise<ConversationMessageRecord>;
44
+ export interface BootstrapConversationAgentRunResult {
45
+ conversation: ConversationRecord;
46
+ message: ConversationMessageRecord;
47
+ run: ConversationRunProjection;
48
+ }
49
+ export declare function bootstrapConversationAgentRun(input: {
50
+ authToken: string;
51
+ apiUrl: string;
52
+ parentConversationId?: string;
53
+ ensureProjectId?: string;
54
+ conversationBody: unknown;
55
+ handoffMessageBody: unknown;
56
+ runId?: string;
57
+ agentId: string;
58
+ projectId?: string | null;
59
+ branchId?: string | null;
60
+ }): Promise<BootstrapConversationAgentRunResult>;
61
+ //# sourceMappingURL=conversation-bootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-bootstrap.d.ts","sourceRoot":"","sources":["../../../src/src/agent/conversation-bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,yBAAyB,EAA8B,MAAM,cAAc,CAAC;AAI1F,eAAO,MAAM,wBAAwB;;;;;;;;;;;;GAUhC,CAAC;AAEN,eAAO,MAAM,+BAA+B;;iBAE1C,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;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AE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAiC/C"}
@@ -0,0 +1,131 @@
1
+ import "../../_dnt.polyfills.js";
2
+ import * as dntShim from "../../_dnt.shims.js";
3
+ import { z } from "zod";
4
+ import { createConversationAgentRun } from "./durable.js";
5
+ const CONVERSATION_API_TIMEOUT_MS = 15_000;
6
+ export const ConversationRecordSchema = z
7
+ .object({
8
+ id: z.string(),
9
+ projectId: z.string().nullable().optional(),
10
+ project_id: z.string().nullable().optional(),
11
+ })
12
+ .passthrough()
13
+ .transform((data) => ({
14
+ id: data.id,
15
+ projectId: data.projectId ?? data.project_id ?? null,
16
+ }));
17
+ export const ConversationMessageRecordSchema = z.object({
18
+ id: z.string().uuid(),
19
+ });
20
+ async function controlPlaneJson(input) {
21
+ const controller = new AbortController();
22
+ const timeout = dntShim.setTimeout(() => controller.abort(), CONVERSATION_API_TIMEOUT_MS);
23
+ let response;
24
+ try {
25
+ response = await fetch(input.url, {
26
+ method: input.method ?? "GET",
27
+ headers: {
28
+ Authorization: `Bearer ${input.authToken}`,
29
+ "Content-Type": "application/json",
30
+ },
31
+ ...(input.body !== undefined ? { body: JSON.stringify(input.body) } : {}),
32
+ signal: controller.signal,
33
+ });
34
+ }
35
+ catch (error) {
36
+ if (error instanceof DOMException && error.name === "AbortError") {
37
+ throw new Error(`${input.operation} timed out after ${CONVERSATION_API_TIMEOUT_MS}ms`);
38
+ }
39
+ throw error;
40
+ }
41
+ finally {
42
+ clearTimeout(timeout);
43
+ }
44
+ if (!response.ok) {
45
+ const body = await response.text().catch(() => "");
46
+ throw new Error(`${input.operation} failed (${response.status}): ${body || response.statusText}`);
47
+ }
48
+ return input.responseSchema.parse(await response.json());
49
+ }
50
+ function buildConversationPath(apiUrl, conversationId) {
51
+ return `${apiUrl}/conversations/${conversationId}`;
52
+ }
53
+ function buildConversationMessagesPath(apiUrl, conversationId) {
54
+ return `${buildConversationPath(apiUrl, conversationId)}/messages`;
55
+ }
56
+ export async function fetchConversationRecord(input) {
57
+ return controlPlaneJson({
58
+ authToken: input.authToken,
59
+ url: buildConversationPath(input.apiUrl, input.conversationId),
60
+ responseSchema: ConversationRecordSchema,
61
+ operation: "Fetch conversation",
62
+ });
63
+ }
64
+ export async function ensureConversationProjectLink(input) {
65
+ const conversation = await fetchConversationRecord(input);
66
+ if (conversation.projectId === input.projectId)
67
+ return;
68
+ if (conversation.projectId !== null) {
69
+ throw new Error(`Conversation ${input.conversationId} is already linked to a different project (${conversation.projectId})`);
70
+ }
71
+ await controlPlaneJson({
72
+ authToken: input.authToken,
73
+ url: buildConversationPath(input.apiUrl, input.conversationId),
74
+ method: "PATCH",
75
+ body: { project_id: input.projectId },
76
+ responseSchema: ConversationRecordSchema,
77
+ operation: "Link conversation to project",
78
+ });
79
+ }
80
+ export async function createConversationRecord(input) {
81
+ return controlPlaneJson({
82
+ authToken: input.authToken,
83
+ url: `${input.apiUrl}/conversations`,
84
+ method: "POST",
85
+ body: input.body,
86
+ responseSchema: ConversationRecordSchema,
87
+ operation: "Create conversation",
88
+ });
89
+ }
90
+ export async function createConversationMessage(input) {
91
+ return controlPlaneJson({
92
+ authToken: input.authToken,
93
+ url: buildConversationMessagesPath(input.apiUrl, input.conversationId),
94
+ method: "POST",
95
+ body: input.body,
96
+ responseSchema: ConversationMessageRecordSchema,
97
+ operation: "Create conversation message",
98
+ });
99
+ }
100
+ export async function bootstrapConversationAgentRun(input) {
101
+ if (input.parentConversationId && input.ensureProjectId) {
102
+ await ensureConversationProjectLink({
103
+ authToken: input.authToken,
104
+ apiUrl: input.apiUrl,
105
+ conversationId: input.parentConversationId,
106
+ projectId: input.ensureProjectId,
107
+ });
108
+ }
109
+ const conversation = await createConversationRecord({
110
+ authToken: input.authToken,
111
+ apiUrl: input.apiUrl,
112
+ body: input.conversationBody,
113
+ });
114
+ const effectiveProjectId = input.projectId ?? conversation.projectId;
115
+ const message = await createConversationMessage({
116
+ authToken: input.authToken,
117
+ apiUrl: input.apiUrl,
118
+ conversationId: conversation.id,
119
+ body: input.handoffMessageBody,
120
+ });
121
+ const run = await createConversationAgentRun({
122
+ authToken: input.authToken,
123
+ apiUrl: input.apiUrl,
124
+ conversationId: conversation.id,
125
+ runId: input.runId,
126
+ agentId: input.agentId,
127
+ projectId: effectiveProjectId,
128
+ branchId: input.branchId,
129
+ });
130
+ return { conversation, message, run };
131
+ }
@@ -89,6 +89,7 @@ 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 { bootstrapConversationAgentRun, type BootstrapConversationAgentRunResult, type ConversationMessageRecord, ConversationMessageRecordSchema, type ConversationRecord, ConversationRecordSchema, createConversationMessage, createConversationRecord, ensureConversationProjectLink, fetchConversationRecord, } from "./conversation-bootstrap.js";
92
93
  export { CompleteConversationRunResponseSchema, type ConversationAgentRunUsage, type ConversationRunProjection, ConversationRunProjectionSchema, type ConversationRunTargets, ConversationRunTargetsSchema, createConversationAgentRun, finalizeConversationAgentRun, resolveConversationRunTargets, } from "./durable.js";
93
94
  export { type HostedChildLifecycleAdapter, type HostedChildLifecycleRunnerOptions, type HostedChildLifecycleRunResult, type HostedChildLifecycleTerminalState, runHostedChildLifecycle, } from "./hosted-child-lifecycle.js";
94
95
  export { type HostedLifecycleAdapter, type HostedLifecycleExecution, type HostedLifecycleRunnerOptions, type HostedLifecycleRunResult, type HostedLifecycleTerminalState, runHostedLifecycle, } from "./hosted-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,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,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnF,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,KAAK,MAAM,EACX,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,WAAW,EACX,KAAK,iBAAiB,EACtB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,WAAW,EACX,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,G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M,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,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnF,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,KAAK,MAAM,EACX,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,WAAW,E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K,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,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"}
@@ -88,6 +88,7 @@ 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 { bootstrapConversationAgentRun, ConversationMessageRecordSchema, ConversationRecordSchema, createConversationMessage, createConversationRecord, ensureConversationProjectLink, fetchConversationRecord, } from "./conversation-bootstrap.js";
91
92
  export { CompleteConversationRunResponseSchema, ConversationRunProjectionSchema, ConversationRunTargetsSchema, createConversationAgentRun, finalizeConversationAgentRun, resolveConversationRunTargets, } from "./durable.js";
92
93
  export { runHostedChildLifecycle, } from "./hosted-child-lifecycle.js";
93
94
  export { runHostedLifecycle, } from "./hosted-lifecycle.js";
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.1.232";
1
+ export declare const VERSION = "0.1.233";
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.232";
3
+ export const VERSION = "0.1.233";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.1.232",
3
+ "version": "0.1.233",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",
@@ -69,6 +69,10 @@
69
69
  "import": "./esm/src/agent/index.js",
70
70
  "types": "./esm/src/agent/index.d.ts"
71
71
  },
72
+ "./agent/conversation-bootstrap": {
73
+ "import": "./esm/src/agent/conversation-bootstrap.js",
74
+ "types": "./esm/src/agent/conversation-bootstrap.d.ts"
75
+ },
72
76
  "./agent/durable": {
73
77
  "import": "./esm/src/agent/durable.js",
74
78
  "types": "./esm/src/agent/durable.d.ts"
package/src/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.232",
3
+ "version": "0.1.233",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "workspace": [
@@ -30,6 +30,7 @@ export default {
30
30
  "./markdown": "./src/markdown/index.ts",
31
31
  "./mdx": "./src/mdx/index.ts",
32
32
  "./agent": "./src/agent/index.ts",
33
+ "./agent/conversation-bootstrap": "./src/agent/conversation-bootstrap.ts",
33
34
  "./agent/durable": "./src/agent/durable.ts",
34
35
  "./channels/control-plane": "./src/channels/control-plane.ts",
35
36
  "./channels/invoke": "./src/channels/invoke.ts",
@@ -0,0 +1,195 @@
1
+ import "../../_dnt.polyfills.js";
2
+ import * as dntShim from "../../_dnt.shims.js";
3
+ import { z } from "zod";
4
+ import { type ConversationRunProjection, createConversationAgentRun } from "./durable.js";
5
+
6
+ const CONVERSATION_API_TIMEOUT_MS = 15_000;
7
+
8
+ export const ConversationRecordSchema = z
9
+ .object({
10
+ id: z.string(),
11
+ projectId: z.string().nullable().optional(),
12
+ project_id: z.string().nullable().optional(),
13
+ })
14
+ .passthrough()
15
+ .transform((data) => ({
16
+ id: data.id,
17
+ projectId: data.projectId ?? data.project_id ?? null,
18
+ }));
19
+
20
+ export const ConversationMessageRecordSchema = z.object({
21
+ id: z.string().uuid(),
22
+ });
23
+
24
+ export type ConversationRecord = z.infer<typeof ConversationRecordSchema>;
25
+ export type ConversationMessageRecord = z.infer<typeof ConversationMessageRecordSchema>;
26
+
27
+ async function controlPlaneJson<T>(input: {
28
+ authToken: string;
29
+ url: string;
30
+ method?: "GET" | "POST" | "PATCH";
31
+ body?: unknown;
32
+ responseSchema: z.ZodSchema<T>;
33
+ operation: string;
34
+ }): Promise<T> {
35
+ const controller = new AbortController();
36
+ const timeout = dntShim.setTimeout(() => controller.abort(), CONVERSATION_API_TIMEOUT_MS);
37
+
38
+ let response: Response;
39
+ try {
40
+ response = await fetch(input.url, {
41
+ method: input.method ?? "GET",
42
+ headers: {
43
+ Authorization: `Bearer ${input.authToken}`,
44
+ "Content-Type": "application/json",
45
+ },
46
+ ...(input.body !== undefined ? { body: JSON.stringify(input.body) } : {}),
47
+ signal: controller.signal,
48
+ });
49
+ } catch (error) {
50
+ if (error instanceof DOMException && error.name === "AbortError") {
51
+ throw new Error(`${input.operation} timed out after ${CONVERSATION_API_TIMEOUT_MS}ms`);
52
+ }
53
+ throw error;
54
+ } finally {
55
+ clearTimeout(timeout);
56
+ }
57
+
58
+ if (!response.ok) {
59
+ const body = await response.text().catch(() => "");
60
+ throw new Error(
61
+ `${input.operation} failed (${response.status}): ${body || response.statusText}`,
62
+ );
63
+ }
64
+
65
+ return input.responseSchema.parse(await response.json());
66
+ }
67
+
68
+ function buildConversationPath(apiUrl: string, conversationId: string): string {
69
+ return `${apiUrl}/conversations/${conversationId}`;
70
+ }
71
+
72
+ function buildConversationMessagesPath(apiUrl: string, conversationId: string): string {
73
+ return `${buildConversationPath(apiUrl, conversationId)}/messages`;
74
+ }
75
+
76
+ export async function fetchConversationRecord(input: {
77
+ authToken: string;
78
+ apiUrl: string;
79
+ conversationId: string;
80
+ }): Promise<ConversationRecord> {
81
+ return controlPlaneJson({
82
+ authToken: input.authToken,
83
+ url: buildConversationPath(input.apiUrl, input.conversationId),
84
+ responseSchema: ConversationRecordSchema,
85
+ operation: "Fetch conversation",
86
+ });
87
+ }
88
+
89
+ export async function ensureConversationProjectLink(input: {
90
+ authToken: string;
91
+ apiUrl: string;
92
+ conversationId: string;
93
+ projectId: string;
94
+ }): Promise<void> {
95
+ const conversation = await fetchConversationRecord(input);
96
+
97
+ if (conversation.projectId === input.projectId) return;
98
+ if (conversation.projectId !== null) {
99
+ throw new Error(
100
+ `Conversation ${input.conversationId} is already linked to a different project (${conversation.projectId})`,
101
+ );
102
+ }
103
+
104
+ await controlPlaneJson({
105
+ authToken: input.authToken,
106
+ url: buildConversationPath(input.apiUrl, input.conversationId),
107
+ method: "PATCH",
108
+ body: { project_id: input.projectId },
109
+ responseSchema: ConversationRecordSchema,
110
+ operation: "Link conversation to project",
111
+ });
112
+ }
113
+
114
+ export async function createConversationRecord(input: {
115
+ authToken: string;
116
+ apiUrl: string;
117
+ body: unknown;
118
+ }): Promise<ConversationRecord> {
119
+ return controlPlaneJson({
120
+ authToken: input.authToken,
121
+ url: `${input.apiUrl}/conversations`,
122
+ method: "POST",
123
+ body: input.body,
124
+ responseSchema: ConversationRecordSchema,
125
+ operation: "Create conversation",
126
+ });
127
+ }
128
+
129
+ export async function createConversationMessage(input: {
130
+ authToken: string;
131
+ apiUrl: string;
132
+ conversationId: string;
133
+ body: unknown;
134
+ }): Promise<ConversationMessageRecord> {
135
+ return controlPlaneJson({
136
+ authToken: input.authToken,
137
+ url: buildConversationMessagesPath(input.apiUrl, input.conversationId),
138
+ method: "POST",
139
+ body: input.body,
140
+ responseSchema: ConversationMessageRecordSchema,
141
+ operation: "Create conversation message",
142
+ });
143
+ }
144
+
145
+ export interface BootstrapConversationAgentRunResult {
146
+ conversation: ConversationRecord;
147
+ message: ConversationMessageRecord;
148
+ run: ConversationRunProjection;
149
+ }
150
+
151
+ export async function bootstrapConversationAgentRun(input: {
152
+ authToken: string;
153
+ apiUrl: string;
154
+ parentConversationId?: string;
155
+ ensureProjectId?: string;
156
+ conversationBody: unknown;
157
+ handoffMessageBody: unknown;
158
+ runId?: string;
159
+ agentId: string;
160
+ projectId?: string | null;
161
+ branchId?: string | null;
162
+ }): Promise<BootstrapConversationAgentRunResult> {
163
+ if (input.parentConversationId && input.ensureProjectId) {
164
+ await ensureConversationProjectLink({
165
+ authToken: input.authToken,
166
+ apiUrl: input.apiUrl,
167
+ conversationId: input.parentConversationId,
168
+ projectId: input.ensureProjectId,
169
+ });
170
+ }
171
+
172
+ const conversation = await createConversationRecord({
173
+ authToken: input.authToken,
174
+ apiUrl: input.apiUrl,
175
+ body: input.conversationBody,
176
+ });
177
+ const effectiveProjectId = input.projectId ?? conversation.projectId;
178
+ const message = await createConversationMessage({
179
+ authToken: input.authToken,
180
+ apiUrl: input.apiUrl,
181
+ conversationId: conversation.id,
182
+ body: input.handoffMessageBody,
183
+ });
184
+ const run = await createConversationAgentRun({
185
+ authToken: input.authToken,
186
+ apiUrl: input.apiUrl,
187
+ conversationId: conversation.id,
188
+ runId: input.runId,
189
+ agentId: input.agentId,
190
+ projectId: effectiveProjectId,
191
+ branchId: input.branchId,
192
+ });
193
+
194
+ return { conversation, message, run };
195
+ }
@@ -180,6 +180,18 @@ export {
180
180
  createAgUiBrowserResponseStream,
181
181
  type CreateAgUiBrowserResponseStreamInput,
182
182
  } from "./ag-ui-browser-response-stream.js";
183
+ export {
184
+ bootstrapConversationAgentRun,
185
+ type BootstrapConversationAgentRunResult,
186
+ type ConversationMessageRecord,
187
+ ConversationMessageRecordSchema,
188
+ type ConversationRecord,
189
+ ConversationRecordSchema,
190
+ createConversationMessage,
191
+ createConversationRecord,
192
+ ensureConversationProjectLink,
193
+ fetchConversationRecord,
194
+ } from "./conversation-bootstrap.js";
183
195
  export {
184
196
  CompleteConversationRunResponseSchema,
185
197
  type ConversationAgentRunUsage,
@@ -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.232";
3
+ export const VERSION = "0.1.233";