@sleep2agi/agent-network 2.3.0-preview.6 → 2.3.0-preview.61
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 -28
- 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-activity-log.d.ts +4 -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 +29 -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/reply-originator.d.ts +20 -0
- package/dist/src/resume-runtime-infer.d.ts +18 -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
|
-
function a0_0x4787(){const _0xc49f0=['connect','normal','autoConnect','getReader','resumeId','emit','toString','sdk','disconnected','result','get_all_status','token','5087173NCbOmp','inbox\x20error:\x20','report_status','11665LrFOiw','connectSSE','message','log','AbortError','SSE\x20reconnecting\x20in\x20','from_session','application/json,\x20text/event-stream','messages','now','slice','min','content','signal','connected','cwd','decode','6982710isOHgq','url','new_task','getAllStatus','text','3606sAtYsO','type','running','catch','toTimeString','27873XqlSYg','alias','replace','text/event-stream','abort','call','broadcast','send_task','sdk-','status','completed','3JfxsGH','POST','new_message','1544pwkTLR','tools/call','SSE\x20failed:\x20','send_reply','idle','reply','heartbeatTimer','s...','heartbeatInterval','application/json','task','Bearer\x20','693624aRuhkw','offline','startsWith','name','get_inbox','server','reconnectDelay','267133AQpkhs','ack_inbox','parse','body','1519210AfjkqA','processInbox','SSE\x20connected','sseAbort','/mcp','2.0','match','agent','/events/','sleep'];a0_0x4787=function(){return _0xc49f0;};return a0_0x4787();}const a0_0x326ef2=a0_0x1d92;(function(_0x2d9f93,_0x55e142){const _0x4352d2=a0_0x1d92,_0x46163d=_0x2d9f93();while(!![]){try{const _0x9c32c4=-parseInt(_0x4352d2(0x1ce))/0x1+parseInt(_0x4352d2(0x1d2))/0x2+-parseInt(_0x4352d2(0x1b8))/0x3*(parseInt(_0x4352d2(0x1c7))/0x4)+-parseInt(_0x4352d2(0x1eb))/0x5*(-parseInt(_0x4352d2(0x1a8))/0x6)+-parseInt(_0x4352d2(0x1e8))/0x7+parseInt(_0x4352d2(0x1bb))/0x8*(parseInt(_0x4352d2(0x1ad))/0x9)+-parseInt(_0x4352d2(0x1a3))/0xa;if(_0x9c32c4===_0x55e142)break;else _0x46163d['push'](_0x46163d['shift']());}catch(_0x87a9d4){_0x46163d['push'](_0x46163d['shift']());}}}(a0_0x4787,0xda3d6));import{EventEmitter as a0_0x9a4b33}from'events';function a0_0x1d92(_0x589de0,_0x7570f1){_0x589de0=_0x589de0-0x195;const _0x4787e6=a0_0x4787();let _0x1d926f=_0x4787e6[_0x589de0];return _0x1d926f;}import{hostname as a0_0x3440fe}from'os';class T extends a0_0x9a4b33{[a0_0x326ef2(0x1a4)];['alias'];[a0_0x326ef2(0x1e7)];['agent'];[a0_0x326ef2(0x1e0)];['heartbeatInterval'];[a0_0x326ef2(0x1cd)];[a0_0x326ef2(0x1c1)];[a0_0x326ef2(0x1d5)];[a0_0x326ef2(0x1aa)]=!0x1;constructor(_0x27d2ee){const _0x2b74ed=a0_0x326ef2;super();if(this[_0x2b74ed(0x1a4)]=_0x27d2ee[_0x2b74ed(0x1a4)][_0x2b74ed(0x1af)](/\/$/,''),this[_0x2b74ed(0x1ae)]=_0x27d2ee[_0x2b74ed(0x1ae)],this['token']=_0x27d2ee[_0x2b74ed(0x1e7)],this[_0x2b74ed(0x1d9)]=_0x27d2ee[_0x2b74ed(0x1d9)]||_0x2b74ed(0x1e3),this[_0x2b74ed(0x1e0)]=_0x2b74ed(0x1b5)+_0x27d2ee[_0x2b74ed(0x1ae)]+'-'+Date[_0x2b74ed(0x19b)]()[_0x2b74ed(0x1e2)](0x24),this[_0x2b74ed(0x1c3)]=_0x27d2ee[_0x2b74ed(0x1c3)]??0x2bf20,this[_0x2b74ed(0x1cd)]=_0x27d2ee['reconnectDelay']??0xbb8,_0x27d2ee[_0x2b74ed(0x1de)]!==!0x1)this[_0x2b74ed(0x1dc)]();}['log'](_0x553859){const _0x5a30db=a0_0x326ef2;console['log']('['+new Date()[_0x5a30db(0x1ac)]()[_0x5a30db(0x19c)](0x0,0x8)+']\x20[commhub:'+this['alias']+']\x20'+_0x553859);}async[a0_0x326ef2(0x1b2)](_0xd1a490,_0x48238b){const _0x8c93f1=a0_0x326ef2;let _0x5074b0={'Content-Type':_0x8c93f1(0x1c4),'Accept':_0x8c93f1(0x199)};if(this[_0x8c93f1(0x1e7)])_0x5074b0['Authorization']=_0x8c93f1(0x1c6)+this[_0x8c93f1(0x1e7)];let _0x504a96=await(await fetch(this[_0x8c93f1(0x1a4)]+_0x8c93f1(0x1d6),{'method':_0x8c93f1(0x1b9),'headers':_0x5074b0,'body':JSON['stringify']({'jsonrpc':_0x8c93f1(0x1d7),'id':Date[_0x8c93f1(0x19b)](),'method':_0x8c93f1(0x1bc),'params':{'name':_0xd1a490,'arguments':_0x48238b}})}))[_0x8c93f1(0x1a7)](),_0x150935=_0x504a96[_0x8c93f1(0x1d8)](/data: (.+)/),_0x4be016=_0x150935?JSON[_0x8c93f1(0x1d0)](_0x150935[0x1]):JSON['parse'](_0x504a96),_0x28a021=_0x4be016?.[_0x8c93f1(0x1e5)]?.['content']?.[0x0]?.['text'];return _0x28a021?JSON[_0x8c93f1(0x1d0)](_0x28a021):_0x4be016;}async[a0_0x326ef2(0x1dc)](){const _0x2cb871=a0_0x326ef2;if(this[_0x2cb871(0x1aa)])return;this[_0x2cb871(0x1aa)]=!0x0,await this['status'](_0x2cb871(0x1bf)),this[_0x2cb871(0x195)]('registered'),this[_0x2cb871(0x1c1)]=setInterval(()=>{const _0x430408=_0x2cb871;this[_0x430408(0x1b6)](_0x430408(0x1bf))[_0x430408(0x1ab)](_0x321f90=>this[_0x430408(0x195)]('heartbeat\x20failed:\x20'+_0x321f90[_0x430408(0x1ed)]));},this[_0x2cb871(0x1c3)]),this[_0x2cb871(0x1ec)]();}async['disconnect'](){const _0x4338ba=a0_0x326ef2;if(this['running']=!0x1,this[_0x4338ba(0x1d5)]?.[_0x4338ba(0x1b1)](),this[_0x4338ba(0x1c1)])clearInterval(this[_0x4338ba(0x1c1)]);await this[_0x4338ba(0x1b6)](_0x4338ba(0x1c8))[_0x4338ba(0x1ab)](()=>{}),this[_0x4338ba(0x195)]('disconnected');}async['send'](_0x5b1ecc,_0x641df2,_0x303ada=a0_0x326ef2(0x1dd)){const _0x393393=a0_0x326ef2;return this[_0x393393(0x1b2)](_0x393393(0x1b4),{'alias':_0x5b1ecc,'task':_0x641df2,'priority':_0x303ada,'from_session':this[_0x393393(0x1ae)]});}async[a0_0x326ef2(0x1ed)](_0x3fea6c,_0x1636f5){const _0x10430c=a0_0x326ef2;return this[_0x10430c(0x1b2)]('send_message',{'alias':_0x3fea6c,'message':_0x1636f5,'from_session':this[_0x10430c(0x1ae)]});}async[a0_0x326ef2(0x1c0)](_0x4ba4b3,_0x3a3281,_0x467043=a0_0x326ef2(0x1b7)){const _0x3706a8=a0_0x326ef2;return this[_0x3706a8(0x1b2)](_0x3706a8(0x1be),{'in_reply_to':_0x4ba4b3,'text':_0x3a3281,'status':_0x467043});}async['status'](_0x1814b2,_0x14f949){const _0x450020=a0_0x326ef2;return this[_0x450020(0x1b2)](_0x450020(0x1ea),{'resume_id':this[_0x450020(0x1e0)],'alias':this['alias'],'status':_0x1814b2,'server':a0_0x3440fe(),'hostname':a0_0x3440fe(),'agent':this['agent'],'project_dir':process[_0x450020(0x1a1)](),..._0x14f949});}async[a0_0x326ef2(0x1a6)](){const _0x254179=a0_0x326ef2;return this['call'](_0x254179(0x1e6),{});}async[a0_0x326ef2(0x1b3)](_0x3010a6,_0x1a36d3){const _0x214d2c=a0_0x326ef2;return this[_0x214d2c(0x1b2)](_0x214d2c(0x1b3),{'message':_0x3010a6,'filter_server':_0x1a36d3?.[_0x214d2c(0x1cc)],'filter_status':_0x1a36d3?.[_0x214d2c(0x1b6)]});}async[a0_0x326ef2(0x1ec)](){const _0x1a0fde=a0_0x326ef2;let _0x5b4d94=encodeURIComponent(this['alias']),_0x1e94a5=this[_0x1a0fde(0x1a4)]+_0x1a0fde(0x1da)+_0x5b4d94,_0x459bbb=this['reconnectDelay'];while(this[_0x1a0fde(0x1aa)]){try{this['sseAbort']=new AbortController();let _0x37d4c5={'Accept':_0x1a0fde(0x1b0)};if(this[_0x1a0fde(0x1e7)])_0x37d4c5['Authorization']=_0x1a0fde(0x1c6)+this['token'];let _0x535b5e=await fetch(_0x1e94a5,{'headers':_0x37d4c5,'signal':this[_0x1a0fde(0x1d5)][_0x1a0fde(0x19f)]});if(!_0x535b5e['ok']||!_0x535b5e[_0x1a0fde(0x1d1)]){this[_0x1a0fde(0x195)](_0x1a0fde(0x1bd)+_0x535b5e[_0x1a0fde(0x1b6)]),await this['sleep'](_0x459bbb),_0x459bbb=Math['min'](_0x459bbb*1.5,0xea60);continue;}_0x459bbb=this[_0x1a0fde(0x1cd)];let _0x51d767=_0x535b5e[_0x1a0fde(0x1d1)][_0x1a0fde(0x1df)](),_0x3c31e1=new TextDecoder(),_0x442bf4='';while(this[_0x1a0fde(0x1aa)]){let {done:_0x4cce5c,value:_0x31f076}=await _0x51d767['read']();if(_0x4cce5c)break;_0x442bf4+=_0x3c31e1[_0x1a0fde(0x1a2)](_0x31f076,{'stream':!0x0});let _0x17f025=_0x442bf4['split']('\x0a');_0x442bf4=_0x17f025['pop']()||'';for(let _0x2b251d of _0x17f025){if(!_0x2b251d[_0x1a0fde(0x1c9)]('data:\x20'))continue;try{let _0x23afbd=JSON[_0x1a0fde(0x1d0)](_0x2b251d[_0x1a0fde(0x19c)](0x6));if(_0x23afbd['type']===_0x1a0fde(0x1a0)){this[_0x1a0fde(0x195)](_0x1a0fde(0x1d4)),this[_0x1a0fde(0x1e1)]('connected');continue;}if(_0x23afbd['type']===_0x1a0fde(0x1a5)||_0x23afbd[_0x1a0fde(0x1a9)]===_0x1a0fde(0x1ba)||_0x23afbd[_0x1a0fde(0x1a9)]==='broadcast')await this[_0x1a0fde(0x1d3)]();}catch{}}}}catch(_0x4ba1f7){if(_0x4ba1f7[_0x1a0fde(0x1ca)]===_0x1a0fde(0x196))break;this[_0x1a0fde(0x1e1)]('error',_0x4ba1f7),this[_0x1a0fde(0x195)]('SSE\x20error:\x20'+_0x4ba1f7[_0x1a0fde(0x1ed)]);}if(this[_0x1a0fde(0x1aa)])this[_0x1a0fde(0x1e1)](_0x1a0fde(0x1e4)),this['log'](_0x1a0fde(0x197)+_0x459bbb/0x3e8+_0x1a0fde(0x1c2)),await this[_0x1a0fde(0x1db)](_0x459bbb),_0x459bbb=Math[_0x1a0fde(0x19d)](_0x459bbb*1.5,0xea60);}}async['processInbox'](){const _0x3ed557=a0_0x326ef2;try{let _0x4d28a0=(await this[_0x3ed557(0x1b2)](_0x3ed557(0x1cb),{'alias':this[_0x3ed557(0x1ae)],'limit':0xa}))?.[_0x3ed557(0x19a)]||[];for(let _0x3d91c7 of _0x4d28a0)await this[_0x3ed557(0x1b2)](_0x3ed557(0x1cf),{'alias':this['alias'],'message_id':_0x3d91c7['id']}),this[_0x3ed557(0x195)]('←\x20'+_0x3d91c7[_0x3ed557(0x198)]+':\x20'+_0x3d91c7[_0x3ed557(0x19e)][_0x3ed557(0x19c)](0x0,0x3c)),this[_0x3ed557(0x1e1)](_0x3ed557(0x1c5),_0x3d91c7),this[_0x3ed557(0x1e1)](_0x3ed557(0x1ed),_0x3d91c7);}catch(_0x4ee1c5){this[_0x3ed557(0x195)](_0x3ed557(0x1e9)+_0x4ee1c5[_0x3ed557(0x1ed)]);}}[a0_0x326ef2(0x1db)](_0x40caed){return new Promise(_0x5e6710=>setTimeout(_0x5e6710,_0x40caed));}}var $=T;export{$ as default,T as CommHub};
|
|
1
|
+
const a0_0x8fd1a4=a0_0x45e1;(function(_0x2f5736,_0xdccac7){const _0x2b656c=a0_0x45e1,_0x372ef1=_0x2f5736();while(!![]){try{const _0x4908ae=parseInt(_0x2b656c(0x110))/0x1+parseInt(_0x2b656c(0x140))/0x2+-parseInt(_0x2b656c(0x102))/0x3+-parseInt(_0x2b656c(0x111))/0x4*(-parseInt(_0x2b656c(0x152))/0x5)+parseInt(_0x2b656c(0x13a))/0x6*(-parseInt(_0x2b656c(0x161))/0x7)+parseInt(_0x2b656c(0x133))/0x8+parseInt(_0x2b656c(0x168))/0x9*(-parseInt(_0x2b656c(0x15f))/0xa);if(_0x4908ae===_0xdccac7)break;else _0x372ef1['push'](_0x372ef1['shift']());}catch(_0x35d864){_0x372ef1['push'](_0x372ef1['shift']());}}}(a0_0x1527,0x868e8));import{EventEmitter as a0_0x524018}from'events';import{hostname as a0_0x6a640d}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x350399,_0x39b4b0)=>(_0x350399??_0x39b4b0)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x8fd1a4(0x124)](0x0,0xf0);function N(_0x56d985){const _0x152dfa=a0_0x8fd1a4;return(_0x56d985 instanceof Error?_0x56d985['message']:String(_0x56d985??_0x152dfa(0x147)))['replace'](K,_0x152dfa(0x130))[_0x152dfa(0xf9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function a0_0x45e1(_0x33692b,_0x1e6f62){_0x33692b=_0x33692b-0xf0;const _0x152716=a0_0x1527();let _0x45e1b1=_0x152716[_0x33692b];return _0x45e1b1;}function O(_0x55263c,_0x4f77f5=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x56fbbb=a0_0x8fd1a4;if(_0x4f77f5)return JSON[_0x56fbbb(0xf3)](_0x55263c);let _0x11632d=L(_0x55263c[_0x56fbbb(0x141)],_0x56fbbb(0x114)),_0x57ceea=L(_0x55263c[_0x56fbbb(0x158)],_0x56fbbb(0x16c)),_0x1d24d0=_0x55263c[_0x56fbbb(0x126)]?'\x20error='+_0x55263c['error_code']+':'+(_0x55263c['error_message']??''):'';return _0x56fbbb(0x148)+_0x55263c['status']+'\x20from='+L(_0x55263c[_0x56fbbb(0x139)],_0x56fbbb(0x132))+_0x56fbbb(0xf4)+L(_0x55263c[_0x56fbbb(0x101)],_0x56fbbb(0x132))+_0x56fbbb(0x149)+_0x57ceea+_0x56fbbb(0xf0)+_0x11632d+_0x56fbbb(0x125)+L(_0x55263c['network_id'],_0x56fbbb(0x132))+_0x56fbbb(0x105)+_0x55263c[_0x56fbbb(0x153)]+_0x56fbbb(0x142)+_0x55263c[_0x56fbbb(0xfc)]+_0x56fbbb(0x12b)+_0x55263c[_0x56fbbb(0x103)]+_0x1d24d0;}function U(_0x1a5911){const _0x218321=a0_0x8fd1a4;return{'event':{'sending':_0x218321(0x15d),'delivered':_0x218321(0xfa),'failed':_0x218321(0x163),'acked':_0x218321(0x104),'started':_0x218321(0x10f),'replied':_0x218321(0x121),'expired':_0x218321(0x11d)}[_0x1a5911[_0x218321(0x157)]],..._0x1a5911};}function j(_0x5b95ab){const _0x4d61e4=a0_0x8fd1a4;let _0x37d096=_0x5b95ab?.[_0x4d61e4(0x158)]||_0x5b95ab?.['message_id']||_0x5b95ab?.['id'];if(_0x37d096)return String(_0x37d096);let _0x3531e1=_0x5b95ab?.[_0x4d61e4(0x11a)]?.[0x0]?.[_0x4d61e4(0x144)];if(typeof _0x3531e1!==_0x4d61e4(0x11f))return null;try{let _0x7c5aab=JSON[_0x4d61e4(0x137)](_0x3531e1);return _0x7c5aab?.[_0x4d61e4(0x158)]||_0x7c5aab?.['message_id']||_0x7c5aab?.['id']||null;}catch{return null;}}async function X(_0x5f5422,_0x54a195){const _0x8fd422=a0_0x8fd1a4;let _0x32e191=_0x54a195[_0x8fd422(0x117)]??Date[_0x8fd422(0x117)],_0x563352=_0x32e191(),_0x3ff01f=(_0x15fc14,_0x1a2ac4,_0x44c42f,_0x18a7a9)=>{const _0x5ef59e=_0x8fd422;_0x54a195[_0x5ef59e(0x123)](O(U({'from_alias':_0x5f5422[_0x5ef59e(0x12f)],'to_alias':_0x5f5422[_0x5ef59e(0x15b)],'task_id':_0x1a2ac4,'parent_task_id':_0x5f5422[_0x5ef59e(0x13c)],'network_id':_0x5f5422[_0x5ef59e(0xfe)],'transport':_0x5f5422[_0x5ef59e(0x153)],'status':_0x15fc14,'duration_ms':_0x32e191()-_0x563352,'lifecycle_tracking':_0x5f5422['lifecycleTracking'],..._0x44c42f!==void 0x0?{'error_code':_0x18a7a9||_0x5ef59e(0x118),'error_message':N(_0x44c42f)}:{}})));};_0x3ff01f(_0x8fd422(0x112),null);try{let _0x60e230=await _0x54a195[_0x8fd422(0x14e)](),_0x136d88=j(_0x60e230);if(_0x136d88)_0x3ff01f('delivered',_0x136d88);else{if(_0x60e230?.['ok']===!0x1||_0x60e230?.[_0x8fd422(0x12c)])_0x3ff01f(_0x8fd422(0xf1),_0x136d88,_0x60e230?.['error']||_0x8fd422(0x134),_0x8fd422(0xf7));else _0x3ff01f(_0x8fd422(0xf1),null,'CommHub\x20response\x20omitted\x20task_id',_0x8fd422(0x169));}return _0x60e230;}catch(_0x178da9){throw _0x3ff01f(_0x8fd422(0xf1),null,_0x178da9,'send_failed'),_0x178da9;}}async function Y(_0x3514d7,_0x44cf02){const _0x32e7f8=a0_0x8fd1a4;return X({'fromAlias':_0x3514d7[_0x32e7f8(0x12f)],'toAlias':_0x3514d7[_0x32e7f8(0xff)],'parentTaskId':_0x3514d7[_0x32e7f8(0x13c)]||null,'networkId':_0x3514d7[_0x32e7f8(0xfe)]||null,'transport':_0x32e7f8(0x16d),'lifecycleTracking':'not_tracked'},_0x44cf02);}class $ extends a0_0x524018{[a0_0x8fd1a4(0x135)];['alias'];[a0_0x8fd1a4(0x167)];[a0_0x8fd1a4(0x10b)];['resumeId'];[a0_0x8fd1a4(0x11c)];['reconnectDelay'];[a0_0x8fd1a4(0xf8)];['sseAbort'];[a0_0x8fd1a4(0x164)]=!0x1;constructor(_0x3b6cbd){const _0x930e2d=a0_0x8fd1a4;super();if(this[_0x930e2d(0x135)]=_0x3b6cbd[_0x930e2d(0x135)][_0x930e2d(0xf9)](/\/$/,''),this['alias']=_0x3b6cbd[_0x930e2d(0xff)],this[_0x930e2d(0x167)]=_0x3b6cbd['token'],this[_0x930e2d(0x10b)]=_0x3b6cbd[_0x930e2d(0x10b)]||'sdk',this[_0x930e2d(0x129)]=_0x930e2d(0x131)+_0x3b6cbd[_0x930e2d(0xff)]+'-'+Date[_0x930e2d(0x117)]()[_0x930e2d(0x14a)](0x24),this[_0x930e2d(0x11c)]=_0x3b6cbd[_0x930e2d(0x11c)]??0x2bf20,this[_0x930e2d(0x165)]=_0x3b6cbd[_0x930e2d(0x165)]??0xbb8,_0x3b6cbd[_0x930e2d(0x162)]!==!0x1)this[_0x930e2d(0x10c)]();}['log'](_0x1c7064){const _0x5a99da=a0_0x8fd1a4;console[_0x5a99da(0x123)]('['+new Date()[_0x5a99da(0x13f)]()[_0x5a99da(0x124)](0x0,0x8)+_0x5a99da(0x109)+this[_0x5a99da(0xff)]+']\x20'+_0x1c7064);}async['call'](_0x522dc9,_0x1dedb2){const _0xd62c3c=a0_0x8fd1a4;let _0x39bb2a={'Content-Type':_0xd62c3c(0x10e),'Accept':'application/json,\x20text/event-stream'};if(this[_0xd62c3c(0x167)])_0x39bb2a[_0xd62c3c(0x11e)]=_0xd62c3c(0x14f)+this[_0xd62c3c(0x167)];let _0x1fe390=await(await fetch(this['url']+_0xd62c3c(0x108),{'method':_0xd62c3c(0xf5),'headers':_0x39bb2a,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date[_0xd62c3c(0x117)](),'method':_0xd62c3c(0x11b),'params':{'name':_0x522dc9,'arguments':_0x1dedb2}})}))['text'](),_0x819515=_0x1fe390[_0xd62c3c(0x145)](/data: (.+)/),_0x4646fb=_0x819515?JSON[_0xd62c3c(0x137)](_0x819515[0x1]):JSON[_0xd62c3c(0x137)](_0x1fe390),_0x496ae5=_0x4646fb?.['result']?.[_0xd62c3c(0x11a)]?.[0x0]?.[_0xd62c3c(0x144)];return _0x496ae5?JSON[_0xd62c3c(0x137)](_0x496ae5):_0x4646fb;}async[a0_0x8fd1a4(0x10c)](){const _0x53a6b8=a0_0x8fd1a4;if(this['running'])return;this[_0x53a6b8(0x164)]=!0x0,await this[_0x53a6b8(0x157)](_0x53a6b8(0x150)),this['log'](_0x53a6b8(0x136)),this[_0x53a6b8(0xf8)]=setInterval(()=>{const _0x3eb51f=_0x53a6b8;this[_0x3eb51f(0x157)]('idle')[_0x3eb51f(0x146)](_0x53d5f8=>this[_0x3eb51f(0x123)]('heartbeat\x20failed:\x20'+_0x53d5f8[_0x3eb51f(0x16a)]));},this[_0x53a6b8(0x11c)]),this[_0x53a6b8(0x156)]();}async[a0_0x8fd1a4(0x115)](){const _0x4a3ec0=a0_0x8fd1a4;if(this[_0x4a3ec0(0x164)]=!0x1,this[_0x4a3ec0(0x15c)]?.[_0x4a3ec0(0xfd)](),this['heartbeatTimer'])clearInterval(this[_0x4a3ec0(0xf8)]);await this['status'](_0x4a3ec0(0x107))[_0x4a3ec0(0x146)](()=>{}),this[_0x4a3ec0(0x123)](_0x4a3ec0(0x120));}async[a0_0x8fd1a4(0x14e)](_0x2c7a5d,_0x2c9121,_0x254879=a0_0x8fd1a4(0x10d)){const _0x4633b3=a0_0x8fd1a4;return Y({'alias':_0x2c7a5d,'fromAlias':this[_0x4633b3(0xff)]},{'log':_0x338cd6=>console[_0x4633b3(0x123)](_0x338cd6),'send':()=>this[_0x4633b3(0x116)](_0x4633b3(0x16b),{'alias':_0x2c7a5d,'task':_0x2c9121,'priority':_0x254879,'from_session':this[_0x4633b3(0xff)]})});}async[a0_0x8fd1a4(0x16a)](_0x4b09a5,_0x931840){const _0x374718=a0_0x8fd1a4;return this[_0x374718(0x116)](_0x374718(0x13d),{'alias':_0x4b09a5,'message':_0x931840,'from_session':this['alias']});}async[a0_0x8fd1a4(0x10a)](_0x44cd9d,_0x32028b,_0x292f14='completed'){const _0xfffd16=a0_0x8fd1a4;return this[_0xfffd16(0x116)](_0xfffd16(0xf2),{'in_reply_to':_0x44cd9d,'text':_0x32028b,'status':_0x292f14});}async[a0_0x8fd1a4(0x157)](_0x208bd8,_0x5cc4e2){const _0x7f5f7=a0_0x8fd1a4;return this[_0x7f5f7(0x116)](_0x7f5f7(0x119),{'resume_id':this[_0x7f5f7(0x129)],'alias':this[_0x7f5f7(0xff)],'status':_0x208bd8,'server':a0_0x6a640d(),'hostname':a0_0x6a640d(),'agent':this[_0x7f5f7(0x10b)],'project_dir':process['cwd'](),..._0x5cc4e2});}async['getAllStatus'](){const _0x3473ff=a0_0x8fd1a4;return this[_0x3473ff(0x116)]('get_all_status',{});}async['broadcast'](_0x2472ee,_0x16900d){const _0x2f2cf=a0_0x8fd1a4;return this[_0x2f2cf(0x116)]('broadcast',{'message':_0x2472ee,'filter_server':_0x16900d?.['server'],'filter_status':_0x16900d?.[_0x2f2cf(0x157)]});}async['connectSSE'](){const _0x3e8d62=a0_0x8fd1a4;let _0x4ee461=encodeURIComponent(this[_0x3e8d62(0xff)]),_0x4903c0=this['url']+_0x3e8d62(0x138)+_0x4ee461,_0x10b2a5=this['reconnectDelay'];while(this['running']){try{this['sseAbort']=new AbortController();let _0x25ae34={'Accept':_0x3e8d62(0x13b)};if(this[_0x3e8d62(0x167)])_0x25ae34['Authorization']='Bearer\x20'+this[_0x3e8d62(0x167)];let _0x5538de=await fetch(_0x4903c0,{'headers':_0x25ae34,'signal':this[_0x3e8d62(0x15c)][_0x3e8d62(0x12d)]});if(!_0x5538de['ok']||!_0x5538de[_0x3e8d62(0x13e)]){this['log']('SSE\x20failed:\x20'+_0x5538de[_0x3e8d62(0x157)]),await this[_0x3e8d62(0x100)](_0x10b2a5),_0x10b2a5=Math[_0x3e8d62(0x166)](_0x10b2a5*1.5,0xea60);continue;}_0x10b2a5=this[_0x3e8d62(0x165)];let _0x4ea403=_0x5538de[_0x3e8d62(0x13e)][_0x3e8d62(0x160)](),_0x2491ab=new TextDecoder(),_0x16d5b0='';while(this['running']){let {done:_0x18052e,value:_0x535023}=await _0x4ea403[_0x3e8d62(0x14c)]();if(_0x18052e)break;_0x16d5b0+=_0x2491ab['decode'](_0x535023,{'stream':!0x0});let _0x2a14b6=_0x16d5b0[_0x3e8d62(0x15e)]('\x0a');_0x16d5b0=_0x2a14b6[_0x3e8d62(0x143)]()||'';for(let _0x5a23fb of _0x2a14b6){if(!_0x5a23fb[_0x3e8d62(0x14b)](_0x3e8d62(0x122)))continue;try{let _0x2a21dc=JSON['parse'](_0x5a23fb[_0x3e8d62(0x124)](0x6));if(_0x2a21dc['type']===_0x3e8d62(0x127)){this[_0x3e8d62(0x123)](_0x3e8d62(0x155)),this['emit'](_0x3e8d62(0x127));continue;}if(_0x2a21dc[_0x3e8d62(0x12e)]==='new_task'||_0x2a21dc[_0x3e8d62(0x12e)]===_0x3e8d62(0x128)||_0x2a21dc[_0x3e8d62(0x12e)]==='broadcast')await this[_0x3e8d62(0x12a)]();}catch{}}}}catch(_0x51c1f6){if(_0x51c1f6[_0x3e8d62(0x106)]==='AbortError')break;this[_0x3e8d62(0x151)](_0x3e8d62(0x12c),_0x51c1f6),this[_0x3e8d62(0x123)](_0x3e8d62(0x159)+_0x51c1f6[_0x3e8d62(0x16a)]);}if(this[_0x3e8d62(0x164)])this[_0x3e8d62(0x151)](_0x3e8d62(0x120)),this[_0x3e8d62(0x123)](_0x3e8d62(0x154)+_0x10b2a5/0x3e8+_0x3e8d62(0xf6)),await this[_0x3e8d62(0x100)](_0x10b2a5),_0x10b2a5=Math[_0x3e8d62(0x166)](_0x10b2a5*1.5,0xea60);}}async['processInbox'](){const _0x5be5e3=a0_0x8fd1a4;try{let _0x40a4a9=(await this[_0x5be5e3(0x116)](_0x5be5e3(0x113),{'alias':this[_0x5be5e3(0xff)],'limit':0xa}))?.[_0x5be5e3(0xfb)]||[];for(let _0x66e67c of _0x40a4a9)await this[_0x5be5e3(0x116)]('ack_inbox',{'alias':this[_0x5be5e3(0xff)],'message_id':_0x66e67c['id']}),this[_0x5be5e3(0x123)]('←\x20'+_0x66e67c[_0x5be5e3(0x14d)]+':\x20'+_0x66e67c[_0x5be5e3(0x11a)]['slice'](0x0,0x3c)),this[_0x5be5e3(0x151)](_0x5be5e3(0x15a),_0x66e67c),this[_0x5be5e3(0x151)]('message',_0x66e67c);}catch(_0x269bb7){this[_0x5be5e3(0x123)]('inbox\x20error:\x20'+_0x269bb7['message']);}}[a0_0x8fd1a4(0x100)](_0x1316e3){return new Promise(_0x553b84=>setTimeout(_0x553b84,_0x1316e3));}}var F=$;export{F as default,$ as CommHub};function a0_0x1527(){const _0x20185e=['task_id','SSE\x20error:\x20','task','toAlias','sseAbort','task.send.start','split','2870SKiNIi','getReader','3288229UZcICW','autoConnect','task.send.failed','running','reconnectDelay','min','token','19071KSSlTX','missing_task_id','message','send_task','<pending>','mcp_http','\x20parent_task_id=','failed','send_reply','stringify','\x20to=','POST','s...','send_rejected','heartbeatTimer','replace','task.send.delivered','messages','duration_ms','abort','networkId','alias','sleep','to_alias','27753yytbVt','lifecycle_tracking','task.ack','\x20transport=','name','offline','/mcp',']\x20[commhub:','reply','agent','connect','normal','application/json','task.started','1087433KktLNA','180gZyMyY','sending','get_inbox','<missing>','disconnect','call','now','send_failed','report_status','content','tools/call','heartbeatInterval','task.expired','Authorization','string','disconnected','task.replied','data:\x20','log','slice','\x20network_id=','error_code','connected','new_message','resumeId','processInbox','\x20lifecycle=','error','signal','type','fromAlias','[REDACTED]','sdk-','<unknown>','1038872dAKRGv','CommHub\x20rejected\x20task','url','registered','parse','/events/','from_alias','12MSnFsB','text/event-stream','parentTaskId','send_message','body','toTimeString','297670EbqfHe','parent_task_id','\x20duration_ms=','pop','text','match','catch','unknown\x20error','[commhub:task]\x20','\x20task_id=','toString','startsWith','read','from_session','send','Bearer\x20','idle','emit','82435hZUHbL','transport','SSE\x20reconnecting\x20in\x20','SSE\x20connected','connectSSE','status'];a0_0x1527=function(){return _0x20185e;};return a0_0x1527();}
|
|
@@ -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;
|