windmill-components 1.700.2 → 1.700.3
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/dist/appPolicy/myFunction.es.js +1337 -0
- package/dist/sharedUtils/common.d.ts +2 -5
- package/dist/sharedUtils/components/apps/components/display/dbtable/queries/select.d.ts +0 -2
- package/dist/sharedUtils/components/apps/components/display/dbtable/utils.d.ts +3 -14
- package/dist/sharedUtils/components/apps/editor/appPolicy.d.ts +1 -1
- package/dist/sharedUtils/components/apps/editor/appUtilsS3.d.ts +1 -12
- package/dist/sharedUtils/components/apps/editor/component/components.d.ts +2 -68
- package/dist/sharedUtils/components/apps/inputType.d.ts +2 -4
- package/dist/sharedUtils/components/apps/sharedTypes.d.ts +0 -2
- package/dist/sharedUtils/components/dbTypes.d.ts +0 -3
- package/dist/sharedUtils/components/raw_apps/rawAppPolicy.d.ts +1 -1
- package/dist/sharedUtils/components/raw_apps/utils.d.ts +1 -1
- package/dist/sharedUtils/components/triggers/utils.d.ts +3 -2
- package/dist/sharedUtils/gen/schemas.gen.d.ts +71 -915
- package/dist/sharedUtils/gen/services.gen.d.ts +23 -329
- package/dist/sharedUtils/gen/types.gen.d.ts +141 -1870
- package/dist/sharedUtils/hub.d.ts +0 -1
- package/dist/sharedUtils/jsr.json +5 -5
- package/dist/sharedUtils/lib.d.ts +1 -1
- package/dist/sharedUtils/lib.es.js +79 -241
- package/dist/sharedUtils/package.json +11 -11
- package/dist/sharedUtils/stores.d.ts +0 -1
- package/dist/sharedUtils/svelte5Utils.svelte.d.ts +1 -32
- package/dist/sharedUtils/utils.d.ts +4 -19
- package/package/components/DisplayResultControlBar.svelte +26 -11
- package/package/components/JobArgs.svelte +43 -24
- package/package/components/ShareModal.svelte.d.ts +1 -1
- package/package/components/apps/components/helpers/RunnableComponent.svelte.d.ts +0 -3
- package/package/components/copilot/CustomAIPrompts.svelte +3 -2
- package/package/components/copilot/chat/AIChatInput.svelte +2 -0
- package/package/components/copilot/chat/AIChatManager.svelte.js +52 -14
- package/package/components/copilot/chat/CreatedResourceActionDrawers.svelte +15 -0
- package/package/components/copilot/chat/ToolMessageActions.svelte +4 -2
- package/package/components/copilot/chat/app/core.js +2 -30
- package/package/components/copilot/chat/flow/core.js +13 -351
- package/package/components/copilot/chat/flow/editableFlowJson.d.ts +52 -0
- package/package/components/copilot/chat/flow/editableFlowJson.js +328 -0
- package/package/components/copilot/chat/flow/inlineScriptsUtils.js +2 -2
- package/package/components/copilot/chat/global/core.d.ts +5 -0
- package/package/components/copilot/chat/global/core.js +1739 -0
- package/package/components/copilot/chat/global/core.test.d.ts +1 -0
- package/package/components/copilot/chat/global/core.test.js +123 -0
- package/package/components/copilot/chat/global/deployRequests.d.ts +7 -0
- package/package/components/copilot/chat/global/deployRequests.js +76 -0
- package/package/components/copilot/chat/global/deployRequests.test.d.ts +1 -0
- package/package/components/copilot/chat/global/deployRequests.test.js +142 -0
- package/package/components/copilot/chat/global/draftStore.svelte.d.ts +55 -0
- package/package/components/copilot/chat/global/draftStore.svelte.js +78 -0
- package/package/components/copilot/chat/global/draftStore.test.d.ts +1 -0
- package/package/components/copilot/chat/global/draftStore.test.js +44 -0
- package/package/components/copilot/chat/global/gate.d.ts +1 -0
- package/package/components/copilot/chat/global/gate.js +27 -0
- package/package/components/copilot/chat/shared.d.ts +16 -2
- package/package/components/copilot/chat/shared.js +40 -0
- package/package/components/copilot/chat/workspaceToolsZod.gen.d.ts +28 -9
- package/package/components/copilot/chat/workspaceToolsZod.gen.js +19 -0
- package/package/components/raw_apps/templates.d.ts +77 -0
- package/package/components/raw_apps/templates.js +618 -0
- package/package/components/runs/runsFilter.d.ts +1 -1
- package/package/components/settings/AIPromptsModal.svelte +5 -2
- package/package/components/triggers/azure/AzureTriggerEditorConfigSection.svelte.d.ts +1 -1
- package/package/gen/core/OpenAPI.js +1 -1
- package/package/gen/schemas.gen.d.ts +37 -355
- package/package/gen/schemas.gen.js +39 -359
- package/package/gen/services.gen.d.ts +4 -280
- package/package/gen/services.gen.js +7 -565
- package/package/gen/types.gen.d.ts +77 -1135
- package/package/system_prompts/index.d.ts +2 -0
- package/package/system_prompts/index.js +8 -0
- package/package/system_prompts/prompts.d.ts +2 -0
- package/package/system_prompts/prompts.js +381 -0
- package/package/utils_deployable.d.ts +5 -318
- package/package.json +1 -1
- package/dist/sharedUtils/components/assets/lib.d.ts +0 -25
- package/dist/sharedUtils/components/icons/index.d.ts +0 -101
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { collectAllFlowModuleIdsFromModules } from '../../../flows/flowTree';
|
|
3
|
+
import { SPECIAL_MODULE_IDS } from '../shared';
|
|
4
|
+
import { validateFlowGroups } from './helperUtils';
|
|
5
|
+
import { flowModuleSchema, flowModulesSchema } from './openFlowZod.gen';
|
|
6
|
+
/**
|
|
7
|
+
* Navigate to a schema at a given path, handling arrays, objects, unions, and wrappers.
|
|
8
|
+
* Uses Zod 4 internal structure.
|
|
9
|
+
*/
|
|
10
|
+
function getSchemaAtPath(schema, path, data) {
|
|
11
|
+
let current = schema;
|
|
12
|
+
let currentData = data;
|
|
13
|
+
for (let i = 0; i < path.length; i++) {
|
|
14
|
+
const segment = path[i];
|
|
15
|
+
if (!current || !current._def)
|
|
16
|
+
return null;
|
|
17
|
+
let type = current._def.type;
|
|
18
|
+
// Unwrap optional/nullable/default/catch
|
|
19
|
+
while (['optional', 'nullable', 'default', 'catch'].includes(type)) {
|
|
20
|
+
current = current._def.innerType;
|
|
21
|
+
if (!current || !current._def)
|
|
22
|
+
return null;
|
|
23
|
+
type = current._def.type;
|
|
24
|
+
}
|
|
25
|
+
if (type === 'array') {
|
|
26
|
+
if (typeof segment === 'number') {
|
|
27
|
+
current = current._def.element;
|
|
28
|
+
if (currentData && Array.isArray(currentData)) {
|
|
29
|
+
currentData = currentData[segment];
|
|
30
|
+
}
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
current = current._def.element;
|
|
34
|
+
i--;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (type === 'object') {
|
|
38
|
+
const shape = current._def.shape;
|
|
39
|
+
const key = String(segment);
|
|
40
|
+
if (shape && key in shape) {
|
|
41
|
+
current = shape[key];
|
|
42
|
+
if (currentData && typeof currentData === 'object') {
|
|
43
|
+
currentData = currentData[key];
|
|
44
|
+
}
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
if (type === 'union') {
|
|
50
|
+
const options = current._def.options;
|
|
51
|
+
if (options) {
|
|
52
|
+
if (currentData && typeof currentData === 'object') {
|
|
53
|
+
const typeValue = currentData.type;
|
|
54
|
+
if (typeValue) {
|
|
55
|
+
for (const option of options) {
|
|
56
|
+
const optionShape = option._def?.shape;
|
|
57
|
+
const optionType = optionShape?.type?._def?.values?.[0];
|
|
58
|
+
if (optionType === typeValue) {
|
|
59
|
+
const remainingPath = path.slice(i);
|
|
60
|
+
const result = getSchemaAtPath(option, remainingPath, currentData);
|
|
61
|
+
if (result)
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
for (const option of options) {
|
|
68
|
+
const remainingPath = path.slice(i);
|
|
69
|
+
const result = getSchemaAtPath(option, remainingPath, currentData);
|
|
70
|
+
if (result)
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
if (type === 'record') {
|
|
77
|
+
current = current._def.valueType;
|
|
78
|
+
if (!current)
|
|
79
|
+
return null;
|
|
80
|
+
if (currentData && typeof currentData === 'object') {
|
|
81
|
+
currentData = currentData[segment];
|
|
82
|
+
}
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return current;
|
|
88
|
+
}
|
|
89
|
+
function formatJsonSchemaForError(jsonSchema) {
|
|
90
|
+
if (jsonSchema.type === 'object' && jsonSchema.properties) {
|
|
91
|
+
const props = Object.entries(jsonSchema.properties)
|
|
92
|
+
.slice(0, 5)
|
|
93
|
+
.map(([k, v]) => {
|
|
94
|
+
if (v.enum) {
|
|
95
|
+
return `${k}: ${v.enum.map((e) => JSON.stringify(e)).join('|')}`;
|
|
96
|
+
}
|
|
97
|
+
return `${k}: ${v.type || 'any'}`;
|
|
98
|
+
})
|
|
99
|
+
.join(', ');
|
|
100
|
+
const moreProps = Object.keys(jsonSchema.properties).length > 5
|
|
101
|
+
? `, ... (${Object.keys(jsonSchema.properties).length - 5} more)`
|
|
102
|
+
: '';
|
|
103
|
+
const required = jsonSchema.required?.length
|
|
104
|
+
? ` (required: ${jsonSchema.required.join(', ')})`
|
|
105
|
+
: '';
|
|
106
|
+
return `{ ${props}${moreProps} }${required}`;
|
|
107
|
+
}
|
|
108
|
+
if (jsonSchema.const !== undefined)
|
|
109
|
+
return JSON.stringify(jsonSchema.const);
|
|
110
|
+
if (jsonSchema.enum) {
|
|
111
|
+
return `one of: ${jsonSchema.enum.map((v) => JSON.stringify(v)).join(', ')}`;
|
|
112
|
+
}
|
|
113
|
+
if (jsonSchema.oneOf)
|
|
114
|
+
return jsonSchema.oneOf.map((s) => formatJsonSchemaForError(s)).join(' | ');
|
|
115
|
+
if (jsonSchema.anyOf)
|
|
116
|
+
return jsonSchema.anyOf.map((s) => formatJsonSchemaForError(s)).join(' | ');
|
|
117
|
+
if (jsonSchema.description)
|
|
118
|
+
return jsonSchema.description;
|
|
119
|
+
return jsonSchema.type || JSON.stringify(jsonSchema);
|
|
120
|
+
}
|
|
121
|
+
function getExpectedFormat(schema) {
|
|
122
|
+
if (!schema || !schema._def)
|
|
123
|
+
return null;
|
|
124
|
+
let current = schema;
|
|
125
|
+
while (current._def.type === 'optional' || current._def.type === 'nullable') {
|
|
126
|
+
current = current._def.innerType;
|
|
127
|
+
if (!current || !current._def)
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
const jsonSchema = z.toJSONSchema(schema);
|
|
132
|
+
if (Object.keys(jsonSchema).length <= 1 ||
|
|
133
|
+
(Object.keys(jsonSchema).length === 1 && jsonSchema.$schema)) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
const formatted = formatJsonSchemaForError(jsonSchema);
|
|
137
|
+
if (formatted && formatted !== 'unknown' && !formatted.startsWith('{'))
|
|
138
|
+
return formatted;
|
|
139
|
+
if (formatted && formatted.startsWith('{') && formatted !== '{ }')
|
|
140
|
+
return formatted;
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
// Ignore errors from toJSONSchema
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
export function validateFlowModules(rawModules, ctx = {}) {
|
|
148
|
+
if (!Array.isArray(rawModules)) {
|
|
149
|
+
throw new Error('Flow modules must be an array');
|
|
150
|
+
}
|
|
151
|
+
const parsedModules = rawModules;
|
|
152
|
+
const modulesSchema = ctx.modulesSchema ?? flowModulesSchema;
|
|
153
|
+
const result = modulesSchema.safeParse(parsedModules);
|
|
154
|
+
if (!result.success) {
|
|
155
|
+
const errors = result.error.issues.slice(0, 5).map((e) => {
|
|
156
|
+
const path = e.path;
|
|
157
|
+
const moduleIndex = typeof path[0] === 'number' ? path[0] : undefined;
|
|
158
|
+
const moduleId = moduleIndex !== undefined ? parsedModules[moduleIndex]?.id : undefined;
|
|
159
|
+
const fieldPath = path.slice(1).join('.');
|
|
160
|
+
let message = e.message;
|
|
161
|
+
if (e.code === 'invalid_type') {
|
|
162
|
+
const targetSchema = getSchemaAtPath(modulesSchema, path, parsedModules);
|
|
163
|
+
if (targetSchema) {
|
|
164
|
+
const expectedFormat = getExpectedFormat(targetSchema);
|
|
165
|
+
if (expectedFormat) {
|
|
166
|
+
message += `\n Expected format: ${expectedFormat}`;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (moduleId) {
|
|
171
|
+
return `Module "${moduleId}" -> ${fieldPath}: ${message}`;
|
|
172
|
+
}
|
|
173
|
+
return `${path.join('.')}: ${message}`;
|
|
174
|
+
});
|
|
175
|
+
throw new Error(`Invalid flow modules:\n${errors.join('\n')}`);
|
|
176
|
+
}
|
|
177
|
+
const ids = collectAllFlowModuleIdsFromModules(parsedModules);
|
|
178
|
+
if (ids.length !== new Set(ids).size) {
|
|
179
|
+
throw new Error('Duplicate module IDs found in flow');
|
|
180
|
+
}
|
|
181
|
+
const reservedIds = ids.filter((id) => id === SPECIAL_MODULE_IDS.PREPROCESSOR || id === SPECIAL_MODULE_IDS.FAILURE);
|
|
182
|
+
if (reservedIds.length > 0) {
|
|
183
|
+
throw new Error('Special modules must be provided via preprocessor_module and failure_module, not inside modules');
|
|
184
|
+
}
|
|
185
|
+
return parsedModules;
|
|
186
|
+
}
|
|
187
|
+
export function validateFlowSchema(rawSchema) {
|
|
188
|
+
if (rawSchema == null)
|
|
189
|
+
return null;
|
|
190
|
+
if (typeof rawSchema !== 'object' || Array.isArray(rawSchema)) {
|
|
191
|
+
throw new Error('Flow schema must be an object or null');
|
|
192
|
+
}
|
|
193
|
+
return rawSchema;
|
|
194
|
+
}
|
|
195
|
+
function validateOptionalFlowModule(rawModule, fieldName) {
|
|
196
|
+
if (rawModule == null)
|
|
197
|
+
return null;
|
|
198
|
+
const result = flowModuleSchema.safeParse(rawModule);
|
|
199
|
+
if (!result.success) {
|
|
200
|
+
const error = result.error.issues[0];
|
|
201
|
+
throw new Error(`Invalid ${fieldName}: ${error?.message ?? 'unknown error'}`);
|
|
202
|
+
}
|
|
203
|
+
return result.data;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Parse and validate a raw object as an `EditableFlowJson`. Validates module
|
|
207
|
+
* shape, schema shape, optional special modules (with their reserved ids),
|
|
208
|
+
* groups, and that no module ids collide.
|
|
209
|
+
*/
|
|
210
|
+
export function validateEditableFlowJson(rawFlow, ctx = {}) {
|
|
211
|
+
if (!rawFlow || typeof rawFlow !== 'object' || Array.isArray(rawFlow)) {
|
|
212
|
+
throw new Error('Flow JSON must be an object');
|
|
213
|
+
}
|
|
214
|
+
const flow = rawFlow;
|
|
215
|
+
const modules = validateFlowModules(flow.modules, ctx);
|
|
216
|
+
const schema = validateFlowSchema(flow.schema);
|
|
217
|
+
const preprocessorModule = validateOptionalFlowModule(flow.preprocessor_module, 'preprocessor_module');
|
|
218
|
+
const failureModule = validateOptionalFlowModule(flow.failure_module, 'failure_module');
|
|
219
|
+
const groupModuleIds = new Set(collectAllFlowModuleIdsFromModules(modules));
|
|
220
|
+
const groups = validateFlowGroups(flow.groups, groupModuleIds);
|
|
221
|
+
if (preprocessorModule) {
|
|
222
|
+
if (preprocessorModule.id !== SPECIAL_MODULE_IDS.PREPROCESSOR) {
|
|
223
|
+
throw new Error(`Invalid preprocessor_module: id must be "${SPECIAL_MODULE_IDS.PREPROCESSOR}"`);
|
|
224
|
+
}
|
|
225
|
+
if (preprocessorModule.value.type !== 'rawscript' &&
|
|
226
|
+
preprocessorModule.value.type !== 'script') {
|
|
227
|
+
throw new Error('Invalid preprocessor_module: only "rawscript" and "script" modules are supported');
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (failureModule) {
|
|
231
|
+
if (failureModule.id !== SPECIAL_MODULE_IDS.FAILURE) {
|
|
232
|
+
throw new Error(`Invalid failure_module: id must be "${SPECIAL_MODULE_IDS.FAILURE}"`);
|
|
233
|
+
}
|
|
234
|
+
if (failureModule.value.type !== 'rawscript' && failureModule.value.type !== 'script') {
|
|
235
|
+
throw new Error('Invalid failure_module: only "rawscript" and "script" modules are supported');
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
const ids = new Set(collectAllFlowModuleIdsFromModules(modules));
|
|
239
|
+
if (preprocessorModule) {
|
|
240
|
+
if (ids.has(preprocessorModule.id)) {
|
|
241
|
+
throw new Error(`Duplicate module ID found in preprocessor_module: ${preprocessorModule.id}`);
|
|
242
|
+
}
|
|
243
|
+
ids.add(preprocessorModule.id);
|
|
244
|
+
}
|
|
245
|
+
if (failureModule && ids.has(failureModule.id)) {
|
|
246
|
+
throw new Error(`Duplicate module ID found in failure_module: ${failureModule.id}`);
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
modules,
|
|
250
|
+
schema,
|
|
251
|
+
preprocessor_module: preprocessorModule,
|
|
252
|
+
failure_module: failureModule,
|
|
253
|
+
groups
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Build the agent-facing compact view of a flow. When an `InlineScriptSession`
|
|
258
|
+
* is provided, every rawscript module's `content` is moved into the session
|
|
259
|
+
* and replaced with the placeholder `inline_script.<moduleId>` (preprocessor
|
|
260
|
+
* and failure modules included).
|
|
261
|
+
*/
|
|
262
|
+
export function buildEditableFlowJson(flow, inlineScriptSession) {
|
|
263
|
+
const modules = inlineScriptSession
|
|
264
|
+
? inlineScriptSession.extractAndReplaceInlineScripts(flow.value.modules)
|
|
265
|
+
: flow.value.modules;
|
|
266
|
+
let preprocessorModule = flow.value.preprocessor_module;
|
|
267
|
+
if (preprocessorModule?.value?.type === 'rawscript' &&
|
|
268
|
+
typeof preprocessorModule.value.content === 'string' &&
|
|
269
|
+
inlineScriptSession) {
|
|
270
|
+
inlineScriptSession.set(preprocessorModule.id, preprocessorModule.value.content);
|
|
271
|
+
preprocessorModule = {
|
|
272
|
+
...preprocessorModule,
|
|
273
|
+
value: {
|
|
274
|
+
...preprocessorModule.value,
|
|
275
|
+
content: `inline_script.${preprocessorModule.id}`
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
let failureModule = flow.value.failure_module;
|
|
280
|
+
if (failureModule?.value?.type === 'rawscript' &&
|
|
281
|
+
typeof failureModule.value.content === 'string' &&
|
|
282
|
+
inlineScriptSession) {
|
|
283
|
+
inlineScriptSession.set(failureModule.id, failureModule.value.content);
|
|
284
|
+
failureModule = {
|
|
285
|
+
...failureModule,
|
|
286
|
+
value: {
|
|
287
|
+
...failureModule.value,
|
|
288
|
+
content: `inline_script.${failureModule.id}`
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
return {
|
|
293
|
+
modules,
|
|
294
|
+
schema: flow.schema ?? null,
|
|
295
|
+
preprocessor_module: preprocessorModule ?? null,
|
|
296
|
+
failure_module: failureModule ?? null,
|
|
297
|
+
groups: flow.value.groups ?? null
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
function restoreSpecialRawscriptModule(module, session) {
|
|
301
|
+
if (!module || module.value.type !== 'rawscript' || !module.value.content)
|
|
302
|
+
return module;
|
|
303
|
+
const match = module.value.content.match(/^inline_script\.(.+)$/);
|
|
304
|
+
if (!match)
|
|
305
|
+
return module;
|
|
306
|
+
const content = session.get(match[1]);
|
|
307
|
+
if (content === undefined)
|
|
308
|
+
return module;
|
|
309
|
+
return { ...module, value: { ...module.value, content } };
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Inverse of `buildEditableFlowJson`. Replaces `inline_script.<moduleId>`
|
|
313
|
+
* placeholders in `editable.modules` and the special modules with the content
|
|
314
|
+
* stored in `session`. Other fields on the original FlowValue (`same_worker`,
|
|
315
|
+
* `concurrent_limit`, etc.) are preserved.
|
|
316
|
+
*
|
|
317
|
+
* Pair with `buildEditableFlowJson` for round-trip patches: extract → patch
|
|
318
|
+
* the compact view → restore.
|
|
319
|
+
*/
|
|
320
|
+
export function applyEditableFlowJsonToFlow(originalValue, editable, session) {
|
|
321
|
+
return {
|
|
322
|
+
...originalValue,
|
|
323
|
+
modules: session.restoreInlineScriptReferences(editable.modules),
|
|
324
|
+
preprocessor_module: restoreSpecialRawscriptModule(editable.preprocessor_module, session) ?? undefined,
|
|
325
|
+
failure_module: restoreSpecialRawscriptModule(editable.failure_module, session) ?? undefined,
|
|
326
|
+
groups: editable.groups ?? undefined
|
|
327
|
+
};
|
|
328
|
+
}
|
|
@@ -34,7 +34,7 @@ function extractAndReplaceInlineScripts(modules, session) {
|
|
|
34
34
|
}
|
|
35
35
|
return modules.map((module) => {
|
|
36
36
|
const newModule = { ...module };
|
|
37
|
-
if (newModule.value.type === 'rawscript' && newModule.value.content) {
|
|
37
|
+
if (newModule.value.type === 'rawscript' && typeof newModule.value.content === 'string') {
|
|
38
38
|
session.set(module.id, newModule.value.content);
|
|
39
39
|
newModule.value = {
|
|
40
40
|
...newModule.value,
|
|
@@ -88,7 +88,7 @@ function extractAndReplaceInlineScripts(modules, session) {
|
|
|
88
88
|
'type' in tool.value &&
|
|
89
89
|
tool.value.type === 'rawscript' &&
|
|
90
90
|
'content' in tool.value &&
|
|
91
|
-
tool.value.content) {
|
|
91
|
+
typeof tool.value.content === 'string') {
|
|
92
92
|
session.set(tool.id, tool.value.content);
|
|
93
93
|
return {
|
|
94
94
|
...tool,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam } from 'openai/resources/chat/completions.mjs';
|
|
2
|
+
import { type Tool } from '../shared';
|
|
3
|
+
export declare const globalTools: Tool<{}>[];
|
|
4
|
+
export declare function prepareGlobalSystemMessage(customPrompt?: string): ChatCompletionSystemMessageParam;
|
|
5
|
+
export declare function prepareGlobalUserMessage(instructions: string): ChatCompletionUserMessageParam;
|