@sleep2agi/agent-network 2.3.0-preview.7 → 2.3.0-preview.70

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 (86) hide show
  1. package/README.md +35 -324
  2. package/dist/bin/anet.cjs +101 -0
  3. package/dist/bin/cli.d.ts +1 -0
  4. package/dist/bin/cli.js +20 -1
  5. package/dist/bin/goal-wake-log-render.d.ts +31 -0
  6. package/dist/src/batch-workdir.d.ts +9 -0
  7. package/dist/src/bootstrap-password-db.d.ts +13 -0
  8. package/dist/src/channel-attachments.d.ts +29 -0
  9. package/dist/src/channel-meta.d.ts +10 -0
  10. package/dist/src/channel-task-trace.d.ts +10 -0
  11. package/dist/src/claude-vendor-env.d.ts +28 -0
  12. package/dist/src/cli-args.d.ts +8 -0
  13. package/dist/src/client-task-trace.d.ts +9 -0
  14. package/dist/src/client.js +1 -1
  15. package/dist/src/codex-copresence-preflight.d.ts +65 -0
  16. package/dist/src/codex-copresence-profile.d.ts +125 -0
  17. package/dist/src/codex-copresence-recovery.d.ts +43 -0
  18. package/dist/src/codex-copresence-thread.d.ts +13 -0
  19. package/dist/src/codex-model-default.d.ts +6 -0
  20. package/dist/src/codex-tui-client-health.d.ts +17 -0
  21. package/dist/src/commhub-response.d.ts +1 -0
  22. package/dist/src/controlled-upload.d.ts +83 -0
  23. package/dist/src/copresence-deps.d.ts +22 -0
  24. package/dist/src/copresence-identity.d.ts +339 -0
  25. package/dist/src/copresence-startup-diagnosis.d.ts +17 -0
  26. package/dist/src/daemon-capability-display.d.ts +58 -0
  27. package/dist/src/daemon-capability-display.js +5 -0
  28. package/dist/src/dashboard-managed-process.d.ts +35 -0
  29. package/dist/src/environ-alias.d.ts +14 -0
  30. package/dist/src/grok-attach-client.d.ts +129 -0
  31. package/dist/src/grok-copresence-disclosure.d.ts +11 -0
  32. package/dist/src/grok-copresence-orchestration.d.ts +70 -0
  33. package/dist/src/grok-copresence-profile.d.ts +65 -0
  34. package/dist/src/im/correlation-store.d.ts +34 -0
  35. package/dist/src/im/feishu/adapter.d.ts +118 -1
  36. package/dist/src/im/feishu/bridge.d.ts +85 -14
  37. package/dist/src/im/feishu/config.d.ts +31 -0
  38. package/dist/src/im/feishu/hub-upload.d.ts +88 -0
  39. package/dist/src/im/feishu/markdown-image-renderer.d.ts +61 -0
  40. package/dist/src/im/feishu/outbound-marker.d.ts +140 -0
  41. package/dist/src/im/feishu/outbound-paths.d.ts +50 -0
  42. package/dist/src/im/feishu/outbound-route.d.ts +62 -0
  43. package/dist/src/im/feishu/worker-lifecycle.d.ts +13 -0
  44. package/dist/src/im/feishu/worker.js +403 -28
  45. package/dist/src/im/types.d.ts +38 -1
  46. package/dist/src/locale-diagnostic.d.ts +12 -0
  47. package/dist/src/mock-llm.d.ts +12 -0
  48. package/dist/src/node-activity-log.d.ts +4 -0
  49. package/dist/src/node-server-payload.d.ts +66 -0
  50. package/dist/src/node-server.js +7 -1
  51. package/dist/src/normalize-runtime.d.ts +29 -2
  52. package/dist/src/opencode-agent-node-pair.d.ts +25 -0
  53. package/dist/src/opencode-auth-login.d.ts +43 -0
  54. package/dist/src/opencode-launch-env.d.ts +13 -0
  55. package/dist/src/opencode-owner-mode.d.ts +6 -0
  56. package/dist/src/opencode-package-binary.d.ts +21 -0
  57. package/dist/src/opencode-pin.d.ts +44 -0
  58. package/dist/src/opencode-preset.d.ts +73 -0
  59. package/dist/src/opencode-runtime-binding.d.ts +30 -0
  60. package/dist/src/opencode-safe-root.d.ts +27 -0
  61. package/dist/src/opencode-smoke-env.d.ts +1 -0
  62. package/dist/src/outbound-tool-names.d.ts +1 -0
  63. package/dist/src/owned-roots.d.ts +58 -0
  64. package/dist/src/owner-env-file.d.ts +2 -0
  65. package/dist/src/package-mode-preflight.d.ts +41 -0
  66. package/dist/src/posix-codex-copresence.d.ts +8 -0
  67. package/dist/src/posix-modes.d.ts +36 -0
  68. package/dist/src/primary-network.d.ts +23 -0
  69. package/dist/src/private-state.d.ts +10 -0
  70. package/dist/src/profile-serialize.d.ts +1 -0
  71. package/dist/src/project-key.d.ts +1 -0
  72. package/dist/src/reply-originator.d.ts +20 -0
  73. package/dist/src/resume-runtime-infer.d.ts +18 -0
  74. package/dist/src/secret-shell-guidance.d.ts +3 -0
  75. package/dist/src/stale-socket.d.ts +118 -0
  76. package/dist/src/task-trace.d.ts +33 -0
  77. package/dist/src/tmux-attach.d.ts +8 -0
  78. package/dist/src/tmux-capability.d.ts +58 -0
  79. package/dist/src/tmux-exact-target.d.ts +34 -0
  80. package/dist/src/tmux-pane-prompt.d.ts +22 -0
  81. package/dist/src/token-cli.d.ts +13 -0
  82. package/dist/src/tool-allowlist.d.ts +28 -0
  83. package/dist/src/unsafe-package-path-reason.d.ts +17 -0
  84. package/dist/src/win-launcher.d.ts +20 -0
  85. package/dist/src/windows-codex-copresence.d.ts +41 -0
  86. package/package.json +14 -6
