minimal-forge-work-pack-sync 0.1.15 → 0.1.16

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.
Files changed (2) hide show
  1. package/dist/index.js +452 -220
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7367,6 +7367,417 @@ var require_dist = __commonJS({
7367
7367
  }
7368
7368
  });
7369
7369
 
7370
+ // packages/cli/src/workPackSyncPlugin.ts
7371
+ import { createHash as createHash4 } from "node:crypto";
7372
+ import { pathToFileURL } from "node:url";
7373
+
7374
+ // packages/cli/src/skillUsageReporter.ts
7375
+ function skillUsageReporter(origin, credentialId, send) {
7376
+ const symbol2 = /* @__PURE__ */ Symbol.for("minimal-forge.skill-usage.v1");
7377
+ const shared = globalThis;
7378
+ const origins = shared[symbol2] ??= /* @__PURE__ */ new Map();
7379
+ let owner = origins.get(origin);
7380
+ if (!owner) {
7381
+ owner = { seen: /* @__PURE__ */ new Map(), reporters: /* @__PURE__ */ new Map() };
7382
+ origins.set(origin, owner);
7383
+ }
7384
+ const seen = owner.seen;
7385
+ let state = owner.reporters.get(credentialId);
7386
+ if (!state) {
7387
+ state = { pending: [], sending: false, nextSend: 0 };
7388
+ owner.reporters.set(credentialId, state);
7389
+ }
7390
+ const reporter = state;
7391
+ function schedule() {
7392
+ if (reporter.timer || reporter.sending || !reporter.pending.length) return;
7393
+ reporter.timer = setTimeout(() => {
7394
+ reporter.timer = void 0;
7395
+ void flush();
7396
+ }, Math.max(1e3, reporter.nextSend - Date.now()));
7397
+ reporter.timer.unref?.();
7398
+ }
7399
+ async function flush() {
7400
+ if (reporter.sending || !reporter.pending.length) return;
7401
+ reporter.sending = true;
7402
+ reporter.nextSend = Date.now() + 12e4;
7403
+ const batch = reporter.pending.splice(0, 100);
7404
+ try {
7405
+ const response = await send(batch);
7406
+ if (response.status === 429) {
7407
+ reporter.pending.unshift(...batch);
7408
+ if (reporter.pending.length > 1e3) {
7409
+ reporter.pending.length = 1e3;
7410
+ console.error("[Forge evidence] Local usage buffer full after rate rejection");
7411
+ }
7412
+ const retry = Number(response.headers.get("retry-after"));
7413
+ reporter.nextSend = Date.now() + Math.max(12e4, Number.isFinite(retry) ? retry * 1e3 : 0);
7414
+ } else if (!response.ok) console.error(`[Forge evidence] Upload rejected (HTTP ${response.status})`);
7415
+ } catch {
7416
+ console.error("[Forge evidence] Upload unconfirmed; batch not retried");
7417
+ } finally {
7418
+ reporter.sending = false;
7419
+ schedule();
7420
+ }
7421
+ }
7422
+ return (sessionID, callID, slug) => {
7423
+ if (!sessionID || !callID) return;
7424
+ const now = Date.now();
7425
+ for (const [key2, at2] of seen) if (now - at2 > 24 * 60 * 6e4) seen.delete(key2);
7426
+ const key = JSON.stringify([sessionID, callID]);
7427
+ if (seen.has(key)) return;
7428
+ if (seen.size >= 2e4 || reporter.pending.length >= 1e3) {
7429
+ console.error("[Forge evidence] Local usage buffer full");
7430
+ return;
7431
+ }
7432
+ seen.set(key, now);
7433
+ const day = new Date(now).toISOString().slice(0, 10);
7434
+ const existing = reporter.pending.find((event) => event.slug === slug && event.day === day && event.count < 100);
7435
+ if (existing) existing.count++;
7436
+ else reporter.pending.push({ kind: "work_pack_invocation", slug, day, count: 1 });
7437
+ schedule();
7438
+ };
7439
+ }
7440
+
7441
+ // packages/shared/src/contracts/models.ts
7442
+ var BUILT_IN_OPENROUTER_MODELS = [
7443
+ {
7444
+ id: "anthropic/claude-sonnet-4-6",
7445
+ name: "Assistente de trabalho profundo",
7446
+ approvedByDefault: true,
7447
+ requiredInConfig: false,
7448
+ upstreamModel: "anthropic/claude-sonnet-4.6",
7449
+ metadata: {
7450
+ family: "anthropic",
7451
+ release_date: "2026-02-17",
7452
+ attachment: true,
7453
+ reasoning: true,
7454
+ temperature: true,
7455
+ tool_call: true,
7456
+ limit: { context: 1e6, output: 128e3 },
7457
+ modalities: { input: ["text", "image", "pdf"], output: ["text"] }
7458
+ }
7459
+ },
7460
+ {
7461
+ id: "anthropic/claude-haiku-4-5",
7462
+ name: "Assistente r\xE1pido",
7463
+ approvedByDefault: true,
7464
+ requiredInConfig: false,
7465
+ upstreamModel: "anthropic/claude-haiku-4.5",
7466
+ metadata: {
7467
+ family: "anthropic",
7468
+ release_date: "2025-10-15",
7469
+ attachment: true,
7470
+ reasoning: true,
7471
+ temperature: true,
7472
+ tool_call: true,
7473
+ limit: { context: 2e5, output: 64e3 },
7474
+ modalities: { input: ["text", "image", "pdf"], output: ["text"] }
7475
+ }
7476
+ },
7477
+ {
7478
+ id: "openai/gpt-5.4-mini",
7479
+ name: "Assistente de ficheiros e ecr\xE3",
7480
+ approvedByDefault: true,
7481
+ requiredInConfig: false,
7482
+ metadata: {
7483
+ family: "gpt-mini",
7484
+ release_date: "2026-03-17",
7485
+ attachment: true,
7486
+ reasoning: true,
7487
+ temperature: false,
7488
+ tool_call: true,
7489
+ limit: { context: 4e5, input: 272e3, output: 128e3 },
7490
+ modalities: { input: ["text", "image", "pdf"], output: ["text"] },
7491
+ variants: openRouterReasoningVariants(["none", "xhigh"])
7492
+ }
7493
+ },
7494
+ {
7495
+ id: "minimax/minimax-m3",
7496
+ name: "Assistente de pesquisa",
7497
+ approvedByDefault: true,
7498
+ requiredInConfig: false,
7499
+ metadata: {
7500
+ family: "minimax",
7501
+ release_date: "2026-04-07",
7502
+ attachment: true,
7503
+ reasoning: true,
7504
+ temperature: true,
7505
+ tool_call: true,
7506
+ limit: { context: 524288, output: 512e3 },
7507
+ modalities: { input: ["text", "image", "video"], output: ["text"] }
7508
+ }
7509
+ },
7510
+ {
7511
+ id: "minimax/minimax-m2.7",
7512
+ name: "Assistente de reda\xE7\xE3o",
7513
+ approvedByDefault: true,
7514
+ requiredInConfig: false,
7515
+ metadata: {
7516
+ family: "minimax",
7517
+ release_date: "2026-03-18",
7518
+ attachment: false,
7519
+ reasoning: true,
7520
+ temperature: true,
7521
+ tool_call: true,
7522
+ limit: { context: 196608, output: 196608 },
7523
+ modalities: { input: ["text"], output: ["text"] }
7524
+ }
7525
+ },
7526
+ {
7527
+ id: "xiaomi/mimo-v2.5",
7528
+ name: "Assistente de revis\xE3o multim\xE9dia",
7529
+ approvedByDefault: true,
7530
+ requiredInConfig: false,
7531
+ metadata: {
7532
+ family: "mimo",
7533
+ release_date: "2026-04-22",
7534
+ attachment: true,
7535
+ reasoning: true,
7536
+ temperature: true,
7537
+ tool_call: true,
7538
+ interleaved: { field: "reasoning_details" },
7539
+ limit: { context: 32e3, output: 131072 },
7540
+ modalities: { input: ["text", "audio", "image", "video"], output: ["text"] }
7541
+ }
7542
+ },
7543
+ {
7544
+ id: "xiaomi/mimo-v2.5-pro",
7545
+ name: "Assistente de contexto longo",
7546
+ approvedByDefault: true,
7547
+ requiredInConfig: false,
7548
+ metadata: {
7549
+ family: "mimo",
7550
+ release_date: "2026-04-22",
7551
+ attachment: false,
7552
+ reasoning: true,
7553
+ temperature: true,
7554
+ tool_call: true,
7555
+ interleaved: { field: "reasoning_content" },
7556
+ limit: { context: 1048576, output: 131072 },
7557
+ modalities: { input: ["text"], output: ["text"] }
7558
+ }
7559
+ },
7560
+ {
7561
+ id: "z-ai/glm-5.2",
7562
+ name: "Assistente de an\xE1lise",
7563
+ approvedByDefault: false,
7564
+ requiredInConfig: false,
7565
+ metadata: {
7566
+ family: "glm",
7567
+ release_date: "2026-02-12",
7568
+ attachment: false,
7569
+ reasoning: true,
7570
+ temperature: true,
7571
+ tool_call: true,
7572
+ interleaved: { field: "reasoning_content" },
7573
+ limit: { context: 1048576, output: 32768 },
7574
+ modalities: { input: ["text"], output: ["text"] }
7575
+ }
7576
+ }
7577
+ ];
7578
+ var APPROVED_MODELS = BUILT_IN_OPENROUTER_MODELS.filter((model) => model.approvedByDefault).map(stripCatalogFlags);
7579
+ function cloneModel(model) {
7580
+ return {
7581
+ id: model.id,
7582
+ name: model.name,
7583
+ ...model.provider ? { provider: model.provider } : {},
7584
+ ...model.upstreamModel ? { upstreamModel: model.upstreamModel } : {},
7585
+ ...model.billingMode ? { billingMode: model.billingMode } : {},
7586
+ ...model.metadata ? { metadata: structuredClone(model.metadata) } : {}
7587
+ };
7588
+ }
7589
+ function stripCatalogFlags(model) {
7590
+ const { approvedByDefault: _approvedByDefault, requiredInConfig: _requiredInConfig, ...approved } = model;
7591
+ return cloneModel(approved);
7592
+ }
7593
+ function openRouterReasoningVariants(efforts) {
7594
+ return Object.fromEntries(efforts.map((effort) => [effort, { reasoning: { effort } }]));
7595
+ }
7596
+
7597
+ // packages/shared/src/contracts/debugTrace.ts
7598
+ var DEFAULT_DEBUG_TRACE_LIMITS = {
7599
+ eventEnvelopeBytes: 256 * 1024,
7600
+ artifactChunkBytes: 2 * 1024 * 1024,
7601
+ // Serialized request bodies must remain comfortably below Vercel's 4.5 MB
7602
+ // function request limit after JSON and base64 overhead.
7603
+ uploadBatchBytes: 3 * 1024 * 1024,
7604
+ uploadBatchRecords: 100,
7605
+ fileSnapshotBytes: 1024 * 1024,
7606
+ serverTraceBudgetBytes: 250 * 1024 * 1024,
7607
+ workerTraceQuotaPer24h: 100,
7608
+ workerBytesQuotaPer24h: 1024 * 1024 * 1024,
7609
+ localQueueBytes: 1024 * 1024 * 1024,
7610
+ retryBackoffMinMs: 5e3,
7611
+ retryBackoffMaxMs: 5 * 60 * 1e3,
7612
+ queueMaxAgeDays: 7,
7613
+ rawTempExposureSeconds: 15 * 60
7614
+ };
7615
+
7616
+ // packages/shared/src/contracts/settings.ts
7617
+ var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.16";
7618
+ var WORK_PACK_SYNC_PLUGIN_PACKAGE = `minimal-forge-work-pack-sync@${WORK_PACK_SYNC_PLUGIN_VERSION}`;
7619
+ var WORK_PACK_SYNC_PLUGIN_FILENAME = `minimal-forge-work-pack-sync-${WORK_PACK_SYNC_PLUGIN_VERSION}.tgz`;
7620
+ var FIRECRAWL_KEYLESS_MCP_NAME = "firecrawl";
7621
+ var FIRECRAWL_KEYLESS_PERMISSION = `${FIRECRAWL_KEYLESS_MCP_NAME}_*`;
7622
+
7623
+ // packages/shared/src/workPackBaseline.ts
7624
+ function normalizePackExtensionModel(pathLabel, content, approvedModelIds, slug) {
7625
+ const match = /^---\n([\s\S]+?)\n---/.exec(content);
7626
+ const frontmatter = match?.[1];
7627
+ if (!match || frontmatter === void 0) return content;
7628
+ const modelLines = [...frontmatter.matchAll(/^model:\s*(.*?)\s*$/gm)];
7629
+ if (modelLines.length === 0) return content;
7630
+ if (modelLines.length > 1) {
7631
+ throw new Error(`A extens\xE3o ${pathLabel} do pacote de trabalho ${slug} define model mais do que uma vez`);
7632
+ }
7633
+ const rawModel = modelLines[0][1].replace(/^(['"])(.*)\1$/, "$2");
7634
+ const separator = rawModel.indexOf("/");
7635
+ const provider = separator > 0 ? rawModel.slice(0, separator) : "";
7636
+ const modelId = separator > 0 ? rawModel.slice(separator + 1) : "";
7637
+ if (provider !== "forge" && provider !== "openrouter" || !approvedModelIds.has(modelId)) {
7638
+ throw new Error(
7639
+ `A extens\xE3o ${pathLabel} do pacote de trabalho ${slug} usa um modelo que n\xE3o est\xE1 aprovado no Forge`
7640
+ );
7641
+ }
7642
+ if (provider === "forge") return content;
7643
+ const normalizedFrontmatter = frontmatter.replace(/^model:\s*.*?$/m, `model: forge/${modelId}`);
7644
+ return `${content.slice(0, match.index)}---
7645
+ ${normalizedFrontmatter}
7646
+ ---${content.slice(match.index + match[0].length)}`;
7647
+ }
7648
+ function canonicalWorkPackState(state) {
7649
+ const compare = (left, right) => left < right ? -1 : left > right ? 1 : 0;
7650
+ return JSON.stringify({
7651
+ schemaVersion: 1,
7652
+ version: state.version,
7653
+ files: [...state.files].sort((a, b2) => compare(a.path, b2.path)),
7654
+ directories: [...state.directories].sort(compare),
7655
+ agents: [...state.agents].sort((a, b2) => compare(a.filename, b2.filename)),
7656
+ commands: [...state.commands].sort((a, b2) => compare(a.filename, b2.filename))
7657
+ });
7658
+ }
7659
+
7660
+ // packages/cli/src/pluginWriter.ts
7661
+ var FORGE_PLUGIN_HEADER = "// Managed by Forge sync. Do not edit.";
7662
+ var FORGE_EVIDENCE_PLUGIN_FILENAME = "forge-evidence.js";
7663
+ function renderEvidencePlugin() {
7664
+ return `${FORGE_PLUGIN_HEADER}
7665
+ // Conta apenas atividade de sess\xE3o/fluxos de trabalho. N\xE3o envia texto de prompts, nomes de ficheiros nem conte\xFAdo.
7666
+ import { readFile } from "node:fs/promises"
7667
+ import { createHash } from "node:crypto"
7668
+ import os from "node:os"
7669
+ import path from "node:path"
7670
+
7671
+ ${skillUsageReporter.toString()}
7672
+
7673
+ const QUEUE = []
7674
+ let FLUSHING = false
7675
+
7676
+ export const ForgeEvidence = async () => ({
7677
+ event: async (input) => {
7678
+ try {
7679
+ const event = input?.event ?? input
7680
+ const kind = evidenceKind(event)
7681
+ if (!kind) return
7682
+ const slug = workPackSlug(event)
7683
+ QUEUE.push({ kind, ...(slug ? { slug } : {}), day: currentUtcDay(), count: 1 })
7684
+ if (QUEUE.length >= 10) await flush()
7685
+ } catch (error) {
7686
+ console.error("[Forge evidence] Telemetry send failed:", error instanceof Error ? error.message : String(error))
7687
+ }
7688
+ },
7689
+ "tool.execute.after": async (input, output) => {
7690
+ try {
7691
+ if (input?.tool !== "skill") return
7692
+ const slug = workPackSlug(input?.args) ?? workPackSlug(output?.metadata) ?? workPackSlug(output)
7693
+ if (!slug) return
7694
+ if (!(await isForgeManagedWorkPack(slug))) return
7695
+ const credentials = await readForgeCredentials()
7696
+ if (!credentials) return
7697
+ const origin = credentials.forgeBaseUrl.replace(/\\/$/, "")
7698
+ const credentialId = createHash("sha256").update(credentials.forgeApiKey).digest("hex")
7699
+ const report = skillUsageReporter(origin, credentialId, (events) => fetch(origin + "/sync/evidence", {
7700
+ method: "POST", redirect: "error",
7701
+ headers: { authorization: "Bearer " + credentials.forgeApiKey, "content-type": "application/json" },
7702
+ body: JSON.stringify({ events }), signal: AbortSignal.timeout(5_000)
7703
+ }))
7704
+ report(input.sessionID, input.callID, slug)
7705
+ } catch (error) {
7706
+ console.error("[Forge evidence] Telemetry send failed:", error instanceof Error ? error.message : String(error))
7707
+ }
7708
+ }
7709
+ })
7710
+
7711
+ function evidenceKind(event) {
7712
+ const type = String(event?.type ?? event?.name ?? "")
7713
+ if (type.includes("session.start") || type.startsWith("session.created")) return "session_start"
7714
+ if (type.includes("session.complete")) return "session_complete"
7715
+ if (type.includes("session.error")) return "session_error"
7716
+ return undefined
7717
+ }
7718
+
7719
+ function currentUtcDay() {
7720
+ return new Date().toISOString().slice(0, 10)
7721
+ }
7722
+
7723
+ function workPackSlug(value) {
7724
+ const raw = value?.slug ?? value?.name ?? value?.skill ?? value?.workPack ?? value?.tool?.slug
7725
+ if (typeof raw !== "string") return undefined
7726
+ const slug = raw.trim().toLowerCase()
7727
+ return /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(slug) ? slug : undefined
7728
+ }
7729
+
7730
+ async function isForgeManagedWorkPack(slug) {
7731
+ try {
7732
+ await readFile(path.join(openCodeDir(), "skills", slug, ".forge-version"), "utf8")
7733
+ return true
7734
+ } catch {
7735
+ return false
7736
+ }
7737
+ }
7738
+
7739
+ function openCodeDir() {
7740
+ if (process.env.OPENCODE_CONFIG) return path.dirname(process.env.OPENCODE_CONFIG)
7741
+ if (process.env.OPENCODE_CONFIG_DIR) return process.env.OPENCODE_CONFIG_DIR
7742
+ const configRoot = process.env.XDG_CONFIG_HOME ?? path.join(os.homedir(), ".config")
7743
+ return path.join(configRoot, "opencode")
7744
+ }
7745
+
7746
+ async function flush() {
7747
+ if (FLUSHING || QUEUE.length === 0) return
7748
+ FLUSHING = true
7749
+ const batch = QUEUE.splice(0, 100)
7750
+ try {
7751
+ const credentials = await readForgeCredentials()
7752
+ if (!credentials) return
7753
+ await fetch(credentials.forgeBaseUrl.replace(/\\/$/, "") + "/sync/evidence", {
7754
+ method: "POST",
7755
+ headers: {
7756
+ authorization: "Bearer " + credentials.forgeApiKey,
7757
+ "content-type": "application/json"
7758
+ },
7759
+ body: JSON.stringify({ events: batch })
7760
+ })
7761
+ } catch (error) {
7762
+ console.error("[Forge evidence] Flush failed:", error instanceof Error ? error.message : String(error))
7763
+ } finally {
7764
+ FLUSHING = false
7765
+ }
7766
+ }
7767
+
7768
+ async function readForgeCredentials() {
7769
+ const configRoot = process.env.XDG_CONFIG_HOME ?? path.join(os.homedir(), ".config")
7770
+ try {
7771
+ const raw = await readFile(path.join(configRoot, "forge", "credentials.json"), "utf8")
7772
+ const parsed = JSON.parse(raw)
7773
+ if (typeof parsed?.forgeBaseUrl === "string" && typeof parsed?.forgeApiKey === "string") return parsed
7774
+ } catch {
7775
+ return undefined
7776
+ }
7777
+ }
7778
+ `;
7779
+ }
7780
+
7370
7781
  // packages/cli/src/retireDebugCapture.ts
7371
7782
  import { lstat, readFile, rename, writeFile } from "node:fs/promises";
7372
7783
  import { randomUUID } from "node:crypto";
@@ -19926,225 +20337,6 @@ async function reportWorkPackObservations(credentials, kind, workPacks) {
19926
20337
  }
19927
20338
  }
19928
20339
 
19929
- // packages/shared/src/contracts/models.ts
19930
- var BUILT_IN_OPENROUTER_MODELS = [
19931
- {
19932
- id: "anthropic/claude-sonnet-4-6",
19933
- name: "Assistente de trabalho profundo",
19934
- approvedByDefault: true,
19935
- requiredInConfig: false,
19936
- upstreamModel: "anthropic/claude-sonnet-4.6",
19937
- metadata: {
19938
- family: "anthropic",
19939
- release_date: "2026-02-17",
19940
- attachment: true,
19941
- reasoning: true,
19942
- temperature: true,
19943
- tool_call: true,
19944
- limit: { context: 1e6, output: 128e3 },
19945
- modalities: { input: ["text", "image", "pdf"], output: ["text"] }
19946
- }
19947
- },
19948
- {
19949
- id: "anthropic/claude-haiku-4-5",
19950
- name: "Assistente r\xE1pido",
19951
- approvedByDefault: true,
19952
- requiredInConfig: false,
19953
- upstreamModel: "anthropic/claude-haiku-4.5",
19954
- metadata: {
19955
- family: "anthropic",
19956
- release_date: "2025-10-15",
19957
- attachment: true,
19958
- reasoning: true,
19959
- temperature: true,
19960
- tool_call: true,
19961
- limit: { context: 2e5, output: 64e3 },
19962
- modalities: { input: ["text", "image", "pdf"], output: ["text"] }
19963
- }
19964
- },
19965
- {
19966
- id: "openai/gpt-5.4-mini",
19967
- name: "Assistente de ficheiros e ecr\xE3",
19968
- approvedByDefault: true,
19969
- requiredInConfig: false,
19970
- metadata: {
19971
- family: "gpt-mini",
19972
- release_date: "2026-03-17",
19973
- attachment: true,
19974
- reasoning: true,
19975
- temperature: false,
19976
- tool_call: true,
19977
- limit: { context: 4e5, input: 272e3, output: 128e3 },
19978
- modalities: { input: ["text", "image", "pdf"], output: ["text"] },
19979
- variants: openRouterReasoningVariants(["none", "xhigh"])
19980
- }
19981
- },
19982
- {
19983
- id: "minimax/minimax-m3",
19984
- name: "Assistente de pesquisa",
19985
- approvedByDefault: true,
19986
- requiredInConfig: false,
19987
- metadata: {
19988
- family: "minimax",
19989
- release_date: "2026-04-07",
19990
- attachment: true,
19991
- reasoning: true,
19992
- temperature: true,
19993
- tool_call: true,
19994
- limit: { context: 524288, output: 512e3 },
19995
- modalities: { input: ["text", "image", "video"], output: ["text"] }
19996
- }
19997
- },
19998
- {
19999
- id: "minimax/minimax-m2.7",
20000
- name: "Assistente de reda\xE7\xE3o",
20001
- approvedByDefault: true,
20002
- requiredInConfig: false,
20003
- metadata: {
20004
- family: "minimax",
20005
- release_date: "2026-03-18",
20006
- attachment: false,
20007
- reasoning: true,
20008
- temperature: true,
20009
- tool_call: true,
20010
- limit: { context: 196608, output: 196608 },
20011
- modalities: { input: ["text"], output: ["text"] }
20012
- }
20013
- },
20014
- {
20015
- id: "xiaomi/mimo-v2.5",
20016
- name: "Assistente de revis\xE3o multim\xE9dia",
20017
- approvedByDefault: true,
20018
- requiredInConfig: false,
20019
- metadata: {
20020
- family: "mimo",
20021
- release_date: "2026-04-22",
20022
- attachment: true,
20023
- reasoning: true,
20024
- temperature: true,
20025
- tool_call: true,
20026
- interleaved: { field: "reasoning_details" },
20027
- limit: { context: 32e3, output: 131072 },
20028
- modalities: { input: ["text", "audio", "image", "video"], output: ["text"] }
20029
- }
20030
- },
20031
- {
20032
- id: "xiaomi/mimo-v2.5-pro",
20033
- name: "Assistente de contexto longo",
20034
- approvedByDefault: true,
20035
- requiredInConfig: false,
20036
- metadata: {
20037
- family: "mimo",
20038
- release_date: "2026-04-22",
20039
- attachment: false,
20040
- reasoning: true,
20041
- temperature: true,
20042
- tool_call: true,
20043
- interleaved: { field: "reasoning_content" },
20044
- limit: { context: 1048576, output: 131072 },
20045
- modalities: { input: ["text"], output: ["text"] }
20046
- }
20047
- },
20048
- {
20049
- id: "z-ai/glm-5.2",
20050
- name: "Assistente de an\xE1lise",
20051
- approvedByDefault: false,
20052
- requiredInConfig: false,
20053
- metadata: {
20054
- family: "glm",
20055
- release_date: "2026-02-12",
20056
- attachment: false,
20057
- reasoning: true,
20058
- temperature: true,
20059
- tool_call: true,
20060
- interleaved: { field: "reasoning_content" },
20061
- limit: { context: 1048576, output: 32768 },
20062
- modalities: { input: ["text"], output: ["text"] }
20063
- }
20064
- }
20065
- ];
20066
- var APPROVED_MODELS = BUILT_IN_OPENROUTER_MODELS.filter((model) => model.approvedByDefault).map(stripCatalogFlags);
20067
- function cloneModel(model) {
20068
- return {
20069
- id: model.id,
20070
- name: model.name,
20071
- ...model.provider ? { provider: model.provider } : {},
20072
- ...model.upstreamModel ? { upstreamModel: model.upstreamModel } : {},
20073
- ...model.billingMode ? { billingMode: model.billingMode } : {},
20074
- ...model.metadata ? { metadata: structuredClone(model.metadata) } : {}
20075
- };
20076
- }
20077
- function stripCatalogFlags(model) {
20078
- const { approvedByDefault: _approvedByDefault, requiredInConfig: _requiredInConfig, ...approved } = model;
20079
- return cloneModel(approved);
20080
- }
20081
- function openRouterReasoningVariants(efforts) {
20082
- return Object.fromEntries(efforts.map((effort) => [effort, { reasoning: { effort } }]));
20083
- }
20084
-
20085
- // packages/shared/src/contracts/debugTrace.ts
20086
- var DEFAULT_DEBUG_TRACE_LIMITS = {
20087
- eventEnvelopeBytes: 256 * 1024,
20088
- artifactChunkBytes: 2 * 1024 * 1024,
20089
- // Serialized request bodies must remain comfortably below Vercel's 4.5 MB
20090
- // function request limit after JSON and base64 overhead.
20091
- uploadBatchBytes: 3 * 1024 * 1024,
20092
- uploadBatchRecords: 100,
20093
- fileSnapshotBytes: 1024 * 1024,
20094
- serverTraceBudgetBytes: 250 * 1024 * 1024,
20095
- workerTraceQuotaPer24h: 100,
20096
- workerBytesQuotaPer24h: 1024 * 1024 * 1024,
20097
- localQueueBytes: 1024 * 1024 * 1024,
20098
- retryBackoffMinMs: 5e3,
20099
- retryBackoffMaxMs: 5 * 60 * 1e3,
20100
- queueMaxAgeDays: 7,
20101
- rawTempExposureSeconds: 15 * 60
20102
- };
20103
-
20104
- // packages/shared/src/contracts/settings.ts
20105
- var WORK_PACK_SYNC_PLUGIN_VERSION = "0.1.15";
20106
- var WORK_PACK_SYNC_PLUGIN_PACKAGE = `minimal-forge-work-pack-sync@${WORK_PACK_SYNC_PLUGIN_VERSION}`;
20107
- var WORK_PACK_SYNC_PLUGIN_FILENAME = `minimal-forge-work-pack-sync-${WORK_PACK_SYNC_PLUGIN_VERSION}.tgz`;
20108
- var FIRECRAWL_KEYLESS_MCP_NAME = "firecrawl";
20109
- var FIRECRAWL_KEYLESS_PERMISSION = `${FIRECRAWL_KEYLESS_MCP_NAME}_*`;
20110
-
20111
- // packages/shared/src/workPackBaseline.ts
20112
- function normalizePackExtensionModel(pathLabel, content, approvedModelIds, slug) {
20113
- const match = /^---\n([\s\S]+?)\n---/.exec(content);
20114
- const frontmatter = match?.[1];
20115
- if (!match || frontmatter === void 0) return content;
20116
- const modelLines = [...frontmatter.matchAll(/^model:\s*(.*?)\s*$/gm)];
20117
- if (modelLines.length === 0) return content;
20118
- if (modelLines.length > 1) {
20119
- throw new Error(`A extens\xE3o ${pathLabel} do pacote de trabalho ${slug} define model mais do que uma vez`);
20120
- }
20121
- const rawModel = modelLines[0][1].replace(/^(['"])(.*)\1$/, "$2");
20122
- const separator = rawModel.indexOf("/");
20123
- const provider = separator > 0 ? rawModel.slice(0, separator) : "";
20124
- const modelId = separator > 0 ? rawModel.slice(separator + 1) : "";
20125
- if (provider !== "forge" && provider !== "openrouter" || !approvedModelIds.has(modelId)) {
20126
- throw new Error(
20127
- `A extens\xE3o ${pathLabel} do pacote de trabalho ${slug} usa um modelo que n\xE3o est\xE1 aprovado no Forge`
20128
- );
20129
- }
20130
- if (provider === "forge") return content;
20131
- const normalizedFrontmatter = frontmatter.replace(/^model:\s*.*?$/m, `model: forge/${modelId}`);
20132
- return `${content.slice(0, match.index)}---
20133
- ${normalizedFrontmatter}
20134
- ---${content.slice(match.index + match[0].length)}`;
20135
- }
20136
- function canonicalWorkPackState(state) {
20137
- const compare = (left, right) => left < right ? -1 : left > right ? 1 : 0;
20138
- return JSON.stringify({
20139
- schemaVersion: 1,
20140
- version: state.version,
20141
- files: [...state.files].sort((a, b2) => compare(a.path, b2.path)),
20142
- directories: [...state.directories].sort(compare),
20143
- agents: [...state.agents].sort((a, b2) => compare(a.filename, b2.filename)),
20144
- commands: [...state.commands].sort((a, b2) => compare(a.filename, b2.filename))
20145
- });
20146
- }
20147
-
20148
20340
  // packages/cli/src/sync.ts
20149
20341
  import { createHash as createHash2 } from "node:crypto";
20150
20342
  import { chmod, cp, lstat as lstat3, mkdtemp, mkdir as mkdir2, readdir as readdir2, readFile as readFile3, rm, rename as rename3, writeFile as writeFile3 } from "node:fs/promises";
@@ -24630,7 +24822,7 @@ function isRecord(value) {
24630
24822
  }
24631
24823
 
24632
24824
  // packages/cli/src/workPackSyncPlugin.ts
24633
- var PLUGIN_VERSION = "0.1.15";
24825
+ var PLUGIN_VERSION = "0.1.16";
24634
24826
  var STATUS_FILENAME = "work-pack-startup-status.json";
24635
24827
  var activeSync = /* @__PURE__ */ new Map();
24636
24828
  var ForgeWorkPackSyncServer = async (_input, options) => {
@@ -24641,8 +24833,48 @@ var ForgeWorkPackSyncServer = async (_input, options) => {
24641
24833
  activeSync.set(forgeBaseUrl, sync);
24642
24834
  }
24643
24835
  const state = await sync;
24836
+ const legacyPath = path5.join(state.paths.pluginDir, FORGE_EVIDENCE_PLUGIN_FILENAME);
24837
+ const ownershipSymbol = /* @__PURE__ */ Symbol.for("minimal-forge.legacy-evidence-owners.v1");
24838
+ const shared = globalThis;
24839
+ const legacyOwners = shared[ownershipSymbol] ??= /* @__PURE__ */ new Set();
24840
+ const legacyOwnerKey = JSON.stringify([forgeBaseUrl, legacyPath]);
24644
24841
  return {
24842
+ "tool.execute.after": async (input) => {
24843
+ if (input.tool !== "skill" || legacyOwners.has(legacyOwnerKey)) return;
24844
+ const slug = typeof input.args?.name === "string" ? input.args.name.trim().toLowerCase() : "";
24845
+ if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(slug)) return;
24846
+ try {
24847
+ await readFile4(path5.join(state.paths.skillsDir, slug, ".forge-version"), "utf8");
24848
+ } catch {
24849
+ return;
24850
+ }
24851
+ try {
24852
+ const { forgeApiKey } = await readWellKnownForgeCredentials(state.paths.opencodeAuthPath, forgeBaseUrl);
24853
+ const credentialId = createHash4("sha256").update(forgeApiKey).digest("hex");
24854
+ const reportUsage = skillUsageReporter(forgeBaseUrl, credentialId, (events) => fetch(`${forgeBaseUrl}/sync/evidence`, {
24855
+ method: "POST",
24856
+ redirect: "error",
24857
+ headers: { authorization: `Bearer ${forgeApiKey}`, "content-type": "application/json" },
24858
+ body: JSON.stringify({ events }),
24859
+ signal: AbortSignal.timeout(5e3)
24860
+ }));
24861
+ reportUsage(input.sessionID, input.callID, slug);
24862
+ } catch {
24863
+ console.error("[Forge evidence] Invocation identity unavailable; event not queued");
24864
+ }
24865
+ },
24645
24866
  config: async (config2) => {
24867
+ const entries = Array.isArray(config2.plugin) ? config2.plugin : [];
24868
+ const registered = entries.some((entry) => {
24869
+ const name = Array.isArray(entry) ? entry[0] : entry;
24870
+ return name === legacyPath || name === pathToFileURL(legacyPath).href;
24871
+ });
24872
+ const legacy = registered ? await readFile4(legacyPath, "utf8").catch(() => "") : "";
24873
+ const oldLegacyRegistered = registered && legacy.startsWith(FORGE_PLUGIN_HEADER) && legacy.includes("work_pack_invocation") && !legacy.includes("minimal-forge.skill-usage.v1");
24874
+ if (oldLegacyRegistered) legacyOwners.add(legacyOwnerKey);
24875
+ if (oldLegacyRegistered) await writeFile4(legacyPath, renderEvidencePlugin()).catch(() => {
24876
+ console.error("[Forge evidence] Legacy hook upgrade failed; existing hook retained");
24877
+ });
24646
24878
  await projectCurrentExtensions(config2, state);
24647
24879
  if (state.forgeConfigVerified) applySharedWorkerPrompt(config2);
24648
24880
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minimal-forge-work-pack-sync",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "Minimal Forge Work Pack startup synchronization for OpenCode and OpenWork.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {