very-happy-cli 0.2.130 → 0.2.132

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 (45) hide show
  1. package/dist/{AcpBackend-5slez7vM.cjs → AcpBackend--EnHZRC4.cjs} +2 -2
  2. package/dist/{AcpBackend-Co3atHW2.mjs → AcpBackend-BNMLGtST.mjs} +2 -2
  3. package/dist/{AcpSessionManager-B0sD6Zi7.mjs → AcpSessionManager-BF5JZYCC.mjs} +1 -1
  4. package/dist/{AcpSessionManager-CxvVg8ec.cjs → AcpSessionManager-RoOyx5KI.cjs} +1 -1
  5. package/dist/{agentGuidance-7pJxf_3b.mjs → agentGuidance-DeOIgOhh.mjs} +1 -1
  6. package/dist/{agentGuidance-TjPzDO7d.cjs → agentGuidance-R9MH5Cd5.cjs} +1 -1
  7. package/dist/codex/happyMcpStdioBridge.cjs +2 -2
  8. package/dist/codex/happyMcpStdioBridge.mjs +2 -2
  9. package/dist/{config-B4Md4FvK.cjs → config-CkmssSRu.cjs} +4 -4
  10. package/dist/{config-BWu8j7bO.mjs → config-ClCkJ1a_.mjs} +4 -4
  11. package/dist/{index-Ds0aHXiU.cjs → index-Bqg6yo5s.cjs} +4 -4
  12. package/dist/{index-DksoP9b2.cjs → index-CjopZZg3.cjs} +14 -7
  13. package/dist/{index-BUhcXX8R.mjs → index-D1gHXtkw.mjs} +68 -20
  14. package/dist/{index-C13U8MkT.mjs → index-DK0qz1y7.mjs} +4 -4
  15. package/dist/{index-CdOVizh_.mjs → index-DdbU8FmA.mjs} +15 -8
  16. package/dist/{index-C7TA3haC.cjs → index-Dn7s2iaT.cjs} +72 -24
  17. package/dist/index.cjs +4 -4
  18. package/dist/index.mjs +4 -4
  19. package/dist/{installTerminalHooks-cNXov61F.cjs → installTerminalHooks-CPZ3vVn8.cjs} +4 -4
  20. package/dist/{installTerminalHooks-kUC6I6Rn.mjs → installTerminalHooks-CRWWmonO.mjs} +4 -4
  21. package/dist/lib.cjs +2 -2
  22. package/dist/lib.d.cts +32 -22
  23. package/dist/lib.d.mts +32 -22
  24. package/dist/lib.mjs +2 -2
  25. package/dist/{limits-CIcZA0Bn.mjs → limits-C9aXkP7U.mjs} +7 -7
  26. package/dist/{limits-BhK6ovLz.cjs → limits-DLlsV71c.cjs} +7 -7
  27. package/dist/{mcp-CNX1qErQ.cjs → mcp-DHkYfENQ.cjs} +4 -4
  28. package/dist/{mcp-D5uyhbfB.mjs → mcp-DkoXvc07.mjs} +4 -4
  29. package/dist/{runGemini-BQd3qlVY.mjs → runGemini-BjEl7syj.mjs} +6 -6
  30. package/dist/{runGemini-DvV6X_GE.cjs → runGemini-Cx1YcK2o.cjs} +6 -6
  31. package/dist/{runOpenClaw-BgtE2jKF.mjs → runOpenClaw-ByHu69K5.mjs} +5 -5
  32. package/dist/{runOpenClaw-jxvPz3bo.cjs → runOpenClaw-I4sGAQf1.cjs} +5 -5
  33. package/dist/{send-BdhUFGTm.mjs → send-CSOeUlQC.mjs} +4 -4
  34. package/dist/{send-Di8Q32Ds.cjs → send-gH1vJ0iv.cjs} +4 -4
  35. package/dist/{sessions-eaAew6IP.cjs → sessions-BBc8L8qf.cjs} +4 -4
  36. package/dist/{sessions-Bo2THj4y.mjs → sessions-CP9FlcJ6.mjs} +4 -4
  37. package/dist/{spawn-6GfCYB5i.cjs → spawn-Dmfbot5k.cjs} +4 -4
  38. package/dist/{spawn-CJxg1JUO.mjs → spawn-DrQo81MW.mjs} +4 -4
  39. package/dist/{teams-CHGj90rR.mjs → teams-Bbvo1G6y.mjs} +4 -4
  40. package/dist/{teams-WdwFtptw.cjs → teams-DtXQYmEK.cjs} +4 -4
  41. package/dist/{todo-C8hDSNBP.mjs → todo-BAwevRyb.mjs} +3 -3
  42. package/dist/{todo-C-wktj2K.cjs → todo-DOi6svw9.cjs} +3 -3
  43. package/dist/{types-QB33ckXt.cjs → types-B15E2OVy.cjs} +9 -2
  44. package/dist/{types-B-ySoSY9.mjs → types-CA-c2NH7.mjs} +8 -2
  45. package/package.json +7 -7
@@ -3,8 +3,8 @@
3
3
  var node_child_process = require('node:child_process');
4
4
  var sdk = require('@agentclientprotocol/sdk');
5
5
  var node_crypto = require('node:crypto');
6
- var persistence = require('./limits-BhK6ovLz.cjs');
7
- var api = require('./types-QB33ckXt.cjs');
6
+ var persistence = require('./limits-DLlsV71c.cjs');
7
+ var api = require('./types-B15E2OVy.cjs');
8
8
 
