@jigging/jig 0.1.0-alpha.6 → 0.1.0-alpha.7
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/README.md +1 -1
- package/libexec/agent/openai-responses-worker.js +115 -2
- package/libexec/installed-cli.js +113 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14096,6 +14096,109 @@ var MAX_INSTRUCTION_CHARACTERS2 = 1048576;
|
|
|
14096
14096
|
var MAX_RESPONSE_SCHEMA_BYTES2 = 256 * 1024;
|
|
14097
14097
|
var RESPONSE_FORMAT_NAME = "jig_agent_run_result";
|
|
14098
14098
|
var MAX_OUTPUT_TOKENS = 4096;
|
|
14099
|
+
var MAX_RESPONSE_SCHEMA_DEPTH = 8;
|
|
14100
|
+
var MAX_PROPERTIES_PER_OBJECT = 32;
|
|
14101
|
+
var MAX_RESPONSE_SCHEMA_PROPERTIES = 128;
|
|
14102
|
+
var MAX_ARRAY_ITEMS = 256;
|
|
14103
|
+
var MAX_RESPONSE_SCHEMA_ENUM_VALUES = 256;
|
|
14104
|
+
var MAX_RESPONSE_SCHEMA_SYMBOL_CHARACTERS = 120000;
|
|
14105
|
+
var MAX_LARGE_ENUM_CHARACTERS = 15000;
|
|
14106
|
+
function assertPrivateAgentResponseSchema(schema) {
|
|
14107
|
+
if (schema.$schema !== "https://flow.jig.md/schemas/schema-1.json")
|
|
14108
|
+
invalidSchemaProfile();
|
|
14109
|
+
const state2 = {
|
|
14110
|
+
properties: 0,
|
|
14111
|
+
enumValues: 0,
|
|
14112
|
+
symbolCharacters: 0
|
|
14113
|
+
};
|
|
14114
|
+
assertResponseSchemaNode(schema, 1, true, state2);
|
|
14115
|
+
}
|
|
14116
|
+
function assertResponseSchemaNode(value, depth, root, state2) {
|
|
14117
|
+
const schema = ordinaryRecord2(value);
|
|
14118
|
+
if (schema === undefined || depth > MAX_RESPONSE_SCHEMA_DEPTH)
|
|
14119
|
+
invalidSchemaProfile();
|
|
14120
|
+
if (schema.type === "object") {
|
|
14121
|
+
assertClosedResponseObject(schema, depth, root, state2);
|
|
14122
|
+
return;
|
|
14123
|
+
}
|
|
14124
|
+
if (root || Object.hasOwn(schema, "$schema"))
|
|
14125
|
+
invalidSchemaProfile();
|
|
14126
|
+
if (schema.type === "array") {
|
|
14127
|
+
const baseExpected = Object.hasOwn(schema, "minItems") ? ["items", "maxItems", "minItems", "type"] : ["items", "maxItems", "type"];
|
|
14128
|
+
if (!exactProfileKeys(schema, baseExpected) || !boundedNonnegativeInteger(schema.maxItems, MAX_ARRAY_ITEMS) || Object.hasOwn(schema, "minItems") && (!boundedNonnegativeInteger(schema.minItems, MAX_ARRAY_ITEMS) || schema.minItems > schema.maxItems)) {
|
|
14129
|
+
invalidSchemaProfile();
|
|
14130
|
+
}
|
|
14131
|
+
assertResponseSchemaNode(schema.items, depth + 1, false, state2);
|
|
14132
|
+
return;
|
|
14133
|
+
}
|
|
14134
|
+
if (schema.type === "integer" || isNullableType(schema.type, "integer")) {
|
|
14135
|
+
if (!exactProfileKeys(schema, ["type"]))
|
|
14136
|
+
invalidSchemaProfile();
|
|
14137
|
+
return;
|
|
14138
|
+
}
|
|
14139
|
+
if (schema.type === "string" || isNullableType(schema.type, "string")) {
|
|
14140
|
+
assertResponseString(schema, isNullableType(schema.type, "string"), state2);
|
|
14141
|
+
return;
|
|
14142
|
+
}
|
|
14143
|
+
invalidSchemaProfile();
|
|
14144
|
+
}
|
|
14145
|
+
function assertClosedResponseObject(schema, depth, root, state2) {
|
|
14146
|
+
const expected = root ? ["$schema", "additionalProperties", "properties", "required", "type"] : ["additionalProperties", "properties", "required", "type"];
|
|
14147
|
+
const properties = ordinaryRecord2(schema.properties);
|
|
14148
|
+
if (!exactProfileKeys(schema, expected) || schema.additionalProperties !== false || properties === undefined || !Array.isArray(schema.required)) {
|
|
14149
|
+
invalidSchemaProfile();
|
|
14150
|
+
}
|
|
14151
|
+
const names = Object.keys(properties);
|
|
14152
|
+
if (names.length === 0 || names.length > MAX_PROPERTIES_PER_OBJECT || schema.required.length !== names.length || new Set(schema.required).size !== names.length || schema.required.some((name) => typeof name !== "string" || !Object.hasOwn(properties, name))) {
|
|
14153
|
+
invalidSchemaProfile();
|
|
14154
|
+
}
|
|
14155
|
+
state2.properties += names.length;
|
|
14156
|
+
if (state2.properties > MAX_RESPONSE_SCHEMA_PROPERTIES)
|
|
14157
|
+
invalidSchemaProfile();
|
|
14158
|
+
for (const name of names) {
|
|
14159
|
+
state2.symbolCharacters += unicodeScalarLength(name);
|
|
14160
|
+
if (state2.symbolCharacters > MAX_RESPONSE_SCHEMA_SYMBOL_CHARACTERS)
|
|
14161
|
+
invalidSchemaProfile();
|
|
14162
|
+
assertResponseSchemaNode(properties[name], depth + 1, false, state2);
|
|
14163
|
+
}
|
|
14164
|
+
}
|
|
14165
|
+
function assertResponseString(schema, nullable, state2) {
|
|
14166
|
+
if (!Object.hasOwn(schema, "enum")) {
|
|
14167
|
+
if (!exactProfileKeys(schema, ["type"]))
|
|
14168
|
+
invalidSchemaProfile();
|
|
14169
|
+
return;
|
|
14170
|
+
}
|
|
14171
|
+
if (!exactProfileKeys(schema, ["enum", "type"]) || !Array.isArray(schema.enum) || schema.enum.length === 0 || schema.enum.length > MAX_RESPONSE_SCHEMA_ENUM_VALUES || schema.enum.some((item) => typeof item !== "string" && (!nullable || item !== null)) || new Set(schema.enum).size !== schema.enum.length || nullable && (!schema.enum.includes(null) || !schema.enum.some((item) => typeof item === "string"))) {
|
|
14172
|
+
invalidSchemaProfile();
|
|
14173
|
+
}
|
|
14174
|
+
state2.enumValues += schema.enum.length;
|
|
14175
|
+
const enumCharacters = schema.enum.reduce((total, item) => total + (typeof item === "string" ? unicodeScalarLength(item) : 0), 0);
|
|
14176
|
+
if (schema.enum.length > 250 && enumCharacters > MAX_LARGE_ENUM_CHARACTERS) {
|
|
14177
|
+
invalidSchemaProfile();
|
|
14178
|
+
}
|
|
14179
|
+
state2.symbolCharacters += enumCharacters;
|
|
14180
|
+
if (state2.enumValues > MAX_RESPONSE_SCHEMA_ENUM_VALUES)
|
|
14181
|
+
invalidSchemaProfile();
|
|
14182
|
+
if (state2.symbolCharacters > MAX_RESPONSE_SCHEMA_SYMBOL_CHARACTERS)
|
|
14183
|
+
invalidSchemaProfile();
|
|
14184
|
+
}
|
|
14185
|
+
function isNullableType(value, base) {
|
|
14186
|
+
return Array.isArray(value) && value.length === 2 && new Set(value).size === 2 && value.includes(base) && value.includes("null");
|
|
14187
|
+
}
|
|
14188
|
+
function exactProfileKeys(value, expected) {
|
|
14189
|
+
if (Object.hasOwn(value, "description") && typeof value.description !== "string")
|
|
14190
|
+
return false;
|
|
14191
|
+
return exactKeys2(value, Object.hasOwn(value, "description") ? [...expected, "description"] : expected);
|
|
14192
|
+
}
|
|
14193
|
+
function boundedNonnegativeInteger(value, maximum) {
|
|
14194
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 && value <= maximum;
|
|
14195
|
+
}
|
|
14196
|
+
function unicodeScalarLength(value) {
|
|
14197
|
+
return [...value].length;
|
|
14198
|
+
}
|
|
14199
|
+
function invalidSchemaProfile() {
|
|
14200
|
+
throw new TypeError("Agent responseSchema must use the bounded structured-output profile");
|
|
14201
|
+
}
|
|
14099
14202
|
async function requestPrivateOpenAIResponse(request, dependencies) {
|
|
14100
14203
|
requireClientRequest(request);
|
|
14101
14204
|
requireApiKey(dependencies.apiKey);
|
|
@@ -14187,13 +14290,13 @@ function createBody(request) {
|
|
|
14187
14290
|
format: {
|
|
14188
14291
|
type: "json_schema",
|
|
14189
14292
|
name: RESPONSE_FORMAT_NAME,
|
|
14190
|
-
schema:
|
|
14293
|
+
schema: projectPrivateAgentResponseSchema(request.responseSchema),
|
|
14191
14294
|
strict: true
|
|
14192
14295
|
}
|
|
14193
14296
|
}
|
|
14194
14297
|
};
|
|
14195
14298
|
}
|
|
14196
|
-
function
|
|
14299
|
+
function projectPrivateAgentResponseSchema(responseSchema) {
|
|
14197
14300
|
return Object.fromEntries(Object.entries(responseSchema).filter(([name]) => name !== "$schema"));
|
|
14198
14301
|
}
|
|
14199
14302
|
function requireClientRequest(request) {
|
|
@@ -14223,6 +14326,11 @@ function requireClientRequest(request) {
|
|
|
14223
14326
|
if (bytes.byteLength > MAX_RESPONSE_SCHEMA_BYTES2) {
|
|
14224
14327
|
throw new PrivateOpenAIResponsesError("AGENT_PROVIDER_CONFIGURATION", "OpenAI response schema exceeds its byte bound");
|
|
14225
14328
|
}
|
|
14329
|
+
try {
|
|
14330
|
+
assertPrivateAgentResponseSchema(request.responseSchema);
|
|
14331
|
+
} catch {
|
|
14332
|
+
throw new PrivateOpenAIResponsesError("AGENT_PROVIDER_CONFIGURATION", "OpenAI response schema is outside the supported profile");
|
|
14333
|
+
}
|
|
14226
14334
|
}
|
|
14227
14335
|
}
|
|
14228
14336
|
function requireEndpoint(baseURL) {
|
|
@@ -14306,6 +14414,11 @@ function ordinaryRecord2(value) {
|
|
|
14306
14414
|
return;
|
|
14307
14415
|
return value;
|
|
14308
14416
|
}
|
|
14417
|
+
function exactKeys2(value, expected) {
|
|
14418
|
+
const actual = Object.keys(value).sort();
|
|
14419
|
+
const sorted = [...expected].sort();
|
|
14420
|
+
return actual.length === sorted.length && actual.every((name, index) => name === sorted[index]);
|
|
14421
|
+
}
|
|
14309
14422
|
function boundedCharacters2(value, maximum) {
|
|
14310
14423
|
if (value.length === 0)
|
|
14311
14424
|
return false;
|
package/libexec/installed-cli.js
CHANGED
|
@@ -58797,23 +58797,108 @@ function protocolFailure2(message) {
|
|
|
58797
58797
|
|
|
58798
58798
|
// src/internal/openai-responses-client.ts
|
|
58799
58799
|
var MAX_RESPONSE_SCHEMA_BYTES2 = 256 * 1024;
|
|
58800
|
-
var
|
|
58801
|
-
var
|
|
58800
|
+
var MAX_RESPONSE_SCHEMA_DEPTH = 8;
|
|
58801
|
+
var MAX_PROPERTIES_PER_OBJECT = 32;
|
|
58802
|
+
var MAX_RESPONSE_SCHEMA_PROPERTIES = 128;
|
|
58803
|
+
var MAX_ARRAY_ITEMS = 256;
|
|
58804
|
+
var MAX_RESPONSE_SCHEMA_ENUM_VALUES = 256;
|
|
58805
|
+
var MAX_RESPONSE_SCHEMA_SYMBOL_CHARACTERS = 120000;
|
|
58806
|
+
var MAX_LARGE_ENUM_CHARACTERS = 15000;
|
|
58802
58807
|
function assertPrivateAgentResponseSchema(schema) {
|
|
58803
|
-
if (
|
|
58804
|
-
|
|
58808
|
+
if (schema.$schema !== "https://flow.jig.md/schemas/schema-1.json")
|
|
58809
|
+
invalidSchemaProfile();
|
|
58810
|
+
const state2 = {
|
|
58811
|
+
properties: 0,
|
|
58812
|
+
enumValues: 0,
|
|
58813
|
+
symbolCharacters: 0
|
|
58814
|
+
};
|
|
58815
|
+
assertResponseSchemaNode(schema, 1, true, state2);
|
|
58816
|
+
}
|
|
58817
|
+
function assertResponseSchemaNode(value, depth, root, state2) {
|
|
58818
|
+
const schema = ordinaryRecord4(value);
|
|
58819
|
+
if (schema === undefined || depth > MAX_RESPONSE_SCHEMA_DEPTH)
|
|
58820
|
+
invalidSchemaProfile();
|
|
58821
|
+
if (schema.type === "object") {
|
|
58822
|
+
assertClosedResponseObject(schema, depth, root, state2);
|
|
58823
|
+
return;
|
|
58824
|
+
}
|
|
58825
|
+
if (root || Object.hasOwn(schema, "$schema"))
|
|
58826
|
+
invalidSchemaProfile();
|
|
58827
|
+
if (schema.type === "array") {
|
|
58828
|
+
const baseExpected = Object.hasOwn(schema, "minItems") ? ["items", "maxItems", "minItems", "type"] : ["items", "maxItems", "type"];
|
|
58829
|
+
if (!exactProfileKeys(schema, baseExpected) || !boundedNonnegativeInteger(schema.maxItems, MAX_ARRAY_ITEMS) || Object.hasOwn(schema, "minItems") && (!boundedNonnegativeInteger(schema.minItems, MAX_ARRAY_ITEMS) || schema.minItems > schema.maxItems)) {
|
|
58830
|
+
invalidSchemaProfile();
|
|
58831
|
+
}
|
|
58832
|
+
assertResponseSchemaNode(schema.items, depth + 1, false, state2);
|
|
58833
|
+
return;
|
|
58834
|
+
}
|
|
58835
|
+
if (schema.type === "integer" || isNullableType(schema.type, "integer")) {
|
|
58836
|
+
if (!exactProfileKeys(schema, ["type"]))
|
|
58837
|
+
invalidSchemaProfile();
|
|
58838
|
+
return;
|
|
58839
|
+
}
|
|
58840
|
+
if (schema.type === "string" || isNullableType(schema.type, "string")) {
|
|
58841
|
+
assertResponseString(schema, isNullableType(schema.type, "string"), state2);
|
|
58842
|
+
return;
|
|
58843
|
+
}
|
|
58844
|
+
invalidSchemaProfile();
|
|
58845
|
+
}
|
|
58846
|
+
function assertClosedResponseObject(schema, depth, root, state2) {
|
|
58847
|
+
const expected = root ? ["$schema", "additionalProperties", "properties", "required", "type"] : ["additionalProperties", "properties", "required", "type"];
|
|
58848
|
+
const properties = ordinaryRecord4(schema.properties);
|
|
58849
|
+
if (!exactProfileKeys(schema, expected) || schema.additionalProperties !== false || properties === undefined || !Array.isArray(schema.required)) {
|
|
58850
|
+
invalidSchemaProfile();
|
|
58805
58851
|
}
|
|
58806
|
-
const properties = schema.properties;
|
|
58807
58852
|
const names = Object.keys(properties);
|
|
58808
|
-
if (names.length === 0 || names.length >
|
|
58809
|
-
|
|
58853
|
+
if (names.length === 0 || names.length > MAX_PROPERTIES_PER_OBJECT || schema.required.length !== names.length || new Set(schema.required).size !== names.length || schema.required.some((name) => typeof name !== "string" || !Object.hasOwn(properties, name))) {
|
|
58854
|
+
invalidSchemaProfile();
|
|
58810
58855
|
}
|
|
58811
|
-
|
|
58812
|
-
|
|
58813
|
-
|
|
58814
|
-
|
|
58815
|
-
|
|
58856
|
+
state2.properties += names.length;
|
|
58857
|
+
if (state2.properties > MAX_RESPONSE_SCHEMA_PROPERTIES)
|
|
58858
|
+
invalidSchemaProfile();
|
|
58859
|
+
for (const name of names) {
|
|
58860
|
+
state2.symbolCharacters += unicodeScalarLength2(name);
|
|
58861
|
+
if (state2.symbolCharacters > MAX_RESPONSE_SCHEMA_SYMBOL_CHARACTERS)
|
|
58862
|
+
invalidSchemaProfile();
|
|
58863
|
+
assertResponseSchemaNode(properties[name], depth + 1, false, state2);
|
|
58864
|
+
}
|
|
58865
|
+
}
|
|
58866
|
+
function assertResponseString(schema, nullable2, state2) {
|
|
58867
|
+
if (!Object.hasOwn(schema, "enum")) {
|
|
58868
|
+
if (!exactProfileKeys(schema, ["type"]))
|
|
58869
|
+
invalidSchemaProfile();
|
|
58870
|
+
return;
|
|
58871
|
+
}
|
|
58872
|
+
if (!exactProfileKeys(schema, ["enum", "type"]) || !Array.isArray(schema.enum) || schema.enum.length === 0 || schema.enum.length > MAX_RESPONSE_SCHEMA_ENUM_VALUES || schema.enum.some((item) => typeof item !== "string" && (!nullable2 || item !== null)) || new Set(schema.enum).size !== schema.enum.length || nullable2 && (!schema.enum.includes(null) || !schema.enum.some((item) => typeof item === "string"))) {
|
|
58873
|
+
invalidSchemaProfile();
|
|
58874
|
+
}
|
|
58875
|
+
state2.enumValues += schema.enum.length;
|
|
58876
|
+
const enumCharacters = schema.enum.reduce((total, item) => total + (typeof item === "string" ? unicodeScalarLength2(item) : 0), 0);
|
|
58877
|
+
if (schema.enum.length > 250 && enumCharacters > MAX_LARGE_ENUM_CHARACTERS) {
|
|
58878
|
+
invalidSchemaProfile();
|
|
58816
58879
|
}
|
|
58880
|
+
state2.symbolCharacters += enumCharacters;
|
|
58881
|
+
if (state2.enumValues > MAX_RESPONSE_SCHEMA_ENUM_VALUES)
|
|
58882
|
+
invalidSchemaProfile();
|
|
58883
|
+
if (state2.symbolCharacters > MAX_RESPONSE_SCHEMA_SYMBOL_CHARACTERS)
|
|
58884
|
+
invalidSchemaProfile();
|
|
58885
|
+
}
|
|
58886
|
+
function isNullableType(value, base) {
|
|
58887
|
+
return Array.isArray(value) && value.length === 2 && new Set(value).size === 2 && value.includes(base) && value.includes("null");
|
|
58888
|
+
}
|
|
58889
|
+
function exactProfileKeys(value, expected) {
|
|
58890
|
+
if (Object.hasOwn(value, "description") && typeof value.description !== "string")
|
|
58891
|
+
return false;
|
|
58892
|
+
return exactKeys5(value, Object.hasOwn(value, "description") ? [...expected, "description"] : expected);
|
|
58893
|
+
}
|
|
58894
|
+
function boundedNonnegativeInteger(value, maximum) {
|
|
58895
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 && value <= maximum;
|
|
58896
|
+
}
|
|
58897
|
+
function unicodeScalarLength2(value) {
|
|
58898
|
+
return [...value].length;
|
|
58899
|
+
}
|
|
58900
|
+
function invalidSchemaProfile() {
|
|
58901
|
+
throw new TypeError("Agent responseSchema must use the bounded structured-output profile");
|
|
58817
58902
|
}
|
|
58818
58903
|
var SILENT_LOGGER = Object.freeze({
|
|
58819
58904
|
error() {},
|
|
@@ -58821,6 +58906,9 @@ var SILENT_LOGGER = Object.freeze({
|
|
|
58821
58906
|
info() {},
|
|
58822
58907
|
debug() {}
|
|
58823
58908
|
});
|
|
58909
|
+
function projectPrivateAgentResponseSchema(responseSchema) {
|
|
58910
|
+
return Object.fromEntries(Object.entries(responseSchema).filter(([name]) => name !== "$schema"));
|
|
58911
|
+
}
|
|
58824
58912
|
function ordinaryRecord4(value) {
|
|
58825
58913
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
58826
58914
|
return;
|
|
@@ -59092,10 +59180,11 @@ function renderPrivateAgentRunInstructions(instructions, manifest) {
|
|
|
59092
59180
|
return rendered;
|
|
59093
59181
|
}
|
|
59094
59182
|
function renderPrivateAcpStructuredInstructions(instructions, responseSchema) {
|
|
59095
|
-
const schema = decoder10.decode(canonicalJson(responseSchema));
|
|
59183
|
+
const schema = decoder10.decode(canonicalJson(projectPrivateAgentResponseSchema(responseSchema)));
|
|
59096
59184
|
const rendered = [
|
|
59097
59185
|
instructions,
|
|
59098
59186
|
"Return only one JSON value matching this canonical FLOW Schema/1 schema:",
|
|
59187
|
+
"Do not wrap the JSON value in Markdown or a code fence.",
|
|
59099
59188
|
schema
|
|
59100
59189
|
].join(`
|
|
59101
59190
|
`);
|
|
@@ -59316,9 +59405,19 @@ function acpResultValue(turn, structuredRequested) {
|
|
|
59316
59405
|
return Object.freeze({
|
|
59317
59406
|
outcome,
|
|
59318
59407
|
text: turn.text,
|
|
59319
|
-
structured:
|
|
59408
|
+
structured: decodePrivateAcpStructuredText(turn.text)
|
|
59320
59409
|
});
|
|
59321
59410
|
}
|
|
59411
|
+
function decodePrivateAcpStructuredText(text) {
|
|
59412
|
+
try {
|
|
59413
|
+
return decodeJson1(encoder11.encode(text));
|
|
59414
|
+
} catch (rawError) {
|
|
59415
|
+
const match = /^```json\r?\n([\s\S]*)\r?\n```$/.exec(text.trim());
|
|
59416
|
+
if (match === null)
|
|
59417
|
+
throw rawError;
|
|
59418
|
+
return decodeJson1(encoder11.encode(match[1]));
|
|
59419
|
+
}
|
|
59420
|
+
}
|
|
59322
59421
|
async function releaseKnownAgent(input, lifecycleValue, fence) {
|
|
59323
59422
|
let lifecycle = lifecycleValue;
|
|
59324
59423
|
const sandbox = parseSandbox2(lifecycle);
|