minimal-forge-work-pack-sync 0.1.22 → 0.1.24
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/index.js +64 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7548,11 +7548,18 @@ var DEFAULT_DEBUG_TRACE_LIMITS = {
|
|
|
7548
7548
|
};
|
|
7549
7549
|
|
|
7550
7550
|
// packages/shared/src/contracts/settings.ts
|
|
7551
|
-
var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.
|
|
7551
|
+
var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.24";
|
|
7552
7552
|
var WORK_PACK_SYNC_PLUGIN_PACKAGE = `minimal-forge-work-pack-sync@${WORK_PACK_SYNC_PLUGIN_VERSION}`;
|
|
7553
7553
|
var WORK_PACK_SYNC_PLUGIN_FILENAME = `minimal-forge-work-pack-sync-${WORK_PACK_SYNC_PLUGIN_VERSION}.tgz`;
|
|
7554
7554
|
var FIRECRAWL_KEYLESS_MCP_NAME = "firecrawl";
|
|
7555
7555
|
var FIRECRAWL_KEYLESS_PERMISSION = `${FIRECRAWL_KEYLESS_MCP_NAME}_*`;
|
|
7556
|
+
function normalizeGatewayBaseUrl(value) {
|
|
7557
|
+
const url2 = new URL(value);
|
|
7558
|
+
if (url2.protocol !== "https:" || url2.username || url2.password || url2.port || url2.pathname !== "/" || url2.search || url2.hash) {
|
|
7559
|
+
throw new Error("Gateway URL must be an HTTPS origin without credentials, path, port, query or fragment");
|
|
7560
|
+
}
|
|
7561
|
+
return url2.origin;
|
|
7562
|
+
}
|
|
7556
7563
|
|
|
7557
7564
|
// packages/shared/src/workPackBaseline.ts
|
|
7558
7565
|
function normalizePackExtensionModel(pathLabel, content, approvedModelIds, slug) {
|
|
@@ -25158,7 +25165,7 @@ function isRecord(value) {
|
|
|
25158
25165
|
}
|
|
25159
25166
|
|
|
25160
25167
|
// packages/cli/src/workPackSyncPlugin.ts
|
|
25161
|
-
var PLUGIN_VERSION = "0.1.
|
|
25168
|
+
var PLUGIN_VERSION = "0.1.24";
|
|
25162
25169
|
var STATUS_FILENAME = "work-pack-startup-status.json";
|
|
25163
25170
|
var activeSync = /* @__PURE__ */ new Map();
|
|
25164
25171
|
var ForgeWorkPackSyncServer = async (_input, options) => {
|
|
@@ -25215,10 +25222,61 @@ var ForgeWorkPackSyncServer = async (_input, options) => {
|
|
|
25215
25222
|
if (state.forgeConfigVerified) applySharedWorkerPrompt(config2);
|
|
25216
25223
|
},
|
|
25217
25224
|
tool: {
|
|
25225
|
+
forge_decide: createForgeDecisionTool(forgeBaseUrl, state.decisionBaseUrl, state.paths),
|
|
25218
25226
|
forge_feedback: createForgeFeedbackTool(forgeBaseUrl, state.paths)
|
|
25219
25227
|
}
|
|
25220
25228
|
};
|
|
25221
25229
|
};
|
|
25230
|
+
function createForgeDecisionTool(forgeBaseUrl, decisionBaseUrl, paths) {
|
|
25231
|
+
const question = tool.schema.discriminatedUnion("type", [
|
|
25232
|
+
tool.schema.object({
|
|
25233
|
+
type: tool.schema.literal("noul"),
|
|
25234
|
+
instructions: tool.schema.string(),
|
|
25235
|
+
criteria: tool.schema.object({ true: tool.schema.string(), false: tool.schema.string() }).optional()
|
|
25236
|
+
}),
|
|
25237
|
+
tool.schema.object({
|
|
25238
|
+
type: tool.schema.literal("choice"),
|
|
25239
|
+
instructions: tool.schema.string(),
|
|
25240
|
+
criteria: tool.schema.record(tool.schema.string(), tool.schema.string())
|
|
25241
|
+
}),
|
|
25242
|
+
tool.schema.object({
|
|
25243
|
+
type: tool.schema.literal("score"),
|
|
25244
|
+
instructions: tool.schema.string(),
|
|
25245
|
+
criteria: tool.schema.array(tool.schema.string())
|
|
25246
|
+
})
|
|
25247
|
+
]);
|
|
25248
|
+
return tool({
|
|
25249
|
+
description: "Pede ao Jev uma ou mais decis\xF5es estruturadas sobre o mesmo estado. Usa este recurso para classifica\xE7\xE3o, escolha ou pontua\xE7\xE3o; n\xE3o para gerar texto livre.",
|
|
25250
|
+
args: {
|
|
25251
|
+
state: tool.schema.union([
|
|
25252
|
+
tool.schema.string(),
|
|
25253
|
+
tool.schema.record(tool.schema.string(), tool.schema.any()),
|
|
25254
|
+
tool.schema.array(tool.schema.any())
|
|
25255
|
+
]).describe("Texto, objeto ou lista com toda a evid\xEAncia necess\xE1ria para decidir"),
|
|
25256
|
+
questions: tool.schema.record(tool.schema.string(), question).describe("Perguntas identificadas por uma chave est\xE1vel")
|
|
25257
|
+
},
|
|
25258
|
+
async execute(args, context) {
|
|
25259
|
+
const credentials = await readWellKnownForgeCredentials(paths.opencodeAuthPath, forgeBaseUrl);
|
|
25260
|
+
const response = await fetch(`${decisionBaseUrl}/v1/decisions`, {
|
|
25261
|
+
method: "POST",
|
|
25262
|
+
redirect: "error",
|
|
25263
|
+
headers: {
|
|
25264
|
+
authorization: `Bearer ${credentials.forgeApiKey}`,
|
|
25265
|
+
"content-type": "application/json"
|
|
25266
|
+
},
|
|
25267
|
+
body: JSON.stringify({ state: args.state, questions: args.questions }),
|
|
25268
|
+
signal: AbortSignal.any([context.abort, AbortSignal.timeout(95e3)])
|
|
25269
|
+
});
|
|
25270
|
+
const body = await response.json().catch(() => void 0);
|
|
25271
|
+
if (response.ok && body && typeof body === "object" && body.answers && typeof body.answers === "object") {
|
|
25272
|
+
return JSON.stringify(body, null, 2);
|
|
25273
|
+
}
|
|
25274
|
+
const nested = body?.error && typeof body.error === "object" && !Array.isArray(body.error) ? body.error.message : void 0;
|
|
25275
|
+
const safeError = typeof nested === "string" && nested.length <= 300 ? nested.replace(/forge_[A-Za-z0-9_-]+/g, "<credencial oculta>") : `O Forge n\xE3o concluiu a decis\xE3o (HTTP ${response.status})`;
|
|
25276
|
+
throw new Error(safeError);
|
|
25277
|
+
}
|
|
25278
|
+
});
|
|
25279
|
+
}
|
|
25222
25280
|
function createForgeFeedbackTool(forgeBaseUrl, paths) {
|
|
25223
25281
|
return tool({
|
|
25224
25282
|
description: "Envia ao respons\xE1vel pelo Forge apenas a mensagem de feedback ou pedido de ajuda aprovada pela pessoa.",
|
|
@@ -25252,11 +25310,13 @@ async function synchronizeAtStartup(forgeBaseUrl, input) {
|
|
|
25252
25310
|
const before = await managedProjectionNames(paths);
|
|
25253
25311
|
let credentials;
|
|
25254
25312
|
let forgeConfigVerified = false;
|
|
25313
|
+
let decisionBaseUrl = forgeBaseUrl;
|
|
25255
25314
|
const runtime = await observeRuntime(input);
|
|
25256
25315
|
try {
|
|
25257
25316
|
await retireDebugCapture(paths);
|
|
25258
25317
|
credentials = await readWellKnownForgeCredentials(paths.opencodeAuthPath, forgeBaseUrl);
|
|
25259
25318
|
const manifest = await fetchManifest(credentials);
|
|
25319
|
+
if (manifest.gatewayBaseUrl) decisionBaseUrl = normalizeGatewayBaseUrl(manifest.gatewayBaseUrl);
|
|
25260
25320
|
forgeConfigVerified = true;
|
|
25261
25321
|
const result = await applyWorkPackManifest(paths, credentials, manifest, {});
|
|
25262
25322
|
await reportWorkPackObservations(credentials, "sync", result.workPackObservations, runtime);
|
|
@@ -25276,7 +25336,7 @@ async function synchronizeAtStartup(forgeBaseUrl, input) {
|
|
|
25276
25336
|
installed: result.installed,
|
|
25277
25337
|
removed: result.removed
|
|
25278
25338
|
});
|
|
25279
|
-
return { paths, before, after, forgeConfigVerified };
|
|
25339
|
+
return { paths, before, after, forgeConfigVerified, decisionBaseUrl };
|
|
25280
25340
|
} catch (error45) {
|
|
25281
25341
|
const message = safeErrorMessage(error45);
|
|
25282
25342
|
console.error("[Forge work-pack sync] Startup sync failed:", message);
|
|
@@ -25289,7 +25349,7 @@ async function synchronizeAtStartup(forgeBaseUrl, input) {
|
|
|
25289
25349
|
}).catch(() => void 0);
|
|
25290
25350
|
if (credentials) await reportFailure(credentials, "sync", new Error(message), runtime);
|
|
25291
25351
|
const after = await managedProjectionNames(paths).catch(() => before);
|
|
25292
|
-
return { paths, before, after, forgeConfigVerified };
|
|
25352
|
+
return { paths, before, after, forgeConfigVerified, decisionBaseUrl };
|
|
25293
25353
|
}
|
|
25294
25354
|
}
|
|
25295
25355
|
function resolveStartupPaths() {
|