@goah/cli 0.13.0 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LICENSE +201 -0
- package/dist/THIRD-PARTY-NOTICES.md +2319 -0
- package/dist/anthropic-messages-WBFOHES5.js +7214 -0
- package/dist/azure-openai-responses-NZFH3PO6.js +253 -0
- package/dist/chunk-25XSBFX6.js +639 -0
- package/dist/chunk-2QBQZGXF.js +110 -0
- package/dist/chunk-2ZP2NBW3.js +345 -0
- package/dist/chunk-4KA63VNZ.js +2 -0
- package/dist/chunk-4M6TXTT5.js +86 -0
- package/dist/chunk-4US7ZHT3.js +20 -0
- package/dist/chunk-6M3OOCKO.js +11809 -0
- package/dist/chunk-7AXAFDPG.js +17 -0
- package/dist/chunk-7E7V6OIU.js +920 -0
- package/dist/chunk-BXA47DTF.js +548 -0
- package/dist/chunk-D2DVAH37.js +25 -0
- package/dist/chunk-FSBUS2BI.js +26 -0
- package/dist/chunk-GKDRAHLI.js +4787 -0
- package/dist/chunk-H462EFJP.js +89 -0
- package/dist/chunk-IIJQ3DW4.js +35 -0
- package/dist/chunk-JQD5EWJY.js +34 -0
- package/dist/chunk-K26BVR6O.js +61 -0
- package/dist/chunk-KAO7WIXG.js +31 -0
- package/dist/chunk-KJ4HJCTK.js +1178 -0
- package/dist/chunk-LBKI23CC.js +9810 -0
- package/dist/chunk-LKBKZEHT.js +41 -0
- package/dist/chunk-MD7TLTXZ.js +18 -0
- package/dist/chunk-MPXK7QBL.js +868 -0
- package/dist/chunk-NRLGWZJC.js +11 -0
- package/dist/chunk-QBD6EJ2Z.js +1746 -0
- package/dist/chunk-R6I3VKME.js +132 -0
- package/dist/chunk-TJON22J4.js +87 -0
- package/dist/chunk-ULY36ME4.js +33097 -0
- package/dist/chunk-XALZLRYK.js +9221 -0
- package/dist/chunk-XPQKM3L7.js +57 -0
- package/dist/chunk-YH6YJ2IB.js +1773 -0
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +13716 -580
- package/dist/console/assets/{index-Rtc_B7cs.js → index-B1vGMXKr.js} +11 -11
- package/dist/console/assets/{index-Rtc_B7cs.js.map → index-B1vGMXKr.js.map} +1 -1
- package/dist/console/index.html +1 -1
- package/dist/dist-65MDQA4Q.js +1126 -0
- package/dist/dist-KNR2XL6J.js +39 -0
- package/dist/execution.d.ts +557 -2
- package/dist/execution.js +37 -2
- package/dist/faux-runner-worker.js +128 -0
- package/dist/google-generative-ai-YMHXZSFE.js +422 -0
- package/dist/google-vertex-X6DB3ZQ6.js +471 -0
- package/dist/index.d.ts +853 -25
- package/dist/index.js +84 -385
- package/dist/kernel.d.ts +39 -2
- package/dist/kernel.js +21 -2
- package/dist/mistral-conversations-TY3MMD6G.js +718 -0
- package/dist/multipart-parser-F6M4NJZU.js +373 -0
- package/dist/openai-codex-responses-BRDUMLN5.js +1374 -0
- package/dist/openai-completions-CX634XN3.js +1139 -0
- package/dist/openai-responses-HMCXJIHT.js +300 -0
- package/dist/openrouter-images-KTWET2H2.js +148 -0
- package/dist/pi-messages-XL5OEC4K.js +307 -0
- package/dist/pi-worker.js +671 -0
- package/dist/runner-pi.d.ts +342 -2
- package/dist/runner-pi.js +46 -2
- package/dist/runner-registry-GD4BYCQC.js +22 -0
- package/dist/sqlite.d.ts +446 -2
- package/dist/sqlite.js +15 -2
- package/dist/src-F2KBSV4T.js +1398 -0
- package/dist/supervisor.d.ts +625 -2
- package/dist/supervisor.js +39 -2
- package/dist/testkit.d.ts +564 -2
- package/dist/testkit.js +127 -2
- package/dist/transcript.d.ts +84 -2
- package/dist/transcript.js +25 -2
- package/dist/verification-worker.js +72 -0
- package/package.json +2 -26
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/control.d.ts +0 -106
- package/dist/control.d.ts.map +0 -1
- package/dist/control.js +0 -242
- package/dist/control.js.map +0 -1
- package/dist/execution.d.ts.map +0 -1
- package/dist/execution.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/kernel.d.ts.map +0 -1
- package/dist/kernel.js.map +0 -1
- package/dist/live-config.d.ts +0 -10
- package/dist/live-config.d.ts.map +0 -1
- package/dist/live-config.js +0 -44
- package/dist/live-config.js.map +0 -1
- package/dist/prompt-queue.d.ts +0 -13
- package/dist/prompt-queue.d.ts.map +0 -1
- package/dist/prompt-queue.js +0 -35
- package/dist/prompt-queue.js.map +0 -1
- package/dist/runner-pi.d.ts.map +0 -1
- package/dist/runner-pi.js.map +0 -1
- package/dist/runner-registry.d.ts +0 -8
- package/dist/runner-registry.d.ts.map +0 -1
- package/dist/runner-registry.js +0 -12
- package/dist/runner-registry.js.map +0 -1
- package/dist/searchable-select.d.ts +0 -24
- package/dist/searchable-select.d.ts.map +0 -1
- package/dist/searchable-select.js +0 -61
- package/dist/searchable-select.js.map +0 -1
- package/dist/secret-input.d.ts +0 -8
- package/dist/secret-input.d.ts.map +0 -1
- package/dist/secret-input.js +0 -14
- package/dist/secret-input.js.map +0 -1
- package/dist/setup-wizard.d.ts +0 -22
- package/dist/setup-wizard.d.ts.map +0 -1
- package/dist/setup-wizard.js +0 -154
- package/dist/setup-wizard.js.map +0 -1
- package/dist/sqlite.d.ts.map +0 -1
- package/dist/sqlite.js.map +0 -1
- package/dist/supervisor.d.ts.map +0 -1
- package/dist/supervisor.js.map +0 -1
- package/dist/testkit.d.ts.map +0 -1
- package/dist/testkit.js.map +0 -1
- package/dist/thread-inspect.d.ts +0 -47
- package/dist/thread-inspect.d.ts.map +0 -1
- package/dist/thread-inspect.js +0 -78
- package/dist/thread-inspect.js.map +0 -1
- package/dist/transcript.d.ts.map +0 -1
- package/dist/transcript.js.map +0 -1
- package/dist/tui-theme.d.ts +0 -17
- package/dist/tui-theme.d.ts.map +0 -1
- package/dist/tui-theme.js +0 -19
- package/dist/tui-theme.js.map +0 -1
- package/dist/tui.d.ts +0 -24
- package/dist/tui.d.ts.map +0 -1
- package/dist/tui.js +0 -784
- package/dist/tui.js.map +0 -1
- package/dist/update.d.ts +0 -16
- package/dist/update.d.ts.map +0 -1
- package/dist/update.js +0 -67
- package/dist/update.js.map +0 -1
- package/dist/web-console.d.ts +0 -33
- package/dist/web-console.d.ts.map +0 -1
- package/dist/web-console.js +0 -242
- package/dist/web-console.js.map +0 -1
- package/dist/welcome.d.ts +0 -30
- package/dist/welcome.d.ts.map +0 -1
- package/dist/welcome.js +0 -69
- package/dist/welcome.js.map +0 -1
- package/node_modules/goah-ledger-contract/dist/execution.d.ts +0 -544
- package/node_modules/goah-ledger-contract/dist/execution.d.ts.map +0 -1
- package/node_modules/goah-ledger-contract/dist/execution.js +0 -52
- package/node_modules/goah-ledger-contract/dist/execution.js.map +0 -1
- package/node_modules/goah-ledger-contract/dist/index.d.ts +0 -4
- package/node_modules/goah-ledger-contract/dist/index.d.ts.map +0 -1
- package/node_modules/goah-ledger-contract/dist/index.js +0 -4
- package/node_modules/goah-ledger-contract/dist/index.js.map +0 -1
- package/node_modules/goah-ledger-contract/dist/kernel.d.ts +0 -37
- package/node_modules/goah-ledger-contract/dist/kernel.d.ts.map +0 -1
- package/node_modules/goah-ledger-contract/dist/kernel.js +0 -8
- package/node_modules/goah-ledger-contract/dist/kernel.js.map +0 -1
- package/node_modules/goah-ledger-contract/dist/transcript.d.ts +0 -63
- package/node_modules/goah-ledger-contract/dist/transcript.d.ts.map +0 -1
- package/node_modules/goah-ledger-contract/dist/transcript.js +0 -115
- package/node_modules/goah-ledger-contract/dist/transcript.js.map +0 -1
- package/node_modules/goah-ledger-contract/package.json +0 -28
- package/node_modules/goah-ledger-sqlite/dist/index.d.ts +0 -86
- package/node_modules/goah-ledger-sqlite/dist/index.d.ts.map +0 -1
- package/node_modules/goah-ledger-sqlite/dist/index.js +0 -1254
- package/node_modules/goah-ledger-sqlite/dist/index.js.map +0 -1
- package/node_modules/goah-ledger-sqlite/package.json +0 -26
- package/node_modules/goah-runner-pi/dist/configurator.d.ts +0 -20
- package/node_modules/goah-runner-pi/dist/configurator.d.ts.map +0 -1
- package/node_modules/goah-runner-pi/dist/configurator.js +0 -423
- package/node_modules/goah-runner-pi/dist/configurator.js.map +0 -1
- package/node_modules/goah-runner-pi/dist/credential-store.d.ts +0 -14
- package/node_modules/goah-runner-pi/dist/credential-store.d.ts.map +0 -1
- package/node_modules/goah-runner-pi/dist/credential-store.js +0 -163
- package/node_modules/goah-runner-pi/dist/credential-store.js.map +0 -1
- package/node_modules/goah-runner-pi/dist/env-spec.d.ts +0 -17
- package/node_modules/goah-runner-pi/dist/env-spec.d.ts.map +0 -1
- package/node_modules/goah-runner-pi/dist/env-spec.js +0 -95
- package/node_modules/goah-runner-pi/dist/env-spec.js.map +0 -1
- package/node_modules/goah-runner-pi/dist/index.d.ts +0 -76
- package/node_modules/goah-runner-pi/dist/index.d.ts.map +0 -1
- package/node_modules/goah-runner-pi/dist/index.js +0 -326
- package/node_modules/goah-runner-pi/dist/index.js.map +0 -1
- package/node_modules/goah-runner-pi/dist/model-provider.d.ts +0 -30
- package/node_modules/goah-runner-pi/dist/model-provider.d.ts.map +0 -1
- package/node_modules/goah-runner-pi/dist/model-provider.js +0 -96
- package/node_modules/goah-runner-pi/dist/model-provider.js.map +0 -1
- package/node_modules/goah-runner-pi/dist/pi-worker.d.ts +0 -31
- package/node_modules/goah-runner-pi/dist/pi-worker.d.ts.map +0 -1
- package/node_modules/goah-runner-pi/dist/pi-worker.js +0 -579
- package/node_modules/goah-runner-pi/dist/pi-worker.js.map +0 -1
- package/node_modules/goah-runner-pi/dist/steering-no-ack.test-fixture.d.ts +0 -2
- package/node_modules/goah-runner-pi/dist/steering-no-ack.test-fixture.d.ts.map +0 -1
- package/node_modules/goah-runner-pi/dist/steering-no-ack.test-fixture.js +0 -3
- package/node_modules/goah-runner-pi/dist/steering-no-ack.test-fixture.js.map +0 -1
- package/node_modules/goah-runner-pi/dist/steering-reject.test-fixture.d.ts +0 -2
- package/node_modules/goah-runner-pi/dist/steering-reject.test-fixture.d.ts.map +0 -1
- package/node_modules/goah-runner-pi/dist/steering-reject.test-fixture.js +0 -5
- package/node_modules/goah-runner-pi/dist/steering-reject.test-fixture.js.map +0 -1
- package/node_modules/goah-runner-pi/dist/steering-worker.test-fixture.d.ts +0 -2
- package/node_modules/goah-runner-pi/dist/steering-worker.test-fixture.d.ts.map +0 -1
- package/node_modules/goah-runner-pi/dist/steering-worker.test-fixture.js +0 -5
- package/node_modules/goah-runner-pi/dist/steering-worker.test-fixture.js.map +0 -1
- package/node_modules/goah-runner-pi/dist/test-helpers.d.ts +0 -4
- package/node_modules/goah-runner-pi/dist/test-helpers.d.ts.map +0 -1
- package/node_modules/goah-runner-pi/dist/test-helpers.js +0 -13
- package/node_modules/goah-runner-pi/dist/test-helpers.js.map +0 -1
- package/node_modules/goah-runner-pi/dist/verification-worker.d.ts +0 -2
- package/node_modules/goah-runner-pi/dist/verification-worker.d.ts.map +0 -1
- package/node_modules/goah-runner-pi/dist/verification-worker.js +0 -46
- package/node_modules/goah-runner-pi/dist/verification-worker.js.map +0 -1
- package/node_modules/goah-runner-pi/package.json +0 -28
- package/node_modules/goah-supervisor/dist/context-view.d.ts +0 -30
- package/node_modules/goah-supervisor/dist/context-view.d.ts.map +0 -1
- package/node_modules/goah-supervisor/dist/context-view.js +0 -58
- package/node_modules/goah-supervisor/dist/context-view.js.map +0 -1
- package/node_modules/goah-supervisor/dist/index.d.ts +0 -96
- package/node_modules/goah-supervisor/dist/index.d.ts.map +0 -1
- package/node_modules/goah-supervisor/dist/index.js +0 -1075
- package/node_modules/goah-supervisor/dist/index.js.map +0 -1
- package/node_modules/goah-supervisor/dist/roles.d.ts +0 -4
- package/node_modules/goah-supervisor/dist/roles.d.ts.map +0 -1
- package/node_modules/goah-supervisor/dist/roles.js +0 -29
- package/node_modules/goah-supervisor/dist/roles.js.map +0 -1
- package/node_modules/goah-supervisor/dist/verification.d.ts +0 -61
- package/node_modules/goah-supervisor/dist/verification.d.ts.map +0 -1
- package/node_modules/goah-supervisor/dist/verification.js +0 -135
- package/node_modules/goah-supervisor/dist/verification.js.map +0 -1
- package/node_modules/goah-supervisor/package.json +0 -26
- package/node_modules/goah-testkit/dist/faux-runner-worker.d.ts +0 -2
- package/node_modules/goah-testkit/dist/faux-runner-worker.d.ts.map +0 -1
- package/node_modules/goah-testkit/dist/faux-runner-worker.js +0 -82
- package/node_modules/goah-testkit/dist/faux-runner-worker.js.map +0 -1
- package/node_modules/goah-testkit/dist/index.d.ts +0 -49
- package/node_modules/goah-testkit/dist/index.d.ts.map +0 -1
- package/node_modules/goah-testkit/dist/index.js +0 -96
- package/node_modules/goah-testkit/dist/index.js.map +0 -1
- package/node_modules/goah-testkit/package.json +0 -29
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
import { createRequire as __goahCreateRequire } from "node:module";
|
|
2
|
+
const require = __goahCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// ../../node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js
|
|
5
|
+
var UnsupportedStrictJsonSchemaError = class extends Error {
|
|
6
|
+
};
|
|
7
|
+
var UNSUPPORTED_STRICT_SCHEMA_KEYS = [
|
|
8
|
+
"$ref",
|
|
9
|
+
"$defs",
|
|
10
|
+
"definitions",
|
|
11
|
+
"allOf",
|
|
12
|
+
"oneOf",
|
|
13
|
+
"patternProperties",
|
|
14
|
+
"dependentSchemas",
|
|
15
|
+
"dependencies",
|
|
16
|
+
"unevaluatedProperties",
|
|
17
|
+
"propertyNames",
|
|
18
|
+
"contains",
|
|
19
|
+
"prefixItems",
|
|
20
|
+
"not",
|
|
21
|
+
"if",
|
|
22
|
+
"then",
|
|
23
|
+
"else"
|
|
24
|
+
];
|
|
25
|
+
function isJsonSchemaObject(value) {
|
|
26
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27
|
+
}
|
|
28
|
+
function isStructuredSchema(schema) {
|
|
29
|
+
if (!isJsonSchemaObject(schema))
|
|
30
|
+
return false;
|
|
31
|
+
const types = typeof schema.type === "string" ? [schema.type] : Array.isArray(schema.type) ? schema.type : [];
|
|
32
|
+
return types.includes("object") || types.includes("array") || schema.properties !== void 0 || schema.items !== void 0;
|
|
33
|
+
}
|
|
34
|
+
function schemaAllowsNull(schema) {
|
|
35
|
+
if (!isJsonSchemaObject(schema))
|
|
36
|
+
return false;
|
|
37
|
+
if (schema.type === "null" || Array.isArray(schema.type) && schema.type.includes("null"))
|
|
38
|
+
return true;
|
|
39
|
+
if (schema.const === null || Array.isArray(schema.enum) && schema.enum.includes(null))
|
|
40
|
+
return true;
|
|
41
|
+
return Array.isArray(schema.anyOf) && schema.anyOf.some((variant) => schemaAllowsNull(variant));
|
|
42
|
+
}
|
|
43
|
+
function makeJsonSchemaNodeStrict(schema) {
|
|
44
|
+
if (!isJsonSchemaObject(schema)) {
|
|
45
|
+
throw new UnsupportedStrictJsonSchemaError("boolean schemas are unsupported");
|
|
46
|
+
}
|
|
47
|
+
for (const key of UNSUPPORTED_STRICT_SCHEMA_KEYS) {
|
|
48
|
+
if (schema[key] !== void 0) {
|
|
49
|
+
throw new UnsupportedStrictJsonSchemaError(`${key} schemas are unsupported`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (schema.anyOf !== void 0) {
|
|
53
|
+
if (!Array.isArray(schema.anyOf) || schema.anyOf.length === 0) {
|
|
54
|
+
throw new UnsupportedStrictJsonSchemaError("anyOf must contain at least one schema");
|
|
55
|
+
}
|
|
56
|
+
for (const variant of schema.anyOf) {
|
|
57
|
+
if (isStructuredSchema(variant)) {
|
|
58
|
+
throw new UnsupportedStrictJsonSchemaError("object and array unions are unsupported");
|
|
59
|
+
}
|
|
60
|
+
makeJsonSchemaNodeStrict(variant);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (schema.items !== void 0) {
|
|
64
|
+
if (Array.isArray(schema.items)) {
|
|
65
|
+
throw new UnsupportedStrictJsonSchemaError("tuple schemas are unsupported");
|
|
66
|
+
}
|
|
67
|
+
makeJsonSchemaNodeStrict(schema.items);
|
|
68
|
+
}
|
|
69
|
+
const isObjectSchema = schema.type === "object";
|
|
70
|
+
if (schema.properties !== void 0 && !isObjectSchema) {
|
|
71
|
+
throw new UnsupportedStrictJsonSchemaError("properties require type object");
|
|
72
|
+
}
|
|
73
|
+
if (!isObjectSchema)
|
|
74
|
+
return;
|
|
75
|
+
if (schema.additionalProperties !== void 0 && schema.additionalProperties !== false) {
|
|
76
|
+
throw new UnsupportedStrictJsonSchemaError("schema-valued or true additionalProperties is unsupported");
|
|
77
|
+
}
|
|
78
|
+
if (schema.properties !== void 0 && !isJsonSchemaObject(schema.properties)) {
|
|
79
|
+
throw new UnsupportedStrictJsonSchemaError("object properties must be a schema map");
|
|
80
|
+
}
|
|
81
|
+
if (schema.required !== void 0 && (!Array.isArray(schema.required) || schema.required.some((key) => typeof key !== "string"))) {
|
|
82
|
+
throw new UnsupportedStrictJsonSchemaError("object required must be a string array");
|
|
83
|
+
}
|
|
84
|
+
const properties = schema.properties ?? {};
|
|
85
|
+
const propertyNames = Object.keys(properties);
|
|
86
|
+
const required = new Set(Array.isArray(schema.required) ? schema.required : []);
|
|
87
|
+
if ([...required].some((key) => !propertyNames.includes(key))) {
|
|
88
|
+
throw new UnsupportedStrictJsonSchemaError("required contains an unknown property");
|
|
89
|
+
}
|
|
90
|
+
for (const [key, property] of Object.entries(properties)) {
|
|
91
|
+
makeJsonSchemaNodeStrict(property);
|
|
92
|
+
if (!required.has(key) && !schemaAllowsNull(property)) {
|
|
93
|
+
properties[key] = { anyOf: [property, { type: "null" }] };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
schema.required = propertyNames;
|
|
97
|
+
schema.additionalProperties = false;
|
|
98
|
+
}
|
|
99
|
+
function makeStrictJsonSchema(schema) {
|
|
100
|
+
const cloned = structuredClone(schema);
|
|
101
|
+
if (!isJsonSchemaObject(cloned)) {
|
|
102
|
+
throw new UnsupportedStrictJsonSchemaError("root schema must have type object");
|
|
103
|
+
}
|
|
104
|
+
makeJsonSchemaNodeStrict(cloned);
|
|
105
|
+
if (cloned.type !== "object") {
|
|
106
|
+
throw new UnsupportedStrictJsonSchemaError("root schema must have type object");
|
|
107
|
+
}
|
|
108
|
+
return cloned;
|
|
109
|
+
}
|
|
110
|
+
function getJsonSchemaToolParameters(tool, strict) {
|
|
111
|
+
return strict === true ? makeStrictJsonSchema(tool.parameters) : tool.parameters;
|
|
112
|
+
}
|
|
113
|
+
function getGrammarToolInput(toolName, arguments_, inputProperty) {
|
|
114
|
+
const input = arguments_[inputProperty];
|
|
115
|
+
if (typeof input !== "string") {
|
|
116
|
+
throw new Error(`Grammar tool call "${toolName}" requires argument "${inputProperty}" to be a string.`);
|
|
117
|
+
}
|
|
118
|
+
return input;
|
|
119
|
+
}
|
|
120
|
+
function appendGrammarToolInputJsonDelta(buffer, inputProperty, nextInput, close) {
|
|
121
|
+
if (buffer.closed) {
|
|
122
|
+
if (close && nextInput === buffer.input)
|
|
123
|
+
return void 0;
|
|
124
|
+
throw new Error(`grammar tool input for property "${inputProperty}" changed after it was closed`);
|
|
125
|
+
}
|
|
126
|
+
if (!nextInput.startsWith(buffer.input)) {
|
|
127
|
+
throw new Error(`grammar tool input for property "${inputProperty}" changed non-monotonically`);
|
|
128
|
+
}
|
|
129
|
+
const inputDelta = nextInput.slice(buffer.input.length);
|
|
130
|
+
if (!close && inputDelta.length === 0)
|
|
131
|
+
return void 0;
|
|
132
|
+
let delta = "";
|
|
133
|
+
if (!buffer.started) {
|
|
134
|
+
delta += `{${JSON.stringify(inputProperty)}:"`;
|
|
135
|
+
buffer.started = true;
|
|
136
|
+
}
|
|
137
|
+
delta += JSON.stringify(inputDelta).slice(1, -1);
|
|
138
|
+
buffer.input = nextInput;
|
|
139
|
+
if (close) {
|
|
140
|
+
delta += '"}';
|
|
141
|
+
buffer.closed = true;
|
|
142
|
+
}
|
|
143
|
+
return delta;
|
|
144
|
+
}
|
|
145
|
+
function inferGrammarInputProperty(tool) {
|
|
146
|
+
const schema = tool.parameters;
|
|
147
|
+
if (schema.type !== "object") {
|
|
148
|
+
throw new Error("grammar constrained sampling requires an object parameter schema");
|
|
149
|
+
}
|
|
150
|
+
if (!Array.isArray(schema.required) || schema.required.length !== 1 || typeof schema.required[0] !== "string") {
|
|
151
|
+
throw new Error("grammar constrained sampling requires exactly one required string property");
|
|
152
|
+
}
|
|
153
|
+
const inputProperty = schema.required[0];
|
|
154
|
+
if (!schema.properties?.[inputProperty]) {
|
|
155
|
+
throw new Error(`grammar constrained sampling requires a properties entry for ${inputProperty}`);
|
|
156
|
+
}
|
|
157
|
+
if (schema.properties[inputProperty]?.type !== "string") {
|
|
158
|
+
throw new Error(`grammar constrained sampling property ${inputProperty} must have type string`);
|
|
159
|
+
}
|
|
160
|
+
return inputProperty;
|
|
161
|
+
}
|
|
162
|
+
function resolveJsonSchemaStrictSampling(tool, supportsStrictMode) {
|
|
163
|
+
const config = tool.constrainedSampling;
|
|
164
|
+
if (!config || config.type !== "json_schema")
|
|
165
|
+
return void 0;
|
|
166
|
+
if (supportsStrictMode) {
|
|
167
|
+
try {
|
|
168
|
+
makeStrictJsonSchema(tool.parameters);
|
|
169
|
+
return true;
|
|
170
|
+
} catch (error) {
|
|
171
|
+
if (!(error instanceof UnsupportedStrictJsonSchemaError))
|
|
172
|
+
throw error;
|
|
173
|
+
if (config.strict !== "require")
|
|
174
|
+
return void 0;
|
|
175
|
+
throw new Error(`Tool "${tool.name}" requires JSON-schema constrained sampling, but ${error.message}.`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (config.strict === "require") {
|
|
179
|
+
throw new Error(`Tool "${tool.name}" requires JSON-schema constrained sampling, but strict tools are unsupported.`);
|
|
180
|
+
}
|
|
181
|
+
return void 0;
|
|
182
|
+
}
|
|
183
|
+
function resolveGrammarConstrainedSampling(tool, supportsOpenAIGrammarTools) {
|
|
184
|
+
const config = tool.constrainedSampling;
|
|
185
|
+
if (!config || config.type !== "grammar") {
|
|
186
|
+
return void 0;
|
|
187
|
+
}
|
|
188
|
+
if (!supportsOpenAIGrammarTools) {
|
|
189
|
+
return void 0;
|
|
190
|
+
}
|
|
191
|
+
const larkDefinition = config.variants.openai_lark;
|
|
192
|
+
const regexDefinition = config.variants.openai_regex;
|
|
193
|
+
const hasLarkDefinition = typeof larkDefinition === "string" && larkDefinition.trim().length > 0;
|
|
194
|
+
const hasRegexDefinition = typeof regexDefinition === "string" && regexDefinition.trim().length > 0;
|
|
195
|
+
if (!hasLarkDefinition && !hasRegexDefinition) {
|
|
196
|
+
throw new Error(`Tool "${tool.name}" cannot use grammar constrained sampling: no supported grammar variant was provided.`);
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
return {
|
|
200
|
+
format: hasLarkDefinition ? "lark" : "regex",
|
|
201
|
+
definition: hasLarkDefinition ? larkDefinition : regexDefinition,
|
|
202
|
+
inputProperty: inferGrammarInputProperty(tool)
|
|
203
|
+
};
|
|
204
|
+
} catch (error) {
|
|
205
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
206
|
+
throw new Error(`Tool "${tool.name}" cannot use grammar constrained sampling: ${message}.`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function createGrammarToolInputProperties(tools, supportsOpenAIGrammarTools) {
|
|
210
|
+
const properties = /* @__PURE__ */ new Map();
|
|
211
|
+
for (const tool of tools ?? []) {
|
|
212
|
+
const grammar = resolveGrammarConstrainedSampling(tool, supportsOpenAIGrammarTools);
|
|
213
|
+
if (grammar) {
|
|
214
|
+
properties.set(tool.name, grammar.inputProperty);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return properties;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// ../../node_modules/@earendil-works/pi-ai/dist/utils/estimate.js
|
|
221
|
+
var CHARS_PER_TOKEN = 4;
|
|
222
|
+
var ESTIMATED_IMAGE_CHARS = 4800;
|
|
223
|
+
function calculateContextTokens(usage) {
|
|
224
|
+
return usage.totalTokens || usage.input + usage.output + usage.cacheRead + usage.cacheWrite;
|
|
225
|
+
}
|
|
226
|
+
function safeJsonStringify(value) {
|
|
227
|
+
try {
|
|
228
|
+
return JSON.stringify(value) ?? "undefined";
|
|
229
|
+
} catch {
|
|
230
|
+
return "[unserializable]";
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
function estimateTextAndImageContentChars(content) {
|
|
234
|
+
if (typeof content === "string")
|
|
235
|
+
return content.length;
|
|
236
|
+
let chars = 0;
|
|
237
|
+
for (const block of content)
|
|
238
|
+
chars += block.type === "text" ? block.text.length : ESTIMATED_IMAGE_CHARS;
|
|
239
|
+
return chars;
|
|
240
|
+
}
|
|
241
|
+
function estimateTextTokens(text) {
|
|
242
|
+
return Math.ceil(text.length / CHARS_PER_TOKEN);
|
|
243
|
+
}
|
|
244
|
+
function estimateTextAndImageContentTokens(content) {
|
|
245
|
+
return Math.ceil(estimateTextAndImageContentChars(content) / CHARS_PER_TOKEN);
|
|
246
|
+
}
|
|
247
|
+
function estimateMessageTokens(message) {
|
|
248
|
+
let chars = 0;
|
|
249
|
+
if (message.role === "user")
|
|
250
|
+
return estimateTextAndImageContentTokens(message.content);
|
|
251
|
+
if (message.role === "toolResult")
|
|
252
|
+
return estimateTextAndImageContentTokens(message.content);
|
|
253
|
+
for (const block of message.content) {
|
|
254
|
+
if (block.type === "text") {
|
|
255
|
+
chars += block.text.length;
|
|
256
|
+
} else if (block.type === "thinking") {
|
|
257
|
+
chars += block.thinking.length;
|
|
258
|
+
} else {
|
|
259
|
+
chars += block.name.length + safeJsonStringify(block.arguments).length;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return Math.ceil(chars / CHARS_PER_TOKEN);
|
|
263
|
+
}
|
|
264
|
+
function getLastAssistantUsageInfo(messages) {
|
|
265
|
+
let latestPrefixTimestamp = Number.NEGATIVE_INFINITY;
|
|
266
|
+
let usageInfo;
|
|
267
|
+
for (let i = 0; i < messages.length; i++) {
|
|
268
|
+
const message = messages[i];
|
|
269
|
+
if (message.role === "assistant") {
|
|
270
|
+
const assistant = message;
|
|
271
|
+
const usageAppliesToPrefix = assistant.timestamp >= latestPrefixTimestamp;
|
|
272
|
+
if (usageAppliesToPrefix && assistant.stopReason !== "aborted" && assistant.stopReason !== "error" && calculateContextTokens(assistant.usage) > 0) {
|
|
273
|
+
usageInfo = { usage: assistant.usage, index: i };
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
latestPrefixTimestamp = Math.max(latestPrefixTimestamp, message.timestamp);
|
|
277
|
+
}
|
|
278
|
+
return usageInfo;
|
|
279
|
+
}
|
|
280
|
+
function estimateMessages(messages) {
|
|
281
|
+
const usageInfo = getLastAssistantUsageInfo(messages);
|
|
282
|
+
if (usageInfo) {
|
|
283
|
+
const usageTokens = calculateContextTokens(usageInfo.usage);
|
|
284
|
+
let trailingTokens = 0;
|
|
285
|
+
for (let i = usageInfo.index + 1; i < messages.length; i++) {
|
|
286
|
+
trailingTokens += estimateMessageTokens(messages[i]);
|
|
287
|
+
}
|
|
288
|
+
return { tokens: usageTokens + trailingTokens, usageTokens, trailingTokens, lastUsageIndex: usageInfo.index };
|
|
289
|
+
}
|
|
290
|
+
let tokens = 0;
|
|
291
|
+
for (const message of messages)
|
|
292
|
+
tokens += estimateMessageTokens(message);
|
|
293
|
+
return { tokens, usageTokens: 0, trailingTokens: tokens, lastUsageIndex: null };
|
|
294
|
+
}
|
|
295
|
+
function estimateToolsTokens(tools) {
|
|
296
|
+
if (!tools || tools.length === 0)
|
|
297
|
+
return 0;
|
|
298
|
+
return estimateTextTokens(safeJsonStringify(tools));
|
|
299
|
+
}
|
|
300
|
+
function isMessageArray(value) {
|
|
301
|
+
return Array.isArray(value);
|
|
302
|
+
}
|
|
303
|
+
function estimateContextTokens(context) {
|
|
304
|
+
if (isMessageArray(context))
|
|
305
|
+
return estimateMessages(context);
|
|
306
|
+
const estimate = estimateMessages(context.messages);
|
|
307
|
+
if (estimate.lastUsageIndex !== null) {
|
|
308
|
+
const addedNames = new Set(context.messages.slice(estimate.lastUsageIndex + 1).filter((message) => message.role === "toolResult").flatMap((message) => message.addedToolNames ?? []));
|
|
309
|
+
const addedToolTokens = estimateToolsTokens(context.tools?.filter((tool) => addedNames.has(tool.name)));
|
|
310
|
+
return {
|
|
311
|
+
tokens: estimate.tokens + addedToolTokens,
|
|
312
|
+
usageTokens: estimate.usageTokens,
|
|
313
|
+
trailingTokens: estimate.trailingTokens + addedToolTokens,
|
|
314
|
+
lastUsageIndex: estimate.lastUsageIndex
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
const prefixTokens = (context.systemPrompt ? estimateTextTokens(context.systemPrompt) : 0) + estimateToolsTokens(context.tools);
|
|
318
|
+
return {
|
|
319
|
+
tokens: estimate.tokens + prefixTokens,
|
|
320
|
+
usageTokens: estimate.usageTokens,
|
|
321
|
+
trailingTokens: estimate.trailingTokens + prefixTokens,
|
|
322
|
+
lastUsageIndex: estimate.lastUsageIndex
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// ../../node_modules/@earendil-works/pi-ai/dist/api/simple-options.js
|
|
327
|
+
var CONTEXT_SAFETY_TOKENS = 4096;
|
|
328
|
+
var MIN_MAX_TOKENS = 1;
|
|
329
|
+
function clampMaxTokensToContext(model, context, maxTokens) {
|
|
330
|
+
if (model.contextWindow <= 0)
|
|
331
|
+
return Math.max(MIN_MAX_TOKENS, maxTokens);
|
|
332
|
+
const available = model.contextWindow - estimateContextTokens(context).tokens - CONTEXT_SAFETY_TOKENS;
|
|
333
|
+
return Math.min(maxTokens, Math.max(MIN_MAX_TOKENS, available));
|
|
334
|
+
}
|
|
335
|
+
function buildBaseOptions(model, context, options, apiKey) {
|
|
336
|
+
const samplingParams = model.samplingParams || options?.samplingParams ? { ...model.samplingParams, ...options?.samplingParams } : void 0;
|
|
337
|
+
return {
|
|
338
|
+
temperature: options?.temperature,
|
|
339
|
+
samplingParams,
|
|
340
|
+
maxTokens: clampMaxTokensToContext(model, context, options?.maxTokens ?? model.maxTokens),
|
|
341
|
+
signal: options?.signal,
|
|
342
|
+
telemetryContext: options?.telemetryContext,
|
|
343
|
+
apiKey: apiKey || options?.apiKey,
|
|
344
|
+
fetch: options?.fetch,
|
|
345
|
+
transport: options?.transport,
|
|
346
|
+
cacheRetention: options?.cacheRetention,
|
|
347
|
+
sessionId: options?.sessionId,
|
|
348
|
+
headers: options?.headers,
|
|
349
|
+
onPayload: options?.onPayload,
|
|
350
|
+
onResponse: options?.onResponse,
|
|
351
|
+
timeoutMs: options?.timeoutMs,
|
|
352
|
+
websocketConnectTimeoutMs: options?.websocketConnectTimeoutMs,
|
|
353
|
+
maxRetries: options?.maxRetries,
|
|
354
|
+
maxRetryDelayMs: options?.maxRetryDelayMs,
|
|
355
|
+
metadata: options?.metadata,
|
|
356
|
+
env: options?.env
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
var MIN_ANSWER_TOKENS = 1024;
|
|
360
|
+
function clampReasoning(effort) {
|
|
361
|
+
return effort === "xhigh" || effort === "max" ? "high" : effort;
|
|
362
|
+
}
|
|
363
|
+
function adjustMaxTokensForThinking(baseMaxTokens, modelMaxTokens, reasoningLevel, customBudgets) {
|
|
364
|
+
const defaultBudgets = {
|
|
365
|
+
minimal: 1024,
|
|
366
|
+
low: 2048,
|
|
367
|
+
medium: 8192,
|
|
368
|
+
high: 16384
|
|
369
|
+
};
|
|
370
|
+
const budgets = { ...defaultBudgets, ...customBudgets };
|
|
371
|
+
const level = clampReasoning(reasoningLevel);
|
|
372
|
+
let thinkingBudget = budgets[level];
|
|
373
|
+
const maxTokens = baseMaxTokens === void 0 ? modelMaxTokens : Math.min(baseMaxTokens + thinkingBudget, modelMaxTokens);
|
|
374
|
+
if (maxTokens <= thinkingBudget) {
|
|
375
|
+
thinkingBudget = Math.max(0, maxTokens - MIN_ANSWER_TOKENS);
|
|
376
|
+
}
|
|
377
|
+
return { maxTokens, thinkingBudget };
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// ../../node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js
|
|
381
|
+
var NON_VISION_USER_IMAGE_PLACEHOLDER = "(image omitted: model does not support images)";
|
|
382
|
+
var NON_VISION_TOOL_IMAGE_PLACEHOLDER = "(tool image omitted: model does not support images)";
|
|
383
|
+
function replaceImagesWithPlaceholder(content, placeholder) {
|
|
384
|
+
const result = [];
|
|
385
|
+
let previousWasPlaceholder = false;
|
|
386
|
+
for (const block of content) {
|
|
387
|
+
if (block.type === "image") {
|
|
388
|
+
if (!previousWasPlaceholder) {
|
|
389
|
+
result.push({ type: "text", text: placeholder });
|
|
390
|
+
}
|
|
391
|
+
previousWasPlaceholder = true;
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
result.push(block);
|
|
395
|
+
previousWasPlaceholder = block.text === placeholder;
|
|
396
|
+
}
|
|
397
|
+
return result;
|
|
398
|
+
}
|
|
399
|
+
function downgradeUnsupportedImages(messages, model) {
|
|
400
|
+
if (model.input.includes("image")) {
|
|
401
|
+
return messages;
|
|
402
|
+
}
|
|
403
|
+
return messages.map((msg) => {
|
|
404
|
+
if (msg.role === "user" && Array.isArray(msg.content)) {
|
|
405
|
+
return {
|
|
406
|
+
...msg,
|
|
407
|
+
content: replaceImagesWithPlaceholder(msg.content, NON_VISION_USER_IMAGE_PLACEHOLDER)
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
if (msg.role === "toolResult") {
|
|
411
|
+
return {
|
|
412
|
+
...msg,
|
|
413
|
+
content: replaceImagesWithPlaceholder(msg.content, NON_VISION_TOOL_IMAGE_PLACEHOLDER)
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
return msg;
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
function transformMessages(messages, model, normalizeToolCallId) {
|
|
420
|
+
const toolCallIdMap = /* @__PURE__ */ new Map();
|
|
421
|
+
const normalizedMessages = messages.map((msg) => msg.content == null ? { ...msg, content: [] } : msg);
|
|
422
|
+
const imageAwareMessages = downgradeUnsupportedImages(normalizedMessages, model);
|
|
423
|
+
const transformed = imageAwareMessages.map((msg) => {
|
|
424
|
+
if (msg.role === "user") {
|
|
425
|
+
return msg;
|
|
426
|
+
}
|
|
427
|
+
if (msg.role === "toolResult") {
|
|
428
|
+
const normalizedId = toolCallIdMap.get(msg.toolCallId);
|
|
429
|
+
if (normalizedId && normalizedId !== msg.toolCallId) {
|
|
430
|
+
return { ...msg, toolCallId: normalizedId };
|
|
431
|
+
}
|
|
432
|
+
return msg;
|
|
433
|
+
}
|
|
434
|
+
if (msg.role === "assistant") {
|
|
435
|
+
const assistantMsg = msg;
|
|
436
|
+
const isSameModel = assistantMsg.provider === model.provider && assistantMsg.api === model.api && assistantMsg.model === model.id;
|
|
437
|
+
const transformedContent = assistantMsg.content.flatMap((block) => {
|
|
438
|
+
if (block.type === "thinking") {
|
|
439
|
+
if (block.redacted) {
|
|
440
|
+
return isSameModel ? block : [];
|
|
441
|
+
}
|
|
442
|
+
if (isSameModel && block.thinkingSignature)
|
|
443
|
+
return block;
|
|
444
|
+
if (!block.thinking || block.thinking.trim() === "")
|
|
445
|
+
return [];
|
|
446
|
+
if (isSameModel)
|
|
447
|
+
return block;
|
|
448
|
+
return {
|
|
449
|
+
type: "text",
|
|
450
|
+
text: block.thinking
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
if (block.type === "text") {
|
|
454
|
+
if (isSameModel)
|
|
455
|
+
return block;
|
|
456
|
+
return {
|
|
457
|
+
type: "text",
|
|
458
|
+
text: block.text
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
if (block.type === "toolCall") {
|
|
462
|
+
const toolCall = block;
|
|
463
|
+
let normalizedToolCall = toolCall;
|
|
464
|
+
if (!isSameModel && toolCall.thoughtSignature) {
|
|
465
|
+
normalizedToolCall = { ...toolCall };
|
|
466
|
+
delete normalizedToolCall.thoughtSignature;
|
|
467
|
+
}
|
|
468
|
+
if (!isSameModel && normalizeToolCallId) {
|
|
469
|
+
const normalizedId = normalizeToolCallId(toolCall.id, model, assistantMsg);
|
|
470
|
+
if (normalizedId !== toolCall.id) {
|
|
471
|
+
toolCallIdMap.set(toolCall.id, normalizedId);
|
|
472
|
+
normalizedToolCall = { ...normalizedToolCall, id: normalizedId };
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
return normalizedToolCall;
|
|
476
|
+
}
|
|
477
|
+
return block;
|
|
478
|
+
});
|
|
479
|
+
return {
|
|
480
|
+
...assistantMsg,
|
|
481
|
+
content: transformedContent
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
return msg;
|
|
485
|
+
});
|
|
486
|
+
const result = [];
|
|
487
|
+
let pendingToolCalls = [];
|
|
488
|
+
let existingToolResultIds = /* @__PURE__ */ new Set();
|
|
489
|
+
const insertSyntheticToolResults = () => {
|
|
490
|
+
if (pendingToolCalls.length > 0) {
|
|
491
|
+
for (const tc of pendingToolCalls) {
|
|
492
|
+
if (!existingToolResultIds.has(tc.id)) {
|
|
493
|
+
result.push({
|
|
494
|
+
role: "toolResult",
|
|
495
|
+
toolCallId: tc.id,
|
|
496
|
+
toolName: tc.name,
|
|
497
|
+
content: [{ type: "text", text: "No result provided" }],
|
|
498
|
+
isError: true,
|
|
499
|
+
timestamp: Date.now()
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
pendingToolCalls = [];
|
|
504
|
+
existingToolResultIds = /* @__PURE__ */ new Set();
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
for (let i = 0; i < transformed.length; i++) {
|
|
508
|
+
const msg = transformed[i];
|
|
509
|
+
if (msg.role === "assistant") {
|
|
510
|
+
insertSyntheticToolResults();
|
|
511
|
+
const assistantMsg = msg;
|
|
512
|
+
if (assistantMsg.stopReason === "error" || assistantMsg.stopReason === "aborted") {
|
|
513
|
+
continue;
|
|
514
|
+
}
|
|
515
|
+
const toolCalls = assistantMsg.content.filter((b) => b.type === "toolCall");
|
|
516
|
+
if (toolCalls.length > 0) {
|
|
517
|
+
pendingToolCalls = toolCalls;
|
|
518
|
+
existingToolResultIds = /* @__PURE__ */ new Set();
|
|
519
|
+
}
|
|
520
|
+
result.push(msg);
|
|
521
|
+
} else if (msg.role === "toolResult") {
|
|
522
|
+
existingToolResultIds.add(msg.toolCallId);
|
|
523
|
+
result.push(msg);
|
|
524
|
+
} else if (msg.role === "user") {
|
|
525
|
+
insertSyntheticToolResults();
|
|
526
|
+
result.push(msg);
|
|
527
|
+
} else {
|
|
528
|
+
result.push(msg);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
insertSyntheticToolResults();
|
|
532
|
+
return result;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
export {
|
|
536
|
+
getJsonSchemaToolParameters,
|
|
537
|
+
getGrammarToolInput,
|
|
538
|
+
appendGrammarToolInputJsonDelta,
|
|
539
|
+
resolveJsonSchemaStrictSampling,
|
|
540
|
+
resolveGrammarConstrainedSampling,
|
|
541
|
+
createGrammarToolInputProperties,
|
|
542
|
+
clampMaxTokensToContext,
|
|
543
|
+
buildBaseOptions,
|
|
544
|
+
MIN_ANSWER_TOKENS,
|
|
545
|
+
clampReasoning,
|
|
546
|
+
adjustMaxTokensForThinking,
|
|
547
|
+
transformMessages
|
|
548
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createRequire as __goahCreateRequire } from "node:module";
|
|
2
|
+
const require = __goahCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
createPiProcessRunner,
|
|
5
|
+
piRunnerConfigurator
|
|
6
|
+
} from "./chunk-7E7V6OIU.js";
|
|
7
|
+
|
|
8
|
+
// node_modules/.dist-original/runner-registry.js
|
|
9
|
+
var plugins = /* @__PURE__ */ new Map([
|
|
10
|
+
["pi", { configurator: piRunnerConfigurator(), create: createPiProcessRunner }]
|
|
11
|
+
]);
|
|
12
|
+
function runnerPlugin(id) {
|
|
13
|
+
const plugin = plugins.get(id);
|
|
14
|
+
if (!plugin)
|
|
15
|
+
throw new Error(`Runner is not installed: ${id}`);
|
|
16
|
+
return plugin;
|
|
17
|
+
}
|
|
18
|
+
function runnerManifests() {
|
|
19
|
+
return [...plugins.values()].map((plugin) => plugin.configurator.describe());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
runnerPlugin,
|
|
24
|
+
runnerManifests
|
|
25
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createRequire as __goahCreateRequire } from "node:module";
|
|
2
|
+
const require = __goahCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// ../../node_modules/@earendil-works/pi-ai/dist/utils/headers.js
|
|
5
|
+
function headersToRecord(headers) {
|
|
6
|
+
const result = {};
|
|
7
|
+
for (const [key, value] of headers.entries()) {
|
|
8
|
+
result[key] = value;
|
|
9
|
+
}
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
function providerHeadersToRecord(headers) {
|
|
13
|
+
if (!headers)
|
|
14
|
+
return void 0;
|
|
15
|
+
const result = {};
|
|
16
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
17
|
+
if (value !== null)
|
|
18
|
+
result[key] = value;
|
|
19
|
+
}
|
|
20
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
headersToRecord,
|
|
25
|
+
providerHeadersToRecord
|
|
26
|
+
};
|