@meistrari/tela-cli 1.9.5 → 1.10.1
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/commands/skills.js +6 -4
- package/dist/index.js +616 -349
- package/package.json +1 -1
package/dist/commands/skills.js
CHANGED
|
@@ -196,22 +196,24 @@ async function upgradeSkills(args, options, io) {
|
|
|
196
196
|
getClient: async () => (await (0, session_1.loadPantry)(flags)).client,
|
|
197
197
|
onDiagnostic: diagnostic => writeSkillManagerDiagnostic(io, diagnostic),
|
|
198
198
|
});
|
|
199
|
-
const { upgraded, unchanged } = await manager.upgradeSkills(flags.rest, {
|
|
199
|
+
const { upgraded, unchanged, replaced } = await manager.upgradeSkills(flags.rest, {
|
|
200
200
|
force: flags.force,
|
|
201
201
|
ignoreScripts: flags.ignoreScripts,
|
|
202
202
|
...(flags.symlink ? {} : { targets: [] }),
|
|
203
203
|
});
|
|
204
|
-
if (upgraded.length === 0 && unchanged.length === 0) {
|
|
204
|
+
if (upgraded.length === 0 && unchanged.length === 0 && replaced.length === 0) {
|
|
205
205
|
if (options.json)
|
|
206
|
-
(0, output_1.writeJson)(io, { upgraded: [], unchanged: [] });
|
|
206
|
+
(0, output_1.writeJson)(io, { upgraded: [], unchanged: [], replaced: [] });
|
|
207
207
|
else
|
|
208
208
|
(0, output_1.writeLine)(io, 'No skills installed.');
|
|
209
209
|
return 0;
|
|
210
210
|
}
|
|
211
211
|
if (options.json) {
|
|
212
|
-
(0, output_1.writeJson)(io, { upgraded, unchanged });
|
|
212
|
+
(0, output_1.writeJson)(io, { upgraded, unchanged, replaced });
|
|
213
213
|
return 0;
|
|
214
214
|
}
|
|
215
|
+
for (const { from, to } of replaced)
|
|
216
|
+
(0, output_1.writeLine)(io, `Replaced deprecated ${from} with ${to.slug} at ${to.sha.slice(0, 7)}`);
|
|
215
217
|
for (const entry of upgraded)
|
|
216
218
|
(0, output_1.writeLine)(io, `Upgraded ${entry.slug} to ${entry.sha.slice(0, 7)}`);
|
|
217
219
|
for (const slug of unchanged)
|
package/dist/index.js
CHANGED
|
@@ -77216,6 +77216,7 @@ var require_skills = __commonJS({
|
|
|
77216
77216
|
name: ingredient.name,
|
|
77217
77217
|
description: ingredient.description,
|
|
77218
77218
|
status: ingredient.status,
|
|
77219
|
+
replacement: ingredient.replacement,
|
|
77219
77220
|
// A listing carries the skill-only fields under `skillDetails`,
|
|
77220
77221
|
// which is null for anything Pantry has not synced as a skill.
|
|
77221
77222
|
bundle: ingredient.skillDetails?.bundle ?? null,
|
|
@@ -77338,13 +77339,42 @@ Run \`tela skills install ${slug} --force\` to replace it, or remove it by hand.
|
|
|
77338
77339
|
const diagnostics = [];
|
|
77339
77340
|
const upgraded = [];
|
|
77340
77341
|
const unchanged = [];
|
|
77342
|
+
const replaced = [];
|
|
77341
77343
|
const emit = createDiagnosticEmitter(options2, diagnostics);
|
|
77342
77344
|
if (selected.length === 0)
|
|
77343
|
-
return { upgraded, unchanged, diagnostics };
|
|
77345
|
+
return { upgraded, unchanged, replaced, diagnostics };
|
|
77344
77346
|
const targets = normalizeTargets(upgradeOptions.targets ?? paths.targets, paths.installRoot);
|
|
77345
77347
|
const client = await resolveClient();
|
|
77346
77348
|
for (const current of selected) {
|
|
77347
|
-
const { snapshot } = await (0, skills_1.fetchSkillFile)(client, current.slug);
|
|
77349
|
+
const { ingredient, snapshot } = await (0, skills_1.fetchSkillFile)(client, current.slug);
|
|
77350
|
+
const replacementSlug = await resolveReplacementSlug(client, current.slug, ingredient);
|
|
77351
|
+
if (replacementSlug) {
|
|
77352
|
+
const installedReplacement = (await (0, tela_local_config_1.listInstalledSkills)(inventoryFile)).find((entry2) => entry2.slug === replacementSlug);
|
|
77353
|
+
const replacement = await installOne({
|
|
77354
|
+
client,
|
|
77355
|
+
diagnostics: emit,
|
|
77356
|
+
...installedReplacement ? { expectedCurrent: installedReplacement, operation: "upgrade" } : {},
|
|
77357
|
+
force: upgradeOptions.force ?? false,
|
|
77358
|
+
ignoreScripts: upgradeOptions.ignoreScripts ?? false,
|
|
77359
|
+
inventoryFile,
|
|
77360
|
+
paths,
|
|
77361
|
+
slug: replacementSlug,
|
|
77362
|
+
targets
|
|
77363
|
+
});
|
|
77364
|
+
if (!replacement)
|
|
77365
|
+
continue;
|
|
77366
|
+
if (await uninstallOne({
|
|
77367
|
+
diagnostics: emit,
|
|
77368
|
+
entry: current,
|
|
77369
|
+
ignoreScripts: upgradeOptions.ignoreScripts ?? false,
|
|
77370
|
+
inventoryFile,
|
|
77371
|
+
operation: "upgrade",
|
|
77372
|
+
paths
|
|
77373
|
+
})) {
|
|
77374
|
+
replaced.push({ from: current.slug, to: replacement });
|
|
77375
|
+
}
|
|
77376
|
+
continue;
|
|
77377
|
+
}
|
|
77348
77378
|
if (snapshot.sha === current.sha) {
|
|
77349
77379
|
unchanged.push(current.slug);
|
|
77350
77380
|
continue;
|
|
@@ -77364,7 +77394,7 @@ Run \`tela skills install ${slug} --force\` to replace it, or remove it by hand.
|
|
|
77364
77394
|
if (entry)
|
|
77365
77395
|
upgraded.push(entry);
|
|
77366
77396
|
}
|
|
77367
|
-
return { upgraded, unchanged, diagnostics };
|
|
77397
|
+
return { upgraded, unchanged, replaced, diagnostics };
|
|
77368
77398
|
},
|
|
77369
77399
|
uninstallSkills: async (slugs, uninstallOptions = {}) => {
|
|
77370
77400
|
for (const slug of slugs)
|
|
@@ -77375,44 +77405,77 @@ Run \`tela skills install ${slug} --force\` to replace it, or remove it by hand.
|
|
|
77375
77405
|
const removed = [];
|
|
77376
77406
|
const emit = createDiagnosticEmitter(options2, diagnostics);
|
|
77377
77407
|
for (const entry of selected) {
|
|
77378
|
-
|
|
77379
|
-
|
|
77380
|
-
|
|
77381
|
-
|
|
77382
|
-
|
|
77383
|
-
|
|
77384
|
-
|
|
77385
|
-
|
|
77386
|
-
type: "concurrent-change",
|
|
77387
|
-
slug: entry.slug,
|
|
77388
|
-
operation: "uninstall",
|
|
77389
|
-
message: `Skipped ${entry.slug}: it was reinstalled while this uninstall ran`
|
|
77390
|
-
});
|
|
77391
|
-
return registered;
|
|
77392
|
-
}
|
|
77393
|
-
assertManagedInstallDir(entry.slug, registered, paths);
|
|
77394
|
-
for (const linkPath of registered.symlinks) {
|
|
77395
|
-
const outcome = await (0, skill_filesystem_1.removeManagedSymlink)(linkPath, registered.dir);
|
|
77396
|
-
if (outcome.reason) {
|
|
77397
|
-
emit({
|
|
77398
|
-
type: "link-removal-skipped",
|
|
77399
|
-
slug: entry.slug,
|
|
77400
|
-
path: linkPath,
|
|
77401
|
-
message: outcome.reason
|
|
77402
|
-
});
|
|
77403
|
-
}
|
|
77404
|
-
}
|
|
77405
|
-
await (0, promises_1.rm)(registered.dir, { recursive: true, force: true });
|
|
77406
|
-
gone = true;
|
|
77407
|
-
return null;
|
|
77408
|
-
}, inventoryFile);
|
|
77409
|
-
if (gone)
|
|
77408
|
+
if (await uninstallOne({
|
|
77409
|
+
diagnostics: emit,
|
|
77410
|
+
entry,
|
|
77411
|
+
ignoreScripts: uninstallOptions.ignoreScripts ?? false,
|
|
77412
|
+
inventoryFile,
|
|
77413
|
+
operation: "uninstall",
|
|
77414
|
+
paths
|
|
77415
|
+
})) {
|
|
77410
77416
|
removed.push(entry.slug);
|
|
77417
|
+
}
|
|
77411
77418
|
}
|
|
77412
77419
|
return { removed, diagnostics };
|
|
77413
77420
|
}
|
|
77414
77421
|
};
|
|
77415
77422
|
}
|
|
77423
|
+
var MAX_REPLACEMENT_HOPS = 5;
|
|
77424
|
+
async function resolveReplacementSlug(client, slug, ingredient) {
|
|
77425
|
+
let replacement = deprecatedReplacement(ingredient);
|
|
77426
|
+
if (!replacement)
|
|
77427
|
+
return null;
|
|
77428
|
+
const visited = /* @__PURE__ */ new Set([slug]);
|
|
77429
|
+
for (let hop = 0; hop < MAX_REPLACEMENT_HOPS; hop++) {
|
|
77430
|
+
(0, skill_filesystem_1.assertSafeSlug)(replacement, "upgrade");
|
|
77431
|
+
if (visited.has(replacement))
|
|
77432
|
+
throw new Error(`Pantry replacements for ${slug} form a cycle through ${replacement}.`);
|
|
77433
|
+
visited.add(replacement);
|
|
77434
|
+
const next = deprecatedReplacement((await (0, skills_1.fetchSkillFile)(client, replacement)).ingredient);
|
|
77435
|
+
if (!next)
|
|
77436
|
+
return replacement;
|
|
77437
|
+
replacement = next;
|
|
77438
|
+
}
|
|
77439
|
+
throw new Error(`Pantry replacements for ${slug} chain through more than ${MAX_REPLACEMENT_HOPS} deprecated skills.`);
|
|
77440
|
+
}
|
|
77441
|
+
function deprecatedReplacement(ingredient) {
|
|
77442
|
+
return ingredient.status === "deprecated" && ingredient.replacement ? ingredient.replacement : null;
|
|
77443
|
+
}
|
|
77444
|
+
async function uninstallOne(options2) {
|
|
77445
|
+
const { entry, paths } = options2;
|
|
77446
|
+
assertManagedInstallDir(entry.slug, entry, paths);
|
|
77447
|
+
await runLifecycle(entry, "uninstall", options2.ignoreScripts, options2.diagnostics);
|
|
77448
|
+
let gone = false;
|
|
77449
|
+
await (0, tela_local_config_1.updateInstalledSkill)(entry.slug, async (registered) => {
|
|
77450
|
+
if (registered === null)
|
|
77451
|
+
return null;
|
|
77452
|
+
if (!isSameInstall(registered, entry)) {
|
|
77453
|
+
options2.diagnostics({
|
|
77454
|
+
type: "concurrent-change",
|
|
77455
|
+
slug: entry.slug,
|
|
77456
|
+
operation: options2.operation,
|
|
77457
|
+
message: `Skipped ${entry.slug}: it was reinstalled while this ${options2.operation} ran`
|
|
77458
|
+
});
|
|
77459
|
+
return registered;
|
|
77460
|
+
}
|
|
77461
|
+
assertManagedInstallDir(entry.slug, registered, paths);
|
|
77462
|
+
for (const linkPath of registered.symlinks) {
|
|
77463
|
+
const outcome = await (0, skill_filesystem_1.removeManagedSymlink)(linkPath, registered.dir);
|
|
77464
|
+
if (outcome.reason) {
|
|
77465
|
+
options2.diagnostics({
|
|
77466
|
+
type: "link-removal-skipped",
|
|
77467
|
+
slug: entry.slug,
|
|
77468
|
+
path: linkPath,
|
|
77469
|
+
message: outcome.reason
|
|
77470
|
+
});
|
|
77471
|
+
}
|
|
77472
|
+
}
|
|
77473
|
+
await (0, promises_1.rm)(registered.dir, { recursive: true, force: true });
|
|
77474
|
+
gone = true;
|
|
77475
|
+
return null;
|
|
77476
|
+
}, options2.inventoryFile);
|
|
77477
|
+
return gone;
|
|
77478
|
+
}
|
|
77416
77479
|
function createDiagnosticEmitter(options2, diagnostics) {
|
|
77417
77480
|
return (diagnostic) => {
|
|
77418
77481
|
diagnostics.push(diagnostic);
|
|
@@ -142874,9 +142937,9 @@ var require_contracts = __commonJS({
|
|
|
142874
142937
|
}
|
|
142875
142938
|
});
|
|
142876
142939
|
|
|
142877
|
-
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
142940
|
+
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/action-ids.cjs
|
|
142878
142941
|
var require_action_ids = __commonJS({
|
|
142879
|
-
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
142942
|
+
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/action-ids.cjs"(exports2, module2) {
|
|
142880
142943
|
"use strict";
|
|
142881
142944
|
var __defProp3 = Object.defineProperty;
|
|
142882
142945
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -142902,6 +142965,7 @@ var require_action_ids = __commonJS({
|
|
|
142902
142965
|
module2.exports = __toCommonJS2(action_ids_exports);
|
|
142903
142966
|
var WORKFLOW_ACTION_IDS = {
|
|
142904
142967
|
llmCompletion: "llm-completion",
|
|
142968
|
+
jevEvaluator: "jev-evaluator",
|
|
142905
142969
|
agent: "agent",
|
|
142906
142970
|
agentFcc: "agent-fcc",
|
|
142907
142971
|
codeExecution: "code-execution",
|
|
@@ -142917,9 +142981,9 @@ var require_action_ids = __commonJS({
|
|
|
142917
142981
|
}
|
|
142918
142982
|
});
|
|
142919
142983
|
|
|
142920
|
-
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
142984
|
+
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/reference-format.cjs
|
|
142921
142985
|
var require_reference_format = __commonJS({
|
|
142922
|
-
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
142986
|
+
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/reference-format.cjs"(exports2, module2) {
|
|
142923
142987
|
"use strict";
|
|
142924
142988
|
var __defProp3 = Object.defineProperty;
|
|
142925
142989
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -142957,9 +143021,9 @@ var require_reference_format = __commonJS({
|
|
|
142957
143021
|
}
|
|
142958
143022
|
});
|
|
142959
143023
|
|
|
142960
|
-
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
143024
|
+
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/action-output-reference.cjs
|
|
142961
143025
|
var require_action_output_reference = __commonJS({
|
|
142962
|
-
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
143026
|
+
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/action-output-reference.cjs"(exports2, module2) {
|
|
142963
143027
|
"use strict";
|
|
142964
143028
|
var __defProp3 = Object.defineProperty;
|
|
142965
143029
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -149816,9 +149880,9 @@ var require_cjs = __commonJS({
|
|
|
149816
149880
|
}
|
|
149817
149881
|
});
|
|
149818
149882
|
|
|
149819
|
-
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
149883
|
+
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/action-schemas.cjs
|
|
149820
149884
|
var require_action_schemas = __commonJS({
|
|
149821
|
-
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
149885
|
+
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/action-schemas.cjs"(exports2, module2) {
|
|
149822
149886
|
"use strict";
|
|
149823
149887
|
var __defProp3 = Object.defineProperty;
|
|
149824
149888
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -149855,6 +149919,8 @@ var require_action_schemas = __commonJS({
|
|
|
149855
149919
|
documentSplitterInput: () => documentSplitterInput,
|
|
149856
149920
|
documentSplitterMode: () => documentSplitterMode,
|
|
149857
149921
|
documentTemplaterInput: () => documentTemplaterInput,
|
|
149922
|
+
jevEvaluatorInput: () => jevEvaluatorInput,
|
|
149923
|
+
jevQuestionSchema: () => jevQuestionSchema,
|
|
149858
149924
|
llmCompletionInput: () => llmCompletionInput,
|
|
149859
149925
|
mapActionInput: () => mapActionInput,
|
|
149860
149926
|
templateActionInput: () => templateActionInput
|
|
@@ -149888,7 +149954,8 @@ async function execute(input: TelaInput) {
|
|
|
149888
149954
|
condition: import_typebox.Type.String(),
|
|
149889
149955
|
steps: import_typebox.Type.Array(import_typebox.Type.Any()),
|
|
149890
149956
|
type: import_typebox.Type.Optional(conditionCaseTypeSchema),
|
|
149891
|
-
portId: import_typebox.Type.Optional(import_typebox.Type.Union([import_typebox.Type.String(), import_typebox.Type.Null()]))
|
|
149957
|
+
portId: import_typebox.Type.Optional(import_typebox.Type.Union([import_typebox.Type.String(), import_typebox.Type.Null()])),
|
|
149958
|
+
repeatFor: import_typebox.Type.Optional(import_typebox.Type.String({ description: "Template-only: list slot key this case is cloned for on instantiation" }))
|
|
149892
149959
|
});
|
|
149893
149960
|
var defaultCaseSchema = import_typebox.Type.Object({
|
|
149894
149961
|
name: import_typebox.Type.Literal("Default"),
|
|
@@ -150008,6 +150075,7 @@ async function execute(input: TelaInput) {
|
|
|
150008
150075
|
default: DEFAULT_LLM_MODEL
|
|
150009
150076
|
})),
|
|
150010
150077
|
temperature: import_typebox.Type.Optional(import_typebox.Type.Number({ default: 0 })),
|
|
150078
|
+
reasoningEffort: import_typebox.Type.Optional(import_typebox.Type.Union([import_typebox.Type.Literal("low"), import_typebox.Type.Literal("medium"), import_typebox.Type.Literal("high"), import_typebox.Type.Null()], { default: null })),
|
|
150011
150079
|
schema: import_typebox.Type.Union([
|
|
150012
150080
|
import_typebox.Type.Null(),
|
|
150013
150081
|
import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any())
|
|
@@ -150015,6 +150083,43 @@ async function execute(input: TelaInput) {
|
|
|
150015
150083
|
citations: import_typebox.Type.Optional(import_typebox.Type.Boolean()),
|
|
150016
150084
|
citationsRationale: import_typebox.Type.Optional(import_typebox.Type.Boolean())
|
|
150017
150085
|
});
|
|
150086
|
+
var jevChoiceQuestionSchema = import_typebox.Type.Object({
|
|
150087
|
+
id: import_typebox.Type.String({ minLength: 1, maxLength: 128 }),
|
|
150088
|
+
type: import_typebox.Type.Literal("choice"),
|
|
150089
|
+
instructions: import_typebox.Type.String({ minLength: 1, maxLength: 4e3 }),
|
|
150090
|
+
criteria: import_typebox.Type.Array(import_typebox.Type.Object({
|
|
150091
|
+
key: import_typebox.Type.String({ minLength: 1, maxLength: 128 }),
|
|
150092
|
+
description: import_typebox.Type.Optional(import_typebox.Type.String({ maxLength: 4e3 }))
|
|
150093
|
+
}), { minItems: 2, maxItems: 255 })
|
|
150094
|
+
});
|
|
150095
|
+
var jevScoreQuestionSchema = import_typebox.Type.Object({
|
|
150096
|
+
id: import_typebox.Type.String({ minLength: 1, maxLength: 128 }),
|
|
150097
|
+
type: import_typebox.Type.Literal("score"),
|
|
150098
|
+
instructions: import_typebox.Type.String({ minLength: 1, maxLength: 4e3 }),
|
|
150099
|
+
criteria: import_typebox.Type.Array(import_typebox.Type.String({ minLength: 1, maxLength: 4e3 }), { minItems: 2, maxItems: 10 })
|
|
150100
|
+
});
|
|
150101
|
+
var jevNoulQuestionSchema = import_typebox.Type.Object({
|
|
150102
|
+
id: import_typebox.Type.String({ minLength: 1, maxLength: 128 }),
|
|
150103
|
+
type: import_typebox.Type.Literal("noul"),
|
|
150104
|
+
instructions: import_typebox.Type.String({ minLength: 1, maxLength: 4e3 }),
|
|
150105
|
+
criteria: import_typebox.Type.Optional(import_typebox.Type.Object({
|
|
150106
|
+
true: import_typebox.Type.String({ minLength: 1, maxLength: 4e3 }),
|
|
150107
|
+
false: import_typebox.Type.String({ minLength: 1, maxLength: 4e3 })
|
|
150108
|
+
}))
|
|
150109
|
+
});
|
|
150110
|
+
var jevQuestionSchema = import_typebox.Type.Union([
|
|
150111
|
+
jevChoiceQuestionSchema,
|
|
150112
|
+
jevScoreQuestionSchema,
|
|
150113
|
+
jevNoulQuestionSchema
|
|
150114
|
+
]);
|
|
150115
|
+
var jevEvaluatorInput = import_typebox.Type.Object({
|
|
150116
|
+
state: import_typebox.Type.String({ default: "" }),
|
|
150117
|
+
model: import_typebox.Type.Optional(import_typebox.Type.Literal("jev-1.13.0", {
|
|
150118
|
+
description: "Pinned TypeSafe Jev model",
|
|
150119
|
+
default: "jev-1.13.0"
|
|
150120
|
+
})),
|
|
150121
|
+
questions: import_typebox.Type.Array(jevQuestionSchema, { minItems: 1, maxItems: 100, default: [] })
|
|
150122
|
+
});
|
|
150018
150123
|
var mapActionInput = import_typebox.Type.Object({
|
|
150019
150124
|
over: import_typebox.Type.Any({ default: "" }),
|
|
150020
150125
|
mapVariable: import_typebox.Type.String(),
|
|
@@ -150087,14 +150192,18 @@ async function execute(input: TelaInput) {
|
|
|
150087
150192
|
var templateActionInput = import_typebox.Type.Object({
|
|
150088
150193
|
templateId: import_typebox.Type.String(),
|
|
150089
150194
|
variables: import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Union([import_typebox.Type.String(), import_typebox.Type.Any()])),
|
|
150090
|
-
tags: import_typebox.Type.Optional(import_typebox.Type.Array(import_typebox.Type.String(), { default: [] }))
|
|
150195
|
+
tags: import_typebox.Type.Optional(import_typebox.Type.Array(import_typebox.Type.String(), { default: [] })),
|
|
150196
|
+
slotValues: import_typebox.Type.Optional(import_typebox.Type.Record(
|
|
150197
|
+
import_typebox.Type.String(),
|
|
150198
|
+
import_typebox.Type.Union([import_typebox.Type.String(), import_typebox.Type.Array(import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.String()))])
|
|
150199
|
+
))
|
|
150091
150200
|
});
|
|
150092
150201
|
}
|
|
150093
150202
|
});
|
|
150094
150203
|
|
|
150095
|
-
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
150204
|
+
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/graph.cjs
|
|
150096
150205
|
var require_graph = __commonJS({
|
|
150097
|
-
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
150206
|
+
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/graph.cjs"(exports2, module2) {
|
|
150098
150207
|
"use strict";
|
|
150099
150208
|
var __defProp3 = Object.defineProperty;
|
|
150100
150209
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -150114,9 +150223,9 @@ var require_graph = __commonJS({
|
|
|
150114
150223
|
}
|
|
150115
150224
|
});
|
|
150116
150225
|
|
|
150117
|
-
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
150226
|
+
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/input-reference.cjs
|
|
150118
150227
|
var require_input_reference = __commonJS({
|
|
150119
|
-
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
150228
|
+
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/input-reference.cjs"(exports2, module2) {
|
|
150120
150229
|
"use strict";
|
|
150121
150230
|
var __defProp3 = Object.defineProperty;
|
|
150122
150231
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -150341,9 +150450,9 @@ var require_input_reference = __commonJS({
|
|
|
150341
150450
|
}
|
|
150342
150451
|
});
|
|
150343
150452
|
|
|
150344
|
-
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
150453
|
+
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/lifecycle.cjs
|
|
150345
150454
|
var require_lifecycle = __commonJS({
|
|
150346
|
-
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
150455
|
+
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/lifecycle.cjs"(exports2, module2) {
|
|
150347
150456
|
"use strict";
|
|
150348
150457
|
var __defProp3 = Object.defineProperty;
|
|
150349
150458
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -150363,9 +150472,9 @@ var require_lifecycle = __commonJS({
|
|
|
150363
150472
|
}
|
|
150364
150473
|
});
|
|
150365
150474
|
|
|
150366
|
-
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
150475
|
+
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/workflow-reference.cjs
|
|
150367
150476
|
var require_workflow_reference = __commonJS({
|
|
150368
|
-
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
150477
|
+
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/workflow-reference.cjs"(exports2, module2) {
|
|
150369
150478
|
"use strict";
|
|
150370
150479
|
var __defProp3 = Object.defineProperty;
|
|
150371
150480
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -150458,9 +150567,9 @@ var require_workflow_reference = __commonJS({
|
|
|
150458
150567
|
}
|
|
150459
150568
|
});
|
|
150460
150569
|
|
|
150461
|
-
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
150570
|
+
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/workflow-update-spec.cjs
|
|
150462
150571
|
var require_workflow_update_spec = __commonJS({
|
|
150463
|
-
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
150572
|
+
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/workflow-update-spec.cjs"(exports2, module2) {
|
|
150464
150573
|
"use strict";
|
|
150465
150574
|
var __defProp3 = Object.defineProperty;
|
|
150466
150575
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -150480,9 +150589,9 @@ var require_workflow_update_spec = __commonJS({
|
|
|
150480
150589
|
}
|
|
150481
150590
|
});
|
|
150482
150591
|
|
|
150483
|
-
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
150592
|
+
// ../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/index.cjs
|
|
150484
150593
|
var require_cjs2 = __commonJS({
|
|
150485
|
-
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.
|
|
150594
|
+
"../../node_modules/.pnpm/@meistrari+workflow-shared@1.7.0/node_modules/@meistrari/workflow-shared/dist/cjs/index.cjs"(exports2, module2) {
|
|
150486
150595
|
"use strict";
|
|
150487
150596
|
var __defProp3 = Object.defineProperty;
|
|
150488
150597
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -150553,6 +150662,410 @@ var require_ids = __commonJS({
|
|
|
150553
150662
|
}
|
|
150554
150663
|
});
|
|
150555
150664
|
|
|
150665
|
+
// ../../packages/workflow-code/dist/compiler/output-schema.js
|
|
150666
|
+
var require_output_schema = __commonJS({
|
|
150667
|
+
"../../packages/workflow-code/dist/compiler/output-schema.js"(exports2) {
|
|
150668
|
+
"use strict";
|
|
150669
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
150670
|
+
exports2.DOC_TEMPLATE_OUTPUT_JSON_SCHEMA = exports2.CROP_OUTPUT_JSON_SCHEMA = exports2.SPLITTER_OUTPUT_JSON_SCHEMA = exports2.FILE_INPUT_JSON_SCHEMA = exports2.FILE_OUTPUT_JSON_SCHEMA = void 0;
|
|
150671
|
+
exports2.createPromptOutputJsonSchema = createPromptOutputJsonSchema;
|
|
150672
|
+
exports2.selectOutputJsonSchema = selectOutputJsonSchema;
|
|
150673
|
+
exports2.isFileCompatibleOutputJsonSchema = isFileCompatibleOutputJsonSchema;
|
|
150674
|
+
exports2.isStringCompatibleOutputJsonSchema = isStringCompatibleOutputJsonSchema;
|
|
150675
|
+
exports2.FILE_OUTPUT_JSON_SCHEMA = Object.freeze({
|
|
150676
|
+
type: "object",
|
|
150677
|
+
properties: Object.freeze({
|
|
150678
|
+
name: Object.freeze({ type: "string" }),
|
|
150679
|
+
fileUrl: Object.freeze({ type: "string" }),
|
|
150680
|
+
mimeType: Object.freeze({ type: "string" }),
|
|
150681
|
+
base64: Object.freeze({ type: "string" }),
|
|
150682
|
+
vaultReference: Object.freeze({ type: "string" })
|
|
150683
|
+
})
|
|
150684
|
+
});
|
|
150685
|
+
exports2.FILE_INPUT_JSON_SCHEMA = Object.freeze({
|
|
150686
|
+
anyOf: Object.freeze([
|
|
150687
|
+
exports2.FILE_OUTPUT_JSON_SCHEMA,
|
|
150688
|
+
Object.freeze({ type: "array", items: exports2.FILE_OUTPUT_JSON_SCHEMA })
|
|
150689
|
+
])
|
|
150690
|
+
});
|
|
150691
|
+
exports2.SPLITTER_OUTPUT_JSON_SCHEMA = Object.freeze({
|
|
150692
|
+
type: "array",
|
|
150693
|
+
items: Object.freeze({
|
|
150694
|
+
type: "object",
|
|
150695
|
+
properties: Object.freeze({
|
|
150696
|
+
startPage: Object.freeze({ type: "number" }),
|
|
150697
|
+
endPage: Object.freeze({ type: "number" }),
|
|
150698
|
+
pages: Object.freeze({ type: "string" }),
|
|
150699
|
+
originalFile: exports2.FILE_OUTPUT_JSON_SCHEMA,
|
|
150700
|
+
file: exports2.FILE_OUTPUT_JSON_SCHEMA,
|
|
150701
|
+
description: Object.freeze({ anyOf: Object.freeze([{ type: "string" }, { type: "null" }]) }),
|
|
150702
|
+
fileType: Object.freeze({ anyOf: Object.freeze([{ type: "string" }, { type: "null" }]) })
|
|
150703
|
+
}),
|
|
150704
|
+
required: Object.freeze(["startPage", "endPage", "pages", "originalFile", "file", "description", "fileType"])
|
|
150705
|
+
})
|
|
150706
|
+
});
|
|
150707
|
+
exports2.CROP_OUTPUT_JSON_SCHEMA = Object.freeze({
|
|
150708
|
+
type: "array",
|
|
150709
|
+
items: Object.freeze({
|
|
150710
|
+
type: "object",
|
|
150711
|
+
properties: Object.freeze({
|
|
150712
|
+
indexes: Object.freeze({
|
|
150713
|
+
type: "array",
|
|
150714
|
+
items: Object.freeze({ anyOf: Object.freeze([{ type: "integer" }, { type: "string" }]) })
|
|
150715
|
+
}),
|
|
150716
|
+
originalFile: exports2.FILE_OUTPUT_JSON_SCHEMA,
|
|
150717
|
+
file: exports2.FILE_OUTPUT_JSON_SCHEMA
|
|
150718
|
+
}),
|
|
150719
|
+
required: Object.freeze(["indexes", "originalFile", "file"])
|
|
150720
|
+
})
|
|
150721
|
+
});
|
|
150722
|
+
exports2.DOC_TEMPLATE_OUTPUT_JSON_SCHEMA = Object.freeze({
|
|
150723
|
+
type: "object",
|
|
150724
|
+
properties: Object.freeze({
|
|
150725
|
+
generatedDocument: exports2.FILE_OUTPUT_JSON_SCHEMA,
|
|
150726
|
+
generatedAt: Object.freeze({ type: "string" }),
|
|
150727
|
+
permalinkUrl: Object.freeze({ type: "string" }),
|
|
150728
|
+
permalinkId: Object.freeze({ type: "string" }),
|
|
150729
|
+
permalinkExpiresAt: Object.freeze({ anyOf: Object.freeze([{ type: "string" }, { type: "null" }]) })
|
|
150730
|
+
}),
|
|
150731
|
+
required: Object.freeze(["generatedDocument", "generatedAt"])
|
|
150732
|
+
});
|
|
150733
|
+
function createPromptOutputJsonSchema(schema) {
|
|
150734
|
+
return schema === void 0 || schema === null ? void 0 : { type: "object", properties: schema };
|
|
150735
|
+
}
|
|
150736
|
+
function selectOutputJsonSchema(schema, path2) {
|
|
150737
|
+
let selected = schema;
|
|
150738
|
+
for (const segment of path2) {
|
|
150739
|
+
if (!selected)
|
|
150740
|
+
return void 0;
|
|
150741
|
+
selected = selectOutputJsonSchemaSegment(selected, segment);
|
|
150742
|
+
}
|
|
150743
|
+
return selected;
|
|
150744
|
+
}
|
|
150745
|
+
function isFileCompatibleOutputJsonSchema(schema) {
|
|
150746
|
+
const variants = jsonSchemaVariants(schema);
|
|
150747
|
+
if (variants)
|
|
150748
|
+
return variants.every(isFileCompatibleOutputJsonSchema);
|
|
150749
|
+
return isFileJsonSchema(schema) || isFileArrayJsonSchema(schema);
|
|
150750
|
+
}
|
|
150751
|
+
function selectOutputJsonSchemaSegment(schema, segment) {
|
|
150752
|
+
const variants = jsonSchemaVariants(schema);
|
|
150753
|
+
if (variants) {
|
|
150754
|
+
const selected = variants.map((variant) => selectOutputJsonSchemaSegment(variant, segment));
|
|
150755
|
+
return selected.every((variant) => variant !== void 0) ? { anyOf: selected } : void 0;
|
|
150756
|
+
}
|
|
150757
|
+
if (schema.type === "array")
|
|
150758
|
+
return /^\d+$/.test(segment) ? schema.items : void 0;
|
|
150759
|
+
return isRecord3(schema.properties) ? schema.properties[segment] : void 0;
|
|
150760
|
+
}
|
|
150761
|
+
function isFileJsonSchema(schema) {
|
|
150762
|
+
const variants = jsonSchemaVariants(schema);
|
|
150763
|
+
if (variants)
|
|
150764
|
+
return variants.every(isFileJsonSchema);
|
|
150765
|
+
if (!isRecord3(schema))
|
|
150766
|
+
return false;
|
|
150767
|
+
const properties = schema.properties;
|
|
150768
|
+
if (schema.type !== "object" || !isRecord3(properties))
|
|
150769
|
+
return false;
|
|
150770
|
+
const stringFields = ["name", "fileUrl", "mimeType", "base64", "vaultReference"];
|
|
150771
|
+
if (!stringFields.every((key) => !(key in properties) || isStringCompatibleOutputJsonSchema(properties[key])))
|
|
150772
|
+
return false;
|
|
150773
|
+
return isStringCompatibleOutputJsonSchema(properties.name) && ["fileUrl", "vaultReference", "base64"].some((key) => isStringCompatibleOutputJsonSchema(properties[key]));
|
|
150774
|
+
}
|
|
150775
|
+
function isFileArrayJsonSchema(schema) {
|
|
150776
|
+
return isRecord3(schema) && schema.type === "array" && isFileJsonSchema(schema.items);
|
|
150777
|
+
}
|
|
150778
|
+
function isStringCompatibleOutputJsonSchema(schema) {
|
|
150779
|
+
const variants = jsonSchemaVariants(schema);
|
|
150780
|
+
if (variants)
|
|
150781
|
+
return variants.every(isStringCompatibleOutputJsonSchema);
|
|
150782
|
+
if (!isRecord3(schema))
|
|
150783
|
+
return false;
|
|
150784
|
+
if (schema.type !== void 0 && schema.type !== "string")
|
|
150785
|
+
return false;
|
|
150786
|
+
const hasStringConst = typeof schema.const === "string";
|
|
150787
|
+
if ("const" in schema && !hasStringConst)
|
|
150788
|
+
return false;
|
|
150789
|
+
const enumValues = schema.enum;
|
|
150790
|
+
const hasStringEnum = Array.isArray(enumValues) && enumValues.length > 0 && enumValues.every((value) => typeof value === "string");
|
|
150791
|
+
if ("enum" in schema && !hasStringEnum)
|
|
150792
|
+
return false;
|
|
150793
|
+
return schema.type === "string" || hasStringConst || hasStringEnum;
|
|
150794
|
+
}
|
|
150795
|
+
function jsonSchemaVariants(schema) {
|
|
150796
|
+
if (!isRecord3(schema))
|
|
150797
|
+
return void 0;
|
|
150798
|
+
const variants = Array.isArray(schema.anyOf) ? schema.anyOf : Array.isArray(schema.oneOf) ? schema.oneOf : void 0;
|
|
150799
|
+
return variants !== void 0 && variants.length > 0 && variants.every(isRecord3) ? variants : void 0;
|
|
150800
|
+
}
|
|
150801
|
+
function isRecord3(value) {
|
|
150802
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
150803
|
+
}
|
|
150804
|
+
}
|
|
150805
|
+
});
|
|
150806
|
+
|
|
150807
|
+
// ../../packages/workflow-code/dist/compiler/refs.js
|
|
150808
|
+
var require_refs = __commonJS({
|
|
150809
|
+
"../../packages/workflow-code/dist/compiler/refs.js"(exports2) {
|
|
150810
|
+
"use strict";
|
|
150811
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
150812
|
+
exports2.resolvePromptRefs = resolvePromptRefs;
|
|
150813
|
+
exports2.resolveReferenceRecordRefs = resolveReferenceRecordRefs;
|
|
150814
|
+
exports2.resolveWorkflowRef = resolveWorkflowRef;
|
|
150815
|
+
exports2.resolveExclusiveRef = resolveExclusiveRef;
|
|
150816
|
+
exports2.resolveVisibleNodeIdentity = resolveVisibleNodeIdentity;
|
|
150817
|
+
var workflow_shared_1 = require_cjs2();
|
|
150818
|
+
function resolvePromptRefs(context) {
|
|
150819
|
+
const diagnostics = [];
|
|
150820
|
+
let prompt = context.prompt;
|
|
150821
|
+
for (const ref of context.refs) {
|
|
150822
|
+
const resolved = resolveWorkflowRef(ref, context);
|
|
150823
|
+
diagnostics.push(...resolved.diagnostics);
|
|
150824
|
+
if (!resolved.reference)
|
|
150825
|
+
continue;
|
|
150826
|
+
prompt = prompt.split(ref.token).join(resolved.reference);
|
|
150827
|
+
}
|
|
150828
|
+
return { prompt, diagnostics };
|
|
150829
|
+
}
|
|
150830
|
+
function resolveReferenceRecordRefs(context) {
|
|
150831
|
+
const diagnostics = [];
|
|
150832
|
+
const values = { ...context.values };
|
|
150833
|
+
for (const ref of context.refs) {
|
|
150834
|
+
const resolved = resolveWorkflowRef(ref, context);
|
|
150835
|
+
if (resolved.reference) {
|
|
150836
|
+
values[ref.key] = resolved.reference;
|
|
150837
|
+
continue;
|
|
150838
|
+
}
|
|
150839
|
+
diagnostics.push(...resolved.diagnostics.map((diagnostic) => ({
|
|
150840
|
+
...diagnostic,
|
|
150841
|
+
message: diagnostic.message.replace("Prompt reference", `Reference record ${ref.key} reference`)
|
|
150842
|
+
})));
|
|
150843
|
+
}
|
|
150844
|
+
return { values: Object.freeze(values), diagnostics };
|
|
150845
|
+
}
|
|
150846
|
+
function resolveWorkflowRef(ref, context) {
|
|
150847
|
+
const resolved = ref.targetKind === "input" ? resolveInputRef(ref, context) : resolveNodeRef(ref, context);
|
|
150848
|
+
if (!resolved) {
|
|
150849
|
+
return {
|
|
150850
|
+
diagnostics: [{
|
|
150851
|
+
code: "compiler.ref.dangling",
|
|
150852
|
+
severity: "error",
|
|
150853
|
+
message: `Prompt reference ${ref.targetKey} does not match a workflow input or previous node`
|
|
150854
|
+
}]
|
|
150855
|
+
};
|
|
150856
|
+
}
|
|
150857
|
+
if (resolved === "forward") {
|
|
150858
|
+
return {
|
|
150859
|
+
diagnostics: [{
|
|
150860
|
+
code: "compiler.ref.forward",
|
|
150861
|
+
severity: "error",
|
|
150862
|
+
message: `Prompt reference ${ref.targetKey} points to a future workflow node`
|
|
150863
|
+
}]
|
|
150864
|
+
};
|
|
150865
|
+
}
|
|
150866
|
+
if (resolved === "scope") {
|
|
150867
|
+
return {
|
|
150868
|
+
diagnostics: [{
|
|
150869
|
+
code: "compiler.ref.scope",
|
|
150870
|
+
severity: "error",
|
|
150871
|
+
message: `Prompt reference ${ref.targetKey} points to a workflow node outside the visible scope`
|
|
150872
|
+
}]
|
|
150873
|
+
};
|
|
150874
|
+
}
|
|
150875
|
+
return {
|
|
150876
|
+
reference: resolved.reference,
|
|
150877
|
+
inputType: "inputType" in resolved ? resolved.inputType : void 0,
|
|
150878
|
+
nodeId: "nodeId" in resolved ? resolved.nodeId : void 0,
|
|
150879
|
+
diagnostics: []
|
|
150880
|
+
};
|
|
150881
|
+
}
|
|
150882
|
+
function resolveExclusiveRef(ref, context) {
|
|
150883
|
+
const resolved = resolveWorkflowRef(ref, context);
|
|
150884
|
+
if (resolved.reference)
|
|
150885
|
+
return resolved;
|
|
150886
|
+
return {
|
|
150887
|
+
diagnostics: resolved.diagnostics.map((diagnostic) => ({
|
|
150888
|
+
...diagnostic,
|
|
150889
|
+
message: diagnostic.message.replace("Prompt reference", "Exclusive reference")
|
|
150890
|
+
}))
|
|
150891
|
+
};
|
|
150892
|
+
}
|
|
150893
|
+
function resolveInputRef(ref, context) {
|
|
150894
|
+
const id = context.inputIdsByKey.get(ref.targetKey);
|
|
150895
|
+
if (!id)
|
|
150896
|
+
return void 0;
|
|
150897
|
+
const reference = workflow_shared_1.InputReferenceURI.fromVariable({ name: id });
|
|
150898
|
+
return {
|
|
150899
|
+
reference: formatPromptReference(reference, ref),
|
|
150900
|
+
inputType: context.inputTypesByKey?.get(ref.targetKey)
|
|
150901
|
+
};
|
|
150902
|
+
}
|
|
150903
|
+
function resolveNodeRef(ref, context) {
|
|
150904
|
+
const candidates = context.nodeIdentitiesByKey.get(ref.targetKey) ?? [];
|
|
150905
|
+
if (candidates.length === 0)
|
|
150906
|
+
return void 0;
|
|
150907
|
+
const visible = resolveVisibleNodeIdentity(ref.targetKey, context);
|
|
150908
|
+
if (visible) {
|
|
150909
|
+
const reference = workflow_shared_1.ActionOutputReferenceURI.fromStepId(visible.id);
|
|
150910
|
+
return { reference: formatPromptReference(reference, ref), nodeId: visible.id };
|
|
150911
|
+
}
|
|
150912
|
+
if (candidates.some((candidate) => samePath(candidate.scopePath, context.currentNode.scopePath) && candidate.sequenceIndex >= context.currentNode.sequenceIndex)) {
|
|
150913
|
+
return "forward";
|
|
150914
|
+
}
|
|
150915
|
+
return "scope";
|
|
150916
|
+
}
|
|
150917
|
+
function resolveVisibleNodeIdentity(key, context) {
|
|
150918
|
+
const currentScopeCandidate = resolvePriorCandidateInScope(key, context.currentNode.scopePath, context.currentNode.sequenceIndex, context);
|
|
150919
|
+
if (currentScopeCandidate)
|
|
150920
|
+
return currentScopeCandidate;
|
|
150921
|
+
for (const boundary of [...context.currentNode.ancestorScopes].reverse()) {
|
|
150922
|
+
const candidate = resolvePriorCandidateInScope(key, boundary.scopePath, boundary.sequenceIndex, context);
|
|
150923
|
+
if (candidate)
|
|
150924
|
+
return candidate;
|
|
150925
|
+
}
|
|
150926
|
+
return void 0;
|
|
150927
|
+
}
|
|
150928
|
+
function resolvePriorCandidateInScope(key, scopePath, beforeSequenceIndex, context) {
|
|
150929
|
+
const candidates = (context.nodeIdentitiesByKey.get(key) ?? []).filter((candidate) => samePath(candidate.scopePath, scopePath) && candidate.sequenceIndex < beforeSequenceIndex).sort((left, right) => right.sequenceIndex - left.sequenceIndex);
|
|
150930
|
+
const nearest = candidates[0];
|
|
150931
|
+
if (!nearest)
|
|
150932
|
+
return void 0;
|
|
150933
|
+
if (candidates.filter((candidate) => candidate.sequenceIndex === nearest.sequenceIndex).length > 1)
|
|
150934
|
+
return void 0;
|
|
150935
|
+
return nearest;
|
|
150936
|
+
}
|
|
150937
|
+
function samePath(left, right) {
|
|
150938
|
+
return left.length === right.length && left.every((segment, index) => segment === right[index]);
|
|
150939
|
+
}
|
|
150940
|
+
function formatPromptReference(reference, ref) {
|
|
150941
|
+
if (ref.path && ref.path.length > 0)
|
|
150942
|
+
reference.appendPath([...ref.path]);
|
|
150943
|
+
if ("format" in ref && ref.format)
|
|
150944
|
+
reference.setFormat(ref.format);
|
|
150945
|
+
return reference.toReference();
|
|
150946
|
+
}
|
|
150947
|
+
}
|
|
150948
|
+
});
|
|
150949
|
+
|
|
150950
|
+
// ../../packages/workflow-code/dist/compiler/classifier.js
|
|
150951
|
+
var require_classifier = __commonJS({
|
|
150952
|
+
"../../packages/workflow-code/dist/compiler/classifier.js"(exports2) {
|
|
150953
|
+
"use strict";
|
|
150954
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
150955
|
+
exports2.classifierModule = void 0;
|
|
150956
|
+
var workflow_shared_1 = require_cjs2();
|
|
150957
|
+
var zod_1 = require_zod();
|
|
150958
|
+
var ids_1 = require_ids();
|
|
150959
|
+
var output_schema_1 = require_output_schema();
|
|
150960
|
+
var refs_1 = require_refs();
|
|
150961
|
+
var sharedInputSchema = zod_1.z.fromJSONSchema(workflow_shared_1.jevEvaluatorInput);
|
|
150962
|
+
function hasValidInput(input) {
|
|
150963
|
+
if (!input || typeof input !== "object")
|
|
150964
|
+
return false;
|
|
150965
|
+
const candidate = input;
|
|
150966
|
+
if (typeof candidate.prompt !== "string" || !candidate.prompt.trim() || !Array.isArray(candidate.questions))
|
|
150967
|
+
return false;
|
|
150968
|
+
if (!sharedInputSchema.safeParse({ ...candidate, state: candidate.prompt }).success)
|
|
150969
|
+
return false;
|
|
150970
|
+
const ids = /* @__PURE__ */ new Set();
|
|
150971
|
+
for (const question of candidate.questions) {
|
|
150972
|
+
if (question.id !== question.id.trim() || !question.instructions.trim() || ids.has(question.id))
|
|
150973
|
+
return false;
|
|
150974
|
+
ids.add(question.id);
|
|
150975
|
+
if (question.type === "choice") {
|
|
150976
|
+
const keys = /* @__PURE__ */ new Set();
|
|
150977
|
+
for (const criterion of question.criteria) {
|
|
150978
|
+
if (criterion.key !== criterion.key.trim() || keys.has(criterion.key))
|
|
150979
|
+
return false;
|
|
150980
|
+
keys.add(criterion.key);
|
|
150981
|
+
}
|
|
150982
|
+
}
|
|
150983
|
+
if (question.type === "score" && question.criteria.some((criterion) => !criterion.trim()))
|
|
150984
|
+
return false;
|
|
150985
|
+
if (question.type === "noul" && question.criteria && (!question.criteria.true.trim() || !question.criteria.false.trim()))
|
|
150986
|
+
return false;
|
|
150987
|
+
}
|
|
150988
|
+
return true;
|
|
150989
|
+
}
|
|
150990
|
+
function invalidInput(node) {
|
|
150991
|
+
return {
|
|
150992
|
+
code: "compiler.module.invalid_input",
|
|
150993
|
+
severity: "error",
|
|
150994
|
+
message: `Node ${node.name || "<unnamed>"} has invalid classifier input; use a nonblank prompt and valid questions with unique, trimmed IDs and choice keys`
|
|
150995
|
+
};
|
|
150996
|
+
}
|
|
150997
|
+
var probability = { type: "number", minimum: 0, maximum: 1 };
|
|
150998
|
+
function objectSchema(properties) {
|
|
150999
|
+
return { type: "object", properties, required: Object.keys(properties), additionalProperties: false };
|
|
151000
|
+
}
|
|
151001
|
+
function answerSchema(question) {
|
|
151002
|
+
if (question.type === "noul")
|
|
151003
|
+
return objectSchema({ type: { const: "noul" }, noul: probability });
|
|
151004
|
+
if (question.type === "choice") {
|
|
151005
|
+
return objectSchema({
|
|
151006
|
+
type: { const: "choice" },
|
|
151007
|
+
choice: { type: "string", enum: question.criteria.map((criterion) => criterion.key) },
|
|
151008
|
+
probabilities: objectSchema(Object.fromEntries(question.criteria.map((criterion) => [criterion.key, probability]))),
|
|
151009
|
+
confidence: probability
|
|
151010
|
+
});
|
|
151011
|
+
}
|
|
151012
|
+
return objectSchema({
|
|
151013
|
+
type: { const: "score" },
|
|
151014
|
+
score: { type: "number", minimum: 0, maximum: question.criteria.length - 1 },
|
|
151015
|
+
legend: objectSchema(Object.fromEntries(question.criteria.map((criterion, index) => [String(index), { const: criterion.trim() }]))),
|
|
151016
|
+
probabilities: objectSchema(Object.fromEntries(question.criteria.map((_2, index) => [String(index), probability]))),
|
|
151017
|
+
confidence: probability
|
|
151018
|
+
});
|
|
151019
|
+
}
|
|
151020
|
+
exports2.classifierModule = {
|
|
151021
|
+
kind: "classifier",
|
|
151022
|
+
actionId: workflow_shared_1.WORKFLOW_ACTION_IDS.jevEvaluator,
|
|
151023
|
+
validate: (node) => hasValidInput(node.input) ? [] : [invalidInput(node)],
|
|
151024
|
+
createFailedInput: () => ({ state: "Workflow Code compilation failed. Check compiler diagnostics.", questions: [] }),
|
|
151025
|
+
lower(node, context) {
|
|
151026
|
+
if (!hasValidInput(node.input))
|
|
151027
|
+
return void 0;
|
|
151028
|
+
for (const ref of node.refs ?? []) {
|
|
151029
|
+
const resolved2 = (0, refs_1.resolveWorkflowRef)(ref, context);
|
|
151030
|
+
const schema = resolved2.nodeId === void 0 ? void 0 : (0, output_schema_1.selectOutputJsonSchema)(context.nodeOutputSchemasById.get(resolved2.nodeId), ref.path ?? []);
|
|
151031
|
+
if (resolved2.inputType === "file" || (0, output_schema_1.isFileCompatibleOutputJsonSchema)(schema) || ref.format !== void 0 && ref.format !== "string") {
|
|
151032
|
+
context.diagnostics.push({
|
|
151033
|
+
code: "compiler.ref.incompatible",
|
|
151034
|
+
severity: "error",
|
|
151035
|
+
message: `Classifier ${node.name} prompt only accepts text values and string-formatted references`
|
|
151036
|
+
});
|
|
151037
|
+
}
|
|
151038
|
+
}
|
|
151039
|
+
const resolved = (0, refs_1.resolvePromptRefs)({ ...context, prompt: node.input.prompt, refs: node.refs ?? [] });
|
|
151040
|
+
context.diagnostics.push(...resolved.diagnostics);
|
|
151041
|
+
const linearPorts = { input: (0, ids_1.defaultInputPortId)(context.nodeId), output: (0, ids_1.defaultOutputPortId)(context.nodeId) };
|
|
151042
|
+
return {
|
|
151043
|
+
node: {
|
|
151044
|
+
id: context.nodeId,
|
|
151045
|
+
name: node.name,
|
|
151046
|
+
actionId: workflow_shared_1.WORKFLOW_ACTION_IDS.jevEvaluator,
|
|
151047
|
+
ports: [
|
|
151048
|
+
{ id: linearPorts.input, dir: "in", type: "default" },
|
|
151049
|
+
{ id: linearPorts.output, dir: "out", type: "default" }
|
|
151050
|
+
],
|
|
151051
|
+
input: {
|
|
151052
|
+
state: resolved.prompt,
|
|
151053
|
+
questions: node.input.questions,
|
|
151054
|
+
...node.input.model !== void 0 ? { model: node.input.model } : {}
|
|
151055
|
+
}
|
|
151056
|
+
},
|
|
151057
|
+
linearPorts,
|
|
151058
|
+
outputSchema: objectSchema({
|
|
151059
|
+
model: { type: "string" },
|
|
151060
|
+
answers: objectSchema(Object.fromEntries(node.input.questions.map((question) => [question.id, answerSchema(question)]))),
|
|
151061
|
+
usage: objectSchema({ input_tokens: { type: "integer", minimum: 0 }, output_tokens: { type: "integer", minimum: 0 } })
|
|
151062
|
+
})
|
|
151063
|
+
};
|
|
151064
|
+
}
|
|
151065
|
+
};
|
|
151066
|
+
}
|
|
151067
|
+
});
|
|
151068
|
+
|
|
150556
151069
|
// ../../packages/workflow-code/dist/authoring/remote.js
|
|
150557
151070
|
var require_remote = __commonJS({
|
|
150558
151071
|
"../../packages/workflow-code/dist/authoring/remote.js"(exports2) {
|
|
@@ -364665,148 +365178,6 @@ var require_imports = __commonJS({
|
|
|
364665
365178
|
}
|
|
364666
365179
|
});
|
|
364667
365180
|
|
|
364668
|
-
// ../../packages/workflow-code/dist/compiler/output-schema.js
|
|
364669
|
-
var require_output_schema = __commonJS({
|
|
364670
|
-
"../../packages/workflow-code/dist/compiler/output-schema.js"(exports2) {
|
|
364671
|
-
"use strict";
|
|
364672
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
364673
|
-
exports2.DOC_TEMPLATE_OUTPUT_JSON_SCHEMA = exports2.CROP_OUTPUT_JSON_SCHEMA = exports2.SPLITTER_OUTPUT_JSON_SCHEMA = exports2.FILE_INPUT_JSON_SCHEMA = exports2.FILE_OUTPUT_JSON_SCHEMA = void 0;
|
|
364674
|
-
exports2.createPromptOutputJsonSchema = createPromptOutputJsonSchema;
|
|
364675
|
-
exports2.selectOutputJsonSchema = selectOutputJsonSchema;
|
|
364676
|
-
exports2.isFileCompatibleOutputJsonSchema = isFileCompatibleOutputJsonSchema;
|
|
364677
|
-
exports2.isStringCompatibleOutputJsonSchema = isStringCompatibleOutputJsonSchema;
|
|
364678
|
-
exports2.FILE_OUTPUT_JSON_SCHEMA = Object.freeze({
|
|
364679
|
-
type: "object",
|
|
364680
|
-
properties: Object.freeze({
|
|
364681
|
-
name: Object.freeze({ type: "string" }),
|
|
364682
|
-
fileUrl: Object.freeze({ type: "string" }),
|
|
364683
|
-
mimeType: Object.freeze({ type: "string" }),
|
|
364684
|
-
base64: Object.freeze({ type: "string" }),
|
|
364685
|
-
vaultReference: Object.freeze({ type: "string" })
|
|
364686
|
-
})
|
|
364687
|
-
});
|
|
364688
|
-
exports2.FILE_INPUT_JSON_SCHEMA = Object.freeze({
|
|
364689
|
-
anyOf: Object.freeze([
|
|
364690
|
-
exports2.FILE_OUTPUT_JSON_SCHEMA,
|
|
364691
|
-
Object.freeze({ type: "array", items: exports2.FILE_OUTPUT_JSON_SCHEMA })
|
|
364692
|
-
])
|
|
364693
|
-
});
|
|
364694
|
-
exports2.SPLITTER_OUTPUT_JSON_SCHEMA = Object.freeze({
|
|
364695
|
-
type: "array",
|
|
364696
|
-
items: Object.freeze({
|
|
364697
|
-
type: "object",
|
|
364698
|
-
properties: Object.freeze({
|
|
364699
|
-
startPage: Object.freeze({ type: "number" }),
|
|
364700
|
-
endPage: Object.freeze({ type: "number" }),
|
|
364701
|
-
pages: Object.freeze({ type: "string" }),
|
|
364702
|
-
originalFile: exports2.FILE_OUTPUT_JSON_SCHEMA,
|
|
364703
|
-
file: exports2.FILE_OUTPUT_JSON_SCHEMA,
|
|
364704
|
-
description: Object.freeze({ anyOf: Object.freeze([{ type: "string" }, { type: "null" }]) }),
|
|
364705
|
-
fileType: Object.freeze({ anyOf: Object.freeze([{ type: "string" }, { type: "null" }]) })
|
|
364706
|
-
}),
|
|
364707
|
-
required: Object.freeze(["startPage", "endPage", "pages", "originalFile", "file", "description", "fileType"])
|
|
364708
|
-
})
|
|
364709
|
-
});
|
|
364710
|
-
exports2.CROP_OUTPUT_JSON_SCHEMA = Object.freeze({
|
|
364711
|
-
type: "array",
|
|
364712
|
-
items: Object.freeze({
|
|
364713
|
-
type: "object",
|
|
364714
|
-
properties: Object.freeze({
|
|
364715
|
-
indexes: Object.freeze({
|
|
364716
|
-
type: "array",
|
|
364717
|
-
items: Object.freeze({ anyOf: Object.freeze([{ type: "integer" }, { type: "string" }]) })
|
|
364718
|
-
}),
|
|
364719
|
-
originalFile: exports2.FILE_OUTPUT_JSON_SCHEMA,
|
|
364720
|
-
file: exports2.FILE_OUTPUT_JSON_SCHEMA
|
|
364721
|
-
}),
|
|
364722
|
-
required: Object.freeze(["indexes", "originalFile", "file"])
|
|
364723
|
-
})
|
|
364724
|
-
});
|
|
364725
|
-
exports2.DOC_TEMPLATE_OUTPUT_JSON_SCHEMA = Object.freeze({
|
|
364726
|
-
type: "object",
|
|
364727
|
-
properties: Object.freeze({
|
|
364728
|
-
generatedDocument: exports2.FILE_OUTPUT_JSON_SCHEMA,
|
|
364729
|
-
generatedAt: Object.freeze({ type: "string" }),
|
|
364730
|
-
permalinkUrl: Object.freeze({ type: "string" }),
|
|
364731
|
-
permalinkId: Object.freeze({ type: "string" }),
|
|
364732
|
-
permalinkExpiresAt: Object.freeze({ anyOf: Object.freeze([{ type: "string" }, { type: "null" }]) })
|
|
364733
|
-
}),
|
|
364734
|
-
required: Object.freeze(["generatedDocument", "generatedAt"])
|
|
364735
|
-
});
|
|
364736
|
-
function createPromptOutputJsonSchema(schema) {
|
|
364737
|
-
return schema === void 0 || schema === null ? void 0 : { type: "object", properties: schema };
|
|
364738
|
-
}
|
|
364739
|
-
function selectOutputJsonSchema(schema, path2) {
|
|
364740
|
-
let selected = schema;
|
|
364741
|
-
for (const segment of path2) {
|
|
364742
|
-
if (!selected)
|
|
364743
|
-
return void 0;
|
|
364744
|
-
selected = selectOutputJsonSchemaSegment(selected, segment);
|
|
364745
|
-
}
|
|
364746
|
-
return selected;
|
|
364747
|
-
}
|
|
364748
|
-
function isFileCompatibleOutputJsonSchema(schema) {
|
|
364749
|
-
const variants = jsonSchemaVariants(schema);
|
|
364750
|
-
if (variants)
|
|
364751
|
-
return variants.every(isFileCompatibleOutputJsonSchema);
|
|
364752
|
-
return isFileJsonSchema(schema) || isFileArrayJsonSchema(schema);
|
|
364753
|
-
}
|
|
364754
|
-
function selectOutputJsonSchemaSegment(schema, segment) {
|
|
364755
|
-
const variants = jsonSchemaVariants(schema);
|
|
364756
|
-
if (variants) {
|
|
364757
|
-
const selected = variants.map((variant) => selectOutputJsonSchemaSegment(variant, segment));
|
|
364758
|
-
return selected.every((variant) => variant !== void 0) ? { anyOf: selected } : void 0;
|
|
364759
|
-
}
|
|
364760
|
-
if (schema.type === "array")
|
|
364761
|
-
return /^\d+$/.test(segment) ? schema.items : void 0;
|
|
364762
|
-
return isRecord3(schema.properties) ? schema.properties[segment] : void 0;
|
|
364763
|
-
}
|
|
364764
|
-
function isFileJsonSchema(schema) {
|
|
364765
|
-
const variants = jsonSchemaVariants(schema);
|
|
364766
|
-
if (variants)
|
|
364767
|
-
return variants.every(isFileJsonSchema);
|
|
364768
|
-
if (!isRecord3(schema))
|
|
364769
|
-
return false;
|
|
364770
|
-
const properties = schema.properties;
|
|
364771
|
-
if (schema.type !== "object" || !isRecord3(properties))
|
|
364772
|
-
return false;
|
|
364773
|
-
const stringFields = ["name", "fileUrl", "mimeType", "base64", "vaultReference"];
|
|
364774
|
-
if (!stringFields.every((key) => !(key in properties) || isStringCompatibleOutputJsonSchema(properties[key])))
|
|
364775
|
-
return false;
|
|
364776
|
-
return isStringCompatibleOutputJsonSchema(properties.name) && ["fileUrl", "vaultReference", "base64"].some((key) => isStringCompatibleOutputJsonSchema(properties[key]));
|
|
364777
|
-
}
|
|
364778
|
-
function isFileArrayJsonSchema(schema) {
|
|
364779
|
-
return isRecord3(schema) && schema.type === "array" && isFileJsonSchema(schema.items);
|
|
364780
|
-
}
|
|
364781
|
-
function isStringCompatibleOutputJsonSchema(schema) {
|
|
364782
|
-
const variants = jsonSchemaVariants(schema);
|
|
364783
|
-
if (variants)
|
|
364784
|
-
return variants.every(isStringCompatibleOutputJsonSchema);
|
|
364785
|
-
if (!isRecord3(schema))
|
|
364786
|
-
return false;
|
|
364787
|
-
if (schema.type !== void 0 && schema.type !== "string")
|
|
364788
|
-
return false;
|
|
364789
|
-
const hasStringConst = typeof schema.const === "string";
|
|
364790
|
-
if ("const" in schema && !hasStringConst)
|
|
364791
|
-
return false;
|
|
364792
|
-
const enumValues = schema.enum;
|
|
364793
|
-
const hasStringEnum = Array.isArray(enumValues) && enumValues.length > 0 && enumValues.every((value) => typeof value === "string");
|
|
364794
|
-
if ("enum" in schema && !hasStringEnum)
|
|
364795
|
-
return false;
|
|
364796
|
-
return schema.type === "string" || hasStringConst || hasStringEnum;
|
|
364797
|
-
}
|
|
364798
|
-
function jsonSchemaVariants(schema) {
|
|
364799
|
-
if (!isRecord3(schema))
|
|
364800
|
-
return void 0;
|
|
364801
|
-
const variants = Array.isArray(schema.anyOf) ? schema.anyOf : Array.isArray(schema.oneOf) ? schema.oneOf : void 0;
|
|
364802
|
-
return variants !== void 0 && variants.length > 0 && variants.every(isRecord3) ? variants : void 0;
|
|
364803
|
-
}
|
|
364804
|
-
function isRecord3(value) {
|
|
364805
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
364806
|
-
}
|
|
364807
|
-
}
|
|
364808
|
-
});
|
|
364809
|
-
|
|
364810
365181
|
// ../../packages/workflow-code/dist/compiler/code-extraction/output-schema.js
|
|
364811
365182
|
var require_output_schema2 = __commonJS({
|
|
364812
365183
|
"../../packages/workflow-code/dist/compiler/code-extraction/output-schema.js"(exports2) {
|
|
@@ -365187,149 +365558,6 @@ var require_rewrite_refs = __commonJS({
|
|
|
365187
365558
|
}
|
|
365188
365559
|
});
|
|
365189
365560
|
|
|
365190
|
-
// ../../packages/workflow-code/dist/compiler/refs.js
|
|
365191
|
-
var require_refs = __commonJS({
|
|
365192
|
-
"../../packages/workflow-code/dist/compiler/refs.js"(exports2) {
|
|
365193
|
-
"use strict";
|
|
365194
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
365195
|
-
exports2.resolvePromptRefs = resolvePromptRefs;
|
|
365196
|
-
exports2.resolveReferenceRecordRefs = resolveReferenceRecordRefs;
|
|
365197
|
-
exports2.resolveWorkflowRef = resolveWorkflowRef;
|
|
365198
|
-
exports2.resolveExclusiveRef = resolveExclusiveRef;
|
|
365199
|
-
exports2.resolveVisibleNodeIdentity = resolveVisibleNodeIdentity;
|
|
365200
|
-
var workflow_shared_1 = require_cjs2();
|
|
365201
|
-
function resolvePromptRefs(context) {
|
|
365202
|
-
const diagnostics = [];
|
|
365203
|
-
let prompt = context.prompt;
|
|
365204
|
-
for (const ref of context.refs) {
|
|
365205
|
-
const resolved = resolveWorkflowRef(ref, context);
|
|
365206
|
-
diagnostics.push(...resolved.diagnostics);
|
|
365207
|
-
if (!resolved.reference)
|
|
365208
|
-
continue;
|
|
365209
|
-
prompt = prompt.split(ref.token).join(resolved.reference);
|
|
365210
|
-
}
|
|
365211
|
-
return { prompt, diagnostics };
|
|
365212
|
-
}
|
|
365213
|
-
function resolveReferenceRecordRefs(context) {
|
|
365214
|
-
const diagnostics = [];
|
|
365215
|
-
const values = { ...context.values };
|
|
365216
|
-
for (const ref of context.refs) {
|
|
365217
|
-
const resolved = resolveWorkflowRef(ref, context);
|
|
365218
|
-
if (resolved.reference) {
|
|
365219
|
-
values[ref.key] = resolved.reference;
|
|
365220
|
-
continue;
|
|
365221
|
-
}
|
|
365222
|
-
diagnostics.push(...resolved.diagnostics.map((diagnostic) => ({
|
|
365223
|
-
...diagnostic,
|
|
365224
|
-
message: diagnostic.message.replace("Prompt reference", `Reference record ${ref.key} reference`)
|
|
365225
|
-
})));
|
|
365226
|
-
}
|
|
365227
|
-
return { values: Object.freeze(values), diagnostics };
|
|
365228
|
-
}
|
|
365229
|
-
function resolveWorkflowRef(ref, context) {
|
|
365230
|
-
const resolved = ref.targetKind === "input" ? resolveInputRef(ref, context) : resolveNodeRef(ref, context);
|
|
365231
|
-
if (!resolved) {
|
|
365232
|
-
return {
|
|
365233
|
-
diagnostics: [{
|
|
365234
|
-
code: "compiler.ref.dangling",
|
|
365235
|
-
severity: "error",
|
|
365236
|
-
message: `Prompt reference ${ref.targetKey} does not match a workflow input or previous node`
|
|
365237
|
-
}]
|
|
365238
|
-
};
|
|
365239
|
-
}
|
|
365240
|
-
if (resolved === "forward") {
|
|
365241
|
-
return {
|
|
365242
|
-
diagnostics: [{
|
|
365243
|
-
code: "compiler.ref.forward",
|
|
365244
|
-
severity: "error",
|
|
365245
|
-
message: `Prompt reference ${ref.targetKey} points to a future workflow node`
|
|
365246
|
-
}]
|
|
365247
|
-
};
|
|
365248
|
-
}
|
|
365249
|
-
if (resolved === "scope") {
|
|
365250
|
-
return {
|
|
365251
|
-
diagnostics: [{
|
|
365252
|
-
code: "compiler.ref.scope",
|
|
365253
|
-
severity: "error",
|
|
365254
|
-
message: `Prompt reference ${ref.targetKey} points to a workflow node outside the visible scope`
|
|
365255
|
-
}]
|
|
365256
|
-
};
|
|
365257
|
-
}
|
|
365258
|
-
return {
|
|
365259
|
-
reference: resolved.reference,
|
|
365260
|
-
inputType: "inputType" in resolved ? resolved.inputType : void 0,
|
|
365261
|
-
nodeId: "nodeId" in resolved ? resolved.nodeId : void 0,
|
|
365262
|
-
diagnostics: []
|
|
365263
|
-
};
|
|
365264
|
-
}
|
|
365265
|
-
function resolveExclusiveRef(ref, context) {
|
|
365266
|
-
const resolved = resolveWorkflowRef(ref, context);
|
|
365267
|
-
if (resolved.reference)
|
|
365268
|
-
return resolved;
|
|
365269
|
-
return {
|
|
365270
|
-
diagnostics: resolved.diagnostics.map((diagnostic) => ({
|
|
365271
|
-
...diagnostic,
|
|
365272
|
-
message: diagnostic.message.replace("Prompt reference", "Exclusive reference")
|
|
365273
|
-
}))
|
|
365274
|
-
};
|
|
365275
|
-
}
|
|
365276
|
-
function resolveInputRef(ref, context) {
|
|
365277
|
-
const id = context.inputIdsByKey.get(ref.targetKey);
|
|
365278
|
-
if (!id)
|
|
365279
|
-
return void 0;
|
|
365280
|
-
const reference = workflow_shared_1.InputReferenceURI.fromVariable({ name: id });
|
|
365281
|
-
return {
|
|
365282
|
-
reference: formatPromptReference(reference, ref),
|
|
365283
|
-
inputType: context.inputTypesByKey?.get(ref.targetKey)
|
|
365284
|
-
};
|
|
365285
|
-
}
|
|
365286
|
-
function resolveNodeRef(ref, context) {
|
|
365287
|
-
const candidates = context.nodeIdentitiesByKey.get(ref.targetKey) ?? [];
|
|
365288
|
-
if (candidates.length === 0)
|
|
365289
|
-
return void 0;
|
|
365290
|
-
const visible = resolveVisibleNodeIdentity(ref.targetKey, context);
|
|
365291
|
-
if (visible) {
|
|
365292
|
-
const reference = workflow_shared_1.ActionOutputReferenceURI.fromStepId(visible.id);
|
|
365293
|
-
return { reference: formatPromptReference(reference, ref), nodeId: visible.id };
|
|
365294
|
-
}
|
|
365295
|
-
if (candidates.some((candidate) => samePath(candidate.scopePath, context.currentNode.scopePath) && candidate.sequenceIndex >= context.currentNode.sequenceIndex)) {
|
|
365296
|
-
return "forward";
|
|
365297
|
-
}
|
|
365298
|
-
return "scope";
|
|
365299
|
-
}
|
|
365300
|
-
function resolveVisibleNodeIdentity(key, context) {
|
|
365301
|
-
const currentScopeCandidate = resolvePriorCandidateInScope(key, context.currentNode.scopePath, context.currentNode.sequenceIndex, context);
|
|
365302
|
-
if (currentScopeCandidate)
|
|
365303
|
-
return currentScopeCandidate;
|
|
365304
|
-
for (const boundary of [...context.currentNode.ancestorScopes].reverse()) {
|
|
365305
|
-
const candidate = resolvePriorCandidateInScope(key, boundary.scopePath, boundary.sequenceIndex, context);
|
|
365306
|
-
if (candidate)
|
|
365307
|
-
return candidate;
|
|
365308
|
-
}
|
|
365309
|
-
return void 0;
|
|
365310
|
-
}
|
|
365311
|
-
function resolvePriorCandidateInScope(key, scopePath, beforeSequenceIndex, context) {
|
|
365312
|
-
const candidates = (context.nodeIdentitiesByKey.get(key) ?? []).filter((candidate) => samePath(candidate.scopePath, scopePath) && candidate.sequenceIndex < beforeSequenceIndex).sort((left, right) => right.sequenceIndex - left.sequenceIndex);
|
|
365313
|
-
const nearest = candidates[0];
|
|
365314
|
-
if (!nearest)
|
|
365315
|
-
return void 0;
|
|
365316
|
-
if (candidates.filter((candidate) => candidate.sequenceIndex === nearest.sequenceIndex).length > 1)
|
|
365317
|
-
return void 0;
|
|
365318
|
-
return nearest;
|
|
365319
|
-
}
|
|
365320
|
-
function samePath(left, right) {
|
|
365321
|
-
return left.length === right.length && left.every((segment, index) => segment === right[index]);
|
|
365322
|
-
}
|
|
365323
|
-
function formatPromptReference(reference, ref) {
|
|
365324
|
-
if (ref.path && ref.path.length > 0)
|
|
365325
|
-
reference.appendPath([...ref.path]);
|
|
365326
|
-
if ("format" in ref && ref.format)
|
|
365327
|
-
reference.setFormat(ref.format);
|
|
365328
|
-
return reference.toReference();
|
|
365329
|
-
}
|
|
365330
|
-
}
|
|
365331
|
-
});
|
|
365332
|
-
|
|
365333
365561
|
// ../../packages/workflow-code/dist/compiler/code-extraction/extract.js
|
|
365334
365562
|
var require_extract3 = __commonJS({
|
|
365335
365563
|
"../../packages/workflow-code/dist/compiler/code-extraction/extract.js"(exports2) {
|
|
@@ -367388,6 +367616,7 @@ var require_modules = __commonJS({
|
|
|
367388
367616
|
"use strict";
|
|
367389
367617
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
367390
367618
|
exports2.nodeModuleRegistry = void 0;
|
|
367619
|
+
var classifier_1 = require_classifier();
|
|
367391
367620
|
var contracts_1 = require_contracts();
|
|
367392
367621
|
var workflow_shared_1 = require_cjs2();
|
|
367393
367622
|
var remote_1 = require_remote();
|
|
@@ -368626,6 +368855,7 @@ var require_modules = __commonJS({
|
|
|
368626
368855
|
};
|
|
368627
368856
|
}
|
|
368628
368857
|
exports2.nodeModuleRegistry = /* @__PURE__ */ new Map([
|
|
368858
|
+
[classifier_1.classifierModule.kind, classifier_1.classifierModule],
|
|
368629
368859
|
[llmModule.kind, llmModule],
|
|
368630
368860
|
[remoteExecutableModule.kind, remoteExecutableModule],
|
|
368631
368861
|
[remoteAgentModule.kind, remoteAgentModule],
|
|
@@ -368943,12 +369173,33 @@ var require_transpile = __commonJS({
|
|
|
368943
369173
|
return createFailedSplitterNode(workflowKey, declaration);
|
|
368944
369174
|
if (declaration.node.nodeKind === "crop")
|
|
368945
369175
|
return createFailedCropNode(workflowKey, declaration);
|
|
369176
|
+
if (declaration.node.nodeKind === "classifier")
|
|
369177
|
+
return createFailedClassifierNode(workflowKey, declaration);
|
|
368946
369178
|
if (declaration.node.nodeKind === "doc-template")
|
|
368947
369179
|
return createFailedDocTemplateNode(workflowKey, declaration);
|
|
368948
369180
|
if (declaration.node.nodeKind === "remote-executable" || declaration.node.nodeKind === "remote-agent" || declaration.node.nodeKind === "remote-template")
|
|
368949
369181
|
return createFailedRemoteNode(workflowKey, declaration);
|
|
368950
369182
|
return createFailedPromptNode(workflowKey, declaration);
|
|
368951
369183
|
}
|
|
369184
|
+
function createFailedClassifierNode(workflowKey, declaration) {
|
|
369185
|
+
const nodeId = (0, ids_1.stableNodeId)(workflowKey, declaration.node, declaration.path);
|
|
369186
|
+
const linearPorts = failedNodePorts(nodeId);
|
|
369187
|
+
const module3 = modules_1.nodeModuleRegistry.get(declaration.node.nodeKind);
|
|
369188
|
+
return {
|
|
369189
|
+
declarationIndex: declaration.ordinal,
|
|
369190
|
+
path: declaration.path,
|
|
369191
|
+
scopePath: declaration.scopePath,
|
|
369192
|
+
sequenceIndex: declaration.sequenceIndex,
|
|
369193
|
+
linearPorts,
|
|
369194
|
+
node: {
|
|
369195
|
+
id: nodeId,
|
|
369196
|
+
name: declaration.node.name,
|
|
369197
|
+
actionId: module3?.actionId ?? workflow_shared_1.WORKFLOW_ACTION_IDS.jevEvaluator,
|
|
369198
|
+
ports: workflowNodePorts(linearPorts),
|
|
369199
|
+
input: module3?.createFailedInput(declaration.node) ?? {}
|
|
369200
|
+
}
|
|
369201
|
+
};
|
|
369202
|
+
}
|
|
368952
369203
|
function createFailedDocTemplateNode(workflowKey, declaration) {
|
|
368953
369204
|
const nodeId = (0, ids_1.stableNodeId)(workflowKey, declaration.node, declaration.path);
|
|
368954
369205
|
const linearPorts = failedNodePorts(nodeId);
|
|
@@ -370249,6 +370500,7 @@ var require_evaluate_source = __commonJS({
|
|
|
370249
370500
|
collectWorkflowCodeAliasBindings(node, node.statements, "build", scopedBindings.buildBindings, scopedBindings.buildNamespaceBindings, scopedBindings.buildNamespaceMemberBindings);
|
|
370250
370501
|
collectWorkflowCodeAliasBindings(node, node.statements, "code", scopedBindings.codeBindings, scopedBindings.codeNamespaceBindings, scopedBindings.codeNamespaceMemberBindings);
|
|
370251
370502
|
collectWorkflowCodeAliasBindings(node, node.statements, "agent", scopedBindings.promptNodeBindings, scopedBindings.promptNodeNamespaceBindings, scopedBindings.promptNodeNamespaceMemberBindings);
|
|
370503
|
+
collectWorkflowCodeAliasBindings(node, node.statements, "classifier", scopedBindings.promptNodeBindings, scopedBindings.promptNodeNamespaceBindings, scopedBindings.promptNodeNamespaceMemberBindings);
|
|
370252
370504
|
collectWorkflowCodeAliasBindings(node, node.statements, "llm", scopedBindings.promptNodeBindings, scopedBindings.promptNodeNamespaceBindings, scopedBindings.promptNodeNamespaceMemberBindings);
|
|
370253
370505
|
collectWorkflowCodeAliasBindings(node, node.statements, "map", scopedBindings.promptNodeBindings, scopedBindings.promptNodeNamespaceBindings, scopedBindings.promptNodeNamespaceMemberBindings);
|
|
370254
370506
|
collectWorkflowCodeAliasBindings(node, node.statements, "docTemplate", scopedBindings.promptNodeBindings, scopedBindings.promptNodeNamespaceBindings, scopedBindings.promptNodeNamespaceMemberBindings);
|
|
@@ -370432,7 +370684,7 @@ var require_evaluate_source = __commonJS({
|
|
|
370432
370684
|
return Boolean(namespaceMemberBindings.get(root)?.has(members.join(".")));
|
|
370433
370685
|
}
|
|
370434
370686
|
function isPromptNodeMemberName(name) {
|
|
370435
|
-
return name === "agent" || name === "condition" || name === "docTemplate" || name === "llm" || name === "map";
|
|
370687
|
+
return name === "agent" || name === "condition" || name === "docTemplate" || name === "classifier" || name === "llm" || name === "map";
|
|
370436
370688
|
}
|
|
370437
370689
|
function isWorkflowCodeMemberExpression(expression, memberName, memberBindings, namespaceBindings, namespaceMemberBindings) {
|
|
370438
370690
|
const unwrapped = unwrapExpression(expression);
|
|
@@ -370952,7 +371204,7 @@ var require_evaluate_source = __commonJS({
|
|
|
370952
371204
|
}
|
|
370953
371205
|
}
|
|
370954
371206
|
function addWorkflowCodePromptNodeMembersToExport(prefix, exportedNamespaces) {
|
|
370955
|
-
for (const memberName of ["agent", "condition", "llm", "map"])
|
|
371207
|
+
for (const memberName of ["agent", "classifier", "condition", "llm", "map"])
|
|
370956
371208
|
exportedNamespaces.add(`${prefix}.${memberName}`);
|
|
370957
371209
|
}
|
|
370958
371210
|
function addWorkflowCodeNamespaceMembersToExport(members, prefix, exportedNamespaces) {
|
|
@@ -371038,7 +371290,7 @@ var require_evaluate_source = __commonJS({
|
|
|
371038
371290
|
exportedNames.codeNamespaces.add(statement.exportClause.name.text);
|
|
371039
371291
|
for (const exportedName of targetExports.codeNamespaces)
|
|
371040
371292
|
exportedNames.codeNamespaces.add(`${statement.exportClause.name.text}.${exportedName}`);
|
|
371041
|
-
for (const memberName of ["agent", "condition", "llm", "map"]) {
|
|
371293
|
+
for (const memberName of ["agent", "classifier", "condition", "llm", "map"]) {
|
|
371042
371294
|
if (targetExports.promptNodes.has(memberName))
|
|
371043
371295
|
exportedNames.promptNodeNamespaces.add(`${statement.exportClause.name.text}.${memberName}`);
|
|
371044
371296
|
}
|
|
@@ -371070,6 +371322,7 @@ var require_evaluate_source = __commonJS({
|
|
|
371070
371322
|
exportedNames.promptNodes.add("agent");
|
|
371071
371323
|
exportedNames.promptNodes.add("docTemplate");
|
|
371072
371324
|
exportedNames.promptNodes.add("condition");
|
|
371325
|
+
exportedNames.promptNodes.add("classifier");
|
|
371073
371326
|
exportedNames.promptNodes.add("llm");
|
|
371074
371327
|
exportedNames.promptNodes.add("map");
|
|
371075
371328
|
return;
|
|
@@ -371173,6 +371426,14 @@ const __workflowCodeApi = (() => {
|
|
|
371173
371426
|
const freeze = Object.freeze
|
|
371174
371427
|
const pathKey = '__workflowCodePath'
|
|
371175
371428
|
const cloneJson = (value) => value == null ? value : JSON.parse(JSON.stringify(value))
|
|
371429
|
+
const freezeClassifierQuestions = (value) => {
|
|
371430
|
+
if (value && typeof value === 'object') {
|
|
371431
|
+
for (const child of Object.values(value))
|
|
371432
|
+
freezeClassifierQuestions(child)
|
|
371433
|
+
freeze(value)
|
|
371434
|
+
}
|
|
371435
|
+
return value
|
|
371436
|
+
}
|
|
371176
371437
|
const remoteRefBindingKey = Symbol.for('@meistrari/workflow-code/remote-ref-binding')
|
|
371177
371438
|
const sourceDiagnostic = (hint, source) => Object.freeze(Object.assign(Object.create(null), {
|
|
371178
371439
|
__workflowCodeSourceDiagnostic: true,
|
|
@@ -371670,6 +371931,10 @@ const __workflowCodeApi = (() => {
|
|
|
371670
371931
|
docTemplate: docTemplateNode,
|
|
371671
371932
|
condition: conditionNode,
|
|
371672
371933
|
input: freeze({ text: (options) => baseInput('text', options), file: (options) => baseInput('file', options) }),
|
|
371934
|
+
classifier: (options) => promptNode('classifier', options, (input) => ({
|
|
371935
|
+
questions: freezeClassifierQuestions(cloneJson(input.questions)),
|
|
371936
|
+
...(input.model !== undefined ? { model: input.model } : {}),
|
|
371937
|
+
})),
|
|
371673
371938
|
llm: (options) => promptNode('llm', options, llmInput),
|
|
371674
371939
|
map: mapNode,
|
|
371675
371940
|
splitter: splitterNode,
|
|
@@ -388835,22 +389100,24 @@ async function upgradeSkills(args, options2, io) {
|
|
|
388835
389100
|
getClient: async () => (await loadPantry(flags)).client,
|
|
388836
389101
|
onDiagnostic: (diagnostic) => writeSkillManagerDiagnostic(io, diagnostic)
|
|
388837
389102
|
});
|
|
388838
|
-
const { upgraded, unchanged } = await manager.upgradeSkills(flags.rest, {
|
|
389103
|
+
const { upgraded, unchanged, replaced } = await manager.upgradeSkills(flags.rest, {
|
|
388839
389104
|
force: flags.force,
|
|
388840
389105
|
ignoreScripts: flags.ignoreScripts,
|
|
388841
389106
|
...flags.symlink ? {} : { targets: [] }
|
|
388842
389107
|
});
|
|
388843
|
-
if (upgraded.length === 0 && unchanged.length === 0) {
|
|
389108
|
+
if (upgraded.length === 0 && unchanged.length === 0 && replaced.length === 0) {
|
|
388844
389109
|
if (options2.json)
|
|
388845
|
-
writeJson(io, { upgraded: [], unchanged: [] });
|
|
389110
|
+
writeJson(io, { upgraded: [], unchanged: [], replaced: [] });
|
|
388846
389111
|
else
|
|
388847
389112
|
writeLine(io, "No skills installed.");
|
|
388848
389113
|
return 0;
|
|
388849
389114
|
}
|
|
388850
389115
|
if (options2.json) {
|
|
388851
|
-
writeJson(io, { upgraded, unchanged });
|
|
389116
|
+
writeJson(io, { upgraded, unchanged, replaced });
|
|
388852
389117
|
return 0;
|
|
388853
389118
|
}
|
|
389119
|
+
for (const { from, to } of replaced)
|
|
389120
|
+
writeLine(io, `Replaced deprecated ${from} with ${to.slug} at ${to.sha.slice(0, 7)}`);
|
|
388854
389121
|
for (const entry of upgraded)
|
|
388855
389122
|
writeLine(io, `Upgraded ${entry.slug} to ${entry.sha.slice(0, 7)}`);
|
|
388856
389123
|
for (const slug of unchanged)
|