@cnwenf/occ 2.1.299 → 2.1.300

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/cli.js +207 -14
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
- globalThis.MACRO={"VERSION":"2.1.299","BINARY_NAME":"occ","BUILD_TIME":"2026-08-12T20:49:17.819Z","FEEDBACK_CHANNEL":"","ISSUES_EXPLAINER":"","NATIVE_PACKAGE_URL":"","PACKAGE_URL":"@cnwenf/occ","VERSION_CHANGELOG":""};
2
+ globalThis.MACRO={"VERSION":"2.1.300","BINARY_NAME":"occ","BUILD_TIME":"2026-08-13T23:37:42.199Z","FEEDBACK_CHANNEL":"","ISSUES_EXPLAINER":"","NATIVE_PACKAGE_URL":"","PACKAGE_URL":"@cnwenf/occ","VERSION_CHANGELOG":""};
3
3
  // @bun
4
4
  var __create = Object.create;
5
5
  var __getProtoOf = Object.getPrototypeOf;
@@ -189468,14 +189468,23 @@ function getCLISyspromptPrefix(options) {
189468
189468
  }
189469
189469
  return DEFAULT_PREFIX;
189470
189470
  }
189471
- function isAttributionHeaderEnabled() {
189472
- if (isEnvDefinedFalsy(process.env.CLAUDE_CODE_ATTRIBUTION_HEADER)) {
189471
+ function isPlainAnthropicApiBaseUrl() {
189472
+ const baseUrl = process.env.ANTHROPIC_BASE_URL;
189473
+ if (!baseUrl) {
189474
+ return true;
189475
+ }
189476
+ try {
189477
+ return ["api.anthropic.com"].includes(new URL(baseUrl).host);
189478
+ } catch {
189473
189479
  return false;
189474
189480
  }
189475
- return getFeatureValue_CACHED_MAY_BE_STALE("tengu_attribution_header", true);
189476
189481
  }
189477
- function getAttributionHeader(fingerprint) {
189478
- if (!isAttributionHeaderEnabled()) {
189482
+ function getAttributionHeader(fingerprint, opts) {
189483
+ const envOptOutBypassed = opts?.ignoreEnvOptOut === true && getAPIProvider() === "firstParty" && isPlainAnthropicApiBaseUrl() && !process.env.ANTHROPIC_UNIX_SOCKET;
189484
+ if (!envOptOutBypassed && isEnvDefinedFalsy(process.env.CLAUDE_CODE_ATTRIBUTION_HEADER)) {
189485
+ return "";
189486
+ }
189487
+ if (!getFeatureValue_CACHED_MAY_BE_STALE("tengu_attribution_header", true)) {
189479
189488
  return "";
189480
189489
  }
189481
189490
  const version5 = `${MACRO.VERSION}.${fingerprint}`;
@@ -389452,7 +389461,7 @@ async function sideQuery(opts) {
389452
389461
  }
389453
389462
  const messageText = extractFirstUserMessageText(messages);
389454
389463
  const fingerprint = computeFingerprint(messageText, MACRO.VERSION);
389455
- const attributionHeader = getAttributionHeader(fingerprint);
389464
+ const attributionHeader = getAttributionHeader(fingerprint, opts.forceAttributionHeader ? { ignoreEnvOptOut: true } : undefined);
389456
389465
  const systemBlocks = [
389457
389466
  attributionHeader ? { type: "text", text: attributionHeader } : null,
389458
389467
  ...skipSystemPromptPrefix ? [] : [
@@ -390318,6 +390327,7 @@ async function classifyYoloActionXml(prefixMessages, systemPrompt, userPrompt, u
390318
390327
  max_tokens: (mode === "fast" ? 256 : 64) + thinkingPadding,
390319
390328
  system: systemBlocks,
390320
390329
  skipSystemPromptPrefix: true,
390330
+ forceAttributionHeader: true,
390321
390331
  temperature: 0,
390322
390332
  thinking: disableThinking,
390323
390333
  messages: [
@@ -390398,6 +390408,7 @@ async function classifyYoloActionXml(prefixMessages, systemPrompt, userPrompt, u
390398
390408
  max_tokens: 4096 + thinkingPadding,
390399
390409
  system: systemBlocks,
390400
390410
  skipSystemPromptPrefix: true,
390411
+ forceAttributionHeader: true,
390401
390412
  temperature: 0,
390402
390413
  thinking: disableThinking,
390403
390414
  messages: [
@@ -390594,6 +390605,7 @@ async function classifyYoloAction(messages, action2, tools, context4, signal) {
390594
390605
  }
390595
390606
  ],
390596
390607
  skipSystemPromptPrefix: true,
390608
+ forceAttributionHeader: true,
390597
390609
  temperature: 0,
390598
390610
  thinking: disableThinking,
390599
390611
  messages: [
@@ -459890,11 +459902,27 @@ var init_bypassPermissionsKillswitch = __esm(() => {
459890
459902
  // src/commands/login/login.tsx
459891
459903
  var exports_login = {};
459892
459904
  __export(exports_login, {
459905
+ getLoginStartingMessage: () => getLoginStartingMessage,
459893
459906
  call: () => call2,
459907
+ buildLoginDoneMessage: () => buildLoginDoneMessage,
459894
459908
  Login: () => Login
459895
459909
  });
459910
+ function getLoginStartingMessage() {
459911
+ return process.env.CLAUDE_CODE_OAUTH_TOKEN ? `Warning: CLAUDE_CODE_OAUTH_TOKEN is set in your environment. This session will switch to your new credentials after logging in, ${ENV_TOKEN_OVERRIDE_WARNING_TAIL}` : undefined;
459912
+ }
459913
+ function buildLoginDoneMessage(success2, opts) {
459914
+ if (!success2)
459915
+ return "Login interrupted";
459916
+ const base2 = opts.bridgeDisconnected ? `Login successful. ${REMOTE_CONTROL_DISCONNECTED_NOTE}` : "Login successful";
459917
+ return opts.envTokenWasSet && !opts.gatewayActive ? `${base2}
459918
+
459919
+ ${ENV_TOKEN_OVERRIDE_DONE_NOTE}` : base2;
459920
+ }
459896
459921
  async function call2(onDone, context6) {
459922
+ const startingMessage = getLoginStartingMessage();
459923
+ const envTokenWasSet = startingMessage !== undefined;
459897
459924
  return /* @__PURE__ */ jsx_runtime84.jsx(Login, {
459925
+ startingMessage,
459898
459926
  onDone: async (success2) => {
459899
459927
  context6.onChangeAPIKey();
459900
459928
  context6.setMessages(stripSignatureBlocks);
@@ -459918,7 +459946,11 @@ async function call2(onDone, context6) {
459918
459946
  authVersion: prev.authVersion + 1
459919
459947
  }));
459920
459948
  }
459921
- onDone(success2 ? "Login successful" : "Login interrupted");
459949
+ onDone(buildLoginDoneMessage(success2, {
459950
+ bridgeDisconnected: false,
459951
+ envTokenWasSet,
459952
+ gatewayActive: getAPIProvider() === "gateway"
459953
+ }));
459922
459954
  }
459923
459955
  });
459924
459956
  }
@@ -459986,7 +460018,7 @@ function _temp14(exitState) {
459986
460018
  description: "cancel"
459987
460019
  });
459988
460020
  }
459989
- var import_compiler_runtime71, jsx_runtime84;
460021
+ var import_compiler_runtime71, jsx_runtime84, ENV_TOKEN_OVERRIDE_WARNING_TAIL = "but if that variable is set in your shell profile or a Claude Code settings file, new `claude` sessions will keep using the old token until you remove it there.", ENV_TOKEN_OVERRIDE_DONE_NOTE, REMOTE_CONTROL_DISCONNECTED_NOTE = "Remote Control disconnected.";
459990
460022
  var init_login = __esm(() => {
459991
460023
  init_featureFlags();
459992
460024
  init_state();
@@ -460000,10 +460032,12 @@ var init_login = __esm(() => {
460000
460032
  init_policyLimits();
460001
460033
  init_remoteManagedSettings();
460002
460034
  init_messages3();
460035
+ init_providers();
460003
460036
  init_bypassPermissionsKillswitch();
460004
460037
  init_user();
460005
460038
  import_compiler_runtime71 = __toESM(require_compiler_runtime(), 1);
460006
460039
  jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
460040
+ ENV_TOKEN_OVERRIDE_DONE_NOTE = `Note: CLAUDE_CODE_OAUTH_TOKEN was set in your environment when /login started. This session will use your new credentials, ${ENV_TOKEN_OVERRIDE_WARNING_TAIL}`;
460007
460041
  });
460008
460042
 
460009
460043
  // src/utils/teleport/api.ts
@@ -584100,6 +584134,142 @@ var init_errors11 = __esm(() => {
584100
584134
  };
584101
584135
  });
584102
584136
 
584137
+ // src/tools/WorkflowTool/prefixStagger.ts
584138
+ function createWarmingEntry() {
584139
+ let release;
584140
+ const ready = new Promise((resolve44) => {
584141
+ release = resolve44;
584142
+ });
584143
+ return { state: "warming", ready, release: () => release?.() };
584144
+ }
584145
+ function sleepWithAbort(ms, signal) {
584146
+ return new Promise((resolve44) => {
584147
+ if (signal?.aborted) {
584148
+ resolve44();
584149
+ return;
584150
+ }
584151
+ const onAbort = () => {
584152
+ clearTimeout(timer2);
584153
+ resolve44();
584154
+ };
584155
+ const timer2 = setTimeout(() => {
584156
+ signal?.removeEventListener("abort", onAbort);
584157
+ resolve44();
584158
+ }, ms);
584159
+ signal?.addEventListener("abort", onAbort, { once: true });
584160
+ });
584161
+ }
584162
+ function raceReadyWithTimeout(ready, timeoutMs, signal) {
584163
+ if (signal?.aborted)
584164
+ return Promise.resolve();
584165
+ const controller = new AbortController;
584166
+ const onAbort = () => controller.abort();
584167
+ signal?.addEventListener("abort", onAbort, { once: true });
584168
+ return Promise.race([ready, sleepWithAbort(timeoutMs, controller.signal)]).finally(() => {
584169
+ controller.abort();
584170
+ signal?.removeEventListener("abort", onAbort);
584171
+ });
584172
+ }
584173
+
584174
+ class WorkflowPrefixStaggerGate {
584175
+ now;
584176
+ entries = new Map;
584177
+ constructor(now2 = Date.now) {
584178
+ this.now = now2;
584179
+ }
584180
+ async enter(key3, opts) {
584181
+ const now2 = this.now();
584182
+ for (const [k5, entry] of this.entries) {
584183
+ if (entry.state === "warm" && entry.until <= now2) {
584184
+ this.entries.delete(k5);
584185
+ }
584186
+ }
584187
+ const existing = this.entries.get(key3);
584188
+ let warming;
584189
+ let waitedMs = 0;
584190
+ if (existing === undefined) {
584191
+ warming = createWarmingEntry();
584192
+ this.entries.set(key3, warming);
584193
+ } else if (existing.state === "warming" && opts.capMs > 0) {
584194
+ const start = this.now();
584195
+ await raceReadyWithTimeout(existing.ready, opts.capMs, opts.signal);
584196
+ waitedMs = Math.max(0, this.now() - start);
584197
+ }
584198
+ let respondedFired = false;
584199
+ return {
584200
+ leader: warming !== undefined,
584201
+ waitedMs,
584202
+ responded: () => {
584203
+ respondedFired = true;
584204
+ this.markWarm(key3);
584205
+ },
584206
+ done: () => {
584207
+ if (respondedFired || warming === undefined)
584208
+ return;
584209
+ if (this.entries.get(key3) === warming && warming.state === "warming") {
584210
+ this.entries.delete(key3);
584211
+ warming.release();
584212
+ }
584213
+ }
584214
+ };
584215
+ }
584216
+ stateOf(key3) {
584217
+ const entry = this.entries.get(key3);
584218
+ if (entry === undefined)
584219
+ return "cold";
584220
+ if (entry.state === "warm") {
584221
+ return entry.until > this.now() ? "warm" : "cold";
584222
+ }
584223
+ return "warming";
584224
+ }
584225
+ clear() {
584226
+ for (const entry of this.entries.values()) {
584227
+ if (entry.state === "warming")
584228
+ entry.release();
584229
+ }
584230
+ this.entries.clear();
584231
+ }
584232
+ markWarm(key3) {
584233
+ const existing = this.entries.get(key3);
584234
+ this.entries.set(key3, {
584235
+ state: "warm",
584236
+ until: this.now() + WORKFLOW_PREFIX_WARM_TTL_MS
584237
+ });
584238
+ if (existing?.state === "warming")
584239
+ existing.release();
584240
+ }
584241
+ }
584242
+ function getWorkflowPrefixStaggerGate() {
584243
+ return singleton ??= new WorkflowPrefixStaggerGate;
584244
+ }
584245
+ function getWorkflowPrefixStaggerCapMs(env7 = process.env) {
584246
+ if (isEnvTruthy(env7.DISABLE_PROMPT_CACHING)) {
584247
+ return 0;
584248
+ }
584249
+ const raw = env7.CLAUDE_CODE_WORKFLOW_PREFIX_STAGGER_MS;
584250
+ if (raw !== undefined && raw !== "") {
584251
+ const parsed = Number.parseInt(raw, 10);
584252
+ if (Number.isFinite(parsed) && parsed >= 0)
584253
+ return parsed;
584254
+ }
584255
+ return WORKFLOW_PREFIX_STAGGER_DEFAULT_MS;
584256
+ }
584257
+ function buildWorkflowPrefixKey(parts) {
584258
+ return [
584259
+ parts.model ?? "",
584260
+ String(parts.effort ?? ""),
584261
+ parts.agentType,
584262
+ parts.toolNames,
584263
+ parts.schemaJson,
584264
+ parts.cwd
584265
+ ].join(`
584266
+ `);
584267
+ }
584268
+ var WORKFLOW_PREFIX_WARM_TTL_MS = 270000, WORKFLOW_PREFIX_STAGGER_DEFAULT_MS = 5000, singleton;
584269
+ var init_prefixStagger = __esm(() => {
584270
+ init_envUtils();
584271
+ });
584272
+
584103
584273
  // src/tools/WorkflowTool/primitives.ts
584104
584274
  function workflowAgentTelemetryAttributes(runId, workflowName) {
584105
584275
  return {
@@ -584291,10 +584461,29 @@ You MUST call the ${SYNTHETIC_OUTPUT_TOOL_NAME} tool exactly once at the end of
584291
584461
  })
584292
584462
  ];
584293
584463
  let agentTokens = 0;
584294
- const onQueryProgress = () => {};
584295
584464
  const agentId = createAgentId("wf");
584296
584465
  const agentShortId = agentId.slice(0, 16);
584297
584466
  const agentLabel = opts.label ?? prompt.slice(0, 80);
584467
+ const agentStartTime = Date.now();
584468
+ const agentModel = opts.model ?? getMainLoopModel();
584469
+ const prefixKey = buildWorkflowPrefixKey({
584470
+ model: agentModel,
584471
+ effort: opts.effort,
584472
+ agentType: agentDef.agentType,
584473
+ toolNames: ctx.availableTools.map((t4) => t4.name).join(","),
584474
+ schemaJson: opts.schema ? JSON.stringify(opts.schema) : "",
584475
+ cwd: worktreePath ?? getCwd()
584476
+ });
584477
+ const staggerHandle = await getWorkflowPrefixStaggerGate().enter(prefixKey, {
584478
+ capMs: getWorkflowPrefixStaggerCapMs(),
584479
+ signal: ctx.abortController.signal
584480
+ });
584481
+ if (staggerHandle.waitedMs > 0) {
584482
+ logForDebugging(`workflow agent [${agentLabel}] held ${staggerHandle.waitedMs}ms for a same-prefix sibling's first response (prompt-cache warm-up)`);
584483
+ }
584484
+ const onQueryProgress = () => {
584485
+ staggerHandle.responded();
584486
+ };
584298
584487
  const gen = runAgent({
584299
584488
  agentDefinition: agentDef,
584300
584489
  promptMessages,
@@ -584313,8 +584502,6 @@ You MUST call the ${SYNTHETIC_OUTPUT_TOOL_NAME} tool exactly once at the end of
584313
584502
  onQueryProgress,
584314
584503
  override: { agentId }
584315
584504
  });
584316
- const agentStartTime = Date.now();
584317
- const agentModel = opts.model ?? getMainLoopModel();
584318
584505
  logEvent2("tengu_workflow_agent_started", {
584319
584506
  ...workflowAgentTelemetryAttributes(ctx.runId, ctx.workflowName),
584320
584507
  agent_id: agentShortId,
@@ -584361,6 +584548,8 @@ You MUST call the ${SYNTHETIC_OUTPUT_TOOL_NAME} tool exactly once at the end of
584361
584548
  elapsedMs: Math.max(0, Date.now() - agentStartTime)
584362
584549
  });
584363
584550
  throw e4;
584551
+ } finally {
584552
+ staggerHandle.done();
584364
584553
  }
584365
584554
  agentTokens = extractTokenUsage(messages);
584366
584555
  ctx.counters.spentTokens += agentTokens;
@@ -584617,7 +584806,10 @@ var init_primitives = __esm(() => {
584617
584806
  init_SyntheticOutputTool();
584618
584807
  init_errors11();
584619
584808
  init_journal();
584809
+ init_prefixStagger();
584620
584810
  init_model();
584811
+ init_cwd2();
584812
+ init_debug();
584621
584813
  });
584622
584814
 
584623
584815
  // src/utils/effort/workflowDiscovery.ts
@@ -616820,7 +617012,7 @@ function getMcpAutoBackgroundMs(tool, {
616820
617012
  function isPipeNonInteractiveModeDefault() {
616821
617013
  return isPipeNonInteractiveMode();
616822
617014
  }
616823
- function sleepWithAbort(ms, signal) {
617015
+ function sleepWithAbort2(ms, signal) {
616824
617016
  return new Promise((resolve53) => {
616825
617017
  if (signal.aborted) {
616826
617018
  resolve53("timeout");
@@ -616862,7 +617054,7 @@ async function callMcpToolWithAutoBackground({
616862
617054
  while (true) {
616863
617055
  const winner = await Promise.race([
616864
617056
  settledPromise,
616865
- sleepWithAbort(autoBackgroundMs, raceController.signal)
617057
+ sleepWithAbort2(autoBackgroundMs, raceController.signal)
616866
617058
  ]);
616867
617059
  if (winner === "settled" || parentAbortController.signal.aborted) {
616868
617060
  raceController.abort();
@@ -823248,6 +823440,7 @@ async function autoModeCritiqueHandler(options) {
823248
823440
  model,
823249
823441
  system: CRITIQUE_SYSTEM_PROMPT,
823250
823442
  skipSystemPromptPrefix: true,
823443
+ forceAttributionHeader: true,
823251
823444
  max_tokens: 4096,
823252
823445
  messages: [
823253
823446
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cnwenf/occ",
3
- "version": "2.1.299",
3
+ "version": "2.1.300",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "bin": {