@roomle/embedding-lib 8.2.0 → 9.0.0-alpha.2
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/docs/md/web/embedding/CHANGELOG.md +251 -133
- package/{drag-ghost-BxqPJdhq.mjs → drag-ghost-BOwjMbG3.mjs} +1 -1
- package/{drag-ghost-CDFtC1pd.mjs → drag-ghost-BQ8r6NVo.mjs} +1 -1
- package/{drag-in-CV1E-DO6.mjs → drag-in-BP_E53zb.mjs} +2 -2
- package/{drag-in-ClPpCYyi.mjs → drag-in-QhL3zGC0.mjs} +2 -2
- package/embedding-plugins.js +1 -1
- package/embedding-plugins.min.js +1 -1
- package/{from-custom-view-Q9A-J7qV.mjs → from-custom-view-BM_zRJCf.mjs} +2 -2
- package/{from-custom-view-Sx6P6iDI.mjs → from-custom-view-D2Z1YmCx.mjs} +2 -2
- package/{from-website-DZJy_l42.mjs → from-website-CPVeVVMI.mjs} +2 -2
- package/{from-website-BmCO2xli.mjs → from-website-DlklVbxU.mjs} +2 -2
- package/hi-mcp-server-BiZlFkBm.mjs +4866 -0
- package/hi-mcp-server-DTQnrykg.mjs +5278 -0
- package/hi.js +110 -2
- package/hi.min.js +95 -2
- package/package.json +1 -1
- package/packages/embedding-lib/src/hi.d.ts +4 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/agent-facing.d.ts +35 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/hi-mcp-server.d.ts +3 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/mcp-tool-types.d.ts +57 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/mcp-tool.d.ts +13 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/plan-history.d.ts +33 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/planner-api.d.ts +32 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/skills.d.ts +23 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp/tool-executors.d.ts +4 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-mcp-tools.d.ts +11 -0
- package/packages/embedding-lib/src/homag-intelligence/hi-planning-assistant.d.ts +55 -0
- package/roomle-embedding-lib.js +64 -57
- package/roomle-embedding-lib.min.js +9 -2
package/hi.js
CHANGED
|
@@ -65,10 +65,118 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
65
65
|
}, window.addEventListener("message", h);
|
|
66
66
|
}, _ = () => {
|
|
67
67
|
h &&= (window.removeEventListener("message", h), null);
|
|
68
|
-
}, v = {
|
|
68
|
+
}, v = async (e) => (await import("./hi-mcp-server-DTQnrykg.mjs")).createHiMcpTools(e), y = (e) => `https://esm.sh/${e}?deps=zod@4.6.5`, b = 16, x = async ({ provider: e, model: t, apiKey: n, baseUrl: r, chatCompletions: i, reasoningEffort: a }) => {
|
|
69
|
+
switch (e) {
|
|
70
|
+
case "azure": {
|
|
71
|
+
let { createAzure: e } = await import(
|
|
72
|
+
/* @vite-ignore */
|
|
73
|
+
y("@ai-sdk/azure@4.0.85")
|
|
74
|
+
), o = e({
|
|
75
|
+
apiKey: n,
|
|
76
|
+
baseURL: r
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
languageModel: i ? o.chat(t) : o(t),
|
|
80
|
+
providerOptions: a ? { azure: { reasoningEffort: a } } : void 0
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
case "mistral": {
|
|
84
|
+
let { createMistral: e } = await import(
|
|
85
|
+
/* @vite-ignore */
|
|
86
|
+
y("@ai-sdk/mistral@4.0.54")
|
|
87
|
+
);
|
|
88
|
+
return { languageModel: e({ apiKey: n })(t) };
|
|
89
|
+
}
|
|
90
|
+
case "anthropic": {
|
|
91
|
+
let { createAnthropic: e } = await import(
|
|
92
|
+
/* @vite-ignore */
|
|
93
|
+
y("@ai-sdk/anthropic@4.0.68")
|
|
94
|
+
);
|
|
95
|
+
return { languageModel: e({
|
|
96
|
+
apiKey: n,
|
|
97
|
+
headers: { "anthropic-dangerous-direct-browser-access": "true" }
|
|
98
|
+
})(t) };
|
|
99
|
+
}
|
|
100
|
+
case "google": {
|
|
101
|
+
let { createGoogleGenerativeAI: e } = await import(
|
|
102
|
+
/* @vite-ignore */
|
|
103
|
+
y("@ai-sdk/google@4.0.85")
|
|
104
|
+
);
|
|
105
|
+
return { languageModel: e({ apiKey: n })(t) };
|
|
106
|
+
}
|
|
107
|
+
default: throw Error(`Unknown provider "${e}" - supported: azure, mistral, anthropic, google`);
|
|
108
|
+
}
|
|
109
|
+
}, S = async (e, t, n) => {
|
|
110
|
+
let r = e.extended, i = (e) => r.planningAssistantOutput(e), a;
|
|
111
|
+
try {
|
|
112
|
+
a = await Promise.all([
|
|
113
|
+
import(
|
|
114
|
+
/* @vite-ignore */
|
|
115
|
+
y("ai@7.0.122")
|
|
116
|
+
),
|
|
117
|
+
x(t),
|
|
118
|
+
r.getExternalObjectAgentPrompts(),
|
|
119
|
+
v(e)
|
|
120
|
+
]);
|
|
121
|
+
} catch (e) {
|
|
122
|
+
console.log("[planning-assistant]", String(e)), i({
|
|
123
|
+
type: "availability",
|
|
124
|
+
available: !1,
|
|
125
|
+
text: String(e)
|
|
126
|
+
});
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
let [{ streamText: o, stepCountIs: s }, c, l, u] = a, d = [];
|
|
130
|
+
r.callbacks.onPlanningAssistantPrompt = async ({ text: e, images: t }) => {
|
|
131
|
+
let r = {
|
|
132
|
+
role: "user",
|
|
133
|
+
content: [{
|
|
134
|
+
type: "text",
|
|
135
|
+
text: e || l.imagePrompt
|
|
136
|
+
}, ...t.map((e) => ({
|
|
137
|
+
type: "file",
|
|
138
|
+
data: e,
|
|
139
|
+
mediaType: "image/jpeg"
|
|
140
|
+
}))]
|
|
141
|
+
};
|
|
142
|
+
try {
|
|
143
|
+
let e = o({
|
|
144
|
+
model: c.languageModel,
|
|
145
|
+
providerOptions: c.providerOptions,
|
|
146
|
+
instructions: l.systemPrompt,
|
|
147
|
+
messages: [...d, r],
|
|
148
|
+
tools: u,
|
|
149
|
+
stopWhen: s(b),
|
|
150
|
+
abortSignal: n,
|
|
151
|
+
prepareStep: ({ stepNumber: e }) => e === b - 1 ? { toolChoice: "none" } : void 0
|
|
152
|
+
});
|
|
153
|
+
for await (let t of e.stream) if (t.type === "text-delta") i({
|
|
154
|
+
type: "text",
|
|
155
|
+
text: t.text
|
|
156
|
+
});
|
|
157
|
+
else if (t.type === "tool-call") i({
|
|
158
|
+
type: "activity",
|
|
159
|
+
text: t.toolName
|
|
160
|
+
});
|
|
161
|
+
else if (t.type === "error") throw t.error;
|
|
162
|
+
d.push(r, ...await e.responseMessages), i({ type: "done" });
|
|
163
|
+
} catch (e) {
|
|
164
|
+
console.log("[planning-assistant]", String(e)), i({
|
|
165
|
+
type: "error",
|
|
166
|
+
text: `The planning assistant failed: ${e instanceof Error ? e.message : String(e)}`
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}, i({
|
|
170
|
+
type: "images",
|
|
171
|
+
enabled: t.readsImages
|
|
172
|
+
}), i({
|
|
173
|
+
type: "availability",
|
|
174
|
+
available: !0
|
|
175
|
+
});
|
|
176
|
+
}, C = {
|
|
69
177
|
HIDE: "hide",
|
|
70
178
|
SHOW_ATTRIBUTES: "attributes",
|
|
71
179
|
SHOW_ARTICLES: "articles"
|
|
72
180
|
};
|
|
73
181
|
//#endregion
|
|
74
|
-
export {
|
|
182
|
+
export { C as HI_PANEL_ACTION, _ as cleanupHi, d as createHiLibraryCallbacks, v as createHiMcpTools, c as libLoadArticleCatalog, u as libLoadCalcScript, l as libLoadMasterData, x as loadChatModel, p as omGetRequest, f as omPostRequest, a as registerLegacyUrlFormat, g as setupHi, S as startPlanningAssistant, o as unregisterLegacyUrlFormat };
|
package/hi.min.js
CHANGED
|
@@ -66,9 +66,102 @@ var n = (e, t) => t === e.libraryId ? e : {
|
|
|
66
66
|
}, window.addEventListener("message", m);
|
|
67
67
|
}, g = () => {
|
|
68
68
|
m &&= (window.removeEventListener("message", m), null);
|
|
69
|
-
}, _ = {
|
|
69
|
+
}, _ = async (e) => (await import("./hi-mcp-server-BiZlFkBm.mjs")).createHiMcpTools(e), v = (e) => `https://esm.sh/${e}?deps=zod@4.6.5`, y = async ({ provider: e, model: t, apiKey: n, baseUrl: r, chatCompletions: i, reasoningEffort: a }) => {
|
|
70
|
+
switch (e) {
|
|
71
|
+
case "azure": {
|
|
72
|
+
let { createAzure: e } = await import(v("@ai-sdk/azure@4.0.85")), o = e({
|
|
73
|
+
apiKey: n,
|
|
74
|
+
baseURL: r
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
languageModel: i ? o.chat(t) : o(t),
|
|
78
|
+
providerOptions: a ? { azure: { reasoningEffort: a } } : void 0
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
case "mistral": {
|
|
82
|
+
let { createMistral: e } = await import(v("@ai-sdk/mistral@4.0.54"));
|
|
83
|
+
return { languageModel: e({ apiKey: n })(t) };
|
|
84
|
+
}
|
|
85
|
+
case "anthropic": {
|
|
86
|
+
let { createAnthropic: e } = await import(v("@ai-sdk/anthropic@4.0.68"));
|
|
87
|
+
return { languageModel: e({
|
|
88
|
+
apiKey: n,
|
|
89
|
+
headers: { "anthropic-dangerous-direct-browser-access": "true" }
|
|
90
|
+
})(t) };
|
|
91
|
+
}
|
|
92
|
+
case "google": {
|
|
93
|
+
let { createGoogleGenerativeAI: e } = await import(v("@ai-sdk/google@4.0.85"));
|
|
94
|
+
return { languageModel: e({ apiKey: n })(t) };
|
|
95
|
+
}
|
|
96
|
+
default: throw Error(`Unknown provider "${e}" - supported: azure, mistral, anthropic, google`);
|
|
97
|
+
}
|
|
98
|
+
}, b = async (e, t, n) => {
|
|
99
|
+
let r = e.extended, i = (e) => r.planningAssistantOutput(e), a;
|
|
100
|
+
try {
|
|
101
|
+
a = await Promise.all([
|
|
102
|
+
import(v("ai@7.0.122")),
|
|
103
|
+
y(t),
|
|
104
|
+
r.getExternalObjectAgentPrompts(),
|
|
105
|
+
_(e)
|
|
106
|
+
]);
|
|
107
|
+
} catch (e) {
|
|
108
|
+
i({
|
|
109
|
+
type: "availability",
|
|
110
|
+
available: !1,
|
|
111
|
+
text: String(e)
|
|
112
|
+
});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
let [{ streamText: o, stepCountIs: s }, c, l, u] = a, d = [];
|
|
116
|
+
r.callbacks.onPlanningAssistantPrompt = async ({ text: e, images: t }) => {
|
|
117
|
+
let r = {
|
|
118
|
+
role: "user",
|
|
119
|
+
content: [{
|
|
120
|
+
type: "text",
|
|
121
|
+
text: e || l.imagePrompt
|
|
122
|
+
}, ...t.map((e) => ({
|
|
123
|
+
type: "file",
|
|
124
|
+
data: e,
|
|
125
|
+
mediaType: "image/jpeg"
|
|
126
|
+
}))]
|
|
127
|
+
};
|
|
128
|
+
try {
|
|
129
|
+
let e = o({
|
|
130
|
+
model: c.languageModel,
|
|
131
|
+
providerOptions: c.providerOptions,
|
|
132
|
+
instructions: l.systemPrompt,
|
|
133
|
+
messages: [...d, r],
|
|
134
|
+
tools: u,
|
|
135
|
+
stopWhen: s(16),
|
|
136
|
+
abortSignal: n,
|
|
137
|
+
prepareStep: ({ stepNumber: e }) => e === 15 ? { toolChoice: "none" } : void 0
|
|
138
|
+
});
|
|
139
|
+
for await (let t of e.stream) if (t.type === "text-delta") i({
|
|
140
|
+
type: "text",
|
|
141
|
+
text: t.text
|
|
142
|
+
});
|
|
143
|
+
else if (t.type === "tool-call") i({
|
|
144
|
+
type: "activity",
|
|
145
|
+
text: t.toolName
|
|
146
|
+
});
|
|
147
|
+
else if (t.type === "error") throw t.error;
|
|
148
|
+
d.push(r, ...await e.responseMessages), i({ type: "done" });
|
|
149
|
+
} catch (e) {
|
|
150
|
+
i({
|
|
151
|
+
type: "error",
|
|
152
|
+
text: `The planning assistant failed: ${e instanceof Error ? e.message : String(e)}`
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}, i({
|
|
156
|
+
type: "images",
|
|
157
|
+
enabled: t.readsImages
|
|
158
|
+
}), i({
|
|
159
|
+
type: "availability",
|
|
160
|
+
available: !0
|
|
161
|
+
});
|
|
162
|
+
}, x = {
|
|
70
163
|
HIDE: "hide",
|
|
71
164
|
SHOW_ATTRIBUTES: "attributes",
|
|
72
165
|
SHOW_ARTICLES: "articles"
|
|
73
166
|
};
|
|
74
|
-
export {
|
|
167
|
+
export { x as HI_PANEL_ACTION, g as cleanupHi, d as createHiLibraryCallbacks, _ as createHiMcpTools, c as libLoadArticleCatalog, u as libLoadCalcScript, l as libLoadMasterData, y as loadChatModel, p as omGetRequest, f as omPostRequest, a as registerLegacyUrlFormat, h as setupHi, b as startPlanningAssistant, o as unregisterLegacyUrlFormat };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roomle/embedding-lib",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0-alpha.2",
|
|
4
4
|
"description": "This is a small library which can be used to communicate with the Roomle Configurator. ES modules only (browser-compatible).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./roomle-embedding-lib.js",
|
|
@@ -14,5 +14,9 @@ export { createHiLibraryCallbacks } from './homag-intelligence/hi-callbacks';
|
|
|
14
14
|
export { libLoadArticleCatalog, libLoadMasterData, libLoadCalcScript, registerLegacyUrlFormat, unregisterLegacyUrlFormat, } from './homag-intelligence/hi-requests';
|
|
15
15
|
export { omPostRequest, omGetRequest, } from './homag-intelligence/hi-order-manager';
|
|
16
16
|
export { setupHi, cleanupHi } from './homag-intelligence/hi-setup';
|
|
17
|
+
export { createHiMcpTools } from './homag-intelligence/hi-mcp-tools';
|
|
18
|
+
export type { HiMcpTool, HiMcpTools, } from './homag-intelligence/hi-mcp/mcp-tool-types';
|
|
19
|
+
export type { HiMcpPlannerApi } from './homag-intelligence/hi-mcp/planner-api';
|
|
20
|
+
export { loadChatModel, startPlanningAssistant, type PlanningAssistantConfig, type PlanningAssistantPlannerApi, } from './homag-intelligence/hi-planning-assistant';
|
|
17
21
|
export { type ExternalObjectSnapshotSaveResult, type HiContextAction, } from '../../web-sdk/packages';
|
|
18
22
|
export { HI_PANEL_ACTION, type HiPanelActionType, type HiOrderHeader, type HiOrder, type HiOrderData, type HiPriceData, type HiCallbacks, } from '../../common/src/hi/hi-types';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
type WallSide = 'left' | 'right' | 'top' | 'bottom';
|
|
2
|
+
interface DerivedWall {
|
|
3
|
+
index: number;
|
|
4
|
+
side: WallSide;
|
|
5
|
+
start: [number, number, number];
|
|
6
|
+
end: [number, number, number];
|
|
7
|
+
lengthMm: number;
|
|
8
|
+
type?: string;
|
|
9
|
+
thicknessMm?: number;
|
|
10
|
+
facingRotationY: number;
|
|
11
|
+
}
|
|
12
|
+
export declare const wallName: (side: WallSide) => string;
|
|
13
|
+
export interface RoomCorner {
|
|
14
|
+
name: string;
|
|
15
|
+
point: [number, number, number];
|
|
16
|
+
posRotationY: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const roomCorners: (walls: DerivedWall[]) => RoomCorner[];
|
|
19
|
+
export declare const spanAlongWall: (wall: DerivedWall, points: [number, number][]) => [number, number];
|
|
20
|
+
export interface WallOfOpening {
|
|
21
|
+
roomIndex: number;
|
|
22
|
+
wall: number;
|
|
23
|
+
fromEndMm: [number, number];
|
|
24
|
+
}
|
|
25
|
+
export declare const wallOfOpening: (outline: [number, number][], rooms: {
|
|
26
|
+
walls?: DerivedWall[];
|
|
27
|
+
}[]) => WallOfOpening | undefined;
|
|
28
|
+
export declare const withSharedSelectionsOnce: (attributes: any[]) => any[];
|
|
29
|
+
export declare const agentFacingAttributes: (masterData: any) => {
|
|
30
|
+
[k: string]: any[];
|
|
31
|
+
};
|
|
32
|
+
export declare const agentFacingArticle: (article: any) => any;
|
|
33
|
+
export declare const agentFacingRooms: (rooms: any) => any;
|
|
34
|
+
export declare const agentFacingObstacles: (obstacles: any, rooms: any) => any;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** The result of a tool as an MCP server answers `tools/call`. */
|
|
2
|
+
export interface McpToolResult {
|
|
3
|
+
content: ({
|
|
4
|
+
type: 'text';
|
|
5
|
+
text: string;
|
|
6
|
+
} | {
|
|
7
|
+
type: 'image';
|
|
8
|
+
data: string;
|
|
9
|
+
mimeType: string;
|
|
10
|
+
})[];
|
|
11
|
+
isError?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** What the model gets of a tool result, as `@ai-sdk/mcp` hands it to the AI SDK. */
|
|
14
|
+
export interface HiMcpModelOutput {
|
|
15
|
+
type: 'content';
|
|
16
|
+
value: ({
|
|
17
|
+
type: 'text';
|
|
18
|
+
text: string;
|
|
19
|
+
} | {
|
|
20
|
+
type: 'file';
|
|
21
|
+
mediaType: string;
|
|
22
|
+
data: {
|
|
23
|
+
type: 'data';
|
|
24
|
+
data: string;
|
|
25
|
+
};
|
|
26
|
+
})[];
|
|
27
|
+
}
|
|
28
|
+
/** The input schema of a tool as a Standard Schema with its JSON Schema. */
|
|
29
|
+
export interface HiMcpInputSchema {
|
|
30
|
+
'~standard': {
|
|
31
|
+
version: 1;
|
|
32
|
+
vendor: string;
|
|
33
|
+
validate: (value: unknown) => {
|
|
34
|
+
value: unknown;
|
|
35
|
+
};
|
|
36
|
+
jsonSchema: {
|
|
37
|
+
input: (options: {
|
|
38
|
+
target: string;
|
|
39
|
+
}) => Record<string, unknown>;
|
|
40
|
+
output: (options: {
|
|
41
|
+
target: string;
|
|
42
|
+
}) => Record<string, unknown>;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** A tool of the HI MCP tool set, in the shape of an AI SDK dynamic tool. */
|
|
47
|
+
export interface HiMcpTool {
|
|
48
|
+
type: 'dynamic';
|
|
49
|
+
description: string;
|
|
50
|
+
inputSchema: HiMcpInputSchema;
|
|
51
|
+
execute: (input: unknown) => Promise<McpToolResult>;
|
|
52
|
+
toModelOutput: (options: {
|
|
53
|
+
output: McpToolResult;
|
|
54
|
+
}) => HiMcpModelOutput;
|
|
55
|
+
}
|
|
56
|
+
/** The HI MCP tools by name, the tool set an AI SDK `streamText` takes. */
|
|
57
|
+
export type HiMcpTools = Record<string, HiMcpTool>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { HiMcpModelOutput, HiMcpTool, McpToolResult } from './mcp-tool-types';
|
|
3
|
+
/** The tool result as `@ai-sdk/mcp` passes it to the model: text parts and images as file parts. */
|
|
4
|
+
export declare const mcpToModelOutput: ({ output, }: {
|
|
5
|
+
output: McpToolResult;
|
|
6
|
+
}) => HiMcpModelOutput;
|
|
7
|
+
/**
|
|
8
|
+
* A tool as an MCP server registers it and an MCP client hands it to the AI
|
|
9
|
+
* SDK: the JSON Schema the MCP SDK serves, which the AI SDK does not validate;
|
|
10
|
+
* the input validated here, an invalid input and a thrown error answered as
|
|
11
|
+
* MCP error results, which the model reads like any other result.
|
|
12
|
+
*/
|
|
13
|
+
export declare const mcpTool: (name: string, description: string, shape: z.ZodRawShape, handler: (args: any) => Promise<McpToolResult>) => HiMcpTool;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** A tool call that changed the plan, as the undo tool reverts it. */
|
|
2
|
+
export interface ToolCallRecord {
|
|
3
|
+
tool: string;
|
|
4
|
+
/** The planner steps the call put on the planner's undo history. */
|
|
5
|
+
steps: number;
|
|
6
|
+
/** The plan's groups before and after the call, as comparison keys. */
|
|
7
|
+
groupsBefore: string;
|
|
8
|
+
groupsAfter: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class PlanHistory {
|
|
11
|
+
private _events;
|
|
12
|
+
private _inFlight;
|
|
13
|
+
private _done;
|
|
14
|
+
private _undone;
|
|
15
|
+
private _changedInPlanner;
|
|
16
|
+
private _waiters;
|
|
17
|
+
get events(): number;
|
|
18
|
+
get changedInPlanner(): boolean;
|
|
19
|
+
historyChanged(): void;
|
|
20
|
+
/** Resolves true once `count` events have arrived, false after the timeout. */
|
|
21
|
+
waitForEvents(count: number, timeoutMs: number): Promise<boolean>;
|
|
22
|
+
begin(): void;
|
|
23
|
+
end(): void;
|
|
24
|
+
/** A new change on top of the history ends redo, as in the planner. */
|
|
25
|
+
record(call: ToolCallRecord): void;
|
|
26
|
+
lastDone(): ToolCallRecord | undefined;
|
|
27
|
+
lastUndone(): ToolCallRecord | undefined;
|
|
28
|
+
markUndone(): void;
|
|
29
|
+
markRedone(): void;
|
|
30
|
+
forget(): void;
|
|
31
|
+
/** A change in the planner was found: no record can be trusted any more. */
|
|
32
|
+
markChangedInPlanner(): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const DEFAULT_CALL_TIMEOUT_MS = 30000;
|
|
2
|
+
export declare const SNAPSHOT_CALL_TIMEOUT_MS = 120000;
|
|
3
|
+
export interface PlannerApi {
|
|
4
|
+
extended: {
|
|
5
|
+
getExternalObjectPlanContext(include: string[], options?: {
|
|
6
|
+
interiorDesign: {
|
|
7
|
+
groupId: string;
|
|
8
|
+
rootId?: string;
|
|
9
|
+
containerModuleId?: string;
|
|
10
|
+
articleId?: string;
|
|
11
|
+
};
|
|
12
|
+
}): Promise<any>;
|
|
13
|
+
externalObjectGroupOperation(command: string, payload: Record<string, unknown>): Promise<any>;
|
|
14
|
+
fetchPrice(): Promise<any>;
|
|
15
|
+
getExternalObjectSnapshot(options: Record<string, boolean>): Promise<any>;
|
|
16
|
+
undo(): Promise<void>;
|
|
17
|
+
redo(): Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The planner API a host hands to the HI MCP tools: the six planner methods
|
|
22
|
+
* the tools call, and the planner's callbacks, whose `onHistoryChange` the
|
|
23
|
+
* tools chain to tell their own planner steps from the user's changes.
|
|
24
|
+
*/
|
|
25
|
+
export type HiMcpPlannerApi = PlannerApi & {
|
|
26
|
+
extended: {
|
|
27
|
+
callbacks: {
|
|
28
|
+
onHistoryChange?: (undo: boolean, redo: boolean) => void;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare const createPlannerApi: ({ extended }: PlannerApi) => PlannerApi;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** A frontmatter field as YAML reads it: a scalar, or a nested field (metadata) as an object of scalars. */
|
|
2
|
+
export type FrontmatterValue = string | Record<string, string>;
|
|
3
|
+
/** A planning skill in the Agent Skills format: a directory with SKILL.md and supporting files. */
|
|
4
|
+
export interface Skill {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
frontmatter: Record<string, FrontmatterValue>;
|
|
8
|
+
/** The text of every file of the skill by its path in the skill's directory. */
|
|
9
|
+
texts: Record<string, string>;
|
|
10
|
+
files: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare const SKILL_FILE = "SKILL.md";
|
|
13
|
+
/**
|
|
14
|
+
* Reads every skill of the skills directory, given as the text of each file by
|
|
15
|
+
* its path below the directory; a broken skill fails the load and names its
|
|
16
|
+
* file.
|
|
17
|
+
*/
|
|
18
|
+
export declare const loadSkills: (files: Record<string, string>) => Skill[];
|
|
19
|
+
/** One line per skill: its name and its description. */
|
|
20
|
+
export declare const skillIndex: (skills: Skill[]) => string;
|
|
21
|
+
/** A file of a skill by its path; only a file of the skill's list is read. */
|
|
22
|
+
export declare const readSkillFile: (skills: Skill[], name: string, file?: string) => string;
|
|
23
|
+
export declare const skills: Skill[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PlanHistory } from './plan-history';
|
|
2
|
+
import { PlannerApi } from './planner-api';
|
|
3
|
+
export type ToolExecutor = (roomDesignerApi: PlannerApi, args: Record<string, unknown>) => Promise<unknown>;
|
|
4
|
+
export declare const createToolExecutors: (planHistory: PlanHistory) => Record<string, ToolExecutor>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HiMcpTools } from './hi-mcp/mcp-tool-types';
|
|
2
|
+
import { HiMcpPlannerApi } from './hi-mcp/planner-api';
|
|
3
|
+
/**
|
|
4
|
+
* Creates the HI MCP tools for an AI agent that plans in the planner of this
|
|
5
|
+
* page: the tools of the HI MCP server as an AI SDK tool set, without the MCP
|
|
6
|
+
* protocol. The host passes the tool set as `tools` to its own `streamText`.
|
|
7
|
+
* The tools call the planner through `roomDesignerApi.extended` and chain its
|
|
8
|
+
* `onHistoryChange` callback; a host that sets its own handler sets it before.
|
|
9
|
+
* The tool code is loaded on the first call.
|
|
10
|
+
*/
|
|
11
|
+
export declare const createHiMcpTools: (roomDesignerApi: HiMcpPlannerApi) => Promise<HiMcpTools>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { PlanningAssistantOutput, PlanningAssistantPrompt } from '../../../web-sdk/packages';
|
|
2
|
+
import { HiMcpPlannerApi } from './hi-mcp/planner-api';
|
|
3
|
+
/**
|
|
4
|
+
* The model of the AI Planning Assistant as a JSON object: everything
|
|
5
|
+
* `loadChatModel` and `startPlanningAssistant` need to reach it.
|
|
6
|
+
*/
|
|
7
|
+
export interface PlanningAssistantConfig {
|
|
8
|
+
/** `azure` for a deployment on an Azure AI Foundry resource, else the provider of the model. */
|
|
9
|
+
provider: 'azure' | 'mistral' | 'anthropic' | 'google';
|
|
10
|
+
/** The model id at the provider; for `azure` the name of the deployment. */
|
|
11
|
+
model: string;
|
|
12
|
+
/** The API key of the provider; for `azure` the key of the Foundry resource. */
|
|
13
|
+
apiKey: string;
|
|
14
|
+
/** `azure` only: the OpenAI v1 endpoint of the Foundry resource, e.g. `https://<resource>.services.ai.azure.com/openai/v1`. */
|
|
15
|
+
baseUrl?: string;
|
|
16
|
+
/** `azure` only: call the deployment through the Chat Completions API instead of the Responses API. */
|
|
17
|
+
chatCompletions?: boolean;
|
|
18
|
+
/** `azure` only: the reasoning effort of the deployment; its default when unset. */
|
|
19
|
+
reasoningEffort?: string;
|
|
20
|
+
/** Whether the model reads images: the window offers the image drop only then. */
|
|
21
|
+
readsImages: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** The planner the planning assistant runs in: the HI MCP tools' planner API, the agent prompts and the window. */
|
|
24
|
+
export type PlanningAssistantPlannerApi = HiMcpPlannerApi & {
|
|
25
|
+
extended: {
|
|
26
|
+
getExternalObjectAgentPrompts(): Promise<{
|
|
27
|
+
systemPrompt: string;
|
|
28
|
+
imagePrompt: string;
|
|
29
|
+
}>;
|
|
30
|
+
planningAssistantOutput(part: PlanningAssistantOutput): unknown;
|
|
31
|
+
callbacks: {
|
|
32
|
+
onPlanningAssistantPrompt?: (prompt: PlanningAssistantPrompt) => Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/** The AI SDK language model of the config and the provider options `streamText` takes with it. */
|
|
37
|
+
export declare const loadChatModel: ({ provider, model, apiKey, baseUrl, chatCompletions, reasoningEffort, }: PlanningAssistantConfig) => Promise<{
|
|
38
|
+
languageModel: any;
|
|
39
|
+
providerOptions: {
|
|
40
|
+
azure: {
|
|
41
|
+
reasoningEffort: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
} | {
|
|
45
|
+
languageModel: any;
|
|
46
|
+
providerOptions?: undefined;
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* Runs the planning agent of the AI Planning Assistant window
|
|
50
|
+
* (featureFlags.planningAssistant) in this page: the window hands every
|
|
51
|
+
* message to "onPlanningAssistantPrompt", the agent calls the HI MCP tools,
|
|
52
|
+
* the tools call the planner of this page, and the agent's output goes to
|
|
53
|
+
* "planningAssistantOutput". Aborting the signal ends a running turn.
|
|
54
|
+
*/
|
|
55
|
+
export declare const startPlanningAssistant: (roomDesignerApi: PlanningAssistantPlannerApi, config: PlanningAssistantConfig, signal: AbortSignal) => Promise<void>;
|