@roomle/embedding-lib 0.0.0-dev-9d077e2 → 0.0.0-dev-b626163
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/{drag-ghost-BOwjMbG3.mjs → drag-ghost-BxqPJdhq.mjs} +1 -1
- package/{drag-ghost-BQ8r6NVo.mjs → drag-ghost-CDFtC1pd.mjs} +1 -1
- package/{drag-in-BP_E53zb.mjs → drag-in-CV1E-DO6.mjs} +2 -2
- package/{drag-in-QhL3zGC0.mjs → drag-in-ClPpCYyi.mjs} +2 -2
- package/embedding-plugins.js +1 -1
- package/embedding-plugins.min.js +1 -1
- package/{from-custom-view-BM_zRJCf.mjs → from-custom-view-Q9A-J7qV.mjs} +2 -2
- package/{from-custom-view-D2Z1YmCx.mjs → from-custom-view-Sx6P6iDI.mjs} +2 -2
- package/{from-website-DlklVbxU.mjs → from-website-BmCO2xli.mjs} +2 -2
- package/{from-website-CPVeVVMI.mjs → from-website-DZJy_l42.mjs} +2 -2
- package/hi.js +283 -37
- package/hi.min.js +239 -36
- package/package.json +1 -8
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp-tools.d.ts +61 -4
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-assistant.d.ts +46 -4
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-usage.d.ts +40 -0
- package/roomle-embedding-lib.js +1 -1
- package/roomle-embedding-lib.min.js +1 -1
- package/configurator.d.ts +0 -2
- package/configurator.js +0 -119
- package/configurator.min.js +0 -117
- package/packages/embedding-lib/src/configurator-agent/chat-recovery.d.ts +0 -9
- package/packages/embedding-lib/src/configurator-agent/configurator-mcp-tools.d.ts +0 -11
- package/packages/embedding-lib/src/configurator-agent/configurator-planning-assistant.d.ts +0 -8
- package/packages/embedding-lib/src/configurator.d.ts +0 -3
- package/packages/embedding-lib/src/planning-assistant/chat-model.d.ts +0 -33
- package/packages/embedding-lib/src/planning-assistant/mcp-tools.d.ts +0 -52
- package/packages/embedding-lib/src/planning-assistant/planning-assistant.d.ts +0 -23
- package/planning-assistant-BW9fNGZO.mjs +0 -158
- package/planning-assistant-CyVA2uUX.mjs +0 -143
- /package/{comlink-BJnhpJa4.mjs → comlink-B2Kj_5Ge.mjs} +0 -0
- /package/{comlink-lSsogKgb.mjs → comlink-B5lV2OWp.mjs} +0 -0
package/configurator.min.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "./planning-assistant-CyVA2uUX.mjs";
|
|
2
|
-
var r = async (e) => {
|
|
3
|
-
if (typeof e.getConfiguratorAgentTools != "function" || typeof e.callConfiguratorAgentTool != "function") throw Error("Update the Rubens UI: configurator agent tools are unavailable.");
|
|
4
|
-
return t(await e.getConfiguratorAgentTools(), (t, n) => e.callConfiguratorAgentTool(t, n), "configurator-mcp");
|
|
5
|
-
}, i = {
|
|
6
|
-
undo: "Undo",
|
|
7
|
-
redo: "Redo",
|
|
8
|
-
"change-component-parameter": "Component parameter change",
|
|
9
|
-
"change-global-parameter": "Global parameter change",
|
|
10
|
-
"dock-component": "Component dock",
|
|
11
|
-
"drag-component": "Component drag",
|
|
12
|
-
"delete-component": "Component deletion",
|
|
13
|
-
"load-configuration": "Configuration load",
|
|
14
|
-
"get-configurator-capabilities": "Capabilities read",
|
|
15
|
-
"get-configuration": "Configuration read",
|
|
16
|
-
"get-component-parameters": "Component parameters read",
|
|
17
|
-
"get-global-parameters": "Global parameters read",
|
|
18
|
-
"get-possible-children": "Possible children read",
|
|
19
|
-
"get-docking-positions": "Docking positions read",
|
|
20
|
-
"get-component-docking-positions": "Component docking positions read",
|
|
21
|
-
"get-delete-impact": "Delete impact read"
|
|
22
|
-
}, a = new Set([
|
|
23
|
-
"get-configurator-capabilities",
|
|
24
|
-
"get-configuration",
|
|
25
|
-
"get-component-parameters",
|
|
26
|
-
"get-global-parameters",
|
|
27
|
-
"get-possible-children",
|
|
28
|
-
"get-docking-positions",
|
|
29
|
-
"get-component-docking-positions",
|
|
30
|
-
"get-delete-impact"
|
|
31
|
-
]), o = (e) => {
|
|
32
|
-
if (e instanceof Error) return e.message;
|
|
33
|
-
try {
|
|
34
|
-
return typeof e == "string" ? e : JSON.stringify(e) ?? String(e);
|
|
35
|
-
} catch {
|
|
36
|
-
return Object.prototype.toString.call(e);
|
|
37
|
-
}
|
|
38
|
-
}, s = (e) => {
|
|
39
|
-
if (e?.structuredContent !== void 0) return e.structuredContent;
|
|
40
|
-
let t = e?.content?.filter((e) => e.type === "text").map((e) => e.text).join("\n");
|
|
41
|
-
if (t === void 0) return e;
|
|
42
|
-
try {
|
|
43
|
-
return JSON.parse(t);
|
|
44
|
-
} catch {
|
|
45
|
-
return t;
|
|
46
|
-
}
|
|
47
|
-
}, c = (e) => {
|
|
48
|
-
if (!e || typeof e != "object") return e == null ? [] : [o(e)];
|
|
49
|
-
let t = [];
|
|
50
|
-
for (let n of [
|
|
51
|
-
"undone",
|
|
52
|
-
"redone",
|
|
53
|
-
"confirmed",
|
|
54
|
-
"canUndo",
|
|
55
|
-
"canRedo"
|
|
56
|
-
]) e[n] !== void 0 && t.push(`${n}: ${o(e[n])}`);
|
|
57
|
-
return e.hint && t.push(o(e.hint)), t;
|
|
58
|
-
}, l = (e) => {
|
|
59
|
-
let t = [];
|
|
60
|
-
return {
|
|
61
|
-
tools: Object.fromEntries(Object.entries(e).map(([e, n]) => {
|
|
62
|
-
if (!n.execute) return [e, n];
|
|
63
|
-
let r = n.execute.bind(n);
|
|
64
|
-
return [e, {
|
|
65
|
-
...n,
|
|
66
|
-
execute: async (n) => {
|
|
67
|
-
let i = {
|
|
68
|
-
toolName: e,
|
|
69
|
-
status: "pending"
|
|
70
|
-
};
|
|
71
|
-
t.push(i);
|
|
72
|
-
try {
|
|
73
|
-
let e = await r(n);
|
|
74
|
-
return i.result = e, i.status = "returned", e;
|
|
75
|
-
} catch (e) {
|
|
76
|
-
throw i.error = e, i.status = "threw", e;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}];
|
|
80
|
-
})),
|
|
81
|
-
summary: () => {
|
|
82
|
-
let e = ["The assistant's reply was interrupted. Any text above is incomplete."];
|
|
83
|
-
if (!t.length) return e.push("No tool ran, so the configuration was not changed."), e.join("\n\n");
|
|
84
|
-
for (let n of t) {
|
|
85
|
-
let t = i[n.toolName] ?? n.toolName;
|
|
86
|
-
if (a.has(n.toolName)) {
|
|
87
|
-
let r = n.status === "returned" && !n.result?.isError, i = r ? s(n.result) : void 0;
|
|
88
|
-
e.push(r ? `- Completed ${t}: ${!1 === i?.complete ? "some requested information was unresolved" : "information was returned"}. The read did not change the configuration.` : `- Incomplete ${t}: ${n.status === "pending" ? "no result was received" : "the read failed"}. The read did not change the configuration.`);
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
if (n.status !== "returned" || n.result?.isError) {
|
|
92
|
-
let r = n.status === "threw" ? o(n.error) : n.status === "returned" ? o(s(n.result)) : "no result was received";
|
|
93
|
-
e.push(`- Unconfirmed ${t}: ${r}. Check the configuration before trying this operation again.`);
|
|
94
|
-
} else {
|
|
95
|
-
let r = s(n.result);
|
|
96
|
-
if (!1 === r?.confirmed) {
|
|
97
|
-
e.push(`- Unconfirmed ${t}: ${r?.hint ?? "the configurator did not report the change"}. Check the configuration before trying this operation again.`);
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
let i = c(r);
|
|
101
|
-
e.push(`- Completed ${t}: ${i.length ? i.join("; ") : "the tool returned successfully."}`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return e.push("These are the recorded tool outcomes; no operation was repeated automatically."), e.join("\n\n");
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
}, u = (e, t, i) => n(e.window, t, i, async () => {
|
|
108
|
-
let [t, n] = await Promise.all([e.configurator.getConfiguratorAgentPrompts(), r(e.configurator)]);
|
|
109
|
-
return {
|
|
110
|
-
prompts: t,
|
|
111
|
-
tools: n
|
|
112
|
-
};
|
|
113
|
-
}, {
|
|
114
|
-
timeoutMs: 3e5,
|
|
115
|
-
recovery: l
|
|
116
|
-
});
|
|
117
|
-
export { r as createConfiguratorMcpTools, e as loadChatModel, u as startConfiguratorPlanningAssistant };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AgentMcpTools } from '../planning-assistant/mcp-tools';
|
|
2
|
-
/**
|
|
3
|
-
* Records tool execution independently of whether the model finishes its
|
|
4
|
-
* step, so an interrupted reply can say what the tools changed.
|
|
5
|
-
*/
|
|
6
|
-
export declare const createChatRecovery: (tools: AgentMcpTools) => {
|
|
7
|
-
tools: AgentMcpTools;
|
|
8
|
-
summary: () => string;
|
|
9
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { AgentToolDefinition, McpToolResult } from '../../../web-sdk/packages';
|
|
2
|
-
export interface ConfiguratorAgentApi {
|
|
3
|
-
getConfiguratorAgentTools(): Promise<AgentToolDefinition[]>;
|
|
4
|
-
callConfiguratorAgentTool(name: string, input: unknown): Promise<McpToolResult>;
|
|
5
|
-
getConfiguratorAgentPrompts(): Promise<{
|
|
6
|
-
systemPrompt: string;
|
|
7
|
-
imagePrompt: string;
|
|
8
|
-
}>;
|
|
9
|
-
}
|
|
10
|
-
/** The native configurator's agent tools forwarded through the embedding bridge. */
|
|
11
|
-
export declare const createConfiguratorMcpTools: (api: ConfiguratorAgentApi) => Promise<import('../hi').HiMcpTools>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AssistantWindow } from '../planning-assistant/planning-assistant';
|
|
2
|
-
import { PlanningAssistantConfig } from '../planning-assistant/chat-model';
|
|
3
|
-
import { ConfiguratorAgentApi } from './configurator-mcp-tools';
|
|
4
|
-
/** Runs a native configurator assistant, with its window supplied separately for planner isolation. */
|
|
5
|
-
export declare const startConfiguratorPlanningAssistant: (endpoints: {
|
|
6
|
-
configurator: ConfiguratorAgentApi;
|
|
7
|
-
window: AssistantWindow;
|
|
8
|
-
}, config: PlanningAssistantConfig, signal: AbortSignal) => Promise<void>;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { createConfiguratorMcpTools, type ConfiguratorAgentApi, } from './configurator-agent/configurator-mcp-tools';
|
|
2
|
-
export { startConfiguratorPlanningAssistant } from './configurator-agent/configurator-planning-assistant';
|
|
3
|
-
export { loadChatModel, type PlanningAssistantConfig, } from './planning-assistant/chat-model';
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The model of the AI Planning Assistant as a JSON object: everything
|
|
3
|
-
* `loadChatModel` and `startPlanningAssistant` need to reach it.
|
|
4
|
-
*/
|
|
5
|
-
export interface PlanningAssistantConfig {
|
|
6
|
-
/** `azure` for a deployment on an Azure AI Foundry resource, else the provider of the model. */
|
|
7
|
-
provider: 'azure' | 'mistral' | 'anthropic' | 'google';
|
|
8
|
-
/** The model id at the provider; for `azure` the name of the deployment. */
|
|
9
|
-
model: string;
|
|
10
|
-
/** The API key of the provider; for `azure` the key of the Foundry resource. */
|
|
11
|
-
apiKey: string;
|
|
12
|
-
/** `azure` only: the OpenAI v1 endpoint of the Foundry resource, e.g. `https://<resource>.services.ai.azure.com/openai/v1`. */
|
|
13
|
-
baseUrl?: string;
|
|
14
|
-
/** `azure` only: call the deployment through the Chat Completions API instead of the Responses API. */
|
|
15
|
-
chatCompletions?: boolean;
|
|
16
|
-
/** `azure` only: the reasoning effort of the deployment; its default when unset. */
|
|
17
|
-
reasoningEffort?: string;
|
|
18
|
-
/** Whether the model reads images: the window offers the image drop only then. */
|
|
19
|
-
readsImages: boolean;
|
|
20
|
-
}
|
|
21
|
-
export declare const esm: (module: string) => string;
|
|
22
|
-
/** The AI SDK language model of the config and the provider options `streamText` takes with it. */
|
|
23
|
-
export declare const loadChatModel: ({ provider, model, apiKey, baseUrl, chatCompletions, reasoningEffort, }: PlanningAssistantConfig) => Promise<{
|
|
24
|
-
languageModel: any;
|
|
25
|
-
providerOptions: {
|
|
26
|
-
azure: {
|
|
27
|
-
reasoningEffort: string;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
} | {
|
|
31
|
-
languageModel: any;
|
|
32
|
-
providerOptions?: undefined;
|
|
33
|
-
}>;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { AgentToolDefinition, McpToolResult } from '../../../web-sdk/packages';
|
|
2
|
-
/** What the model gets of a tool result, as `@ai-sdk/mcp` hands it to the AI SDK. */
|
|
3
|
-
export interface AgentMcpModelOutput {
|
|
4
|
-
type: 'content';
|
|
5
|
-
value: ({
|
|
6
|
-
type: 'text';
|
|
7
|
-
text: string;
|
|
8
|
-
} | {
|
|
9
|
-
type: 'file';
|
|
10
|
-
mediaType: string;
|
|
11
|
-
data: {
|
|
12
|
-
type: 'data';
|
|
13
|
-
data: string;
|
|
14
|
-
};
|
|
15
|
-
})[];
|
|
16
|
-
}
|
|
17
|
-
/** The input schema of a tool as a Standard Schema with its JSON Schema. */
|
|
18
|
-
export interface AgentMcpInputSchema {
|
|
19
|
-
'~standard': {
|
|
20
|
-
version: 1;
|
|
21
|
-
vendor: string;
|
|
22
|
-
validate: (value: unknown) => {
|
|
23
|
-
value: unknown;
|
|
24
|
-
};
|
|
25
|
-
jsonSchema: {
|
|
26
|
-
input: (options: {
|
|
27
|
-
target: string;
|
|
28
|
-
}) => Record<string, unknown>;
|
|
29
|
-
output: (options: {
|
|
30
|
-
target: string;
|
|
31
|
-
}) => Record<string, unknown>;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
/** A tool of the HI MCP tool set, in the shape of an AI SDK dynamic tool. */
|
|
36
|
-
export interface AgentMcpTool {
|
|
37
|
-
type: 'dynamic';
|
|
38
|
-
annotations?: AgentToolDefinition['annotations'];
|
|
39
|
-
description: string;
|
|
40
|
-
inputSchema: AgentMcpInputSchema;
|
|
41
|
-
execute: (input: unknown) => Promise<McpToolResult>;
|
|
42
|
-
toModelOutput: (options: {
|
|
43
|
-
output: McpToolResult;
|
|
44
|
-
}) => AgentMcpModelOutput;
|
|
45
|
-
}
|
|
46
|
-
/** The HI MCP tools by name, the tool set an AI SDK `streamText` takes. */
|
|
47
|
-
export type AgentMcpTools = Record<string, AgentMcpTool>;
|
|
48
|
-
/** The tool result as `@ai-sdk/mcp` passes it to the model: text parts and images as file parts. */
|
|
49
|
-
export declare const mcpToModelOutput: ({ output, }: {
|
|
50
|
-
output: McpToolResult;
|
|
51
|
-
}) => AgentMcpModelOutput;
|
|
52
|
-
export declare const createAgentMcpTools: (definitions: AgentToolDefinition[], call: (name: string, input: unknown) => Promise<McpToolResult>, vendor: string) => AgentMcpTools;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { PlanningAssistantOutput, PlanningAssistantPrompt } from '../../../web-sdk/packages';
|
|
2
|
-
import { PlanningAssistantConfig } from './chat-model';
|
|
3
|
-
import { AgentMcpTools } from './mcp-tools';
|
|
4
|
-
export interface AssistantWindow {
|
|
5
|
-
planningAssistantOutput(part: PlanningAssistantOutput): unknown;
|
|
6
|
-
callbacks: {
|
|
7
|
-
onPlanningAssistantPrompt?: (prompt: PlanningAssistantPrompt) => Promise<void>;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
/** Runs a browser agent with the tools and prompts supplied by its SDK domain. */
|
|
11
|
-
export declare const startAssistant: (windowApi: AssistantWindow, config: PlanningAssistantConfig, signal: AbortSignal, setupDomain: () => Promise<{
|
|
12
|
-
prompts: {
|
|
13
|
-
systemPrompt: string;
|
|
14
|
-
imagePrompt: string;
|
|
15
|
-
};
|
|
16
|
-
tools: AgentMcpTools;
|
|
17
|
-
}>, turnPolicy?: {
|
|
18
|
-
timeoutMs: number;
|
|
19
|
-
recovery: (tools: AgentMcpTools) => {
|
|
20
|
-
tools: AgentMcpTools;
|
|
21
|
-
summary(): string;
|
|
22
|
-
};
|
|
23
|
-
}) => Promise<void>;
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
//#region packages/embedding-lib/src/planning-assistant/mcp-tools.ts
|
|
2
|
-
var e = ({ output: e }) => ({
|
|
3
|
-
type: "content",
|
|
4
|
-
value: e.content.map((e) => e.type === "text" ? {
|
|
5
|
-
type: "text",
|
|
6
|
-
text: e.text
|
|
7
|
-
} : {
|
|
8
|
-
type: "file",
|
|
9
|
-
mediaType: e.mimeType,
|
|
10
|
-
data: {
|
|
11
|
-
type: "data",
|
|
12
|
-
data: e.data
|
|
13
|
-
}
|
|
14
|
-
})
|
|
15
|
-
}), t = (t, n, r) => Object.fromEntries(t.map(({ name: t, description: i, inputSchema: a, annotations: o }) => {
|
|
16
|
-
let s = () => a;
|
|
17
|
-
return [t, {
|
|
18
|
-
type: "dynamic",
|
|
19
|
-
...o && { annotations: o },
|
|
20
|
-
description: i,
|
|
21
|
-
inputSchema: { "~standard": {
|
|
22
|
-
version: 1,
|
|
23
|
-
vendor: r,
|
|
24
|
-
validate: (e) => ({ value: e }),
|
|
25
|
-
jsonSchema: {
|
|
26
|
-
input: s,
|
|
27
|
-
output: s
|
|
28
|
-
}
|
|
29
|
-
} },
|
|
30
|
-
execute: (e) => n(t, e).catch((e) => ({
|
|
31
|
-
content: [{
|
|
32
|
-
type: "text",
|
|
33
|
-
text: e instanceof Error ? e.message : String(e)
|
|
34
|
-
}],
|
|
35
|
-
isError: !0
|
|
36
|
-
})),
|
|
37
|
-
toModelOutput: e
|
|
38
|
-
}];
|
|
39
|
-
})), n = (e) => `https://esm.sh/${e}?deps=zod@4.6.5`, r = async ({ provider: e, model: t, apiKey: r, baseUrl: i, chatCompletions: a, reasoningEffort: o }) => {
|
|
40
|
-
switch (e) {
|
|
41
|
-
case "azure": {
|
|
42
|
-
let { createAzure: e } = await import(
|
|
43
|
-
/* @vite-ignore */
|
|
44
|
-
n("@ai-sdk/azure@4.0.85")
|
|
45
|
-
), s = e({
|
|
46
|
-
apiKey: r,
|
|
47
|
-
baseURL: i
|
|
48
|
-
});
|
|
49
|
-
return {
|
|
50
|
-
languageModel: a ? s.chat(t) : s(t),
|
|
51
|
-
providerOptions: o ? { azure: { reasoningEffort: o } } : void 0
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
case "mistral": {
|
|
55
|
-
let { createMistral: e } = await import(
|
|
56
|
-
/* @vite-ignore */
|
|
57
|
-
n("@ai-sdk/mistral@4.0.54")
|
|
58
|
-
);
|
|
59
|
-
return { languageModel: e({ apiKey: r })(t) };
|
|
60
|
-
}
|
|
61
|
-
case "anthropic": {
|
|
62
|
-
let { createAnthropic: e } = await import(
|
|
63
|
-
/* @vite-ignore */
|
|
64
|
-
n("@ai-sdk/anthropic@4.0.68")
|
|
65
|
-
);
|
|
66
|
-
return { languageModel: e({
|
|
67
|
-
apiKey: r,
|
|
68
|
-
headers: { "anthropic-dangerous-direct-browser-access": "true" }
|
|
69
|
-
})(t) };
|
|
70
|
-
}
|
|
71
|
-
case "google": {
|
|
72
|
-
let { createGoogleGenerativeAI: e } = await import(
|
|
73
|
-
/* @vite-ignore */
|
|
74
|
-
n("@ai-sdk/google@4.0.85")
|
|
75
|
-
);
|
|
76
|
-
return { languageModel: e({ apiKey: r })(t) };
|
|
77
|
-
}
|
|
78
|
-
default: throw Error(`Unknown provider "${e}" - supported: azure, mistral, anthropic, google`);
|
|
79
|
-
}
|
|
80
|
-
}, i = async (e, t, i, a, o) => {
|
|
81
|
-
let s = (t) => e.planningAssistantOutput(t), c;
|
|
82
|
-
try {
|
|
83
|
-
c = await Promise.all([
|
|
84
|
-
import(
|
|
85
|
-
/* @vite-ignore */
|
|
86
|
-
n("ai@7.0.122")
|
|
87
|
-
),
|
|
88
|
-
r(t),
|
|
89
|
-
a()
|
|
90
|
-
]);
|
|
91
|
-
} catch (e) {
|
|
92
|
-
s({
|
|
93
|
-
type: "availability",
|
|
94
|
-
available: !1,
|
|
95
|
-
text: String(e)
|
|
96
|
-
});
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
let [{ streamText: l, stepCountIs: u }, d, { prompts: f, tools: p }] = c, m = [];
|
|
100
|
-
e.callbacks.onPlanningAssistantPrompt = async ({ text: e, images: t }) => {
|
|
101
|
-
let n = {
|
|
102
|
-
role: "user",
|
|
103
|
-
content: [{
|
|
104
|
-
type: "text",
|
|
105
|
-
text: e || f.imagePrompt
|
|
106
|
-
}, ...t.map((e) => ({
|
|
107
|
-
type: "file",
|
|
108
|
-
data: e,
|
|
109
|
-
mediaType: "image/jpeg"
|
|
110
|
-
}))]
|
|
111
|
-
}, r = o?.recovery(p), a = new AbortController(), c = () => a.abort(i.reason);
|
|
112
|
-
i.addEventListener("abort", c, { once: !0 }), i.aborted && c();
|
|
113
|
-
let h = o ? setTimeout(() => a.abort(/* @__PURE__ */ Error("The configurator assistant turn exceeded five minutes.")), o.timeoutMs) : void 0;
|
|
114
|
-
try {
|
|
115
|
-
let e = l({
|
|
116
|
-
model: d.languageModel,
|
|
117
|
-
providerOptions: d.providerOptions,
|
|
118
|
-
instructions: f.systemPrompt,
|
|
119
|
-
messages: [...m, n],
|
|
120
|
-
tools: r?.tools ?? p,
|
|
121
|
-
stopWhen: u(16),
|
|
122
|
-
abortSignal: o ? a.signal : i,
|
|
123
|
-
prepareStep: ({ stepNumber: e }) => e === 15 ? { toolChoice: "none" } : void 0
|
|
124
|
-
});
|
|
125
|
-
for await (let t of e.stream) if (t.type === "text-delta") s({
|
|
126
|
-
type: "text",
|
|
127
|
-
text: t.text
|
|
128
|
-
});
|
|
129
|
-
else if (t.type === "tool-call") s({
|
|
130
|
-
type: "activity",
|
|
131
|
-
text: t.toolName
|
|
132
|
-
});
|
|
133
|
-
else if (t.type === "error") throw t.error;
|
|
134
|
-
else if (t.type === "abort" && o) throw a.signal.reason ?? /* @__PURE__ */ Error("Turn aborted");
|
|
135
|
-
if (o && a.signal.aborted) throw a.signal.reason;
|
|
136
|
-
m.push(n, ...await e.responseMessages), s({ type: "done" });
|
|
137
|
-
} catch (e) {
|
|
138
|
-
let t = r?.summary();
|
|
139
|
-
t && m.push(n, {
|
|
140
|
-
role: "assistant",
|
|
141
|
-
content: t
|
|
142
|
-
}), s({
|
|
143
|
-
type: "error",
|
|
144
|
-
text: `The planning assistant failed: ${e instanceof Error ? e.message : String(e)}${t ? `\n\n${t}` : ""}`
|
|
145
|
-
});
|
|
146
|
-
} finally {
|
|
147
|
-
clearTimeout(h), i.removeEventListener("abort", c);
|
|
148
|
-
}
|
|
149
|
-
}, s({
|
|
150
|
-
type: "images",
|
|
151
|
-
enabled: t.readsImages
|
|
152
|
-
}), s({
|
|
153
|
-
type: "availability",
|
|
154
|
-
available: !0
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
//#endregion
|
|
158
|
-
export { r as n, t as r, i as t };
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
var e = ({ output: e }) => ({
|
|
2
|
-
type: "content",
|
|
3
|
-
value: e.content.map((e) => e.type === "text" ? {
|
|
4
|
-
type: "text",
|
|
5
|
-
text: e.text
|
|
6
|
-
} : {
|
|
7
|
-
type: "file",
|
|
8
|
-
mediaType: e.mimeType,
|
|
9
|
-
data: {
|
|
10
|
-
type: "data",
|
|
11
|
-
data: e.data
|
|
12
|
-
}
|
|
13
|
-
})
|
|
14
|
-
}), t = (t, n, r) => Object.fromEntries(t.map(({ name: t, description: i, inputSchema: a, annotations: o }) => {
|
|
15
|
-
let s = () => a;
|
|
16
|
-
return [t, {
|
|
17
|
-
type: "dynamic",
|
|
18
|
-
...o && { annotations: o },
|
|
19
|
-
description: i,
|
|
20
|
-
inputSchema: { "~standard": {
|
|
21
|
-
version: 1,
|
|
22
|
-
vendor: r,
|
|
23
|
-
validate: (e) => ({ value: e }),
|
|
24
|
-
jsonSchema: {
|
|
25
|
-
input: s,
|
|
26
|
-
output: s
|
|
27
|
-
}
|
|
28
|
-
} },
|
|
29
|
-
execute: (e) => n(t, e).catch((e) => ({
|
|
30
|
-
content: [{
|
|
31
|
-
type: "text",
|
|
32
|
-
text: e instanceof Error ? e.message : String(e)
|
|
33
|
-
}],
|
|
34
|
-
isError: !0
|
|
35
|
-
})),
|
|
36
|
-
toModelOutput: e
|
|
37
|
-
}];
|
|
38
|
-
})), n = (e) => `https://esm.sh/${e}?deps=zod@4.6.5`, r = async ({ provider: e, model: t, apiKey: r, baseUrl: i, chatCompletions: a, reasoningEffort: o }) => {
|
|
39
|
-
switch (e) {
|
|
40
|
-
case "azure": {
|
|
41
|
-
let { createAzure: e } = await import(n("@ai-sdk/azure@4.0.85")), s = e({
|
|
42
|
-
apiKey: r,
|
|
43
|
-
baseURL: i
|
|
44
|
-
});
|
|
45
|
-
return {
|
|
46
|
-
languageModel: a ? s.chat(t) : s(t),
|
|
47
|
-
providerOptions: o ? { azure: { reasoningEffort: o } } : void 0
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
case "mistral": {
|
|
51
|
-
let { createMistral: e } = await import(n("@ai-sdk/mistral@4.0.54"));
|
|
52
|
-
return { languageModel: e({ apiKey: r })(t) };
|
|
53
|
-
}
|
|
54
|
-
case "anthropic": {
|
|
55
|
-
let { createAnthropic: e } = await import(n("@ai-sdk/anthropic@4.0.68"));
|
|
56
|
-
return { languageModel: e({
|
|
57
|
-
apiKey: r,
|
|
58
|
-
headers: { "anthropic-dangerous-direct-browser-access": "true" }
|
|
59
|
-
})(t) };
|
|
60
|
-
}
|
|
61
|
-
case "google": {
|
|
62
|
-
let { createGoogleGenerativeAI: e } = await import(n("@ai-sdk/google@4.0.85"));
|
|
63
|
-
return { languageModel: e({ apiKey: r })(t) };
|
|
64
|
-
}
|
|
65
|
-
default: throw Error(`Unknown provider "${e}" - supported: azure, mistral, anthropic, google`);
|
|
66
|
-
}
|
|
67
|
-
}, i = async (e, t, i, a, o) => {
|
|
68
|
-
let s = (t) => e.planningAssistantOutput(t), c;
|
|
69
|
-
try {
|
|
70
|
-
c = await Promise.all([
|
|
71
|
-
import(n("ai@7.0.122")),
|
|
72
|
-
r(t),
|
|
73
|
-
a()
|
|
74
|
-
]);
|
|
75
|
-
} catch (e) {
|
|
76
|
-
s({
|
|
77
|
-
type: "availability",
|
|
78
|
-
available: !1,
|
|
79
|
-
text: String(e)
|
|
80
|
-
});
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
let [{ streamText: l, stepCountIs: u }, d, { prompts: f, tools: p }] = c, m = [];
|
|
84
|
-
e.callbacks.onPlanningAssistantPrompt = async ({ text: e, images: t }) => {
|
|
85
|
-
let n = {
|
|
86
|
-
role: "user",
|
|
87
|
-
content: [{
|
|
88
|
-
type: "text",
|
|
89
|
-
text: e || f.imagePrompt
|
|
90
|
-
}, ...t.map((e) => ({
|
|
91
|
-
type: "file",
|
|
92
|
-
data: e,
|
|
93
|
-
mediaType: "image/jpeg"
|
|
94
|
-
}))]
|
|
95
|
-
}, r = o?.recovery(p), a = new AbortController(), c = () => a.abort(i.reason);
|
|
96
|
-
i.addEventListener("abort", c, { once: !0 }), i.aborted && c();
|
|
97
|
-
let h = o ? setTimeout(() => a.abort(/* @__PURE__ */ Error("The configurator assistant turn exceeded five minutes.")), o.timeoutMs) : void 0;
|
|
98
|
-
try {
|
|
99
|
-
let e = l({
|
|
100
|
-
model: d.languageModel,
|
|
101
|
-
providerOptions: d.providerOptions,
|
|
102
|
-
instructions: f.systemPrompt,
|
|
103
|
-
messages: [...m, n],
|
|
104
|
-
tools: r?.tools ?? p,
|
|
105
|
-
stopWhen: u(16),
|
|
106
|
-
abortSignal: o ? a.signal : i,
|
|
107
|
-
prepareStep: ({ stepNumber: e }) => e === 15 ? { toolChoice: "none" } : void 0
|
|
108
|
-
});
|
|
109
|
-
for await (let t of e.stream) if (t.type === "text-delta") s({
|
|
110
|
-
type: "text",
|
|
111
|
-
text: t.text
|
|
112
|
-
});
|
|
113
|
-
else if (t.type === "tool-call") s({
|
|
114
|
-
type: "activity",
|
|
115
|
-
text: t.toolName
|
|
116
|
-
});
|
|
117
|
-
else {
|
|
118
|
-
if (t.type === "error") throw t.error;
|
|
119
|
-
if (t.type === "abort" && o) throw a.signal.reason ?? /* @__PURE__ */ Error("Turn aborted");
|
|
120
|
-
}
|
|
121
|
-
if (o && a.signal.aborted) throw a.signal.reason;
|
|
122
|
-
m.push(n, ...await e.responseMessages), s({ type: "done" });
|
|
123
|
-
} catch (e) {
|
|
124
|
-
let t = r?.summary();
|
|
125
|
-
t && m.push(n, {
|
|
126
|
-
role: "assistant",
|
|
127
|
-
content: t
|
|
128
|
-
}), s({
|
|
129
|
-
type: "error",
|
|
130
|
-
text: `The planning assistant failed: ${e instanceof Error ? e.message : String(e)}${t ? `\n\n${t}` : ""}`
|
|
131
|
-
});
|
|
132
|
-
} finally {
|
|
133
|
-
clearTimeout(h), i.removeEventListener("abort", c);
|
|
134
|
-
}
|
|
135
|
-
}, s({
|
|
136
|
-
type: "images",
|
|
137
|
-
enabled: t.readsImages
|
|
138
|
-
}), s({
|
|
139
|
-
type: "availability",
|
|
140
|
-
available: !0
|
|
141
|
-
});
|
|
142
|
-
};
|
|
143
|
-
export { r as n, t as r, i as t };
|
|
File without changes
|
|
File without changes
|