@sleep2agi/agent-network 2.3.0-preview.5 → 2.3.0-preview.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -324
- package/dist/bin/anet.cjs +101 -0
- package/dist/bin/cli.d.ts +1 -0
- package/dist/bin/cli.js +20 -1
- package/dist/bin/goal-wake-log-render.d.ts +31 -0
- package/dist/src/batch-workdir.d.ts +9 -0
- package/dist/src/bootstrap-password-db.d.ts +13 -0
- package/dist/src/channel-attachments.d.ts +29 -0
- package/dist/src/channel-meta.d.ts +10 -0
- package/dist/src/channel-task-trace.d.ts +10 -0
- package/dist/src/claude-vendor-env.d.ts +28 -0
- package/dist/src/cli-args.d.ts +8 -0
- package/dist/src/client-task-trace.d.ts +9 -0
- package/dist/src/client.js +1 -1
- package/dist/src/codex-copresence-preflight.d.ts +65 -0
- package/dist/src/codex-copresence-profile.d.ts +68 -0
- package/dist/src/codex-copresence-recovery.d.ts +43 -0
- package/dist/src/codex-copresence-thread.d.ts +13 -0
- package/dist/src/codex-model-default.d.ts +6 -0
- package/dist/src/codex-tui-client-health.d.ts +17 -0
- package/dist/src/commhub-response.d.ts +1 -0
- package/dist/src/controlled-upload.d.ts +83 -0
- package/dist/src/copresence-deps.d.ts +22 -0
- package/dist/src/copresence-identity.d.ts +339 -0
- package/dist/src/dashboard-managed-process.d.ts +35 -0
- package/dist/src/environ-alias.d.ts +14 -0
- package/dist/src/grok-attach-client.d.ts +129 -0
- package/dist/src/grok-copresence-disclosure.d.ts +11 -0
- package/dist/src/grok-copresence-orchestration.d.ts +70 -0
- package/dist/src/grok-copresence-profile.d.ts +65 -0
- package/dist/src/im/correlation-store.d.ts +34 -0
- package/dist/src/im/feishu/adapter.d.ts +149 -1
- package/dist/src/im/feishu/bridge.d.ts +85 -14
- package/dist/src/im/feishu/config.d.ts +31 -0
- package/dist/src/im/feishu/hub-upload.d.ts +88 -0
- package/dist/src/im/feishu/markdown-image-renderer.d.ts +61 -0
- package/dist/src/im/feishu/outbound-marker.d.ts +140 -0
- package/dist/src/im/feishu/outbound-paths.d.ts +50 -0
- package/dist/src/im/feishu/outbound-route.d.ts +62 -0
- package/dist/src/im/feishu/worker-lifecycle.d.ts +13 -0
- package/dist/src/im/feishu/worker.js +403 -27
- package/dist/src/im/types.d.ts +38 -1
- package/dist/src/locale-diagnostic.d.ts +12 -0
- package/dist/src/mock-llm.d.ts +12 -0
- package/dist/src/node-server-payload.d.ts +66 -0
- package/dist/src/node-server.js +7 -1
- package/dist/src/normalize-runtime.d.ts +14 -2
- package/dist/src/opencode-agent-node-pair.d.ts +25 -0
- package/dist/src/opencode-auth-login.d.ts +43 -0
- package/dist/src/opencode-launch-env.d.ts +13 -0
- package/dist/src/opencode-owner-mode.d.ts +6 -0
- package/dist/src/opencode-package-binary.d.ts +21 -0
- package/dist/src/opencode-pin.d.ts +44 -0
- package/dist/src/opencode-preset.d.ts +73 -0
- package/dist/src/opencode-runtime-binding.d.ts +30 -0
- package/dist/src/opencode-safe-root.d.ts +27 -0
- package/dist/src/opencode-smoke-env.d.ts +1 -0
- package/dist/src/outbound-tool-names.d.ts +1 -0
- package/dist/src/owner-env-file.d.ts +2 -0
- package/dist/src/package-mode-preflight.d.ts +31 -0
- package/dist/src/posix-codex-copresence.d.ts +8 -0
- package/dist/src/primary-network.d.ts +23 -0
- package/dist/src/private-state.d.ts +10 -0
- package/dist/src/project-key.d.ts +1 -0
- package/dist/src/secret-shell-guidance.d.ts +3 -0
- package/dist/src/task-trace.d.ts +33 -0
- package/dist/src/tmux-attach.d.ts +8 -0
- package/dist/src/tmux-capability.d.ts +58 -0
- package/dist/src/tmux-exact-target.d.ts +34 -0
- package/dist/src/tmux-pane-prompt.d.ts +22 -0
- package/dist/src/token-cli.d.ts +13 -0
- package/dist/src/unsafe-package-path-reason.d.ts +17 -0
- package/dist/src/windows-codex-copresence.d.ts +41 -0
- package/package.json +10 -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[];
|
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a0_0x55d81d=a0_0x4e98;(function(_0xbeb9b8,_0x4dc3fa){const _0x837b0=a0_0x4e98,_0x828840=_0xbeb9b8();while(!![]){try{const _0x1f4431=-parseInt(_0x837b0(0x201))/0x1*(-parseInt(_0x837b0(0x1e9))/0x2)+-parseInt(_0x837b0(0x1e0))/0x3*(-parseInt(_0x837b0(0x1b9))/0x4)+parseInt(_0x837b0(0x1bd))/0x5+-parseInt(_0x837b0(0x1fe))/0x6*(parseInt(_0x837b0(0x1fd))/0x7)+parseInt(_0x837b0(0x1f5))/0x8*(-parseInt(_0x837b0(0x1b8))/0x9)+parseInt(_0x837b0(0x20a))/0xa*(-parseInt(_0x837b0(0x1e4))/0xb)+parseInt(_0x837b0(0x1e2))/0xc;if(_0x1f4431===_0x4dc3fa)break;else _0x828840['push'](_0x828840['shift']());}catch(_0x5c26ca){_0x828840['push'](_0x828840['shift']());}}}(a0_0x562b,0xcdbde));import{EventEmitter as a0_0x180c4e}from'events';import{hostname as a0_0x46611e}from'os';function a0_0x4e98(_0x13fe77,_0x5d396f){_0x13fe77=_0x13fe77-0x1b6;const _0x562ba9=a0_0x562b();let _0x4e986c=_0x562ba9[_0x13fe77];return _0x4e986c;}function a0_0x562b(){const _0x13bec3=['min','type','98729dGOQPq','heartbeatTimer','SSE\x20connected','application/json','error','content','Bearer\x20','/mcp','log','4430810kQqtpR','send_reply','registered','task','abort','connect','ack_inbox','toString','agent','connected','completed','new_task','alias','send_message','running','1062081urYIvd','922252EWeFMj','SSE\x20error:\x20','sseAbort','get_inbox','8211425DdatKv','server','name','reply','new_message','Authorization','slice','send_task','report_status','sleep','signal','inbox\x20error:\x20','processInbox','messages','result','autoConnect',']\x20[commhub:','send','broadcast','from_session','reconnectDelay','sdk-','catch','call','POST','get_all_status','body','getAllStatus','resumeId','tools/call','sdk','SSE\x20failed:\x20','connectSSE','match','token','6TPINwo','status','644916nqizwo','getReader','11walScv','emit','pop','normal','disconnected','10pENkcK','idle','text/event-stream','url','text','message','heartbeat\x20failed:\x20','heartbeatInterval','toTimeString','read','parse','startsWith','24fmqLeb','data:\x20','split','/events/','now','stringify','replace','2.0','416283CHXBRR','102vJHbea'];a0_0x562b=function(){return _0x13bec3;};return a0_0x562b();}class T extends a0_0x180c4e{['url'];['alias'];[a0_0x55d81d(0x1df)];[a0_0x55d81d(0x212)];[a0_0x55d81d(0x1d9)];[a0_0x55d81d(0x1f0)];['reconnectDelay'];[a0_0x55d81d(0x202)];[a0_0x55d81d(0x1bb)];['running']=!0x1;constructor(_0x5b1133){const _0x5711f9=a0_0x55d81d;super();if(this[_0x5711f9(0x1ec)]=_0x5b1133[_0x5711f9(0x1ec)][_0x5711f9(0x1fb)](/\/$/,''),this[_0x5711f9(0x216)]=_0x5b1133[_0x5711f9(0x216)],this[_0x5711f9(0x1df)]=_0x5b1133[_0x5711f9(0x1df)],this[_0x5711f9(0x212)]=_0x5b1133[_0x5711f9(0x212)]||_0x5711f9(0x1db),this['resumeId']=_0x5711f9(0x1d2)+_0x5b1133[_0x5711f9(0x216)]+'-'+Date['now']()[_0x5711f9(0x211)](0x24),this[_0x5711f9(0x1f0)]=_0x5b1133[_0x5711f9(0x1f0)]??0x2bf20,this[_0x5711f9(0x1d1)]=_0x5b1133[_0x5711f9(0x1d1)]??0xbb8,_0x5b1133[_0x5711f9(0x1cc)]!==!0x1)this[_0x5711f9(0x20f)]();}[a0_0x55d81d(0x209)](_0x170760){const _0x4bc411=a0_0x55d81d;console[_0x4bc411(0x209)]('['+new Date()[_0x4bc411(0x1f1)]()[_0x4bc411(0x1c3)](0x0,0x8)+_0x4bc411(0x1cd)+this['alias']+']\x20'+_0x170760);}async[a0_0x55d81d(0x1d4)](_0x3ce539,_0x2993f){const _0x48d24d=a0_0x55d81d;let _0x9707de={'Content-Type':_0x48d24d(0x204),'Accept':'application/json,\x20text/event-stream'};if(this[_0x48d24d(0x1df)])_0x9707de[_0x48d24d(0x1c2)]=_0x48d24d(0x207)+this[_0x48d24d(0x1df)];let _0x4b08f0=await(await fetch(this[_0x48d24d(0x1ec)]+_0x48d24d(0x208),{'method':_0x48d24d(0x1d5),'headers':_0x9707de,'body':JSON[_0x48d24d(0x1fa)]({'jsonrpc':_0x48d24d(0x1fc),'id':Date[_0x48d24d(0x1f9)](),'method':_0x48d24d(0x1da),'params':{'name':_0x3ce539,'arguments':_0x2993f}})}))[_0x48d24d(0x1ed)](),_0x5280fa=_0x4b08f0[_0x48d24d(0x1de)](/data: (.+)/),_0x81d7c1=_0x5280fa?JSON[_0x48d24d(0x1f3)](_0x5280fa[0x1]):JSON[_0x48d24d(0x1f3)](_0x4b08f0),_0x1ffed4=_0x81d7c1?.[_0x48d24d(0x1cb)]?.[_0x48d24d(0x206)]?.[0x0]?.[_0x48d24d(0x1ed)];return _0x1ffed4?JSON['parse'](_0x1ffed4):_0x81d7c1;}async[a0_0x55d81d(0x20f)](){const _0x4d940f=a0_0x55d81d;if(this[_0x4d940f(0x1b7)])return;this[_0x4d940f(0x1b7)]=!0x0,await this[_0x4d940f(0x1e1)](_0x4d940f(0x1ea)),this[_0x4d940f(0x209)](_0x4d940f(0x20c)),this[_0x4d940f(0x202)]=setInterval(()=>{const _0x3bd91f=_0x4d940f;this['status']('idle')[_0x3bd91f(0x1d3)](_0x2419ce=>this[_0x3bd91f(0x209)](_0x3bd91f(0x1ef)+_0x2419ce['message']));},this[_0x4d940f(0x1f0)]),this[_0x4d940f(0x1dd)]();}async['disconnect'](){const _0x35f613=a0_0x55d81d;if(this[_0x35f613(0x1b7)]=!0x1,this['sseAbort']?.[_0x35f613(0x20e)](),this['heartbeatTimer'])clearInterval(this[_0x35f613(0x202)]);await this[_0x35f613(0x1e1)]('offline')['catch'](()=>{}),this[_0x35f613(0x209)](_0x35f613(0x1e8));}async[a0_0x55d81d(0x1ce)](_0x280819,_0x2e4661,_0x568659=a0_0x55d81d(0x1e7)){const _0xae56cb=a0_0x55d81d;return this[_0xae56cb(0x1d4)](_0xae56cb(0x1c4),{'alias':_0x280819,'task':_0x2e4661,'priority':_0x568659,'from_session':this['alias']});}async['message'](_0x6da5fe,_0x1125d1){const _0x40d758=a0_0x55d81d;return this[_0x40d758(0x1d4)](_0x40d758(0x1b6),{'alias':_0x6da5fe,'message':_0x1125d1,'from_session':this[_0x40d758(0x216)]});}async[a0_0x55d81d(0x1c0)](_0x179458,_0x558877,_0x40dc6d=a0_0x55d81d(0x214)){const _0x7c53f4=a0_0x55d81d;return this[_0x7c53f4(0x1d4)](_0x7c53f4(0x20b),{'in_reply_to':_0x179458,'text':_0x558877,'status':_0x40dc6d});}async['status'](_0x475e7d,_0x264586){const _0x1837fd=a0_0x55d81d;return this['call'](_0x1837fd(0x1c5),{'resume_id':this[_0x1837fd(0x1d9)],'alias':this[_0x1837fd(0x216)],'status':_0x475e7d,'server':a0_0x46611e(),'hostname':a0_0x46611e(),'agent':this[_0x1837fd(0x212)],'project_dir':process['cwd'](),..._0x264586});}async[a0_0x55d81d(0x1d8)](){const _0x420c96=a0_0x55d81d;return this['call'](_0x420c96(0x1d6),{});}async['broadcast'](_0x13643d,_0x2c7320){const _0x530b2c=a0_0x55d81d;return this[_0x530b2c(0x1d4)](_0x530b2c(0x1cf),{'message':_0x13643d,'filter_server':_0x2c7320?.[_0x530b2c(0x1be)],'filter_status':_0x2c7320?.[_0x530b2c(0x1e1)]});}async[a0_0x55d81d(0x1dd)](){const _0x3dc2ea=a0_0x55d81d;let _0x435bb4=encodeURIComponent(this[_0x3dc2ea(0x216)]),_0x5769ba=this['url']+_0x3dc2ea(0x1f8)+_0x435bb4,_0xdd7941=this[_0x3dc2ea(0x1d1)];while(this['running']){try{this[_0x3dc2ea(0x1bb)]=new AbortController();let _0x52e294={'Accept':_0x3dc2ea(0x1eb)};if(this['token'])_0x52e294['Authorization']='Bearer\x20'+this['token'];let _0x203788=await fetch(_0x5769ba,{'headers':_0x52e294,'signal':this[_0x3dc2ea(0x1bb)][_0x3dc2ea(0x1c7)]});if(!_0x203788['ok']||!_0x203788[_0x3dc2ea(0x1d7)]){this[_0x3dc2ea(0x209)](_0x3dc2ea(0x1dc)+_0x203788[_0x3dc2ea(0x1e1)]),await this[_0x3dc2ea(0x1c6)](_0xdd7941),_0xdd7941=Math['min'](_0xdd7941*1.5,0xea60);continue;}_0xdd7941=this[_0x3dc2ea(0x1d1)];let _0x295ef6=_0x203788[_0x3dc2ea(0x1d7)][_0x3dc2ea(0x1e3)](),_0x6f7893=new TextDecoder(),_0xa91ae1='';while(this['running']){let {done:_0x252d26,value:_0xba285}=await _0x295ef6[_0x3dc2ea(0x1f2)]();if(_0x252d26)break;_0xa91ae1+=_0x6f7893['decode'](_0xba285,{'stream':!0x0});let _0x4524f2=_0xa91ae1[_0x3dc2ea(0x1f7)]('\x0a');_0xa91ae1=_0x4524f2[_0x3dc2ea(0x1e6)]()||'';for(let _0x502b78 of _0x4524f2){if(!_0x502b78[_0x3dc2ea(0x1f4)](_0x3dc2ea(0x1f6)))continue;try{let _0x1594bb=JSON[_0x3dc2ea(0x1f3)](_0x502b78[_0x3dc2ea(0x1c3)](0x6));if(_0x1594bb[_0x3dc2ea(0x200)]==='connected'){this[_0x3dc2ea(0x209)](_0x3dc2ea(0x203)),this[_0x3dc2ea(0x1e5)](_0x3dc2ea(0x213));continue;}if(_0x1594bb[_0x3dc2ea(0x200)]===_0x3dc2ea(0x215)||_0x1594bb[_0x3dc2ea(0x200)]===_0x3dc2ea(0x1c1)||_0x1594bb['type']===_0x3dc2ea(0x1cf))await this[_0x3dc2ea(0x1c9)]();}catch{}}}}catch(_0xad562b){if(_0xad562b[_0x3dc2ea(0x1bf)]==='AbortError')break;this[_0x3dc2ea(0x1e5)](_0x3dc2ea(0x205),_0xad562b),this[_0x3dc2ea(0x209)](_0x3dc2ea(0x1ba)+_0xad562b['message']);}if(this[_0x3dc2ea(0x1b7)])this['emit'](_0x3dc2ea(0x1e8)),this[_0x3dc2ea(0x209)]('SSE\x20reconnecting\x20in\x20'+_0xdd7941/0x3e8+'s...'),await this[_0x3dc2ea(0x1c6)](_0xdd7941),_0xdd7941=Math[_0x3dc2ea(0x1ff)](_0xdd7941*1.5,0xea60);}}async[a0_0x55d81d(0x1c9)](){const _0x5c6ee0=a0_0x55d81d;try{let _0x28fd8e=(await this[_0x5c6ee0(0x1d4)](_0x5c6ee0(0x1bc),{'alias':this[_0x5c6ee0(0x216)],'limit':0xa}))?.[_0x5c6ee0(0x1ca)]||[];for(let _0x288a7f of _0x28fd8e)await this[_0x5c6ee0(0x1d4)](_0x5c6ee0(0x210),{'alias':this[_0x5c6ee0(0x216)],'message_id':_0x288a7f['id']}),this[_0x5c6ee0(0x209)]('←\x20'+_0x288a7f[_0x5c6ee0(0x1d0)]+':\x20'+_0x288a7f[_0x5c6ee0(0x206)][_0x5c6ee0(0x1c3)](0x0,0x3c)),this[_0x5c6ee0(0x1e5)](_0x5c6ee0(0x20d),_0x288a7f),this[_0x5c6ee0(0x1e5)](_0x5c6ee0(0x1ee),_0x288a7f);}catch(_0x29c5f4){this['log'](_0x5c6ee0(0x1c8)+_0x29c5f4[_0x5c6ee0(0x1ee)]);}}[a0_0x55d81d(0x1c6)](_0x31cb43){return new Promise(_0x55aba7=>setTimeout(_0x55aba7,_0x31cb43));}}var $=T;export{$ as default,T as CommHub};
|
|
1
|
+
const a0_0x2b779f=a0_0x4ece;(function(_0x33dff6,_0x800a3e){const _0x4cbabb=a0_0x4ece,_0x581bce=_0x33dff6();while(!![]){try{const _0x27f1ab=-parseInt(_0x4cbabb(0x21b))/0x1*(-parseInt(_0x4cbabb(0x254))/0x2)+parseInt(_0x4cbabb(0x1ff))/0x3*(parseInt(_0x4cbabb(0x1fc))/0x4)+parseInt(_0x4cbabb(0x242))/0x5*(parseInt(_0x4cbabb(0x1f4))/0x6)+parseInt(_0x4cbabb(0x25a))/0x7*(-parseInt(_0x4cbabb(0x1ea))/0x8)+parseInt(_0x4cbabb(0x20f))/0x9+-parseInt(_0x4cbabb(0x25c))/0xa*(parseInt(_0x4cbabb(0x24c))/0xb)+-parseInt(_0x4cbabb(0x23e))/0xc;if(_0x27f1ab===_0x800a3e)break;else _0x581bce['push'](_0x581bce['shift']());}catch(_0x525195){_0x581bce['push'](_0x581bce['shift']());}}}(a0_0x47b1,0xc4bf1));function a0_0x47b1(){const _0x5b081c=[']\x20[commhub:','signal','12459573wrQwkW','result','json','<missing>','string','message_id','fromAlias','failed','parse','agent','call','data:\x20','1zPjjgd','stringify','2.0','split','connectSSE','from_session','send_failed','broadcast','processInbox','\x20to=','error_code','heartbeatTimer','idle','get_all_status','task_id','toTimeString','resumeId','reply','emit','sdk','reconnectDelay','name','connected','completed','send','<unknown>','transport','url','body','heartbeatInterval','AbortError','content','message','SSE\x20reconnecting\x20in\x20','alias','30442920AsmCoO','application/json','sending','<pending>','851470dYXNFq','slice','sdk-','server','new_task','sseAbort','unknown\x20error','running','\x20from=','send_message','11bXZBjS','task','CommHub\x20response\x20omitted\x20task_id','normal','Bearer\x20','missing_task_id','task.send.start','\x20parent_task_id=','1455124AwkmyA','send_rejected','networkId','disconnected','Authorization','\x20transport=','2912pghnVo','sleep','664270TVAAWz','autoConnect','error_message','registered','task.send.failed','now','CommHub\x20rejected\x20task','status','\x20error=','not_tracked','tools/call','parent_task_id','startsWith','delivered','6776RelsAe','toAlias','duration_ms','read','\x20duration_ms=','cwd','min','\x20lifecycle=','disconnect','inbox\x20error:\x20','18YRCXLQ','getAllStatus','task.expired','application/json,\x20text/event-stream','connect','/mcp','error','text','628sCFUjC','task.started','SSE\x20failed:\x20','21759pofOfW','catch','to_alias','offline','task.replied','log','type','pop','s...','token','\x20task_id=','from_alias','parentTaskId','replace'];a0_0x47b1=function(){return _0x5b081c;};return a0_0x47b1();}import{EventEmitter as a0_0x181164}from'events';import{hostname as a0_0x2f50b2}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x57501c,_0xe54201)=>(_0x57501c??_0xe54201)[a0_0x2b779f(0x20c)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x490806){const _0xbf88f6=a0_0x2b779f;return(_0x490806 instanceof Error?_0x490806['message']:String(_0x490806??_0xbf88f6(0x248)))['replace'](K,'[REDACTED]')[_0xbf88f6(0x20c)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x2d2397,_0x3a60f7=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2b779f(0x211)){const _0x49bb4a=a0_0x2b779f;if(_0x3a60f7)return JSON[_0x49bb4a(0x21c)](_0x2d2397);let _0x4d0ec9=L(_0x2d2397[_0x49bb4a(0x1e7)],_0x49bb4a(0x212)),_0x241605=L(_0x2d2397[_0x49bb4a(0x229)],_0x49bb4a(0x241)),_0x3d170e=_0x2d2397['error_code']?_0x49bb4a(0x1e4)+_0x2d2397[_0x49bb4a(0x225)]+':'+(_0x2d2397[_0x49bb4a(0x25e)]??''):'';return'[commhub:task]\x20'+_0x2d2397[_0x49bb4a(0x1e3)]+_0x49bb4a(0x24a)+L(_0x2d2397[_0x49bb4a(0x20a)],'<unknown>')+_0x49bb4a(0x224)+L(_0x2d2397[_0x49bb4a(0x201)],_0x49bb4a(0x234))+_0x49bb4a(0x209)+_0x241605+_0x49bb4a(0x253)+_0x4d0ec9+'\x20network_id='+L(_0x2d2397['network_id'],_0x49bb4a(0x234))+_0x49bb4a(0x259)+_0x2d2397['transport']+_0x49bb4a(0x1ee)+_0x2d2397[_0x49bb4a(0x1ec)]+_0x49bb4a(0x1f1)+_0x2d2397['lifecycle_tracking']+_0x3d170e;}function U(_0x3d3213){const _0x14a1d2=a0_0x2b779f;return{'event':{'sending':_0x14a1d2(0x252),'delivered':'task.send.delivered','failed':_0x14a1d2(0x260),'acked':'task.ack','started':_0x14a1d2(0x1fd),'replied':_0x14a1d2(0x203),'expired':_0x14a1d2(0x1f6)}[_0x3d3213['status']],..._0x3d3213};}function j(_0x18fe2c){const _0x1c050d=a0_0x2b779f;let _0xa7f551=_0x18fe2c?.[_0x1c050d(0x229)]||_0x18fe2c?.[_0x1c050d(0x214)]||_0x18fe2c?.['id'];if(_0xa7f551)return String(_0xa7f551);let _0x246e0a=_0x18fe2c?.[_0x1c050d(0x23a)]?.[0x0]?.['text'];if(typeof _0x246e0a!==_0x1c050d(0x213))return null;try{let _0x477b19=JSON['parse'](_0x246e0a);return _0x477b19?.[_0x1c050d(0x229)]||_0x477b19?.[_0x1c050d(0x214)]||_0x477b19?.['id']||null;}catch{return null;}}async function X(_0x4964e9,_0x4c9477){const _0x5e5941=a0_0x2b779f;let _0x484139=_0x4c9477[_0x5e5941(0x261)]??Date[_0x5e5941(0x261)],_0x3a1d92=_0x484139(),_0x1d7be1=(_0x1fc045,_0x533a3c,_0x5d57d4,_0x4eb632)=>{const _0x21a1b0=_0x5e5941;_0x4c9477[_0x21a1b0(0x204)](O(U({'from_alias':_0x4964e9['fromAlias'],'to_alias':_0x4964e9[_0x21a1b0(0x1eb)],'task_id':_0x533a3c,'parent_task_id':_0x4964e9[_0x21a1b0(0x20b)],'network_id':_0x4964e9[_0x21a1b0(0x256)],'transport':_0x4964e9[_0x21a1b0(0x235)],'status':_0x1fc045,'duration_ms':_0x484139()-_0x3a1d92,'lifecycle_tracking':_0x4964e9['lifecycleTracking'],..._0x5d57d4!==void 0x0?{'error_code':_0x4eb632||_0x21a1b0(0x221),'error_message':N(_0x5d57d4)}:{}})));};_0x1d7be1(_0x5e5941(0x240),null);try{let _0x3b332a=await _0x4c9477[_0x5e5941(0x233)](),_0x4241c5=j(_0x3b332a);if(_0x4241c5)_0x1d7be1(_0x5e5941(0x1e9),_0x4241c5);else{if(_0x3b332a?.['ok']===!0x1||_0x3b332a?.[_0x5e5941(0x1fa)])_0x1d7be1('failed',_0x4241c5,_0x3b332a?.[_0x5e5941(0x1fa)]||_0x5e5941(0x1e2),_0x5e5941(0x255));else _0x1d7be1(_0x5e5941(0x216),null,_0x5e5941(0x24e),_0x5e5941(0x251));}return _0x3b332a;}catch(_0x37fafe){throw _0x1d7be1(_0x5e5941(0x216),null,_0x37fafe,_0x5e5941(0x221)),_0x37fafe;}}async function Y(_0x402726,_0x5f418d){const _0x4e70a0=a0_0x2b779f;return X({'fromAlias':_0x402726[_0x4e70a0(0x215)],'toAlias':_0x402726['alias'],'parentTaskId':_0x402726['parentTaskId']||null,'networkId':_0x402726['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0x4e70a0(0x1e5)},_0x5f418d);}class $ extends a0_0x181164{[a0_0x2b779f(0x236)];[a0_0x2b779f(0x23d)];[a0_0x2b779f(0x208)];[a0_0x2b779f(0x218)];[a0_0x2b779f(0x22b)];[a0_0x2b779f(0x238)];[a0_0x2b779f(0x22f)];[a0_0x2b779f(0x226)];['sseAbort'];[a0_0x2b779f(0x249)]=!0x1;constructor(_0x1c10e4){const _0x3c3c18=a0_0x2b779f;super();if(this['url']=_0x1c10e4[_0x3c3c18(0x236)]['replace'](/\/$/,''),this['alias']=_0x1c10e4[_0x3c3c18(0x23d)],this[_0x3c3c18(0x208)]=_0x1c10e4[_0x3c3c18(0x208)],this[_0x3c3c18(0x218)]=_0x1c10e4[_0x3c3c18(0x218)]||_0x3c3c18(0x22e),this[_0x3c3c18(0x22b)]=_0x3c3c18(0x244)+_0x1c10e4[_0x3c3c18(0x23d)]+'-'+Date[_0x3c3c18(0x261)]()['toString'](0x24),this[_0x3c3c18(0x238)]=_0x1c10e4[_0x3c3c18(0x238)]??0x2bf20,this[_0x3c3c18(0x22f)]=_0x1c10e4[_0x3c3c18(0x22f)]??0xbb8,_0x1c10e4[_0x3c3c18(0x25d)]!==!0x1)this[_0x3c3c18(0x1f8)]();}[a0_0x2b779f(0x204)](_0x26eeaa){const _0x416f61=a0_0x2b779f;console[_0x416f61(0x204)]('['+new Date()[_0x416f61(0x22a)]()[_0x416f61(0x243)](0x0,0x8)+_0x416f61(0x20d)+this['alias']+']\x20'+_0x26eeaa);}async[a0_0x2b779f(0x219)](_0x20c518,_0x55a6ea){const _0x23b090=a0_0x2b779f;let _0x103ab8={'Content-Type':_0x23b090(0x23f),'Accept':_0x23b090(0x1f7)};if(this[_0x23b090(0x208)])_0x103ab8[_0x23b090(0x258)]=_0x23b090(0x250)+this[_0x23b090(0x208)];let _0x301545=await(await fetch(this[_0x23b090(0x236)]+_0x23b090(0x1f9),{'method':'POST','headers':_0x103ab8,'body':JSON['stringify']({'jsonrpc':_0x23b090(0x21d),'id':Date[_0x23b090(0x261)](),'method':_0x23b090(0x1e6),'params':{'name':_0x20c518,'arguments':_0x55a6ea}})}))[_0x23b090(0x1fb)](),_0x544d3a=_0x301545['match'](/data: (.+)/),_0x3dd80f=_0x544d3a?JSON[_0x23b090(0x217)](_0x544d3a[0x1]):JSON[_0x23b090(0x217)](_0x301545),_0x59ea66=_0x3dd80f?.[_0x23b090(0x210)]?.[_0x23b090(0x23a)]?.[0x0]?.[_0x23b090(0x1fb)];return _0x59ea66?JSON[_0x23b090(0x217)](_0x59ea66):_0x3dd80f;}async['connect'](){const _0x5dd280=a0_0x2b779f;if(this[_0x5dd280(0x249)])return;this[_0x5dd280(0x249)]=!0x0,await this[_0x5dd280(0x1e3)]('idle'),this[_0x5dd280(0x204)](_0x5dd280(0x25f)),this[_0x5dd280(0x226)]=setInterval(()=>{const _0x3ec35a=_0x5dd280;this[_0x3ec35a(0x1e3)](_0x3ec35a(0x227))[_0x3ec35a(0x200)](_0x5d63f5=>this['log']('heartbeat\x20failed:\x20'+_0x5d63f5[_0x3ec35a(0x23b)]));},this[_0x5dd280(0x238)]),this[_0x5dd280(0x21f)]();}async[a0_0x2b779f(0x1f2)](){const _0x393368=a0_0x2b779f;if(this['running']=!0x1,this[_0x393368(0x247)]?.['abort'](),this[_0x393368(0x226)])clearInterval(this['heartbeatTimer']);await this[_0x393368(0x1e3)](_0x393368(0x202))[_0x393368(0x200)](()=>{}),this[_0x393368(0x204)]('disconnected');}async[a0_0x2b779f(0x233)](_0x3efe6d,_0x36f785,_0xa97aa8=a0_0x2b779f(0x24f)){const _0x372f1d=a0_0x2b779f;return Y({'alias':_0x3efe6d,'fromAlias':this[_0x372f1d(0x23d)]},{'log':_0x447162=>console[_0x372f1d(0x204)](_0x447162),'send':()=>this[_0x372f1d(0x219)]('send_task',{'alias':_0x3efe6d,'task':_0x36f785,'priority':_0xa97aa8,'from_session':this['alias']})});}async['message'](_0x4ccd32,_0x4aec71){const _0x4de587=a0_0x2b779f;return this['call'](_0x4de587(0x24b),{'alias':_0x4ccd32,'message':_0x4aec71,'from_session':this['alias']});}async[a0_0x2b779f(0x22c)](_0x21845b,_0xcfac8a,_0xdf6037=a0_0x2b779f(0x232)){return this['call']('send_reply',{'in_reply_to':_0x21845b,'text':_0xcfac8a,'status':_0xdf6037});}async[a0_0x2b779f(0x1e3)](_0x28c5b4,_0x23eb94){const _0x137cc0=a0_0x2b779f;return this['call']('report_status',{'resume_id':this[_0x137cc0(0x22b)],'alias':this['alias'],'status':_0x28c5b4,'server':a0_0x2f50b2(),'hostname':a0_0x2f50b2(),'agent':this[_0x137cc0(0x218)],'project_dir':process[_0x137cc0(0x1ef)](),..._0x23eb94});}async[a0_0x2b779f(0x1f5)](){const _0x329956=a0_0x2b779f;return this[_0x329956(0x219)](_0x329956(0x228),{});}async[a0_0x2b779f(0x222)](_0x5ac6f6,_0x45bb3b){const _0x1866a9=a0_0x2b779f;return this[_0x1866a9(0x219)](_0x1866a9(0x222),{'message':_0x5ac6f6,'filter_server':_0x45bb3b?.[_0x1866a9(0x245)],'filter_status':_0x45bb3b?.[_0x1866a9(0x1e3)]});}async['connectSSE'](){const _0x335cc6=a0_0x2b779f;let _0x5650bc=encodeURIComponent(this[_0x335cc6(0x23d)]),_0x5d7ea9=this[_0x335cc6(0x236)]+'/events/'+_0x5650bc,_0x487e7f=this[_0x335cc6(0x22f)];while(this[_0x335cc6(0x249)]){try{this[_0x335cc6(0x247)]=new AbortController();let _0x2dd40c={'Accept':'text/event-stream'};if(this[_0x335cc6(0x208)])_0x2dd40c[_0x335cc6(0x258)]=_0x335cc6(0x250)+this[_0x335cc6(0x208)];let _0x1734bb=await fetch(_0x5d7ea9,{'headers':_0x2dd40c,'signal':this[_0x335cc6(0x247)][_0x335cc6(0x20e)]});if(!_0x1734bb['ok']||!_0x1734bb[_0x335cc6(0x237)]){this[_0x335cc6(0x204)](_0x335cc6(0x1fe)+_0x1734bb[_0x335cc6(0x1e3)]),await this[_0x335cc6(0x25b)](_0x487e7f),_0x487e7f=Math[_0x335cc6(0x1f0)](_0x487e7f*1.5,0xea60);continue;}_0x487e7f=this[_0x335cc6(0x22f)];let _0x2e4811=_0x1734bb['body']['getReader'](),_0x21fbc2=new TextDecoder(),_0x5d3af1='';while(this[_0x335cc6(0x249)]){let {done:_0x57543c,value:_0x3d9a04}=await _0x2e4811[_0x335cc6(0x1ed)]();if(_0x57543c)break;_0x5d3af1+=_0x21fbc2['decode'](_0x3d9a04,{'stream':!0x0});let _0x3b2a13=_0x5d3af1[_0x335cc6(0x21e)]('\x0a');_0x5d3af1=_0x3b2a13[_0x335cc6(0x206)]()||'';for(let _0xcaf418 of _0x3b2a13){if(!_0xcaf418[_0x335cc6(0x1e8)](_0x335cc6(0x21a)))continue;try{let _0x2f6d13=JSON[_0x335cc6(0x217)](_0xcaf418[_0x335cc6(0x243)](0x6));if(_0x2f6d13[_0x335cc6(0x205)]===_0x335cc6(0x231)){this['log']('SSE\x20connected'),this[_0x335cc6(0x22d)](_0x335cc6(0x231));continue;}if(_0x2f6d13[_0x335cc6(0x205)]===_0x335cc6(0x246)||_0x2f6d13['type']==='new_message'||_0x2f6d13[_0x335cc6(0x205)]===_0x335cc6(0x222))await this['processInbox']();}catch{}}}}catch(_0x1472db){if(_0x1472db[_0x335cc6(0x230)]===_0x335cc6(0x239))break;this[_0x335cc6(0x22d)](_0x335cc6(0x1fa),_0x1472db),this[_0x335cc6(0x204)]('SSE\x20error:\x20'+_0x1472db['message']);}if(this[_0x335cc6(0x249)])this[_0x335cc6(0x22d)](_0x335cc6(0x257)),this[_0x335cc6(0x204)](_0x335cc6(0x23c)+_0x487e7f/0x3e8+_0x335cc6(0x207)),await this[_0x335cc6(0x25b)](_0x487e7f),_0x487e7f=Math[_0x335cc6(0x1f0)](_0x487e7f*1.5,0xea60);}}async[a0_0x2b779f(0x223)](){const _0x2fe3af=a0_0x2b779f;try{let _0x2c7599=(await this[_0x2fe3af(0x219)]('get_inbox',{'alias':this[_0x2fe3af(0x23d)],'limit':0xa}))?.['messages']||[];for(let _0xf5885c of _0x2c7599)await this[_0x2fe3af(0x219)]('ack_inbox',{'alias':this[_0x2fe3af(0x23d)],'message_id':_0xf5885c['id']}),this['log']('←\x20'+_0xf5885c[_0x2fe3af(0x220)]+':\x20'+_0xf5885c[_0x2fe3af(0x23a)]['slice'](0x0,0x3c)),this[_0x2fe3af(0x22d)](_0x2fe3af(0x24d),_0xf5885c),this['emit'](_0x2fe3af(0x23b),_0xf5885c);}catch(_0x4a0df7){this[_0x2fe3af(0x204)](_0x2fe3af(0x1f3)+_0x4a0df7['message']);}}[a0_0x2b779f(0x25b)](_0x1f7c9a){return new Promise(_0x1f3dff=>setTimeout(_0x1f3dff,_0x1f7c9a));}}function a0_0x4ece(_0x3c6a4a,_0x43f008){_0x3c6a4a=_0x3c6a4a-0x1e2;const _0x47b182=a0_0x47b1();let _0x4ece34=_0x47b182[_0x3c6a4a];return _0x4ece34;}var F=$;export{F as default,$ as CommHub};
|
|
@@ -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,68 @@
|
|
|
1
|
+
export interface CodexCopresenceProfileFields {
|
|
2
|
+
readonly runtime?: string;
|
|
3
|
+
readonly codexCopresence?: boolean;
|
|
4
|
+
readonly codexCopresenceFullAccess?: boolean;
|
|
5
|
+
readonly flags?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export declare const CODEX_COPRESENCE_RUNTIME = "codex-app-server";
|
|
8
|
+
/**
|
|
9
|
+
* Should this `anet node start` bring up the co-presence stack?
|
|
10
|
+
*
|
|
11
|
+
* The flag still works for a one-off; the profile field is what makes the
|
|
12
|
+
* second start a single command.
|
|
13
|
+
*/
|
|
14
|
+
export declare function codexCopresenceRequested(flagPassed: boolean, profile: CodexCopresenceProfileFields): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* True when a plain `anet node start` just became enough for this node — i.e.
|
|
17
|
+
* the flag was passed and the profile had not recorded it yet. Callers persist
|
|
18
|
+
* `codexCopresence: true` and tell the user they can drop the flag.
|
|
19
|
+
*/
|
|
20
|
+
export declare function shouldPersistCodexCopresence(flagPassed: boolean, profile: CodexCopresenceProfileFields): boolean;
|
|
21
|
+
export interface CodexCopresencePosture {
|
|
22
|
+
readonly sandboxMode: "danger-full-access" | "read-only";
|
|
23
|
+
readonly approvalPolicy: "never" | "on-request";
|
|
24
|
+
/** Set when the node asked for full access and is NOT getting it. */
|
|
25
|
+
readonly downgradeNotice?: string;
|
|
26
|
+
/** Set when a remembered grant (not this invocation's flag) opened it up. */
|
|
27
|
+
readonly grantedFromProfile: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Resolve the sandbox the co-presence app-server runs under.
|
|
31
|
+
*
|
|
32
|
+
* Precedence: this invocation's flag → a grant already recorded on the profile
|
|
33
|
+
* → read-only. `flags.sandboxMode` alone never opens the sandbox; it only
|
|
34
|
+
* decides whether staying closed is worth telling the user about.
|
|
35
|
+
*/
|
|
36
|
+
export declare function codexCopresencePosture(dangerFlagPassed: boolean, profile: CodexCopresenceProfileFields, displayName?: string): CodexCopresencePosture;
|
|
37
|
+
/** True when an explicit grant should be written to the profile for next time. */
|
|
38
|
+
export declare function shouldPersistCodexFullAccess(dangerFlagPassed: boolean, profile: CodexCopresenceProfileFields): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* What `anet node create --runtime codex-app-server` should record, so that a
|
|
41
|
+
* later `anet node start <name>` is a single command with no flag.
|
|
42
|
+
*
|
|
43
|
+
* Shape copied from opencode, which already does exactly this at create time:
|
|
44
|
+
*
|
|
45
|
+
* ...(runtime === "opencode-cli"
|
|
46
|
+
* ? { opencodeMode: opts.mode === "copresence" || opts.copresence === "true"
|
|
47
|
+
* ? "copresence" : "headless" }
|
|
48
|
+
* : {}),
|
|
49
|
+
*
|
|
50
|
+
* Deliberately NOT keyed on which alias the operator typed. `codex-tui`,
|
|
51
|
+
* `codex-appserver` and `codex-app-server` are documented as aliases of one
|
|
52
|
+
* runtime (agent-node/src/cli.ts); giving one of them a different default would
|
|
53
|
+
* quietly break that contract, and "I typed the short name" is not a reliable
|
|
54
|
+
* statement of intent. Opting in stays explicit, exactly as it is for opencode.
|
|
55
|
+
*/
|
|
56
|
+
export declare function codexCopresenceCreateFields(normalizedRuntime: string | undefined, copresenceOpt: string | boolean | undefined): {
|
|
57
|
+
codexCopresence?: true;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* One line at create time for a node that will start headless.
|
|
61
|
+
*
|
|
62
|
+
* NOT keyed on which alias the operator typed: by the time create builds the
|
|
63
|
+
* profile, `opts.runtime` has already been normalized to `codex-app-server`, so
|
|
64
|
+
* `codex-tui` is simply not recoverable here — a hint that tried to read it
|
|
65
|
+
* would never fire. (It didn't; that is how this was found.) Keying on the
|
|
66
|
+
* runtime instead also keeps the aliases true synonyms.
|
|
67
|
+
*/
|
|
68
|
+
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,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;
|