@@ -0,0 +1,31 @@
1
+ export interface WakeLogEntryShape {
2
+ ts?: string;
3
+ status?: string;
4
+ summary?: string;
5
+ task_id?: string;
6
+ }
7
+ export interface WakeLogGoalShape {
8
+ goal_id: string;
9
+ progress_log?: WakeLogEntryShape[];
10
+ }
11
+ export interface WakeLogRenderOpts {
12
+ /** Trim to the last N entries. undefined = all. */
13
+ tail?: number;
14
+ }
15
+ /**
16
+ * Format progress_log as a JSON object suitable for `--json` output.
17
+ * Pure. Never reads/writes filesystem. Legacy goals without
18
+ * progress_log render as empty array (not error).
19
+ */
20
+ export declare function renderWakeLogJson(goal: WakeLogGoalShape, opts?: WakeLogRenderOpts): {
21
+ goal_id: string;
22
+ total: number;
23
+ returned: number;
24
+ entries: WakeLogEntryShape[];
25
+ };
26
+ /**
27
+ * Format progress_log as a table for human console output.
28
+ * Column layout mirrors printGoalShow so the two commands read
29
+ * consistently. Empty log renders a single "(none)" line, not an error.
30
+ */
31
+ export declare function renderWakeLogText(goal: WakeLogGoalShape, opts?: WakeLogRenderOpts): string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Resolve one batch workdir before any mkdir/chdir loop starts.
3
+ *
4
+ * Node does not expand shell tildes. Leaving `~/team` relative means every
5
+ * iteration can resolve it from the previous node's cwd and create paths such
6
+ * as `/work/~/team/~/team`. Only the current user's `~` form is supported;
7
+ * `~other` is rejected instead of being written as a literal directory.
8
+ */
9
+ export declare function normalizeBatchWorkdir(input: string, cwd?: string, home?: string): string;
@@ -0,0 +1,13 @@
1
+ export interface BootstrapPasswordUpdateInvocation {
2
+ argv: string[];
3
+ env: NodeJS.ProcessEnv;
4
+ script: string;
5
+ }
6
+ /**
7
+ * Resolve the database selected for the local Hub into an explicit absolute
8
+ * path before launching the bootstrap helper. The helper must never infer a
9
+ * database from its own HOME/cwd: those can differ from the parent process.
10
+ */
11
+ export declare function resolveBootstrapDatabasePath(env: NodeJS.ProcessEnv, home: string, cwd: string): string;
12
+ export declare const BOOTSTRAP_PASSWORD_UPDATE_SCRIPT: string;
13
+ export declare function buildBootstrapPasswordUpdateInvocation(userId: string, dbPath: string, baseEnv?: NodeJS.ProcessEnv): BootstrapPasswordUpdateInvocation;
@@ -0,0 +1,29 @@
1
+ interface AttachmentDescriptor {
2
+ type?: unknown;
3
+ file_id?: unknown;
4
+ path?: unknown;
5
+ mime?: unknown;
6
+ name?: unknown;
7
+ size?: unknown;
8
+ }
9
+ export interface ChannelAttachmentDeps {
10
+ hubUrl: string;
11
+ authToken: string;
12
+ cacheDir: string;
13
+ fetch?: typeof fetch;
14
+ maxBytes?: number;
15
+ }
16
+ export interface ChannelAttachmentResult {
17
+ paths: string[];
18
+ failures: Array<{
19
+ fileId: string;
20
+ code: string;
21
+ message: string;
22
+ }>;
23
+ }
24
+ export declare function readableAttachmentsFromInbox(message: any): AttachmentDescriptor[];
25
+ export declare function channelAttachmentCacheDir(home: string, alias: string): string;
26
+ export declare function downloadChannelAttachments(message: any, deps: ChannelAttachmentDeps): Promise<ChannelAttachmentResult>;
27
+ export declare const downloadChannelImageAttachments: typeof downloadChannelAttachments;
28
+ export declare function appendChannelAttachmentPaths(content: string, paths: readonly string[]): string;
29
+ export {};
@@ -0,0 +1,10 @@
1
+ /** One inbound inbox row → the meta Claude Code renders as `<channel …>` attrs.
2
+ *
3
+ * Pure so the attribute set is assertable; it used to be inline in the SSE
4
+ * handler, where nothing could see it. */
5
+ export declare function inboundChannelMeta(msg: {
6
+ id: string;
7
+ from_session?: string | null;
8
+ priority?: string | null;
9
+ created_at?: string | null;
10
+ }): Record<string, string>;
@@ -0,0 +1,10 @@
1
+ export declare function sendChannelTaskWithTrace(input: {
2
+ alias: string;
3
+ task: string;
4
+ priority?: string;
5
+ fromAlias: string;
6
+ networkId?: string | null;
7
+ }, deps: {
8
+ send: (args: Record<string, unknown>) => Promise<any>;
9
+ log: (line: string) => void;
10
+ }): Promise<any>;
@@ -0,0 +1,28 @@
1
+ export declare const CLAUDE_VENDOR_ENV_KEYS: readonly ["ANTHROPIC_BASE_URL", "ANTHROPIC_AUTH_TOKEN", "ANTHROPIC_API_KEY"];
2
+ export type PlainSecretEnvRewrite = {
3
+ key: string;
4
+ refName: string;
5
+ value: string;
6
+ };
7
+ /**
8
+ * Plan the values that the node-create writer will move into its line-oriented
9
+ * `.env` file. This is deliberately side-effect free: callers can run it as a
10
+ * preflight before creating a node directory, changing process.env, or writing
11
+ * config.json. Keeping the line-break rejection here makes it cover every
12
+ * caller of the dotenv writer, including the no-name interactive wizard.
13
+ */
14
+ export declare function planPlainSecretEnvRewrites(input: {
15
+ env: unknown;
16
+ nodeId: string;
17
+ }): PlainSecretEnvRewrite[];
18
+ /**
19
+ * Persist the exact Anthropic-compatible vendor environment used by an
20
+ * explicit claude-agent-sdk create. Explicit --env values retain precedence;
21
+ * ambient shell values only fill missing known keys. Other environment values
22
+ * are intentionally ignored so node create never snapshots the whole shell.
23
+ */
24
+ export declare function collectClaudeVendorEnvForCreate(input: {
25
+ runtime: string;
26
+ explicitEnv: readonly string[];
27
+ shellEnv: Readonly<Record<string, string | undefined>>;
28
+ }): string[];
@@ -0,0 +1,8 @@
1
+ export type ParsedCliOptions = {
2
+ [key: string]: string | string[];
3
+ _channels: string[];
4
+ _envs: string[];
5
+ };
6
+ export declare const BOOLEAN_FLAGS: Set<string>;
7
+ export declare function parseCliOptions(argv: string[]): ParsedCliOptions;
8
+ export declare function positionalArgs(argv: string[]): string[];
@@ -0,0 +1,9 @@
1
+ export declare function sendClientTaskWithTrace(input: {
2
+ alias: string;
3
+ fromAlias: string;
4
+ parentTaskId?: string | null;
5
+ networkId?: string | null;
6
+ }, dependencies: {
7
+ send: () => Promise<any>;
8
+ log: (line: string) => void;
9
+ }): Promise<any>;
@@ -1 +1 @@
1
- const a0_0x399040=a0_0x340f;(function(_0x39361b,_0x4180f8){const _0x315c67=a0_0x340f,_0x271cd3=_0x39361b();while(!![]){try{const _0x5a31d2=-parseInt(_0x315c67(0x142))/0x1*(-parseInt(_0x315c67(0x110))/0x2)+-parseInt(_0x315c67(0x149))/0x3+-parseInt(_0x315c67(0x15c))/0x4*(-parseInt(_0x315c67(0x130))/0x5)+-parseInt(_0x315c67(0x155))/0x6+parseInt(_0x315c67(0x118))/0x7*(parseInt(_0x315c67(0x153))/0x8)+parseInt(_0x315c67(0x11a))/0x9+parseInt(_0x315c67(0x12a))/0xa*(-parseInt(_0x315c67(0x147))/0xb);if(_0x5a31d2===_0x4180f8)break;else _0x271cd3['push'](_0x271cd3['shift']());}catch(_0x4b1e5a){_0x271cd3['push'](_0x271cd3['shift']());}}}(a0_0x5a89,0x54140));import{EventEmitter as a0_0x55ec56}from'events';function a0_0x340f(_0x5ea411,_0x424a15){_0x5ea411=_0x5ea411-0x108;const _0x5a89f0=a0_0x5a89();let _0x340f9e=_0x5a89f0[_0x5ea411];return _0x340f9e;}function a0_0x5a89(){const _0x31783e=['get_inbox','send_message','application/json,\x20text/event-stream','pop','min','send','report_status','2AnWlsV','offline','processInbox','heartbeatTimer','message','connect','autoConnect','ack_inbox','128996RRPghX','AbortError','5791725jsDCBh','catch','read','content','now','application/json','sseAbort','/events/','sdk-','task','getAllStatus','resumeId','startsWith','token','cwd','completed','6028210yecmod','heartbeatInterval','status','inbox\x20error:\x20','registered','heartbeat\x20failed:\x20','743455qDgZJb','url','result','replace','type','server','getReader','alias','reply','name','error','messages','POST','call',']\x20[commhub:','SSE\x20connected','disconnected','sdk','683419MzHxpd','abort','connectSSE','Authorization','disconnect','11GkgKBc','emit','2029374jmbGrS','sleep','agent','toTimeString','send_task','text','/mcp','broadcast','toString','body','152kdkLSg','new_task','3889062KUpUJH','log','parse','slice','Bearer\x20','idle','signal','16QlcPHD','split','reconnectDelay','text/event-stream','running'];a0_0x5a89=function(){return _0x31783e;};return a0_0x5a89();}import{hostname as a0_0x236b0c}from'os';class T extends a0_0x55ec56{['url'];['alias'];[a0_0x399040(0x127)];[a0_0x399040(0x14b)];[a0_0x399040(0x125)];[a0_0x399040(0x12b)];[a0_0x399040(0x15e)];[a0_0x399040(0x113)];['sseAbort'];[a0_0x399040(0x108)]=!0x1;constructor(_0x57aedd){const _0x5c20d6=a0_0x399040;super();if(this[_0x5c20d6(0x131)]=_0x57aedd[_0x5c20d6(0x131)][_0x5c20d6(0x133)](/\/$/,''),this['alias']=_0x57aedd[_0x5c20d6(0x137)],this[_0x5c20d6(0x127)]=_0x57aedd[_0x5c20d6(0x127)],this[_0x5c20d6(0x14b)]=_0x57aedd[_0x5c20d6(0x14b)]||_0x5c20d6(0x141),this[_0x5c20d6(0x125)]=_0x5c20d6(0x122)+_0x57aedd['alias']+'-'+Date[_0x5c20d6(0x11e)]()[_0x5c20d6(0x151)](0x24),this[_0x5c20d6(0x12b)]=_0x57aedd[_0x5c20d6(0x12b)]??0x2bf20,this['reconnectDelay']=_0x57aedd['reconnectDelay']??0xbb8,_0x57aedd[_0x5c20d6(0x116)]!==!0x1)this['connect']();}[a0_0x399040(0x156)](_0x2e1f5f){const _0xfaeef9=a0_0x399040;console['log']('['+new Date()[_0xfaeef9(0x14c)]()[_0xfaeef9(0x158)](0x0,0x8)+_0xfaeef9(0x13e)+this['alias']+']\x20'+_0x2e1f5f);}async['call'](_0x32db5e,_0x4993e1){const _0x25c2d5=a0_0x399040;let _0x50ec78={'Content-Type':_0x25c2d5(0x11f),'Accept':_0x25c2d5(0x10b)};if(this[_0x25c2d5(0x127)])_0x50ec78[_0x25c2d5(0x145)]=_0x25c2d5(0x159)+this['token'];let _0x19eff5=await(await fetch(this[_0x25c2d5(0x131)]+_0x25c2d5(0x14f),{'method':_0x25c2d5(0x13c),'headers':_0x50ec78,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date['now'](),'method':'tools/call','params':{'name':_0x32db5e,'arguments':_0x4993e1}})}))[_0x25c2d5(0x14e)](),_0xa1ada5=_0x19eff5['match'](/data: (.+)/),_0x172873=_0xa1ada5?JSON[_0x25c2d5(0x157)](_0xa1ada5[0x1]):JSON['parse'](_0x19eff5),_0x286359=_0x172873?.[_0x25c2d5(0x132)]?.[_0x25c2d5(0x11d)]?.[0x0]?.[_0x25c2d5(0x14e)];return _0x286359?JSON[_0x25c2d5(0x157)](_0x286359):_0x172873;}async[a0_0x399040(0x115)](){const _0x4c706f=a0_0x399040;if(this[_0x4c706f(0x108)])return;this[_0x4c706f(0x108)]=!0x0,await this[_0x4c706f(0x12c)](_0x4c706f(0x15a)),this['log'](_0x4c706f(0x12e)),this[_0x4c706f(0x113)]=setInterval(()=>{const _0x5bddf2=_0x4c706f;this[_0x5bddf2(0x12c)](_0x5bddf2(0x15a))['catch'](_0x9c819b=>this[_0x5bddf2(0x156)](_0x5bddf2(0x12f)+_0x9c819b['message']));},this['heartbeatInterval']),this[_0x4c706f(0x144)]();}async[a0_0x399040(0x146)](){const _0x578f3e=a0_0x399040;if(this['running']=!0x1,this['sseAbort']?.[_0x578f3e(0x143)](),this[_0x578f3e(0x113)])clearInterval(this[_0x578f3e(0x113)]);await this[_0x578f3e(0x12c)](_0x578f3e(0x111))[_0x578f3e(0x11b)](()=>{}),this[_0x578f3e(0x156)](_0x578f3e(0x140));}async[a0_0x399040(0x10e)](_0x30a6e0,_0x587824,_0x3fb8ac='normal'){const _0x4203ac=a0_0x399040;return this['call'](_0x4203ac(0x14d),{'alias':_0x30a6e0,'task':_0x587824,'priority':_0x3fb8ac,'from_session':this['alias']});}async[a0_0x399040(0x114)](_0x5bcff8,_0x3108bf){const _0x4d65d5=a0_0x399040;return this[_0x4d65d5(0x13d)](_0x4d65d5(0x10a),{'alias':_0x5bcff8,'message':_0x3108bf,'from_session':this[_0x4d65d5(0x137)]});}async[a0_0x399040(0x138)](_0x41a286,_0x20add6,_0x1d8e7c=a0_0x399040(0x129)){const _0x36fa1f=a0_0x399040;return this[_0x36fa1f(0x13d)]('send_reply',{'in_reply_to':_0x41a286,'text':_0x20add6,'status':_0x1d8e7c});}async['status'](_0x18ece1,_0x2352f3){const _0x573b42=a0_0x399040;return this[_0x573b42(0x13d)](_0x573b42(0x10f),{'resume_id':this[_0x573b42(0x125)],'alias':this[_0x573b42(0x137)],'status':_0x18ece1,'server':a0_0x236b0c(),'hostname':a0_0x236b0c(),'agent':this[_0x573b42(0x14b)],'project_dir':process[_0x573b42(0x128)](),..._0x2352f3});}async[a0_0x399040(0x124)](){const _0x5825f9=a0_0x399040;return this[_0x5825f9(0x13d)]('get_all_status',{});}async[a0_0x399040(0x150)](_0x16d6d3,_0x41cfe1){const _0x3aa5fe=a0_0x399040;return this[_0x3aa5fe(0x13d)](_0x3aa5fe(0x150),{'message':_0x16d6d3,'filter_server':_0x41cfe1?.[_0x3aa5fe(0x135)],'filter_status':_0x41cfe1?.[_0x3aa5fe(0x12c)]});}async[a0_0x399040(0x144)](){const _0x532a18=a0_0x399040;let _0x114f53=encodeURIComponent(this[_0x532a18(0x137)]),_0x5df645=this[_0x532a18(0x131)]+_0x532a18(0x121)+_0x114f53,_0x10afd0=this[_0x532a18(0x15e)];while(this['running']){try{this[_0x532a18(0x120)]=new AbortController();let _0x1bd2b5={'Accept':_0x532a18(0x15f)};if(this[_0x532a18(0x127)])_0x1bd2b5['Authorization']='Bearer\x20'+this[_0x532a18(0x127)];let _0x195262=await fetch(_0x5df645,{'headers':_0x1bd2b5,'signal':this[_0x532a18(0x120)][_0x532a18(0x15b)]});if(!_0x195262['ok']||!_0x195262[_0x532a18(0x152)]){this[_0x532a18(0x156)]('SSE\x20failed:\x20'+_0x195262[_0x532a18(0x12c)]),await this[_0x532a18(0x14a)](_0x10afd0),_0x10afd0=Math['min'](_0x10afd0*1.5,0xea60);continue;}_0x10afd0=this['reconnectDelay'];let _0x673f17=_0x195262['body'][_0x532a18(0x136)](),_0x526c55=new TextDecoder(),_0x3d58f6='';while(this[_0x532a18(0x108)]){let {done:_0x185423,value:_0x52b3aa}=await _0x673f17[_0x532a18(0x11c)]();if(_0x185423)break;_0x3d58f6+=_0x526c55['decode'](_0x52b3aa,{'stream':!0x0});let _0x113149=_0x3d58f6[_0x532a18(0x15d)]('\x0a');_0x3d58f6=_0x113149[_0x532a18(0x10c)]()||'';for(let _0xda92e9 of _0x113149){if(!_0xda92e9[_0x532a18(0x126)]('data:\x20'))continue;try{let _0x297867=JSON[_0x532a18(0x157)](_0xda92e9['slice'](0x6));if(_0x297867[_0x532a18(0x134)]==='connected'){this[_0x532a18(0x156)](_0x532a18(0x13f)),this[_0x532a18(0x148)]('connected');continue;}if(_0x297867[_0x532a18(0x134)]===_0x532a18(0x154)||_0x297867[_0x532a18(0x134)]==='new_message'||_0x297867['type']===_0x532a18(0x150))await this[_0x532a18(0x112)]();}catch{}}}}catch(_0x4c7cae){if(_0x4c7cae[_0x532a18(0x139)]===_0x532a18(0x119))break;this[_0x532a18(0x148)](_0x532a18(0x13a),_0x4c7cae),this[_0x532a18(0x156)]('SSE\x20error:\x20'+_0x4c7cae[_0x532a18(0x114)]);}if(this[_0x532a18(0x108)])this[_0x532a18(0x148)](_0x532a18(0x140)),this['log']('SSE\x20reconnecting\x20in\x20'+_0x10afd0/0x3e8+'s...'),await this[_0x532a18(0x14a)](_0x10afd0),_0x10afd0=Math[_0x532a18(0x10d)](_0x10afd0*1.5,0xea60);}}async[a0_0x399040(0x112)](){const _0x1bd4ba=a0_0x399040;try{let _0x344cd2=(await this[_0x1bd4ba(0x13d)](_0x1bd4ba(0x109),{'alias':this['alias'],'limit':0xa}))?.[_0x1bd4ba(0x13b)]||[];for(let _0x5244ff of _0x344cd2)await this['call'](_0x1bd4ba(0x117),{'alias':this[_0x1bd4ba(0x137)],'message_id':_0x5244ff['id']}),this[_0x1bd4ba(0x156)]('←\x20'+_0x5244ff['from_session']+':\x20'+_0x5244ff[_0x1bd4ba(0x11d)][_0x1bd4ba(0x158)](0x0,0x3c)),this['emit'](_0x1bd4ba(0x123),_0x5244ff),this[_0x1bd4ba(0x148)](_0x1bd4ba(0x114),_0x5244ff);}catch(_0xe0b16d){this['log'](_0x1bd4ba(0x12d)+_0xe0b16d['message']);}}[a0_0x399040(0x14a)](_0x576196){return new Promise(_0x278a9=>setTimeout(_0x278a9,_0x576196));}}var $=T;export{$ as default,T as CommHub};
1
+ const a0_0x2b4667=a0_0x3544;function a0_0x3544(_0x4457c7,_0x1a17ca){_0x4457c7=_0x4457c7-0xba;const _0x54b653=a0_0x54b6();let _0x3544c5=_0x54b653[_0x4457c7];return _0x3544c5;}(function(_0x17732e,_0x3ab4bb){const _0x269eb9=a0_0x3544,_0x53073c=_0x17732e();while(!![]){try{const _0x2f71b2=-parseInt(_0x269eb9(0xc4))/0x1+-parseInt(_0x269eb9(0x12a))/0x2+parseInt(_0x269eb9(0xfd))/0x3+parseInt(_0x269eb9(0x11b))/0x4*(parseInt(_0x269eb9(0xd3))/0x5)+parseInt(_0x269eb9(0xe2))/0x6*(parseInt(_0x269eb9(0xf5))/0x7)+-parseInt(_0x269eb9(0xc3))/0x8+parseInt(_0x269eb9(0xda))/0x9;if(_0x2f71b2===_0x3ab4bb)break;else _0x53073c['push'](_0x53073c['shift']());}catch(_0x1c9b5e){_0x53073c['push'](_0x53073c['shift']());}}}(a0_0x54b6,0x6eee3));import{EventEmitter as a0_0x2dfb31}from'events';import{hostname as a0_0x10acf7}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4e8f9,_0x1dafd4)=>(_0x4e8f9??_0x1dafd4)[a0_0x2b4667(0xd9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x2b4667(0x10f)](0x0,0xf0);function N(_0x1d1193){const _0x27a759=a0_0x2b4667;return(_0x1d1193 instanceof Error?_0x1d1193['message']:String(_0x1d1193??_0x27a759(0x139)))[_0x27a759(0xd9)](K,_0x27a759(0xf2))[_0x27a759(0xd9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x27a759(0x10f)](0x0,0xf0);}function O(_0x2d7f24,_0x67262d=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2b4667(0xea)){const _0x347e4e=a0_0x2b4667;if(_0x67262d)return JSON[_0x347e4e(0x11f)](_0x2d7f24);let _0x3caf55=L(_0x2d7f24[_0x347e4e(0xc6)],_0x347e4e(0xeb)),_0x1f2df1=L(_0x2d7f24[_0x347e4e(0x10a)],_0x347e4e(0x128)),_0x4628ea=_0x2d7f24[_0x347e4e(0xca)]?'\x20error='+_0x2d7f24['error_code']+':'+(_0x2d7f24[_0x347e4e(0xe5)]??''):'';return'[commhub:task]\x20'+_0x2d7f24[_0x347e4e(0xc5)]+'\x20from='+L(_0x2d7f24[_0x347e4e(0x122)],_0x347e4e(0xd7))+_0x347e4e(0xd0)+L(_0x2d7f24[_0x347e4e(0x114)],_0x347e4e(0xd7))+_0x347e4e(0x100)+_0x1f2df1+_0x347e4e(0x13a)+_0x3caf55+_0x347e4e(0xd8)+L(_0x2d7f24[_0x347e4e(0x126)],_0x347e4e(0xd7))+_0x347e4e(0x133)+_0x2d7f24[_0x347e4e(0xdd)]+_0x347e4e(0xfe)+_0x2d7f24[_0x347e4e(0x106)]+_0x347e4e(0xf6)+_0x2d7f24['lifecycle_tracking']+_0x4628ea;}function U(_0x48cb8c){const _0xadbd9c=a0_0x2b4667;return{'event':{'sending':_0xadbd9c(0xed),'delivered':_0xadbd9c(0xc8),'failed':_0xadbd9c(0xf1),'acked':_0xadbd9c(0xd6),'started':_0xadbd9c(0x10b),'replied':_0xadbd9c(0x103),'expired':'task.expired'}[_0x48cb8c[_0xadbd9c(0xc5)]],..._0x48cb8c};}function j(_0x24bc89){const _0x100450=a0_0x2b4667;let _0x5dc550=_0x24bc89?.[_0x100450(0x10a)]||_0x24bc89?.[_0x100450(0xfb)]||_0x24bc89?.['id'];if(_0x5dc550)return String(_0x5dc550);let _0xb141c5=_0x24bc89?.['content']?.[0x0]?.[_0x100450(0x12e)];if(typeof _0xb141c5!==_0x100450(0x123))return null;try{let _0x508ba7=JSON[_0x100450(0x109)](_0xb141c5);return _0x508ba7?.['task_id']||_0x508ba7?.[_0x100450(0xfb)]||_0x508ba7?.['id']||null;}catch{return null;}}async function X(_0x1c6f0a,_0x4a44ad){const _0x27e6be=a0_0x2b4667;let _0x59b767=_0x4a44ad[_0x27e6be(0xe8)]??Date[_0x27e6be(0xe8)],_0x4f1e7a=_0x59b767(),_0x5c98af=(_0x214e87,_0x5af6be,_0x233477,_0x3dc598)=>{const _0x22d346=_0x27e6be;_0x4a44ad['log'](O(U({'from_alias':_0x1c6f0a[_0x22d346(0xf0)],'to_alias':_0x1c6f0a[_0x22d346(0xd2)],'task_id':_0x5af6be,'parent_task_id':_0x1c6f0a[_0x22d346(0x132)],'network_id':_0x1c6f0a[_0x22d346(0x11c)],'transport':_0x1c6f0a[_0x22d346(0xdd)],'status':_0x214e87,'duration_ms':_0x59b767()-_0x4f1e7a,'lifecycle_tracking':_0x1c6f0a[_0x22d346(0x129)],..._0x233477!==void 0x0?{'error_code':_0x3dc598||_0x22d346(0x10d),'error_message':N(_0x233477)}:{}})));};_0x5c98af('sending',null);try{let _0x4c960d=await _0x4a44ad[_0x27e6be(0x117)](),_0xc85dc8=j(_0x4c960d);if(_0xc85dc8)_0x5c98af('delivered',_0xc85dc8);else{if(_0x4c960d?.['ok']===!0x1||_0x4c960d?.[_0x27e6be(0x111)])_0x5c98af(_0x27e6be(0x127),_0xc85dc8,_0x4c960d?.[_0x27e6be(0x111)]||_0x27e6be(0xcc),_0x27e6be(0x113));else _0x5c98af('failed',null,_0x27e6be(0xef),_0x27e6be(0x105));}return _0x4c960d;}catch(_0x3d2491){throw _0x5c98af(_0x27e6be(0x127),null,_0x3d2491,_0x27e6be(0x10d)),_0x3d2491;}}async function Y(_0x42b534,_0x221594){const _0x21b8a1=a0_0x2b4667;return X({'fromAlias':_0x42b534['fromAlias'],'toAlias':_0x42b534[_0x21b8a1(0x131)],'parentTaskId':_0x42b534[_0x21b8a1(0x132)]||null,'networkId':_0x42b534[_0x21b8a1(0x11c)]||null,'transport':'mcp_http','lifecycleTracking':_0x21b8a1(0xc2)},_0x221594);}class $ extends a0_0x2dfb31{[a0_0x2b4667(0xf8)];['alias'];[a0_0x2b4667(0x10c)];[a0_0x2b4667(0xd5)];[a0_0x2b4667(0xcf)];[a0_0x2b4667(0xde)];[a0_0x2b4667(0xdc)];[a0_0x2b4667(0x125)];[a0_0x2b4667(0xce)];[a0_0x2b4667(0xbc)]=!0x1;constructor(_0x4d0237){const _0x305694=a0_0x2b4667;super();if(this[_0x305694(0xf8)]=_0x4d0237[_0x305694(0xf8)][_0x305694(0xd9)](/\/$/,''),this[_0x305694(0x131)]=_0x4d0237['alias'],this['token']=_0x4d0237[_0x305694(0x10c)],this['agent']=_0x4d0237[_0x305694(0xd5)]||_0x305694(0xc9),this[_0x305694(0xcf)]=_0x305694(0x119)+_0x4d0237[_0x305694(0x131)]+'-'+Date[_0x305694(0xe8)]()[_0x305694(0x108)](0x24),this[_0x305694(0xde)]=_0x4d0237[_0x305694(0xde)]??0x2bf20,this[_0x305694(0xdc)]=_0x4d0237[_0x305694(0xdc)]??0xbb8,_0x4d0237[_0x305694(0x102)]!==!0x1)this['connect']();}[a0_0x2b4667(0xdf)](_0x4a8835){const _0x1e6a12=a0_0x2b4667;console[_0x1e6a12(0xdf)]('['+new Date()[_0x1e6a12(0x116)]()[_0x1e6a12(0x10f)](0x0,0x8)+_0x1e6a12(0x13b)+this[_0x1e6a12(0x131)]+']\x20'+_0x4a8835);}async[a0_0x2b4667(0x135)](_0x383540,_0x271f6c){const _0x421165=a0_0x2b4667;let _0x53662b={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this['token'])_0x53662b[_0x421165(0x11d)]='Bearer\x20'+this['token'];let _0x13cfd7=await(await fetch(this[_0x421165(0xf8)]+_0x421165(0xff),{'method':_0x421165(0x12b),'headers':_0x53662b,'body':JSON[_0x421165(0x11f)]({'jsonrpc':_0x421165(0x130),'id':Date[_0x421165(0xe8)](),'method':_0x421165(0xfa),'params':{'name':_0x383540,'arguments':_0x271f6c}})}))[_0x421165(0x12e)](),_0x3a11f7=_0x13cfd7['match'](/data: (.+)/),_0x112073=_0x3a11f7?JSON[_0x421165(0x109)](_0x3a11f7[0x1]):JSON['parse'](_0x13cfd7),_0x5cdf90=_0x112073?.[_0x421165(0xba)]?.[_0x421165(0x110)]?.[0x0]?.[_0x421165(0x12e)];return _0x5cdf90?JSON[_0x421165(0x109)](_0x5cdf90):_0x112073;}async[a0_0x2b4667(0xdb)](){const _0x281715=a0_0x2b4667;if(this[_0x281715(0xbc)])return;this[_0x281715(0xbc)]=!0x0,await this[_0x281715(0xc5)](_0x281715(0x134)),this[_0x281715(0xdf)]('registered'),this[_0x281715(0x125)]=setInterval(()=>{const _0x2ab521=_0x281715;this['status'](_0x2ab521(0x134))[_0x2ab521(0x107)](_0x31266f=>this[_0x2ab521(0xdf)](_0x2ab521(0xe3)+_0x31266f['message']));},this[_0x281715(0xde)]),this[_0x281715(0x12c)]();}async[a0_0x2b4667(0xe1)](){const _0x53014b=a0_0x2b4667;if(this['running']=!0x1,this[_0x53014b(0xce)]?.['abort'](),this[_0x53014b(0x125)])clearInterval(this[_0x53014b(0x125)]);await this[_0x53014b(0xc5)](_0x53014b(0xec))[_0x53014b(0x107)](()=>{}),this[_0x53014b(0xdf)](_0x53014b(0xe6));}async[a0_0x2b4667(0x117)](_0x428c90,_0x183259,_0xd33d03=a0_0x2b4667(0x121)){const _0x24a7c0=a0_0x2b4667;return Y({'alias':_0x428c90,'fromAlias':this[_0x24a7c0(0x131)]},{'log':_0x29c2a6=>console[_0x24a7c0(0xdf)](_0x29c2a6),'send':()=>this['call'](_0x24a7c0(0xbd),{'alias':_0x428c90,'task':_0x183259,'priority':_0xd33d03,'from_session':this[_0x24a7c0(0x131)]})});}async[a0_0x2b4667(0x120)](_0x1d2f64,_0x2a5afe){const _0x546c02=a0_0x2b4667;return this[_0x546c02(0x135)](_0x546c02(0x112),{'alias':_0x1d2f64,'message':_0x2a5afe,'from_session':this[_0x546c02(0x131)]});}async[a0_0x2b4667(0x101)](_0xe1c92d,_0x3c928f,_0x3e245e=a0_0x2b4667(0xf3)){const _0x26e87f=a0_0x2b4667;return this[_0x26e87f(0x135)](_0x26e87f(0x136),{'in_reply_to':_0xe1c92d,'text':_0x3c928f,'status':_0x3e245e});}async[a0_0x2b4667(0xc5)](_0x56cd81,_0x4a84d2){const _0x5eff87=a0_0x2b4667;return this[_0x5eff87(0x135)](_0x5eff87(0xbb),{'resume_id':this['resumeId'],'alias':this[_0x5eff87(0x131)],'status':_0x56cd81,'server':a0_0x10acf7(),'hostname':a0_0x10acf7(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x4a84d2});}async[a0_0x2b4667(0xbe)](){const _0x4ceb76=a0_0x2b4667;return this[_0x4ceb76(0x135)](_0x4ceb76(0x115),{});}async['broadcast'](_0x346c07,_0x58e48f){const _0x4447bc=a0_0x2b4667;return this['call'](_0x4447bc(0x118),{'message':_0x346c07,'filter_server':_0x58e48f?.['server'],'filter_status':_0x58e48f?.[_0x4447bc(0xc5)]});}async[a0_0x2b4667(0x12c)](){const _0x140660=a0_0x2b4667;let _0x91af80=encodeURIComponent(this[_0x140660(0x131)]),_0xec7f36=this['url']+'/events/'+_0x91af80,_0x20f615=this[_0x140660(0xdc)];while(this[_0x140660(0xbc)]){try{this[_0x140660(0xce)]=new AbortController();let _0x1f91d6={'Accept':_0x140660(0x11a)};if(this[_0x140660(0x10c)])_0x1f91d6[_0x140660(0x11d)]='Bearer\x20'+this[_0x140660(0x10c)];let _0x1e84fa=await fetch(_0xec7f36,{'headers':_0x1f91d6,'signal':this[_0x140660(0xce)]['signal']});if(!_0x1e84fa['ok']||!_0x1e84fa[_0x140660(0xf7)]){this[_0x140660(0xdf)]('SSE\x20failed:\x20'+_0x1e84fa[_0x140660(0xc5)]),await this[_0x140660(0x10e)](_0x20f615),_0x20f615=Math[_0x140660(0x104)](_0x20f615*1.5,0xea60);continue;}_0x20f615=this['reconnectDelay'];let _0x110cda=_0x1e84fa['body'][_0x140660(0x137)](),_0x38e757=new TextDecoder(),_0x50c4c5='';while(this[_0x140660(0xbc)]){let {done:_0xd65249,value:_0x48d4fd}=await _0x110cda['read']();if(_0xd65249)break;_0x50c4c5+=_0x38e757[_0x140660(0xe9)](_0x48d4fd,{'stream':!0x0});let _0x33ce16=_0x50c4c5[_0x140660(0xc0)]('\x0a');_0x50c4c5=_0x33ce16[_0x140660(0xc7)]()||'';for(let _0x40ace3 of _0x33ce16){if(!_0x40ace3[_0x140660(0xd1)](_0x140660(0x12d)))continue;try{let _0x5e978f=JSON['parse'](_0x40ace3[_0x140660(0x10f)](0x6));if(_0x5e978f[_0x140660(0xee)]===_0x140660(0x124)){this[_0x140660(0xdf)](_0x140660(0xf9)),this[_0x140660(0xcd)](_0x140660(0x124));continue;}if(_0x5e978f[_0x140660(0xee)]===_0x140660(0xcb)||_0x5e978f['type']==='new_message'||_0x5e978f[_0x140660(0xee)]===_0x140660(0x118))await this[_0x140660(0xe7)]();}catch{}}}}catch(_0x2ba21b){if(_0x2ba21b[_0x140660(0x11e)]===_0x140660(0xfc))break;this[_0x140660(0xcd)](_0x140660(0x111),_0x2ba21b),this['log'](_0x140660(0xc1)+_0x2ba21b['message']);}if(this[_0x140660(0xbc)])this[_0x140660(0xcd)](_0x140660(0xe6)),this[_0x140660(0xdf)](_0x140660(0x138)+_0x20f615/0x3e8+_0x140660(0xbf)),await this['sleep'](_0x20f615),_0x20f615=Math[_0x140660(0x104)](_0x20f615*1.5,0xea60);}}async['processInbox'](){const _0x2e9632=a0_0x2b4667;try{let _0x4a8a95=(await this['call'](_0x2e9632(0xd4),{'alias':this[_0x2e9632(0x131)],'limit':0xa}))?.['messages']||[];for(let _0x47c9c1 of _0x4a8a95)await this['call'](_0x2e9632(0x12f),{'alias':this[_0x2e9632(0x131)],'message_id':_0x47c9c1['id']}),this[_0x2e9632(0xdf)]('←\x20'+_0x47c9c1[_0x2e9632(0xf4)]+':\x20'+_0x47c9c1['content'][_0x2e9632(0x10f)](0x0,0x3c)),this['emit'](_0x2e9632(0xe0),_0x47c9c1),this[_0x2e9632(0xcd)](_0x2e9632(0x120),_0x47c9c1);}catch(_0x219806){this[_0x2e9632(0xdf)](_0x2e9632(0xe4)+_0x219806['message']);}}[a0_0x2b4667(0x10e)](_0x1c81a2){return new Promise(_0x1e572d=>setTimeout(_0x1e572d,_0x1c81a2));}}var F=$;export{F as default,$ as CommHub};function a0_0x54b6(){const _0x11ed58=['startsWith','toAlias','1892615QYgPWy','get_inbox','agent','task.ack','<unknown>','\x20network_id=','replace','12066372xTcWHd','connect','reconnectDelay','transport','heartbeatInterval','log','task','disconnect','78XFnEaW','heartbeat\x20failed:\x20','inbox\x20error:\x20','error_message','disconnected','processInbox','now','decode','json','<missing>','offline','task.send.start','type','CommHub\x20response\x20omitted\x20task_id','fromAlias','task.send.failed','[REDACTED]','completed','from_session','16457QoWVXx','\x20lifecycle=','body','url','SSE\x20connected','tools/call','message_id','AbortError','1404675WQgPAU','\x20duration_ms=','/mcp','\x20task_id=','reply','autoConnect','task.replied','min','missing_task_id','duration_ms','catch','toString','parse','task_id','task.started','token','send_failed','sleep','slice','content','error','send_message','send_rejected','to_alias','get_all_status','toTimeString','send','broadcast','sdk-','text/event-stream','4Umzxtc','networkId','Authorization','name','stringify','message','normal','from_alias','string','connected','heartbeatTimer','network_id','failed','<pending>','lifecycleTracking','1756376WUCfxS','POST','connectSSE','data:\x20','text','ack_inbox','2.0','alias','parentTaskId','\x20transport=','idle','call','send_reply','getReader','SSE\x20reconnecting\x20in\x20','unknown\x20error','\x20parent_task_id=',']\x20[commhub:','result','report_status','running','send_task','getAllStatus','s...','split','SSE\x20error:\x20','not_tracked','652280kbqGIm','803925sUnTkh','status','parent_task_id','pop','task.send.delivered','sdk','error_code','new_task','CommHub\x20rejected\x20task','emit','sseAbort','resumeId','\x20to='];a0_0x54b6=function(){return _0x11ed58;};return a0_0x54b6();}
@@ -0,0 +1,65 @@
1
+ export interface CodexHomeInheritedFile {
2
+ readonly name: string;
3
+ readonly mode: number;
4
+ /** Why a node needs it — printed when staged, so the action is legible. */
5
+ readonly because: string;
6
+ }
7
+ export declare const CODEX_HOME_INHERITED_FILES: readonly CodexHomeInheritedFile[];
8
+ export interface StatLike {
9
+ readonly mtimeMs: number;
10
+ }
11
+ export type StatFn = (path: string) => StatLike | null;
12
+ export interface CodexHomeStageStep {
13
+ readonly name: string;
14
+ readonly src: string;
15
+ readonly dst: string;
16
+ readonly mode: number;
17
+ readonly reason: "missing" | "host-newer";
18
+ readonly because: string;
19
+ }
20
+ /**
21
+ * What to copy from the host CODEX_HOME into the node's, right now.
22
+ *
23
+ * Pure: takes the stat function so the ordering rules are testable without a
24
+ * filesystem. A node file that is NEWER than the host's is left alone — codex
25
+ * refreshes its own copy in place, and clobbering it would throw away a fresher
26
+ * token than the one we hold.
27
+ */
28
+ export declare function codexHomeStagePlan(hostHome: string, nodeHome: string, stat: StatFn, join: (a: string, b: string) => string, files?: readonly CodexHomeInheritedFile[]): CodexHomeStageStep[];
29
+ export type CodexTuiBlocker = "sign-in" | "update-prompt" | "trust-prompt";
30
+ export type CodexTuiPaneState = CodexTuiBlocker | "not-painted" | "usable";
31
+ /**
32
+ * Classify the TUI, from two different reads of the same pane.
33
+ *
34
+ * They answer different questions and need different tmux flags — the same
35
+ * distinction `waitForTmuxPaneText` documents one screenful up:
36
+ *
37
+ * onScreen (capture-pane, no -S) → "is it sitting on a prompt right now"
38
+ * A prompt that was already answered stays in scrollback forever,
39
+ * so reading history here would report a fixed node as blocked.
40
+ *
41
+ * everSeen (capture-pane -S -N) → "did the TUI ever paint"
42
+ * The banner is printed once and scrolls away — an MCP error burst
43
+ * was enough to push it off screen in under a minute — so reading
44
+ * only the current screen here would report a working node as dead.
45
+ *
46
+ * 🔴 And "the pane has text" answers neither. An earlier version of this used
47
+ * "≥3 non-empty lines ⇒ ready" and passed a node parked on the sign-in page.
48
+ * Measured timeline for that start:
49
+ *
50
+ * t≈3s 22 non-empty lines ← launcher output, TUI not up yet
51
+ * t≈6s 0 non-empty lines ← codex clears the screen and takes over
52
+ * t≈9s 10 non-empty lines ← the sign-in page finally paints
53
+ *
54
+ * The rule fired at t≈3s, six seconds before the thing it was meant to catch
55
+ * existed.
56
+ */
57
+ export declare function codexTuiPaneState(onScreen: string, everSeen?: string): CodexTuiPaneState;
58
+ /**
59
+ * What the operator should read when a node came up but cannot work. Names the
60
+ * blocker AND where to look — a launcher that only says "not ready" sends
61
+ * someone hunting through three tmux sessions.
62
+ */
63
+ export declare function describeCodexTuiBlocker(blocker: CodexTuiBlocker, displayName: string, tuiSession: string): string;
64
+ /** The TUI never painted at all — a distinct failure from being blocked. */
65
+ export declare function describeCodexTuiNotPainted(displayName: string, tuiSession: string, waitedMs: number): string;
@@ -0,0 +1,125 @@
1
+ export interface CodexCopresenceProfileFields {
2
+ readonly runtime?: string;
3
+ readonly codexCopresence?: boolean;
4
+ readonly codexCopresenceFullAccess?: boolean;
5
+ readonly flags?: Record<string, unknown>;
6
+ /** Absolute project directory to launch the codex TUI in. Passed as
7
+ * `-C <dir>` to `codex resume`. Also cross-checked against hub-reported
8
+ * `session.project_dir` in Phase 4.3. */
9
+ readonly codexProjectDir?: string;
10
+ /** Which launch adapter to use in Phase 3.2. `"codex-standard"` = stock
11
+ * `codex app-server` + `codex resume`; `"codex-custom-wrapper"` = TMHR狗-class
12
+ * custom LLM API wrapper (hosted tool / compaction / image-output compat).
13
+ * Unknown / absent → Phase 0 fail-closed (unknown adapters must not fall
14
+ * through to a default that might not fit the node's real topology). */
15
+ readonly codexLaunchAdapter?: "codex-standard" | "codex-custom-wrapper";
16
+ /** Alias of the peer that will verify this node's identity in Phase 6.
17
+ * Peer MUST be (a) registered in the same network, (b) online at resume
18
+ * time, (c) not this node itself. Identity attestation uses a fresh
19
+ * Hub outbound `send_task` from THIS node's Bridge to <codexProbePeer>
20
+ * carrying a nonce; peer echoes the nonce back; CLI cross-checks Hub's
21
+ * recorded `from_name / from_node_id / to_name / to_node_id`.
22
+ *
23
+ * 🔴 self-loop is deliberately not accepted here — it cannot prove
24
+ * cross-node routing closure (design v7 Phase 6 = D, per TMHR
25
+ * 06cfb29a). Single-node users cannot run `anet node resume` in
26
+ * this initial cut; tracked at #1527. */
27
+ readonly codexProbePeer?: string;
28
+ }
29
+ /** #1521 — the three fields `anet node resume <alias>` will require on a
30
+ * codex-copresence node once the resume dispatcher lands (#1528, Draft).
31
+ * In this PR, only shape-level enumeration exists (see
32
+ * `missingCodexResumeFields` below); no CLI code reads that enumeration
33
+ * and the operator-facing remediation flow is deliberately deferred
34
+ * along with its real caller. */
35
+ export type CodexResumeRequiredField = "codexProjectDir" | "codexLaunchAdapter" | "codexProbePeer";
36
+ export declare const CODEX_RESUME_REQUIRED_FIELDS: readonly CodexResumeRequiredField[];
37
+ /** Enumerate which of the three resume-required fields are absent /
38
+ * wrong-shaped on this profile. Returns [] when all three are present
39
+ * and well-shaped.
40
+ *
41
+ * 🔴 SHAPE-ONLY validation:
42
+ * - codexProjectDir : string starting with `/`. This is a CHEAP typo
43
+ * filter, NOT the security gate. Phase 0 (in #1528) MUST additionally
44
+ * `realpath`/canonicalize + reject NUL, `/`, and any untrusted target
45
+ * before passing this value to `codex resume -C <dir>` (per TMHR
46
+ * 4bab8196: "startsWith('/') 不是最终安全门").
47
+ * - codexLaunchAdapter : enum membership.
48
+ * - codexProbePeer : Hub exact-alias lookup, so value MUST equal its own
49
+ * trim. Values with leading/trailing whitespace would fail Hub lookup
50
+ * 100% of the time; rejecting them at the shape layer is a witnessed-red
51
+ * canary rather than a permissive pass-through (per TMHR 048d0061 R2:
52
+ * "不要 pin 一个必然在 Hub exact lookup 阶段失败的 well-shaped 值").
53
+ * Liveness (registered + online + non-self) is a separate hub-side
54
+ * check in Phase 0.
55
+ *
56
+ * Deliberately NOT included: an operator-facing diagnostic helper. An
57
+ * earlier draft included `codexResumeMissingConfigHint` that referenced
58
+ * a `anet node config apply` verb which does not exist in the tree —
59
+ * TMHR 4bab8196 blocked it as the exact "存在 ≠ 会执行" antipattern.
60
+ * The diagnostic lands with its real caller in a later PR that either
61
+ * (a) implements `anet node config apply` first, or (b) reworks the
62
+ * diagnostic to reference existing commands only. */
63
+ export declare function missingCodexResumeFields(profile: CodexCopresenceProfileFields): CodexResumeRequiredField[];
64
+ export declare const CODEX_COPRESENCE_RUNTIME = "codex-app-server";
65
+ /**
66
+ * Should this `anet node start` bring up the co-presence stack?
67
+ *
68
+ * The flag still works for a one-off; the profile field is what makes the
69
+ * second start a single command.
70
+ */
71
+ export declare function codexCopresenceRequested(flagPassed: boolean, profile: CodexCopresenceProfileFields): boolean;
72
+ /**
73
+ * True when a plain `anet node start` just became enough for this node — i.e.
74
+ * the flag was passed and the profile had not recorded it yet. Callers persist
75
+ * `codexCopresence: true` and tell the user they can drop the flag.
76
+ */
77
+ export declare function shouldPersistCodexCopresence(flagPassed: boolean, profile: CodexCopresenceProfileFields): boolean;
78
+ export interface CodexCopresencePosture {
79
+ readonly sandboxMode: "danger-full-access" | "read-only";
80
+ readonly approvalPolicy: "never" | "on-request";
81
+ /** Set when the node asked for full access and is NOT getting it. */
82
+ readonly downgradeNotice?: string;
83
+ /** Set when a remembered grant (not this invocation's flag) opened it up. */
84
+ readonly grantedFromProfile: boolean;
85
+ }
86
+ /**
87
+ * Resolve the sandbox the co-presence app-server runs under.
88
+ *
89
+ * Precedence: this invocation's flag → a grant already recorded on the profile
90
+ * → read-only. `flags.sandboxMode` alone never opens the sandbox; it only
91
+ * decides whether staying closed is worth telling the user about.
92
+ */
93
+ export declare function codexCopresencePosture(dangerFlagPassed: boolean, profile: CodexCopresenceProfileFields, displayName?: string): CodexCopresencePosture;
94
+ /** True when an explicit grant should be written to the profile for next time. */
95
+ export declare function shouldPersistCodexFullAccess(dangerFlagPassed: boolean, profile: CodexCopresenceProfileFields): boolean;
96
+ /**
97
+ * What `anet node create --runtime codex-app-server` should record, so that a
98
+ * later `anet node start <name>` is a single command with no flag.
99
+ *
100
+ * Shape copied from opencode, which already does exactly this at create time:
101
+ *
102
+ * ...(runtime === "opencode-cli"
103
+ * ? { opencodeMode: opts.mode === "copresence" || opts.copresence === "true"
104
+ * ? "copresence" : "headless" }
105
+ * : {}),
106
+ *
107
+ * Deliberately NOT keyed on which alias the operator typed. `codex-tui`,
108
+ * `codex-appserver` and `codex-app-server` are documented as aliases of one
109
+ * runtime (agent-node/src/cli.ts); giving one of them a different default would
110
+ * quietly break that contract, and "I typed the short name" is not a reliable
111
+ * statement of intent. Opting in stays explicit, exactly as it is for opencode.
112
+ */
113
+ export declare function codexCopresenceCreateFields(normalizedRuntime: string | undefined, copresenceOpt: string | boolean | undefined): {
114
+ codexCopresence?: true;
115
+ };
116
+ /**
117
+ * One line at create time for a node that will start headless.
118
+ *
119
+ * NOT keyed on which alias the operator typed: by the time create builds the
120
+ * profile, `opts.runtime` has already been normalized to `codex-app-server`, so
121
+ * `codex-tui` is simply not recoverable here — a hint that tried to read it
122
+ * would never fire. (It didn't; that is how this was found.) Keying on the
123
+ * runtime instead also keeps the aliases true synonyms.
124
+ */
125
+ export declare function codexCopresenceCreateHint(normalizedRuntime: string | undefined, copresenceOpt: string | boolean | undefined, displayName: string): string | undefined;
@@ -0,0 +1,43 @@
1
+ export interface CodexRecoveryVerification {
2
+ method: "thread/start" | "thread/resume";
3
+ threadId: string;
4
+ verifiedAt: string;
5
+ historyTurnCount: number;
6
+ historyFingerprint: string;
7
+ }
8
+ export interface CodexRecoveryBackup {
9
+ backupDir: string;
10
+ createdAt: string;
11
+ stateFiles: string[];
12
+ }
13
+ /** Transaction boundary shared by Windows and POSIX cutovers: the snapshot
14
+ * cannot begin until every authoritative state writer has quiesced. */
15
+ export declare function quiesceThenSnapshot<T>(quiesce: () => Promise<void>, snapshot: () => T): Promise<T>;
16
+ /** A stored thread is never considered resumed until app-server reads the
17
+ * exact thread back with persisted history. This is deliberately stricter
18
+ * than accepting a successful thread/resume RPC response. */
19
+ export declare function verifyCodexThreadHistory(method: "thread/start" | "thread/resume", expectedThreadId: string, readResult: unknown, now?: Date): CodexRecoveryVerification;
20
+ export declare function resumeAndVerifyCodexThread(threadId: string, request: (method: string, params: Record<string, unknown>) => Promise<unknown>): Promise<CodexRecoveryVerification>;
21
+ /** Private, node-local recovery point. config-recovery.json is deliberately
22
+ * redacted non-credential audit/recovery metadata, not an identity backup.
23
+ * Identity recovery relies on leaving the original node config and CODEX_HOME
24
+ * in place. Credentials are never copied into this snapshot. */
25
+ export declare function backupCodexRecoveryState(opts: {
26
+ nodeDir: string;
27
+ codexHome: string;
28
+ now?: Date;
29
+ }): CodexRecoveryBackup;
30
+ export declare function codexTopologyAudit(profile: Record<string, any>, nodeDir: string, cwd: string): {
31
+ launchMode: string;
32
+ cwd: string;
33
+ codexHome: string;
34
+ remote: any;
35
+ threadId: any;
36
+ model: any;
37
+ flags: any;
38
+ lastRecoveryVerification: any;
39
+ lastRecoveryBackup: {
40
+ createdAt: any;
41
+ stateFiles: any;
42
+ } | null;
43
+ };
@@ -0,0 +1,13 @@
1
+ export type CopresenceThreadPlan = {
2
+ method: "thread/resume";
3
+ params: {
4
+ threadId: string;
5
+ };
6
+ bootstrap: false;
7
+ } | {
8
+ method: "thread/start";
9
+ params: Record<string, never>;
10
+ bootstrap: true;
11
+ };
12
+ /** Restarting a node must preserve its conversation; only a virgin node starts one. */
13
+ export declare function copresenceThreadPlan(storedThreadId?: string): CopresenceThreadPlan;
@@ -0,0 +1,6 @@
1
+ export declare const DEFAULT_CODEX_MODEL = "gpt-5.6-sol";
2
+ export declare const CODEX_MODEL_CHOICES: ReadonlyArray<{
3
+ readonly id: string;
4
+ readonly default?: boolean;
5
+ }>;
6
+ export declare function defaultCodexModelForRuntime(runtime: string): string | undefined;
@@ -0,0 +1,17 @@
1
+ export declare function bridgeClientHealthReceipt(remote: string, threadId: string): string;
2
+ export interface MigratedCodexPendingThread {
3
+ version: 1;
4
+ threadId: string;
5
+ serverUrl: string;
6
+ marker: string;
7
+ }
8
+ /**
9
+ * Move a crash-window deferred candidate onto the launcher's new owned
10
+ * app-server generation. The old URL is an authority supplied by the same
11
+ * private node config, not by the pending object itself; every mismatch is a
12
+ * hard stop so restart never guesses or adopts a second thread.
13
+ */
14
+ export declare function migrateCodexPendingThread(value: unknown, oldServerUrl: unknown, expectedOldMarker: unknown, newServerUrl: string, newMarker: string): MigratedCodexPendingThread;
15
+ export declare function requirePromotedCodexPendingThread(value: unknown, pendingThreadId: string): string;
16
+ export declare function codexTuiLaunchArgs(remote: string, model: string, threadId?: string, dangerFullAccess?: boolean): string[];
17
+ export declare function assertPendingServerQuiesced(serverUrl: unknown, isListening: (port: number) => boolean | Promise<boolean>): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function parseCommhubToolResult(json: any): any;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * #693 — token-bound node controlled local file → Hub /api/upload bridge.
3
+ *
4
+ * Security boundary (hard gates):
5
+ * 1. Cross-host: bytes travel over HTTP multipart; Hub never reads agent FS.
6
+ * 2. Identity: caller supplies the node's bearer token; ntok binds network.
7
+ * 3. Path safety: realpath + allowlisted roots; reject NUL, symlink, traversal.
8
+ * 4. Size ≤ 12 MiB enforced with same-fd fstat + bounded read (no full slurp).
9
+ * 5. Hub /api/upload is the sole write surface (atomic on hub side).
10
+ *
11
+ * Adversarial add-only (#694 DO-NOT-MERGE fixes):
12
+ * - TOCTOU: open O_NOFOLLOW → fstat(fd) → read(fd) only; no re-open by path.
13
+ * - Bounded read: never allocate/read past CONTROLLED_UPLOAD_MAX_BYTES.
14
+ * - NUL guard is live and reachable before any fs call.
15
+ */
16
+ /** Mirrors server/src/uploads.ts MAX_UPLOAD_BYTES. */
17
+ export declare const CONTROLLED_UPLOAD_MAX_BYTES: number;
18
+ /** Chunk size for bounded streaming read from a single fd. */
19
+ export declare const CONTROLLED_UPLOAD_READ_CHUNK: number;
20
+ export type ControlledUploadErrorCode = "path_required" | "path_nul" | "path_not_found" | "path_untrusted" | "path_symlink" | "path_not_regular" | "path_empty" | "payload_too_large" | "read_failed" | "auth_required" | "hub_url_required" | "upload_failed" | "bad_response" | "missing_file_id";
21
+ export type ControlledUploadFail = {
22
+ ok: false;
23
+ error: ControlledUploadErrorCode;
24
+ message: string;
25
+ };
26
+ export type ControlledUploadOk = {
27
+ ok: true;
28
+ file_id: string;
29
+ name: string;
30
+ mime: string;
31
+ size: number;
32
+ url?: string;
33
+ };
34
+ export type ControlledUploadResult = ControlledUploadOk | ControlledUploadFail;
35
+ export interface ControlledUploadDeps {
36
+ hubUrl: string;
37
+ authToken: string;
38
+ allowedRoots?: string[];
39
+ alias?: string;
40
+ nodeDir?: string;
41
+ fetch?: typeof fetch;
42
+ home?: string;
43
+ }
44
+ /** Normalize a client filename: basename only, strip controls, cap 255. */
45
+ export declare function normalizeUploadName(input: string | undefined | null, fallback?: string): string;
46
+ export declare function defaultControlledUploadRoots(opts?: {
47
+ home?: string;
48
+ alias?: string;
49
+ nodeDir?: string;
50
+ cwd?: string;
51
+ env?: NodeJS.ProcessEnv;
52
+ }): string[];
53
+ /** True iff canonicalPath is strictly inside one of the allowlisted roots. */
54
+ export declare function isPathInsideAllowedRoots(canonicalPath: string, allowedRoots: string[]): boolean;
55
+ /**
56
+ * Resolve a user-supplied path to a canonical path under an allowlisted root.
57
+ * Does not open the file for reading — open+fstat+read is a separate same-fd step.
58
+ */
59
+ export declare function resolveControlledUploadPath(rawPath: string, allowedRoots: string[]): {
60
+ ok: true;
61
+ canonicalPath: string;
62
+ } | ControlledUploadFail;
63
+ export type ControlledFileBytes = {
64
+ ok: true;
65
+ bytes: Buffer;
66
+ size: number;
67
+ canonicalPath: string;
68
+ } | ControlledUploadFail;
69
+ /**
70
+ * Open → fstat(fd) → bounded read(fd) on the **same fd** (TOCTOU hard gate).
71
+ * Uses O_NOFOLLOW when available so a symlink swap at open is rejected.
72
+ * Never uses path-based readFileSync after the initial open.
73
+ */
74
+ export declare function openFstatBoundedReadControlledFile(canonicalPath: string, allowedRoots: string[], maxBytes?: number): ControlledFileBytes;
75
+ /**
76
+ * Upload a controlled local file to Hub POST /api/upload.
77
+ * Returns file_id + metadata for send_reply attachments.
78
+ * Never falls back to sending a raw path to the Hub.
79
+ */
80
+ export declare function uploadControlledLocalFile(rawPath: string, deps: ControlledUploadDeps, opts?: {
81
+ name?: string;
82
+ mime?: string;
83
+ }): Promise<ControlledUploadResult>;
@@ -0,0 +1,22 @@
1
+ export interface CopresenceDep {
2
+ readonly name: string;
3
+ readonly present: boolean;
4
+ /** Exact command for this platform, or null when we cannot name one. */
5
+ readonly install: string | null;
6
+ readonly why: string;
7
+ }
8
+ export type CommandProbe = (cmd: string) => boolean;
9
+ /** Which agent binary this co-presence lane is built on. */
10
+ export type CopresenceAgent = "codex" | "grok";
11
+ export declare function copresenceDeps(probe: CommandProbe, platform?: NodeJS.Platform, agent?: CopresenceAgent): CopresenceDep[];
12
+ export declare function missingCopresenceDeps(probe: CommandProbe, platform?: NodeJS.Platform, agent?: CopresenceAgent): CopresenceDep[];
13
+ /** One block naming every gap and how to close it — never one gap at a time. */
14
+ export declare function describeMissingDeps(missing: readonly CopresenceDep[], displayName: string): string;
15
+ /**
16
+ * May we start this hub ourselves?
17
+ *
18
+ * Only a loopback hub. A remote URL that refuses the connection is somebody
19
+ * else's service — spawning a local one would silently point the node at a
20
+ * DIFFERENT hub than its profile names, which is worse than failing.
21
+ */
22
+ export declare function isLoopbackHub(hubUrl: string): boolean;