minimal-forge-work-pack-sync 0.1.26 → 0.1.28
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 +47 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7548,7 +7548,7 @@ 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.28";
|
|
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";
|
|
@@ -7922,7 +7922,7 @@ async function replaceFile(filename, contents) {
|
|
|
7922
7922
|
|
|
7923
7923
|
// packages/cli/src/workPackSyncPlugin.ts
|
|
7924
7924
|
var import_yaml = __toESM(require_dist(), 1);
|
|
7925
|
-
import { mkdir as mkdir3, readdir as readdir4, readFile as readFile4, rename as rename4, writeFile as writeFile4 } from "node:fs/promises";
|
|
7925
|
+
import { mkdir as mkdir3, mkdtemp as mkdtemp2, readdir as readdir4, readFile as readFile4, rename as rename4, writeFile as writeFile4 } from "node:fs/promises";
|
|
7926
7926
|
import path6 from "node:path";
|
|
7927
7927
|
|
|
7928
7928
|
// node_modules/@opencode-ai/plugin/node_modules/zod/v4/classic/external.js
|
|
@@ -25165,7 +25165,7 @@ function isRecord(value) {
|
|
|
25165
25165
|
}
|
|
25166
25166
|
|
|
25167
25167
|
// packages/cli/src/workPackSyncPlugin.ts
|
|
25168
|
-
var PLUGIN_VERSION = "0.1.
|
|
25168
|
+
var PLUGIN_VERSION = "0.1.28";
|
|
25169
25169
|
var FORGE_DECISION_TIMEOUT_MS = 11e4;
|
|
25170
25170
|
var STATUS_FILENAME = "work-pack-startup-status.json";
|
|
25171
25171
|
var activeSync = /* @__PURE__ */ new Map();
|
|
@@ -25224,6 +25224,7 @@ var ForgeWorkPackSyncServer = async (_input, options) => {
|
|
|
25224
25224
|
},
|
|
25225
25225
|
tool: {
|
|
25226
25226
|
forge_decide: createForgeDecisionTool(forgeBaseUrl, state.decisionBaseUrl, state.paths),
|
|
25227
|
+
forge_generate_codebook: createForgeCodebookTool(forgeBaseUrl, state.decisionBaseUrl, state.paths),
|
|
25227
25228
|
forge_feedback: createForgeFeedbackTool(forgeBaseUrl, state.paths)
|
|
25228
25229
|
}
|
|
25229
25230
|
};
|
|
@@ -25247,7 +25248,7 @@ function createForgeDecisionTool(forgeBaseUrl, decisionBaseUrl, paths) {
|
|
|
25247
25248
|
})
|
|
25248
25249
|
]);
|
|
25249
25250
|
return tool({
|
|
25250
|
-
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.",
|
|
25251
|
+
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. Guarda a resposta integral num ficheiro local e devolve response_file; copiar esse ficheiro, sem transcrever o JSON.",
|
|
25251
25252
|
args: {
|
|
25252
25253
|
state: tool.schema.union([
|
|
25253
25254
|
tool.schema.string(),
|
|
@@ -25257,6 +25258,8 @@ function createForgeDecisionTool(forgeBaseUrl, decisionBaseUrl, paths) {
|
|
|
25257
25258
|
questions: tool.schema.record(tool.schema.string(), question).describe("Perguntas identificadas por uma chave est\xE1vel")
|
|
25258
25259
|
},
|
|
25259
25260
|
async execute(args, context) {
|
|
25261
|
+
const responseDir = await mkdtemp2(path6.join(context.directory, ".forge-decision-"));
|
|
25262
|
+
const responseFile = path6.join(responseDir, "response.json");
|
|
25260
25263
|
const credentials = await readWellKnownForgeCredentials(paths.opencodeAuthPath, forgeBaseUrl);
|
|
25261
25264
|
const response = await fetch(`${decisionBaseUrl}/v1/decisions`, {
|
|
25262
25265
|
method: "POST",
|
|
@@ -25268,9 +25271,23 @@ function createForgeDecisionTool(forgeBaseUrl, decisionBaseUrl, paths) {
|
|
|
25268
25271
|
body: JSON.stringify({ state: args.state, questions: args.questions }),
|
|
25269
25272
|
signal: AbortSignal.any([context.abort, AbortSignal.timeout(FORGE_DECISION_TIMEOUT_MS)])
|
|
25270
25273
|
});
|
|
25271
|
-
const
|
|
25274
|
+
const raw = await response.text();
|
|
25275
|
+
let body;
|
|
25276
|
+
try {
|
|
25277
|
+
body = JSON.parse(raw);
|
|
25278
|
+
} catch {
|
|
25279
|
+
}
|
|
25272
25280
|
if (response.ok && body && typeof body === "object" && body.answers && typeof body.answers === "object") {
|
|
25273
|
-
|
|
25281
|
+
try {
|
|
25282
|
+
await writeFile4(responseFile, raw, { flag: "wx", mode: 384 });
|
|
25283
|
+
return JSON.stringify({ ...body, response_file: responseFile }, null, 2);
|
|
25284
|
+
} catch {
|
|
25285
|
+
return JSON.stringify({
|
|
25286
|
+
...body,
|
|
25287
|
+
response_file: null,
|
|
25288
|
+
persistence_error: "A decis\xE3o foi conclu\xEDda, mas n\xE3o foi poss\xEDvel guardar o ficheiro. Recuperar esta resposta do hist\xF3rico da ferramenta; n\xE3o repetir a chamada ao Jev."
|
|
25289
|
+
}, null, 2);
|
|
25290
|
+
}
|
|
25274
25291
|
}
|
|
25275
25292
|
const nested = body?.error && typeof body.error === "object" && !Array.isArray(body.error) ? body.error.message : void 0;
|
|
25276
25293
|
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})`;
|
|
@@ -25278,6 +25295,30 @@ function createForgeDecisionTool(forgeBaseUrl, decisionBaseUrl, paths) {
|
|
|
25278
25295
|
}
|
|
25279
25296
|
});
|
|
25280
25297
|
}
|
|
25298
|
+
function createForgeCodebookTool(forgeBaseUrl, gatewayBaseUrl, paths) {
|
|
25299
|
+
return tool({
|
|
25300
|
+
description: "Gera um rascunho de codebook em portugu\xEAs europeu a partir de uma pergunta e das respostas. Apresentar para aprova\xE7\xE3o humana antes de codificar; n\xE3o aplica c\xF3digos nem altera ficheiros.",
|
|
25301
|
+
args: {
|
|
25302
|
+
question: tool.schema.string().trim().min(1).max(1e4).describe("Texto da pergunta aberta"),
|
|
25303
|
+
responses: tool.schema.array(tool.schema.string().trim().min(1).max(2e4)).min(1).max(2e3).describe("Respostas da mesma pergunta, sem identificadores pessoais desnecess\xE1rios")
|
|
25304
|
+
},
|
|
25305
|
+
async execute(args, context) {
|
|
25306
|
+
const credentials = await readWellKnownForgeCredentials(paths.opencodeAuthPath, forgeBaseUrl);
|
|
25307
|
+
const response = await fetch(`${gatewayBaseUrl}/v1/codebooks`, {
|
|
25308
|
+
method: "POST",
|
|
25309
|
+
redirect: "error",
|
|
25310
|
+
headers: { authorization: `Bearer ${credentials.forgeApiKey}`, "content-type": "application/json" },
|
|
25311
|
+
body: JSON.stringify({ question: args.question, responses: args.responses }),
|
|
25312
|
+
signal: AbortSignal.any([context.abort, AbortSignal.timeout(FORGE_DECISION_TIMEOUT_MS)])
|
|
25313
|
+
});
|
|
25314
|
+
const body = await response.json().catch(() => void 0);
|
|
25315
|
+
if (response.ok && body && typeof body.codebook === "object" && body.codebook !== null) {
|
|
25316
|
+
return JSON.stringify(body, null, 2);
|
|
25317
|
+
}
|
|
25318
|
+
throw new Error(`O Forge n\xE3o concluiu o codebook (HTTP ${response.status}). Pe\xE7a ao respons\xE1vel para verificar a liga\xE7\xE3o Groq.`);
|
|
25319
|
+
}
|
|
25320
|
+
});
|
|
25321
|
+
}
|
|
25281
25322
|
function createForgeFeedbackTool(forgeBaseUrl, paths) {
|
|
25282
25323
|
return tool({
|
|
25283
25324
|
description: "Envia ao respons\xE1vel pelo Forge apenas a mensagem de feedback ou pedido de ajuda aprovada pela pessoa.",
|