9
9
  function acpImageBlocks(attachments, supportsImages) {
10
10
  return attachments.filter((file) => ["image/jpeg", "image/png", "image/gif", "image/webp"].includes(file.mimeType)).map((file) => {
@@ -1,8 +1,8 @@
1
1
  import { spawn } from 'node:child_process';
2
2
  import { ndJsonStream, ClientSideConnection } from '@agentclientprotocol/sdk';
3
3
  import { randomUUID } from 'node:crypto';
4
- import { l as logger, p as packageJson } from './limits-CIcZA0Bn.mjs';
5
- import { d as contentLogMetadata, e as errorLogMetadata, h as delay } from './types-B-ySoSY9.mjs';
4
+ import { l as logger, p as packageJson } from './limits-C9aXkP7U.mjs';
5
+ import { d as contentLogMetadata, e as errorLogMetadata, h as delay } from './types-CA-c2NH7.mjs';
6
6
 
7
7
  function acpImageBlocks(attachments, supportsImages) {
8
8
  return attachments.filter((file) => ["image/jpeg", "image/png", "image/gif", "image/webp"].includes(file.mimeType)).map((file) => {
@@ -1,5 +1,5 @@
1
1
  import { createId } from '@paralleldrive/cuid2';
2
- import { s as streamKeyOf, c as createEnvelope } from './types-B-ySoSY9.mjs';
2
+ import { s as streamKeyOf, c as createEnvelope } from './types-CA-c2NH7.mjs';
3
3
 
4
4
  function turnOptions(turnId, time) {
5
5
  return turnId ? { turn: turnId, time } : { time };
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var cuid2 = require('@paralleldrive/cuid2');
4
- var api = require('./types-QB33ckXt.cjs');
4
+ var api = require('./types-B15E2OVy.cjs');
5
5
 
6
6
  function turnOptions(turnId, time) {
7
7
  return turnId ? { turn: turnId, time } : { time };
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { randomUUID } from 'node:crypto';
3
- import { n as normalizeHttpEndpoint, c as configuration, g as readSettings, r as readPersistedSessions, d as readCredentialsForConfiguredRelay } from './limits-CIcZA0Bn.mjs';
3
+ import { n as normalizeHttpEndpoint, c as configuration, g as readSettings, r as readPersistedSessions, d as readCredentialsForConfiguredRelay } from './limits-C9aXkP7U.mjs';
4
4
  import { open, mkdir, rename, unlink } from 'node:fs/promises';
5
5
  import { constants } from 'node:fs';
6
6
  import { isAbsolute, join, dirname } from 'node:path';
@@ -2,7 +2,7 @@
2
2
 
3
3
  var z = require('zod');
4
4
  var node_crypto = require('node:crypto');
5
- var persistence = require('./limits-BhK6ovLz.cjs');
5
+ var persistence = require('./limits-DLlsV71c.cjs');
6
6
  var promises = require('node:fs/promises');
7
7
  var node_fs = require('node:fs');
8
8
  var path = require('node:path');
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var agentGuidance = require('../agentGuidance-TjPzDO7d.cjs');
3
+ var agentGuidance = require('../agentGuidance-R9MH5Cd5.cjs');
4
4
  var mcp_js = require('@modelcontextprotocol/sdk/server/mcp.js');
5
5
  var stdio_js = require('@modelcontextprotocol/sdk/server/stdio.js');
6
6
  var index_js = require('@modelcontextprotocol/sdk/client/index.js');
7
7
  var streamableHttp_js = require('@modelcontextprotocol/sdk/client/streamableHttp.js');
8
8
  var z = require('zod');
9
- var persistence = require('../limits-BhK6ovLz.cjs');
9
+ var persistence = require('../limits-DLlsV71c.cjs');
10
10
  require('node:crypto');
11
11
  require('node:fs/promises');
12
12
  require('node:fs');
@@ -1,10 +1,10 @@
1
- import { P as PREVIEW_TOOL_NAME, a as PREVIEW_TOOL_TITLE, b as PREVIEW_TOOL_DESCRIPTION, r as registerTeamsTools } from '../agentGuidance-7pJxf_3b.mjs';
1
+ import { P as PREVIEW_TOOL_NAME, a as PREVIEW_TOOL_TITLE, b as PREVIEW_TOOL_DESCRIPTION, r as registerTeamsTools } from '../agentGuidance-DeOIgOhh.mjs';
2
2
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
3
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
4
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
5
5
  import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
6
6
  import { z } from 'zod';
7
- import { C as CLIPBOARD_TOOL_NAME, a as CLIPBOARD_TOOL_TITLE, b as CLIPBOARD_TOOL_DESCRIPTION } from '../limits-CIcZA0Bn.mjs';
7
+ import { C as CLIPBOARD_TOOL_NAME, a as CLIPBOARD_TOOL_TITLE, b as CLIPBOARD_TOOL_DESCRIPTION } from '../limits-C9aXkP7U.mjs';
8
8
  import 'node:crypto';
9
9
  import 'node:fs/promises';
10
10
  import 'node:fs';
@@ -4,8 +4,8 @@ var fs = require('fs');
4
4
  var path = require('path');
5
5
  var os = require('os');
6
6
  var child_process = require('child_process');
7
- var persistence = require('./limits-BhK6ovLz.cjs');
8
- var index = require('./index-C7TA3haC.cjs');
7
+ var persistence = require('./limits-DLlsV71c.cjs');
8
+ var index = require('./index-Dn7s2iaT.cjs');
9
9
  require('node:fs/promises');
10
10
  require('node:fs');
11
11
  require('node:os');
@@ -15,7 +15,7 @@ require('node:crypto');
15
15
  require('tweetnacl');
16
16
  require('chalk');
17
17
  require('node:util');
18
- require('./types-QB33ckXt.cjs');
18
+ require('./types-B15E2OVy.cjs');
19
19
  require('axios');
20
20
  require('node:events');
21
21
  require('socket.io-client');
@@ -30,7 +30,7 @@ require('node-pty');
30
30
  require('node:readline');
31
31
  require('@anthropic-ai/sandbox-runtime');
32
32
  require('expo-server-sdk');
33
- require('./agentGuidance-TjPzDO7d.cjs');
33
+ require('./agentGuidance-R9MH5Cd5.cjs');
34
34
  require('ink');
35
35
  require('react');
36
36
  require('@anthropic-ai/claude-agent-sdk');
@@ -2,8 +2,8 @@ import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'fs';
2
2
  import { join } from 'path';
3
3
  import { homedir } from 'os';
4
4
  import { execSync } from 'child_process';
5
- import { l as logger } from './limits-CIcZA0Bn.mjs';
6
- import { j as DEFAULT_GEMINI_MODEL, G as GEMINI_MODEL_ENV } from './index-BUhcXX8R.mjs';
5
+ import { l as logger } from './limits-C9aXkP7U.mjs';
6
+ import { j as DEFAULT_GEMINI_MODEL, G as GEMINI_MODEL_ENV } from './index-D1gHXtkw.mjs';
7
7
  import 'node:fs/promises';
8
8
  import 'node:fs';
9
9
  import 'node:os';
@@ -13,7 +13,7 @@ import 'node:crypto';
13
13
  import 'tweetnacl';
14
14
  import 'chalk';
15
15
  import 'node:util';
16
- import './types-B-ySoSY9.mjs';
16
+ import './types-CA-c2NH7.mjs';
17
17
  import 'axios';
18
18
  import 'node:events';
19
19
  import 'socket.io-client';
@@ -28,7 +28,7 @@ import 'node-pty';
28
28
  import 'node:readline';
29
29
  import '@anthropic-ai/sandbox-runtime';
30
30
  import 'expo-server-sdk';
31
- import './agentGuidance-7pJxf_3b.mjs';
31
+ import './agentGuidance-DeOIgOhh.mjs';
32
32
  import 'ink';
33
33
  import 'react';
34
34
  import '@anthropic-ai/claude-agent-sdk';
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-C7TA3haC.cjs');
3
+ var index = require('./index-Dn7s2iaT.cjs');
4
4
  var claudeAgentSdk = require('@anthropic-ai/claude-agent-sdk');
5
5
  require('chalk');
6
6
  require('node:os');
7
7
  require('node:crypto');
8
- require('./types-QB33ckXt.cjs');
8
+ require('./types-B15E2OVy.cjs');
9
9
  require('axios');
10
- require('./limits-BhK6ovLz.cjs');
10
+ require('./limits-DLlsV71c.cjs');
11
11
  require('node:fs/promises');
12
12
  require('node:fs');
13
13
  require('node:path');
@@ -31,7 +31,7 @@ require('fs');
31
31
  require('node:readline');
32
32
  require('@anthropic-ai/sandbox-runtime');
33
33
  require('expo-server-sdk');
34
- require('./agentGuidance-TjPzDO7d.cjs');
34
+ require('./agentGuidance-R9MH5Cd5.cjs');
35
35
  require('ink');
36
36
  require('react');
37
37
  require('ps-list');
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var AcpBackend = require('./AcpBackend-5slez7vM.cjs');
4
- var persistence = require('./limits-BhK6ovLz.cjs');
5
- var AcpSessionManager = require('./AcpSessionManager-CxvVg8ec.cjs');
6
- var api = require('./types-QB33ckXt.cjs');
7
- var index = require('./index-C7TA3haC.cjs');
3
+ var AcpBackend = require('./AcpBackend--EnHZRC4.cjs');
4
+ var persistence = require('./limits-DLlsV71c.cjs');
5
+ var AcpSessionManager = require('./AcpSessionManager-RoOyx5KI.cjs');
6
+ var api = require('./types-B15E2OVy.cjs');
7
+ var index = require('./index-Dn7s2iaT.cjs');
8
8
  var promises = require('node:fs/promises');
9
9
  var node_crypto = require('node:crypto');
10
10
  var path = require('node:path');
@@ -33,7 +33,7 @@ require('fs');
33
33
  require('node:readline');
34
34
  require('@anthropic-ai/sandbox-runtime');
35
35
  require('expo-server-sdk');
36
- require('./agentGuidance-TjPzDO7d.cjs');
36
+ require('./agentGuidance-R9MH5Cd5.cjs');
37
37
  require('ink');
38
38
  require('react');
39
39
  require('@anthropic-ai/claude-agent-sdk');
@@ -707,7 +707,13 @@ async function runAcp(opts) {
707
707
  return true;
708
708
  };
709
709
  const isAssistantVariant = process.env.HAPPY_SESSION_VARIANT === "assistant";
710
- const happyServer = await index.startHappyServer(session, { assistant: isAssistantVariant });
710
+ const happyServer = await index.startHappyServer(session, {
711
+ assistant: isAssistantVariant,
712
+ ...opts.agentName === "pi" ? { onContextUsage: (contextUsage) => {
713
+ session.updateAgentState((state2) => ({ ...state2, contextUsage }));
714
+ } } : {}
715
+ });
716
+ if (opts.agentName === "pi") session.updateAgentState((state2) => ({ ...state2, contextUsage: null }));
711
717
  const mcpServers = {
712
718
  happy: {
713
719
  command: path.join(api.projectPath(), "bin", "very-happy-mcp.mjs"),
@@ -723,6 +729,7 @@ async function runAcp(opts) {
723
729
  env: {
724
730
  ...teamsPiEnv,
725
731
  HAPPY_MCP_URL: happyServer.url,
732
+ ...happyServer.contextUsageUrl ? { HAPPY_CONTEXT_USAGE_URL: happyServer.contextUsageUrl } : {},
726
733
  HAPPY_SESSION_ID: session.sessionId,
727
734
  HAPPY_PERMISSION_MODE: initialPermissionMode
728
735
  },
@@ -1,13 +1,13 @@
1
1
  import{createRequire as _pkgrollCR}from"node:module";const require=_pkgrollCR(import.meta.url);import chalk from 'chalk';
2
2
  import os, { homedir, userInfo, tmpdir } from 'node:os';
3
3
  import { randomUUID, randomBytes, createHash as createHash$1, timingSafeEqual } from 'node:crypto';
4
- import { j as getProjectPath, g as BUILTIN_TODO_DISCOVERY, p as projectPath, k as initializeSandbox, w as wrapCommand, d as contentLogMetadata, I as InvalidateSync, R as RawJSONLinesSchema, h as delay, l as AsyncLock, S as STREAM_DELTA_MAX_CHARS, M as MAX_CHAT_ATTACHMENT_SOURCE_BYTES, m as commandOnPath, n as deriveLocalCliUpdateSummary, o as isClaudeSessionId, q as getLocalHappyAgentCredentialPath, r as readLocalHappyAgentCredentials, t as parseExactVersion, u as compareExactVersions, v as extractCompleteLines, x as decideBackfill, y as parseTerminalHookPayload, z as tmuxArgs, C as scrubTmuxClientEnv, D as decideMirrorBinding, E as MIRROR_BACKFILL_LINES_DEFAULT, F as mirrorLineKey, G as mirrorLocalId, H as detectCLIAvailability, J as detectResumeSupport, K as summarizeSpawnSessionForLog, L as shellescape, A as ApiClient, N as fetchCliUpdateState, O as resolveCliUpdateCheckInterval, P as DEFAULT_CLI_UPDATE_CHECK_INTERVAL_MS, i as isValidSessionId, Q as listVhTerminals, T as isValidTerminalId, U as readVhTerminal, V as sendToVhTerminal, W as TITLE_PROMPT_PREFIX, X as BOARD_ANALYZER_PROMPT_PREFIX, f as connectionState, Y as startOfflineReconnection, c as createEnvelope, Z as CodexAppServerClient } from './types-B-ySoSY9.mjs';
5
- import { z as readDaemonState, l as logger, c as configuration, A as clearDaemonState, B as ensurePrivateDirectory, D as hardenPrivateFile, p as packageJson, g as readSettings, E as readCredentials, s as credentialRelayProblem, i as encodeBase64, F as readSettingsOutcome, G as updateSettings, H as encodeBase64Url, m as decodeBase64, I as writeCredentialsLegacy, J as writeCredentialsDataKey, d as readCredentialsForConfiguredRelay, j as encrypt, r as readPersistedSessions, w as writePrivateFileSync, K as decryptWithDataKey, L as decryptLegacy, M as persistSession, k as decrypt, f as ensurePrivateDirectorySync, N as acquireDaemonLock, O as deletePersistedSessions, P as writeDaemonState, Q as writeSettings, R as releaseDaemonLock, C as CLIPBOARD_TOOL_NAME, a as CLIPBOARD_TOOL_TITLE, b as CLIPBOARD_TOOL_DESCRIPTION, e as CLIPBOARD_MAX_BYTES, S as clearCredentials, T as clearMachineId, U as SandboxConfigSchema, V as getLatestDaemonLog } from './limits-CIcZA0Bn.mjs';
4
+ import { j as getProjectPath, g as BUILTIN_TODO_DISCOVERY, p as projectPath, k as initializeSandbox, w as wrapCommand, d as contentLogMetadata, I as InvalidateSync, R as RawJSONLinesSchema, h as delay, l as AsyncLock, S as STREAM_DELTA_MAX_CHARS, M as MAX_CHAT_ATTACHMENT_SOURCE_BYTES, m as commandOnPath, n as deriveLocalCliUpdateSummary, o as isClaudeSessionId, q as getLocalHappyAgentCredentialPath, r as readLocalHappyAgentCredentials, t as parseExactVersion, u as compareExactVersions, v as extractCompleteLines, x as decideBackfill, y as parseTerminalHookPayload, z as tmuxArgs, C as scrubTmuxClientEnv, D as decideMirrorBinding, E as MIRROR_BACKFILL_LINES_DEFAULT, F as mirrorLineKey, G as mirrorLocalId, H as detectCLIAvailability, J as detectResumeSupport, K as summarizeSpawnSessionForLog, L as shellescape, A as ApiClient, N as fetchCliUpdateState, O as resolveCliUpdateCheckInterval, P as DEFAULT_CLI_UPDATE_CHECK_INTERVAL_MS, i as isValidSessionId, Q as listVhTerminals, T as isValidTerminalId, U as readVhTerminal, V as sendToVhTerminal, W as ContextUsageSchema, X as TITLE_PROMPT_PREFIX, Y as BOARD_ANALYZER_PROMPT_PREFIX, f as connectionState, Z as startOfflineReconnection, c as createEnvelope, _ as CodexAppServerClient } from './types-CA-c2NH7.mjs';
5
+ import { z as readDaemonState, l as logger, c as configuration, A as clearDaemonState, B as ensurePrivateDirectory, D as hardenPrivateFile, p as packageJson, g as readSettings, E as readCredentials, s as credentialRelayProblem, i as encodeBase64, F as readSettingsOutcome, G as updateSettings, H as encodeBase64Url, m as decodeBase64, I as writeCredentialsLegacy, J as writeCredentialsDataKey, d as readCredentialsForConfiguredRelay, j as encrypt, r as readPersistedSessions, w as writePrivateFileSync, K as decryptWithDataKey, L as decryptLegacy, M as persistSession, k as decrypt, f as ensurePrivateDirectorySync, N as acquireDaemonLock, O as deletePersistedSessions, P as writeDaemonState, Q as writeSettings, R as releaseDaemonLock, C as CLIPBOARD_TOOL_NAME, a as CLIPBOARD_TOOL_TITLE, b as CLIPBOARD_TOOL_DESCRIPTION, e as CLIPBOARD_MAX_BYTES, S as clearCredentials, T as clearMachineId, U as SandboxConfigSchema, V as getLatestDaemonLog } from './limits-C9aXkP7U.mjs';
6
6
  import spawn$1, { spawn } from 'cross-spawn';
7
7
  import path, { join, resolve, basename, isAbsolute, dirname, sep, delimiter, normalize } from 'node:path';
8
8
  import { createInterface } from 'node:readline';
9
9
  import { existsSync, readFileSync, readdirSync, statSync, mkdirSync, unlinkSync, renameSync, writeFileSync, accessSync, constants, openSync, fsyncSync, closeSync, rmSync as rmSync$1, chmodSync as chmodSync$1 } from 'node:fs';
10
- import { f as trimIdent, A as AGENT_GUIDANCE, t as teamScopePath, T as TeamConnectionPreflightError, e as createTeamsClient, P as PREVIEW_TOOL_NAME, R as REPORT_PROGRESS_TOOL_NAME, g as TEAM_TOOL_NAMES, r as registerTeamsTools, a as PREVIEW_TOOL_TITLE, b as PREVIEW_TOOL_DESCRIPTION, h as REPORT_PROGRESS_TOOL_TITLE, i as REPORT_PROGRESS_TOOL_DESCRIPTION } from './agentGuidance-7pJxf_3b.mjs';
10
+ import { f as trimIdent, A as AGENT_GUIDANCE, t as teamScopePath, T as TeamConnectionPreflightError, e as createTeamsClient, P as PREVIEW_TOOL_NAME, R as REPORT_PROGRESS_TOOL_NAME, g as TEAM_TOOL_NAMES, r as registerTeamsTools, a as PREVIEW_TOOL_TITLE, b as PREVIEW_TOOL_DESCRIPTION, h as REPORT_PROGRESS_TOOL_TITLE, i as REPORT_PROGRESS_TOOL_DESCRIPTION } from './agentGuidance-DeOIgOhh.mjs';
11
11
  import { readFile, writeFile, rename, unlink, mkdir, symlink, rm, readlink, lstat, stat, open as open$1, appendFile } from 'node:fs/promises';
12
12
  import fs, { watch, access } from 'fs/promises';
13
13
  import { useStdout, useInput, Box, Text, render } from 'ink';
@@ -8873,6 +8873,24 @@ export default async function(pi) {
8873
8873
  const {readFile} = await import('node:fs/promises');
8874
8874
  const {join} = await import('node:path');
8875
8875
  const {homedir} = await import('node:os');
8876
+ const contextEndpoint = process.env.HAPPY_CONTEXT_USAGE_URL;
8877
+ if (contextEndpoint) {
8878
+ const target = new URL(contextEndpoint);
8879
+ if (target.origin !== url.origin || !target.pathname.startsWith('/runtime-context/')) throw new Error('Very Happy context must be local');
8880
+ let reporting = Promise.resolve();
8881
+ for (const name of ['session_start', 'session_switch', 'session_compact', 'model_select', 'turn_end', 'agent_end']) {
8882
+ pi.on(name, async (_event, ctx) => {
8883
+ const usage = ctx.getContextUsage?.();
8884
+ const contextWindow = usage?.contextWindow ?? ctx.model?.contextWindow;
8885
+ if (!(contextWindow > 0)) return;
8886
+ const snapshot = {source:'pi', tokens:usage?.tokens ?? null, contextWindow};
8887
+ reporting = reporting.catch(() => {}).then(async () => {
8888
+ try { await fetch(contextEndpoint, {method:'POST', redirect:'error', headers:{'content-type':'application/json'}, body:JSON.stringify(snapshot), signal:AbortSignal.timeout(2000)}); } catch {}
8889
+ });
8890
+ await reporting;
8891
+ });
8892
+ }
8893
+ }
8876
8894
  pi.on('tool_call', async (event, ctx) => {
8877
8895
  let mode = process.env.HAPPY_PERMISSION_MODE || 'default';
8878
8896
  const sid = process.env.HAPPY_SESSION_ID;
@@ -9465,6 +9483,8 @@ function writeReceipt(home, receipt) {
9465
9483
  const exec = promisify(execFile);
9466
9484
  const git = async (directory, args) => (await exec("git", ["-C", directory, ...args], { timeout: 3e4, maxBuffer: 2 * 1024 * 1024 })).stdout.trim();
9467
9485
  async function prepareTeamWorktree(home, repository, id) {
9486
+ if (repository === "~") repository = homedir();
9487
+ else if (repository.startsWith("~/") || process.platform === "win32" && repository.startsWith("~\\")) repository = join(homedir(), repository.slice(2));
9468
9488
  if (!isAbsolute(repository) || !/^[a-zA-Z0-9_-]{1,128}$/.test(id)) throw new Error("A team task requires an absolute repository path and valid operation id");
9469
9489
  await git(repository, ["rev-parse", "--show-toplevel"]);
9470
9490
  const root = join(home, "teams", "worktrees");
@@ -9596,6 +9616,10 @@ function createTeamWorker(deps) {
9596
9616
  await deps.stopAndWait(op.sessionId);
9597
9617
  await archiveSession(op.sessionId);
9598
9618
  }
9619
+ if (team.archivedAt !== void 0) {
9620
+ await complete(op, receipt);
9621
+ return;
9622
+ }
9599
9623
  const origins = team.operations.filter((candidate) => candidate.type === "spawn" && candidate.botId === op.botId && candidate.generation === op.generation && candidate.sessionId === op.sessionId);
9600
9624
  if (origins.length !== 1) throw new Error("Original worktree ownership is unknown; manual reconciliation required");
9601
9625
  const resource = readReceipt(home, origins[0].id);
@@ -9680,7 +9704,7 @@ Use the teams tools to inspect current task state before acting. This message is
9680
9704
  const status = axios.isAxiosError(error) ? error.response?.status : void 0;
9681
9705
  if (status !== 404) deps.log("Teams schedule advancement unavailable; regular reconciliation continues");
9682
9706
  }
9683
- const { data } = await http.get("/v1/teams/operations", { params: { machineId: deps.machineId, schedulesVersion: 1, teamLaunchVersion: 1 } });
9707
+ const { data } = await http.get("/v1/teams/operations", { params: { machineId: deps.machineId, schedulesVersion: 1, teamLaunchVersion: 1, teamArchiveVersion: 1 } });
9684
9708
  knownSessionIds = new Set((data.teams ?? []).flatMap((team) => team.bots.flatMap((bot) => bot.sessionId ? [bot.sessionId] : [])));
9685
9709
  for (const op of data.operations) {
9686
9710
  if (closed) break;
@@ -11762,7 +11786,30 @@ async function startHappyServer(client, options) {
11762
11786
  }
11763
11787
  }
11764
11788
  };
11789
+ const contextPath = "/runtime-context/" + randomUUID();
11765
11790
  const server = createServer(async (req, res) => {
11791
+ if (req.url?.startsWith("/runtime-context/")) {
11792
+ if (!options?.onContextUsage || req.url !== contextPath || req.method !== "POST" || req.headers.origin) {
11793
+ res.writeHead(403).end();
11794
+ return;
11795
+ }
11796
+ try {
11797
+ let body = "";
11798
+ for await (const chunk of req) {
11799
+ body += chunk.toString();
11800
+ if (Buffer.byteLength(body) > 2048) {
11801
+ res.writeHead(413).end();
11802
+ return;
11803
+ }
11804
+ }
11805
+ const usage = ContextUsageSchema.parse({ ...JSON.parse(body), updatedAt: Date.now() });
11806
+ options.onContextUsage(usage);
11807
+ res.writeHead(204).end();
11808
+ } catch {
11809
+ if (!res.headersSent) res.writeHead(400).end();
11810
+ }
11811
+ return;
11812
+ }
11766
11813
  const mcp = createMcpServer(handlers, options, client.sessionId);
11767
11814
  try {
11768
11815
  const transport = new StreamableHTTPServerTransport({
@@ -11796,6 +11843,7 @@ async function startHappyServer(client, options) {
11796
11843
  logger.debug(`[happyMCP] server:ready sessionId=${client.sessionId} url=${baseUrl.toString()}`);
11797
11844
  return {
11798
11845
  url: baseUrl.toString(),
11846
+ contextUsageUrl: options?.onContextUsage ? new URL(contextPath, baseUrl).toString() : void 0,
11799
11847
  toolNames: [
11800
11848
  "change_title",
11801
11849
  CLIPBOARD_TOOL_NAME,
@@ -12063,7 +12111,7 @@ function registerSideQuestionHandler(rpc, deps) {
12063
12111
  const retainMs = deps.retainMs ?? SIDE_QUESTION_RETAIN_MS;
12064
12112
  const maxRunMs = deps.maxRunMs ?? SIDE_QUESTION_MAX_RUN_MS;
12065
12113
  const run = deps.run ?? (async (input) => {
12066
- const { query } = await import('./index-C13U8MkT.mjs');
12114
+ const { query } = await import('./index-DK0qz1y7.mjs');
12067
12115
  return runSideQuestion(query, input);
12068
12116
  });
12069
12117
  const slots = /* @__PURE__ */ new Map();
@@ -17080,7 +17128,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
17080
17128
  process.exit(0);
17081
17129
  } else if (subcommand === "install-terminal-hooks") {
17082
17130
  try {
17083
- const { installTerminalHooks, parseTerminalHooksArgs, TERMINAL_HOOKS_HELP } = await import('./installTerminalHooks-kUC6I6Rn.mjs');
17131
+ const { installTerminalHooks, parseTerminalHooksArgs, TERMINAL_HOOKS_HELP } = await import('./installTerminalHooks-CRWWmonO.mjs');
17084
17132
  const command = parseTerminalHooksArgs(args.slice(1));
17085
17133
  if (command.action === "help") {
17086
17134
  console.log(TERMINAL_HOOKS_HELP);
@@ -17097,7 +17145,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
17097
17145
  }
17098
17146
  } else if (subcommand === "spawn") {
17099
17147
  try {
17100
- const { handleSpawnCommand } = await import('./spawn-CJxg1JUO.mjs');
17148
+ const { handleSpawnCommand } = await import('./spawn-DrQo81MW.mjs');
17101
17149
  await handleSpawnCommand(args.slice(1));
17102
17150
  } catch (error) {
17103
17151
  console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
@@ -17109,7 +17157,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
17109
17157
  return;
17110
17158
  } else if (subcommand === "sessions") {
17111
17159
  try {
17112
- const { handleSessionsCommand } = await import('./sessions-Bo2THj4y.mjs');
17160
+ const { handleSessionsCommand } = await import('./sessions-CP9FlcJ6.mjs');
17113
17161
  await handleSessionsCommand(args.slice(1));
17114
17162
  } catch (error) {
17115
17163
  console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
@@ -17121,7 +17169,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
17121
17169
  return;
17122
17170
  } else if (subcommand === "send") {
17123
17171
  try {
17124
- const { handleSendCommand } = await import('./send-BdhUFGTm.mjs');
17172
+ const { handleSendCommand } = await import('./send-CSOeUlQC.mjs');
17125
17173
  await handleSendCommand(args.slice(1));
17126
17174
  } catch (error) {
17127
17175
  console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
@@ -17227,9 +17275,9 @@ Conversation history is preserved on the server, but in-flight tool calls are in
17227
17275
  if (geminiSubcommand === "project" && args[2] === "set" && args[3]) {
17228
17276
  const projectId = args[3];
17229
17277
  try {
17230
- const { saveGoogleCloudProjectToConfig } = await import('./config-BWu8j7bO.mjs');
17231
- const { readCredentialsForConfiguredRelay: readCredentialsForConfiguredRelay2 } = await import('./limits-CIcZA0Bn.mjs').then(function (n) { return n.W; });
17232
- const { ApiClient: ApiClient2 } = await import('./types-B-ySoSY9.mjs').then(function (n) { return n._; });
17278
+ const { saveGoogleCloudProjectToConfig } = await import('./config-ClCkJ1a_.mjs');
17279
+ const { readCredentialsForConfiguredRelay: readCredentialsForConfiguredRelay2 } = await import('./limits-C9aXkP7U.mjs').then(function (n) { return n.W; });
17280
+ const { ApiClient: ApiClient2 } = await import('./types-CA-c2NH7.mjs').then(function (n) { return n.$; });
17233
17281
  let userEmail = void 0;
17234
17282
  try {
17235
17283
  const credentials = await readCredentialsForConfiguredRelay2();
@@ -17260,7 +17308,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
17260
17308
  }
17261
17309
  if (geminiSubcommand === "project" && args[2] === "get") {
17262
17310
  try {
17263
- const { readGeminiLocalConfig } = await import('./config-BWu8j7bO.mjs');
17311
+ const { readGeminiLocalConfig } = await import('./config-ClCkJ1a_.mjs');
17264
17312
  const config = readGeminiLocalConfig();
17265
17313
  if (config.googleCloudProject) {
17266
17314
  console.log(`Current Google Cloud Project: ${config.googleCloudProject}`);
@@ -17300,7 +17348,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
17300
17348
  process.exit(0);
17301
17349
  }
17302
17350
  try {
17303
- const { runGemini } = await import('./runGemini-BQd3qlVY.mjs');
17351
+ const { runGemini } = await import('./runGemini-BjEl7syj.mjs');
17304
17352
  let startedBy = void 0;
17305
17353
  for (let i = 1; i < args.length; i++) {
17306
17354
  if (args[i] === "--started-by") {
@@ -17330,7 +17378,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
17330
17378
  }
17331
17379
  };
17332
17380
  try {
17333
- const { runAcp, resolveAcpAgentConfig } = await import('./index-CdOVizh_.mjs');
17381
+ const { runAcp, resolveAcpAgentConfig } = await import('./index-DdbU8FmA.mjs');
17334
17382
  const parsed = parsePiRunnerArgs(args.slice(1));
17335
17383
  const resolved = resolveAcpAgentConfig(["pi", ...parsed.passthrough]);
17336
17384
  const { credentials } = await authAndSetupMachineIfNeeded();
@@ -17358,7 +17406,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
17358
17406
  return;
17359
17407
  } else if (subcommand === "acp") {
17360
17408
  try {
17361
- const { runAcp, resolveAcpAgentConfig } = await import('./index-CdOVizh_.mjs');
17409
+ const { runAcp, resolveAcpAgentConfig } = await import('./index-DdbU8FmA.mjs');
17362
17410
  let startedBy = void 0;
17363
17411
  let verbose = false;
17364
17412
  const acpArgs = [];
@@ -17398,7 +17446,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
17398
17446
  return;
17399
17447
  } else if (subcommand === "openclaw") {
17400
17448
  try {
17401
- const { runOpenClaw } = await import('./runOpenClaw-BgtE2jKF.mjs');
17449
+ const { runOpenClaw } = await import('./runOpenClaw-ByHu69K5.mjs');
17402
17450
  let startedBy = void 0;
17403
17451
  let verbose = false;
17404
17452
  let gatewayUrl;
@@ -17449,7 +17497,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
17449
17497
  return;
17450
17498
  } else if (subcommand === "todo") {
17451
17499
  try {
17452
- const { handleTodoCommand } = await import('./todo-C8hDSNBP.mjs');
17500
+ const { handleTodoCommand } = await import('./todo-BAwevRyb.mjs');
17453
17501
  await handleTodoCommand(args.slice(1));
17454
17502
  } catch (error) {
17455
17503
  console.error(JSON.stringify({ error: error instanceof Error ? error.message : "Todo command failed" }));
@@ -17458,7 +17506,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
17458
17506
  return;
17459
17507
  } else if (subcommand === "teams") {
17460
17508
  try {
17461
- const { handleTeamsCommand } = await import('./teams-CHGj90rR.mjs');
17509
+ const { handleTeamsCommand } = await import('./teams-Bbvo1G6y.mjs');
17462
17510
  await handleTeamsCommand(args.slice(1));
17463
17511
  } catch (error) {
17464
17512
  console.error(error instanceof Error ? error.message : "Teams command failed");
@@ -17467,7 +17515,7 @@ Conversation history is preserved on the server, but in-flight tool calls are in
17467
17515
  return;
17468
17516
  } else if (subcommand === "mcp" && args.length === 1) {
17469
17517
  try {
17470
- const { handleMcpCommand } = await import('./mcp-D5uyhbfB.mjs');
17518
+ const { handleMcpCommand } = await import('./mcp-DkoXvc07.mjs');
17471
17519
  await handleMcpCommand();
17472
17520
  } catch (error) {
17473
17521
  process.stderr.write(`[very-happy mcp] Fatal: ${error instanceof Error ? error.message : String(error)}
@@ -1,11 +1,11 @@
1
- import { q as query } from './index-BUhcXX8R.mjs';
1
+ import { q as query } from './index-D1gHXtkw.mjs';
2
2
  export { AbortError } from '@anthropic-ai/claude-agent-sdk';
3
3
  import 'chalk';
4
4
  import 'node:os';
5
5
  import 'node:crypto';
6
- import './types-B-ySoSY9.mjs';
6
+ import './types-CA-c2NH7.mjs';
7
7
  import 'axios';
8
- import './limits-CIcZA0Bn.mjs';
8
+ import './limits-C9aXkP7U.mjs';
9
9
  import 'node:fs/promises';
10
10
  import 'node:fs';
11
11
  import 'node:path';
@@ -29,7 +29,7 @@ import 'fs';
29
29
  import 'node:readline';
30
30
  import '@anthropic-ai/sandbox-runtime';
31
31
  import 'expo-server-sdk';
32
- import './agentGuidance-7pJxf_3b.mjs';
32
+ import './agentGuidance-DeOIgOhh.mjs';
33
33
  import 'ink';
34
34
  import 'react';
35
35
  import 'ps-list';
@@ -1,9 +1,9 @@
1
- import { D as DefaultTransport, A as AcpBackend } from './AcpBackend-Co3atHW2.mjs';
2
- export { a as DEFAULT_IDLE_TIMEOUT_MS, b as DEFAULT_TOOL_CALL_TIMEOUT_MS, e as extractErrorDetail, f as formatDuration, c as formatDurationMinutes, h as handleAgentMessageChunk, d as handleAgentThoughtChunk, g as handleLegacyMessageChunk, i as handlePlanUpdate, j as handleThinkingUpdate, k as handleToolCall, l as handleToolCallUpdate, p as parseArgsFromContent } from './AcpBackend-Co3atHW2.mjs';
3
- import { c as configuration, g as readSettings, i as encodeBase64, l as logger } from './limits-CIcZA0Bn.mjs';
4
- import { A as AcpSessionManager } from './AcpSessionManager-B0sD6Zi7.mjs';
5
- import { f as connectionState, A as ApiClient, p as projectPath, g as BUILTIN_TODO_DISCOVERY } from './types-B-ySoSY9.mjs';
6
- import { P as PI_TEAMS_EXTENSION, n as initialMachineMetadata, o as createSessionMetadata, u as setupOfflineReconnection, v as notifyDaemonSessionStarted, z as StreamRelay, x as MessageQueue2, B as hashObject, C as startHappyServer, E as registerAgentAttachmentDownloads, F as TitleGenerator, y as registerKillSessionHandler, H as CLAUDE_ATTACHMENT_KINDS, I as stageClaudeAttachments, J as appendStagedAttachmentsToPrompt, K as BasePermissionHandler, L as writeSessionModeFile, N as normalizeAcpPermissionMode, O as removeSessionModeFile } from './index-BUhcXX8R.mjs';
1
+ import { D as DefaultTransport, A as AcpBackend } from './AcpBackend-BNMLGtST.mjs';
2
+ export { a as DEFAULT_IDLE_TIMEOUT_MS, b as DEFAULT_TOOL_CALL_TIMEOUT_MS, e as extractErrorDetail, f as formatDuration, c as formatDurationMinutes, h as handleAgentMessageChunk, d as handleAgentThoughtChunk, g as handleLegacyMessageChunk, i as handlePlanUpdate, j as handleThinkingUpdate, k as handleToolCall, l as handleToolCallUpdate, p as parseArgsFromContent } from './AcpBackend-BNMLGtST.mjs';
3
+ import { c as configuration, g as readSettings, i as encodeBase64, l as logger } from './limits-C9aXkP7U.mjs';
4
+ import { A as AcpSessionManager } from './AcpSessionManager-BF5JZYCC.mjs';
5
+ import { f as connectionState, A as ApiClient, p as projectPath, g as BUILTIN_TODO_DISCOVERY } from './types-CA-c2NH7.mjs';
6
+ import { P as PI_TEAMS_EXTENSION, n as initialMachineMetadata, o as createSessionMetadata, u as setupOfflineReconnection, v as notifyDaemonSessionStarted, z as StreamRelay, x as MessageQueue2, B as hashObject, C as startHappyServer, E as registerAgentAttachmentDownloads, F as TitleGenerator, y as registerKillSessionHandler, H as CLAUDE_ATTACHMENT_KINDS, I as stageClaudeAttachments, J as appendStagedAttachmentsToPrompt, K as BasePermissionHandler, L as writeSessionModeFile, N as normalizeAcpPermissionMode, O as removeSessionModeFile } from './index-D1gHXtkw.mjs';
7
7
  import { mkdir, chmod, writeFile, rename } from 'node:fs/promises';
8
8
  import { randomUUID } from 'node:crypto';
9
9
  import { join } from 'node:path';
@@ -32,7 +32,7 @@ import 'fs';
32
32
  import 'node:readline';
33
33
  import '@anthropic-ai/sandbox-runtime';
34
34
  import 'expo-server-sdk';
35
- import './agentGuidance-7pJxf_3b.mjs';
35
+ import './agentGuidance-DeOIgOhh.mjs';
36
36
  import 'ink';
37
37
  import 'react';
38
38
  import '@anthropic-ai/claude-agent-sdk';
@@ -706,7 +706,13 @@ async function runAcp(opts) {
706
706
  return true;
707
707
  };
708
708
  const isAssistantVariant = process.env.HAPPY_SESSION_VARIANT === "assistant";
709
- const happyServer = await startHappyServer(session, { assistant: isAssistantVariant });
709
+ const happyServer = await startHappyServer(session, {
710
+ assistant: isAssistantVariant,
711
+ ...opts.agentName === "pi" ? { onContextUsage: (contextUsage) => {
712
+ session.updateAgentState((state2) => ({ ...state2, contextUsage }));
713
+ } } : {}
714
+ });
715
+ if (opts.agentName === "pi") session.updateAgentState((state2) => ({ ...state2, contextUsage: null }));
710
716
  const mcpServers = {
711
717
  happy: {
712
718
  command: join(projectPath(), "bin", "very-happy-mcp.mjs"),
@@ -722,6 +728,7 @@ async function runAcp(opts) {
722
728
  env: {
723
729
  ...teamsPiEnv,
724
730
  HAPPY_MCP_URL: happyServer.url,
731
+ ...happyServer.contextUsageUrl ? { HAPPY_CONTEXT_USAGE_URL: happyServer.contextUsageUrl } : {},
725
732
  HAPPY_SESSION_ID: session.sessionId,
726
733
  HAPPY_PERMISSION_MODE: initialPermissionMode
727
734
  },