@sleep2agi/agent-network 2.3.0-preview.22 → 2.3.0-preview.220
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/build-info.json +7 -0
- package/dist/bin/anet.cjs +101 -0
- package/dist/bin/cli.d.ts +1 -1
- package/dist/bin/cli.js +20 -1
- package/dist/src/active-network-task.d.ts +28 -0
- package/dist/src/batch-workdir.d.ts +9 -0
- package/dist/src/bootstrap-password-db.d.ts +13 -0
- package/dist/src/build-info.d.ts +26 -0
- package/dist/src/channel-attachments.d.ts +29 -0
- package/dist/src/channel-inbox-wake.d.ts +21 -0
- package/dist/src/channel-meta.d.ts +10 -0
- package/dist/src/channel-peer-reply.d.ts +41 -0
- package/dist/src/channel-task-trace.d.ts +14 -0
- package/dist/src/claude-vendor-env.d.ts +28 -0
- package/dist/src/cli-args.d.ts +8 -0
- package/dist/src/cli-auth-session.d.ts +47 -0
- package/dist/src/cli-errors.d.ts +41 -0
- package/dist/src/cli-exit.d.ts +11 -0
- package/dist/src/cli-help.d.ts +10 -0
- package/dist/src/cli-version-display.d.ts +16 -0
- package/dist/src/client-task-trace.d.ts +9 -0
- package/dist/src/client.js +1 -1
- package/dist/src/codex-adopt.d.ts +46 -0
- package/dist/src/codex-auth-fingerprint.d.ts +211 -0
- package/dist/src/codex-bin-pin.d.ts +23 -0
- package/dist/src/codex-commhub-mcp.d.ts +22 -0
- package/dist/src/codex-copresence-bridge-log.d.ts +44 -0
- package/dist/src/codex-copresence-env.d.ts +5 -0
- package/dist/src/codex-copresence-login-gate.d.ts +18 -0
- package/dist/src/codex-copresence-model.d.ts +23 -0
- package/dist/src/codex-copresence-preflight.d.ts +78 -0
- package/dist/src/codex-copresence-profile.d.ts +126 -0
- package/dist/src/codex-copresence-recovery.d.ts +70 -0
- package/dist/src/codex-copresence-resume-timeout.d.ts +28 -0
- package/dist/src/codex-copresence-rollout-guard.d.ts +36 -0
- package/dist/src/codex-copresence-rpc.d.ts +17 -0
- package/dist/src/codex-copresence-thread.d.ts +13 -0
- package/dist/src/codex-copresence-yolo.d.ts +16 -0
- package/dist/src/codex-external-appserver.d.ts +130 -0
- package/dist/src/codex-fork-recovery.d.ts +52 -0
- package/dist/src/codex-home-enforce.d.ts +88 -0
- package/dist/src/codex-lifecycle-account.d.ts +104 -0
- package/dist/src/codex-lifecycle-canary.d.ts +20 -0
- package/dist/src/codex-lifecycle-facts.d.ts +53 -0
- package/dist/src/codex-lifecycle-fork.d.ts +91 -0
- package/dist/src/codex-lifecycle-preflight.d.ts +79 -0
- package/dist/src/codex-lifecycle-receipt.d.ts +53 -0
- package/dist/src/codex-lifecycle-restart.d.ts +88 -0
- package/dist/src/codex-login-share-guard.d.ts +146 -0
- package/dist/src/codex-menu.d.ts +99 -0
- package/dist/src/codex-model-default.d.ts +6 -0
- package/dist/src/codex-node-login.d.ts +98 -0
- package/dist/src/codex-pending-thread-restart.d.ts +69 -0
- package/dist/src/codex-reasoning-effort.d.ts +17 -0
- package/dist/src/codex-recovery-lease.d.ts +39 -0
- package/dist/src/codex-recovery-resource-gate.d.ts +15 -0
- package/dist/src/codex-resume.d.ts +89 -0
- package/dist/src/codex-rollout-history-guard.d.ts +84 -0
- package/dist/src/codex-tui-client-health.d.ts +30 -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 +363 -0
- package/dist/src/copresence-startup-diagnosis.d.ts +17 -0
- package/dist/src/daemon-adopt.d.ts +14 -0
- package/dist/src/daemon-anet-bin.d.ts +32 -0
- package/dist/src/daemon-capability-display.d.ts +110 -0
- package/dist/src/daemon-capability-display.js +21 -0
- package/dist/src/daemon-codex-inventory.d.ts +65 -0
- package/dist/src/daemon-inherited-env.d.ts +9 -0
- package/dist/src/daemon-provider-account-custody.d.ts +28 -0
- package/dist/src/daemon-provider-account-readback.d.ts +3 -0
- package/dist/src/daemon-provider-application.d.ts +36 -0
- package/dist/src/daemon-provider-apply-command.d.ts +9 -0
- package/dist/src/daemon-provider-collect.d.ts +29 -0
- package/dist/src/daemon-provider-command.d.ts +7 -0
- package/dist/src/daemon-provider-initialize.d.ts +27 -0
- package/dist/src/daemon-provider-lifecycle.d.ts +4 -0
- package/dist/src/daemon-provider-store.d.ts +104 -0
- package/dist/src/daemon-runtime-path-preflight.d.ts +22 -0
- package/dist/src/daemon-runtime-staleness.d.ts +13 -0
- package/dist/src/dashboard-managed-process.d.ts +35 -0
- package/dist/src/display-width.d.ts +27 -0
- package/dist/src/doctor-node-count.d.ts +28 -0
- package/dist/src/grok-attach-client.d.ts +129 -0
- package/dist/src/grok-build-drift.d.ts +15 -0
- package/dist/src/grok-copresence-disclosure.d.ts +11 -0
- package/dist/src/grok-copresence-orchestration.d.ts +75 -0
- package/dist/src/grok-copresence-profile.d.ts +65 -0
- package/dist/src/grok-create-mode.d.ts +19 -0
- package/dist/src/host-telemetry.d.ts +14 -0
- package/dist/src/hub-health-timeout.d.ts +4 -0
- package/dist/src/hub-server-version.d.ts +64 -0
- package/dist/src/hub-stop.d.ts +74 -0
- package/dist/src/hub-time-display.d.ts +20 -0
- package/dist/src/hub-version-skew.d.ts +19 -0
- package/dist/src/im/correlation-store.d.ts +34 -0
- package/dist/src/im/feishu/adapter.d.ts +47 -0
- package/dist/src/im/feishu/bridge.d.ts +72 -14
- package/dist/src/im/feishu/chat-context.d.ts +44 -0
- package/dist/src/im/feishu/config.d.ts +15 -1
- package/dist/src/im/feishu/hub-upload.d.ts +1 -1
- package/dist/src/im/feishu/queue-notice.d.ts +2 -0
- package/dist/src/im/feishu/worker-lifecycle.d.ts +13 -0
- package/dist/src/im/feishu/worker.js +171 -154
- package/dist/src/inbox-drain.d.ts +20 -0
- package/dist/src/local-process-state.d.ts +12 -0
- package/dist/src/locale-diagnostic.d.ts +12 -0
- package/dist/src/login-client-label.d.ts +6 -0
- package/dist/src/ls-columns.d.ts +15 -0
- package/dist/src/mock-llm.d.ts +12 -0
- package/dist/src/node-activity-log.d.ts +4 -0
- package/dist/src/node-clone.d.ts +134 -0
- package/dist/src/node-delete-hub.d.ts +42 -0
- package/dist/src/node-files.d.ts +62 -0
- package/dist/src/node-locate.d.ts +60 -0
- package/dist/src/node-ls-all.d.ts +80 -0
- package/dist/src/node-menu.d.ts +40 -0
- package/dist/src/node-not-found.d.ts +1 -0
- package/dist/src/node-remote.d.ts +180 -0
- package/dist/src/node-running-guard.d.ts +9 -0
- package/dist/src/node-secret-file.d.ts +32 -0
- package/dist/src/node-server-identity.d.ts +35 -0
- package/dist/src/node-server-payload.d.ts +66 -0
- package/dist/src/node-server-rules-file.d.ts +14 -0
- package/dist/src/node-server-secrets.d.ts +60 -0
- package/dist/src/node-server-version.d.ts +39 -0
- package/dist/src/node-server.d.ts +0 -12
- package/dist/src/node-server.js +8 -1
- package/dist/src/node-skills.d.ts +57 -0
- package/dist/src/normalize-runtime.d.ts +29 -2
- package/dist/src/offline-age.d.ts +29 -0
- package/dist/src/one-line-cell.d.ts +20 -0
- package/dist/src/opencode-agent-node-pair.d.ts +28 -0
- package/dist/src/opencode-auth-login.d.ts +43 -0
- package/dist/src/opencode-free-tier.d.ts +27 -0
- package/dist/src/opencode-generation-create.d.ts +27 -0
- package/dist/src/opencode-generation-record.d.ts +24 -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 +44 -0
- package/dist/src/opencode-pin.d.ts +28 -8
- package/dist/src/opencode-preset.d.ts +42 -8
- package/dist/src/opencode-runtime-binding.d.ts +30 -0
- package/dist/src/opencode-safe-root.d.ts +36 -0
- package/dist/src/opencode-shared-server-create.d.ts +5 -0
- package/dist/src/opencode-smoke-env.d.ts +1 -0
- package/dist/src/opencode-start-mode.d.ts +8 -0
- package/dist/src/opencode-v2-configured-model.d.ts +34 -0
- package/dist/src/opencode-v2-create-align.d.ts +18 -0
- package/dist/src/opencode-versions.d.ts +44 -0
- package/dist/src/os-user.d.ts +4 -0
- package/dist/src/outbound-attachments.d.ts +60 -0
- package/dist/src/outbound-tool-names.d.ts +1 -0
- package/dist/src/owned-roots.d.ts +58 -0
- package/dist/src/owner-env-file.d.ts +2 -0
- package/dist/src/package-mode-preflight.d.ts +41 -0
- package/dist/src/posix-codex-copresence.d.ts +33 -0
- package/dist/src/posix-modes.d.ts +36 -0
- package/dist/src/primary-network.d.ts +23 -0
- package/dist/src/private-state.d.ts +18 -0
- package/dist/src/process-telemetry.d.ts +12 -0
- package/dist/src/profile-merge.d.ts +12 -0
- package/dist/src/profile-serialize.d.ts +1 -0
- package/dist/src/provider-application-contract.d.ts +11 -0
- package/dist/src/provider-apply.d.ts +28 -0
- package/dist/src/provider-presets.d.ts +76 -0
- package/dist/src/reply-local-links.d.ts +47 -0
- package/dist/src/reply-originator.d.ts +20 -0
- package/dist/src/resume-runtime-infer.d.ts +18 -0
- package/dist/src/rules-file.d.ts +53 -0
- package/dist/src/scoped-secrets.d.ts +56 -0
- package/dist/src/secret-shell-guidance.d.ts +4 -0
- package/dist/src/session-status-class.d.ts +48 -0
- package/dist/src/shared/opencode-borrowed-launch-health.d.ts +29 -0
- package/dist/src/shared/provider-collection.d.ts +9 -0
- package/dist/src/shared/provider-initialization.d.ts +7 -0
- package/dist/src/shared/reserved-env.d.ts +3 -0
- package/dist/src/shared/scoped-secret-contract.d.ts +1 -0
- package/dist/src/shared/scoped-secret-env.d.ts +3 -0
- package/dist/src/sibling-agent-node.d.ts +23 -0
- package/dist/src/stale-socket.d.ts +118 -0
- package/dist/src/standalone-bin.d.ts +101 -0
- package/dist/src/standalone-build-stamp.d.ts +33 -0
- package/dist/src/start-resource-gate.d.ts +146 -0
- package/dist/src/stopped-receipt.d.ts +8 -0
- package/dist/src/subcommand-redirect.d.ts +26 -0
- package/dist/src/task-trace.d.ts +33 -0
- package/dist/src/tmux-attach.d.ts +11 -0
- package/dist/src/tmux-capability.d.ts +58 -0
- package/dist/src/tmux-exact-target.d.ts +36 -0
- package/dist/src/tmux-format.d.ts +20 -0
- package/dist/src/tmux-pane-prompt.d.ts +22 -0
- package/dist/src/tmux.d.ts +44 -0
- package/dist/src/token-cli.d.ts +13 -0
- package/dist/src/tool-allowlist.d.ts +28 -0
- package/dist/src/unsafe-package-path-reason.d.ts +31 -0
- package/dist/src/upgrade-channel.d.ts +31 -0
- package/dist/src/win-launcher.d.ts +20 -0
- package/dist/src/windows-codex-copresence.d.ts +238 -0
- package/dist/src/windows-rename-retry.d.ts +13 -0
- package/package.json +19 -9
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type TaskTraceTransport = "mcp_http" | "sdk_mcp_proxy" | "channel_mcp_proxy";
|
|
2
|
+
export type TaskTraceStatus = "sending" | "delivered" | "failed" | "acked" | "started" | "replied" | "expired";
|
|
3
|
+
export interface TaskTraceEvent {
|
|
4
|
+
event: string;
|
|
5
|
+
from_alias: string;
|
|
6
|
+
to_alias: string;
|
|
7
|
+
task_id: string | null;
|
|
8
|
+
parent_task_id: string | null;
|
|
9
|
+
network_id: string | null;
|
|
10
|
+
transport: TaskTraceTransport;
|
|
11
|
+
status: TaskTraceStatus;
|
|
12
|
+
duration_ms: number;
|
|
13
|
+
lifecycle_tracking: "tracked" | "not_tracked";
|
|
14
|
+
error_code?: string;
|
|
15
|
+
error_message?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function safeTaskTraceError(value: unknown): string;
|
|
18
|
+
export declare function renderTaskTrace(event: TaskTraceEvent, json?: boolean): string;
|
|
19
|
+
export declare function taskTraceEvent(input: Omit<TaskTraceEvent, "event">): TaskTraceEvent;
|
|
20
|
+
export interface SendTaskTraceInput {
|
|
21
|
+
fromAlias: string;
|
|
22
|
+
toAlias: string;
|
|
23
|
+
parentTaskId: string | null;
|
|
24
|
+
networkId: string | null;
|
|
25
|
+
transport: TaskTraceTransport;
|
|
26
|
+
lifecycleTracking: "tracked" | "not_tracked";
|
|
27
|
+
}
|
|
28
|
+
export interface SendTaskTraceDependencies {
|
|
29
|
+
send: () => Promise<any>;
|
|
30
|
+
log: (line: string) => void;
|
|
31
|
+
now?: () => number;
|
|
32
|
+
}
|
|
33
|
+
export declare function sendTaskWithTrace(input: SendTaskTraceInput, dependencies: SendTaskTraceDependencies): Promise<any>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type TmuxSession = {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
};
|
|
5
|
+
/** argv for `execTmux`: `-u list-sessions -F '#{session_id}|ANETSEP|#{session_name}'` (#533). */
|
|
6
|
+
export declare const SESSION_LIST_ARGS: readonly string[];
|
|
7
|
+
/** Parse SESSION_LIST_ARGS output (legacy `id\tname` rows still accepted). */
|
|
8
|
+
export declare function parseTmuxSessions(output: string): TmuxSession[];
|
|
9
|
+
/** Resolve by exact decoded session name, then attach by tmux's opaque ID.
|
|
10
|
+
* This avoids tmux target prefix matching and works for Unicode names. */
|
|
11
|
+
export declare function findExactTmuxSession(output: string, expectedName: string): TmuxSession | null;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** Lowest tmux version whose `new-session` understands `-e KEY=VALUE`. */
|
|
2
|
+
export declare const MIN_TMUX_MAJOR = 3;
|
|
3
|
+
export declare const MIN_TMUX_MINOR = 2;
|
|
4
|
+
export interface TmuxVersion {
|
|
5
|
+
major: number;
|
|
6
|
+
minor: number;
|
|
7
|
+
/** Trailing letter suffix, e.g. the "a" of "3.0a". Not used for ordering. */
|
|
8
|
+
suffix: string;
|
|
9
|
+
raw: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parse the output of `tmux -V`, e.g.:
|
|
13
|
+
* "tmux 3.2a" → { major: 3, minor: 2, suffix: "a" }
|
|
14
|
+
* "tmux 3.0a" → { major: 3, minor: 0, suffix: "a" }
|
|
15
|
+
* "tmux 3.4" → { major: 3, minor: 4, suffix: "" }
|
|
16
|
+
* "tmux next-3.4" → { major: 3, minor: 4, suffix: "" }
|
|
17
|
+
* "tmux 2.9" → { major: 2, minor: 9, suffix: "" }
|
|
18
|
+
*
|
|
19
|
+
* Returns null when no version can be extracted (unknown build, empty
|
|
20
|
+
* output, `tmux master` with no numbers). Callers must treat null as
|
|
21
|
+
* "unknown" and NOT as "too old" — refusing to start on an unparseable
|
|
22
|
+
* version string would break hosts whose tmux is perfectly capable.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseTmuxVersion(raw: string): TmuxVersion | null;
|
|
25
|
+
/**
|
|
26
|
+
* True when this version's `new-session` supports `-e KEY=VALUE` (>= 3.2).
|
|
27
|
+
* Note 3.0a / 3.1c sort BELOW 3.2 — the letter suffix is a patch marker,
|
|
28
|
+
* never a minor bump, so it must not participate in the comparison.
|
|
29
|
+
*/
|
|
30
|
+
export declare function tmuxSupportsSessionEnv(v: TmuxVersion): boolean;
|
|
31
|
+
export type TmuxCapabilityVerdict = {
|
|
32
|
+
kind: "ok";
|
|
33
|
+
version: TmuxVersion;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "unknown";
|
|
36
|
+
detail: string;
|
|
37
|
+
} | {
|
|
38
|
+
kind: "too_old";
|
|
39
|
+
version: TmuxVersion;
|
|
40
|
+
detail: string;
|
|
41
|
+
remedy: string[];
|
|
42
|
+
} | {
|
|
43
|
+
kind: "missing";
|
|
44
|
+
detail: string;
|
|
45
|
+
remedy: string[];
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Pure decision function — `runVersionCmd` returns `tmux -V` output, or
|
|
49
|
+
* throws if tmux is absent/unrunnable. Split from the printing/exiting
|
|
50
|
+
* wrapper so tests drive every branch without a tmux binary.
|
|
51
|
+
*/
|
|
52
|
+
export declare function checkTmuxCapability(runVersionCmd: () => string): TmuxCapabilityVerdict;
|
|
53
|
+
/**
|
|
54
|
+
* cli.ts wrapper: run the check, print an actionable message, and exit
|
|
55
|
+
* non-zero when tmux cannot carry the marker. `unknown` is deliberately
|
|
56
|
+
* permissive — we log and continue.
|
|
57
|
+
*/
|
|
58
|
+
export declare function assertTmuxSupportsSessionEnv(runVersionCmd: () => string, log: (msg: string) => void, fail: (msg: string) => never): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exact-match tmux target for a session name.
|
|
3
|
+
*
|
|
4
|
+
* tmux treats a leading `=` as "this exact name, no prefix matching". Names are
|
|
5
|
+
* passed to tmux as argv entries, never through a shell, so no quoting belongs
|
|
6
|
+
* here — callers that build a copy-pasteable command for a human should shell-
|
|
7
|
+
* quote the result themselves.
|
|
8
|
+
*/
|
|
9
|
+
export declare function exactSession(name: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* True when this target is already pinned to an exact session.
|
|
12
|
+
*
|
|
13
|
+
* Applying the prefix twice would look for a session literally named `=x`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isExactTarget(target: string): boolean;
|
|
16
|
+
/** Idempotent form, for call sites that may receive either shape. */
|
|
17
|
+
export declare function ensureExactSession(nameOrTarget: string): string;
|
|
18
|
+
/** One row of `tmux -u list-panes -a -F PANE_LIST_FORMAT` (session, `window.pane`). */
|
|
19
|
+
export interface PaneRow {
|
|
20
|
+
session: string;
|
|
21
|
+
/** `window.pane`, e.g. `0.0`. */
|
|
22
|
+
coord: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function parsePaneRows(listOutput: string): PaneRow[];
|
|
25
|
+
/**
|
|
26
|
+
* Pane target for a session, or null when that exact session has no pane.
|
|
27
|
+
*
|
|
28
|
+
* Matching is exact string equality on the session name — the whole point is to
|
|
29
|
+
* not hand tmux a name it might prefix-match, and to not hand it a `=` form it
|
|
30
|
+
* cannot resolve for non-ASCII names.
|
|
31
|
+
*/
|
|
32
|
+
export declare function paneTargetFor(listOutput: string, sessionName: string): string | null;
|
|
33
|
+
/** The format string the two functions above expect. */
|
|
34
|
+
export declare const PANE_LIST_FORMAT: string;
|
|
35
|
+
/** Full argv (`-u list-panes -a -F …`) for `execTmux`; locale-proof (#533). */
|
|
36
|
+
export declare const PANE_LIST_ARGS: readonly string[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Field separator inside a `-F` format. Printable, so tmux never rewrites it. */
|
|
2
|
+
export declare const TMUX_FIELD_SEP = "|ANETSEP|";
|
|
3
|
+
/** Prefix tmux argv with `-u` so its output keeps UTF-8 names in any locale. */
|
|
4
|
+
export declare function tmuxUtf8Args(args: readonly string[]): string[];
|
|
5
|
+
/** The `-F` format string for these fields. */
|
|
6
|
+
export declare function tmuxFormat(fields: readonly string[]): string;
|
|
7
|
+
/**
|
|
8
|
+
* argv for a tmux listing whose output anet parses:
|
|
9
|
+
* `tmuxListArgs(["list-sessions"], ["#{session_id}", "#{session_name}"])`
|
|
10
|
+
* → `["-u", "list-sessions", "-F", "#{session_id}|ANETSEP|#{session_name}"]`.
|
|
11
|
+
* Pass the result to `execTmux` (which adds `-S` isolation in front).
|
|
12
|
+
*/
|
|
13
|
+
export declare function tmuxListArgs(command: readonly string[], fields: readonly string[]): string[];
|
|
14
|
+
/**
|
|
15
|
+
* Split tmux format output into rows of exactly `fieldCount` fields.
|
|
16
|
+
* Lines with a different field count are dropped (never guessed at).
|
|
17
|
+
* A line without the separator is read as a legacy TAB-separated row, so
|
|
18
|
+
* fixtures and callers that captured the old wire shape still parse.
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseTmuxRows(output: string, fieldCount: number): string[][];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** A prompt the watcher knows how to answer, or null. */
|
|
2
|
+
export type PanePrompt = "dev-channels" | "folder-trust";
|
|
3
|
+
/**
|
|
4
|
+
* Which known prompt (if any) the pane is currently blocking on.
|
|
5
|
+
*
|
|
6
|
+
* Dev-channels is checked FIRST, even though it appears second in time. The two
|
|
7
|
+
* prompts are sequential — trust, then channels — so a capture showing both
|
|
8
|
+
* means the trust prompt is already answered and only its text is still sitting
|
|
9
|
+
* in the pane. Classifying that as "folder-trust" would make a watcher that has
|
|
10
|
+
* already answered trust ignore the prompt it was waiting for, and the node
|
|
11
|
+
* would hang exactly as if the fix had never been made. Preferring the later
|
|
12
|
+
* prompt keeps a stale line of scrollback from outranking the live prompt.
|
|
13
|
+
*/
|
|
14
|
+
export declare function classifyPanePrompt(pane: string): PanePrompt | null;
|
|
15
|
+
/**
|
|
16
|
+
* Best-effort one-line explanation of why a detached start died, taken from the
|
|
17
|
+
* dead pane's own output.
|
|
18
|
+
*
|
|
19
|
+
* Returns null when the pane holds nothing that looks like a refusal — the
|
|
20
|
+
* caller must then fall back to a generic message rather than inventing one.
|
|
21
|
+
*/
|
|
22
|
+
export declare function extractStartFailureReason(pane: string): string | null;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ChildProcess, type ExecFileSyncOptions, type ExecFileSyncOptionsWithBufferEncoding, type ExecFileSyncOptionsWithStringEncoding, type SpawnOptions, type SpawnSyncOptions, type SpawnSyncReturns } from "node:child_process";
|
|
2
|
+
export type TmuxEnv = Record<string, string | undefined>;
|
|
3
|
+
export interface TmuxIsolation {
|
|
4
|
+
/** Socket path passed to tmux as `-S`. */
|
|
5
|
+
socket: string;
|
|
6
|
+
/** Which variable asked for isolation. */
|
|
7
|
+
source: "ANET_TMUX_SOCKET" | "TMUX_TMPDIR";
|
|
8
|
+
}
|
|
9
|
+
export declare class TmuxKillServerRefused extends Error {
|
|
10
|
+
constructor(args: readonly string[]);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Where tmux should talk to, or null for "today's default behaviour".
|
|
14
|
+
* `TMUX_TMPDIR` resolves the same way tmux itself does: `$TMUX_TMPDIR/tmux-<uid>/default`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveTmuxIsolation(env?: TmuxEnv, uid?: number): TmuxIsolation | null;
|
|
17
|
+
/** The socket path inside `$TMUX` (`<socket>,<server pid>,<session idx>`), or null. */
|
|
18
|
+
export declare function socketOfTmuxVar(value: string | undefined): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* True when argv asks tmux to kill its server, including `a ; kill-server`
|
|
21
|
+
* chains and the unambiguous prefixes tmux accepts (`kill-ser`, `kill-serv`, …).
|
|
22
|
+
*/
|
|
23
|
+
export declare function isKillServer(args: readonly string[]): boolean;
|
|
24
|
+
export interface TmuxInvocation {
|
|
25
|
+
file: "tmux";
|
|
26
|
+
args: string[];
|
|
27
|
+
/** undefined ⇒ inherit the caller's env exactly as before (no isolation requested). */
|
|
28
|
+
env: TmuxEnv | undefined;
|
|
29
|
+
isolation: TmuxIsolation | null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Pure argv/env builder. Throws TmuxKillServerRefused for kill-server.
|
|
33
|
+
* `env` is the env the child would otherwise get (the caller's `options.env`,
|
|
34
|
+
* else process.env); isolation is decided from it.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildTmuxInvocation(args: readonly string[], env?: TmuxEnv, uid?: number): TmuxInvocation;
|
|
37
|
+
/** `execFileSync("tmux", args, options)` through the #505 rules. */
|
|
38
|
+
export declare function execTmux(args: readonly string[], options: ExecFileSyncOptionsWithStringEncoding): string;
|
|
39
|
+
export declare function execTmux(args: readonly string[], options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
|
|
40
|
+
export declare function execTmux(args: readonly string[], options?: ExecFileSyncOptions): string | Buffer;
|
|
41
|
+
/** `spawnSync("tmux", args, options)` through the #505 rules. */
|
|
42
|
+
export declare function spawnSyncTmux(args: readonly string[], options?: SpawnSyncOptions): SpawnSyncReturns<string | Buffer>;
|
|
43
|
+
/** `spawn("tmux", args, options)` through the #505 rules. */
|
|
44
|
+
export declare function spawnTmux(args: readonly string[], options?: SpawnOptions): ChildProcess;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type TokenCreateNameResult = {
|
|
2
|
+
ok: true;
|
|
3
|
+
name: string;
|
|
4
|
+
} | {
|
|
5
|
+
ok: false;
|
|
6
|
+
error: string;
|
|
7
|
+
};
|
|
8
|
+
/** Parse only `anet token create` operands.
|
|
9
|
+
*
|
|
10
|
+
* The legacy positional form stays supported, while flag parsing is strict so
|
|
11
|
+
* a typo cannot become the name of a newly issued credential.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseTokenCreateName(argv: readonly string[]): TokenCreateNameResult;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const CLAUDE_KNOWN_TOOLS: readonly string[];
|
|
2
|
+
type Runtime = string;
|
|
3
|
+
/** Parse the comma-joined --tools string, validate each token, return the
|
|
4
|
+
* trimmed list. Runtime-scoped:
|
|
5
|
+
*
|
|
6
|
+
* Claude-lineage → each token must be in CLAUDE_KNOWN_TOOLS OR match
|
|
7
|
+
* the MCP pattern (mcp__<server>__<tool>).
|
|
8
|
+
* Other runtimes → only the basic per-token format check runs, so grok /
|
|
9
|
+
* codex / opencode tools flow through unchanged and get
|
|
10
|
+
* validated by their own downstream layers.
|
|
11
|
+
*
|
|
12
|
+
* Throws on the first offense with a message naming the bad token and,
|
|
13
|
+
* for Claude-side violations, the expected set. Never returns a
|
|
14
|
+
* partially-cleaned list — a typo must surface, not silently reshape the
|
|
15
|
+
* persisted profile.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseAndValidateTools(raw: string, runtime: Runtime): string[];
|
|
18
|
+
/** Minimal --model validation: non-empty after trim, no whitespace inside.
|
|
19
|
+
*
|
|
20
|
+
* We do NOT enforce a known-model allowlist — models are vendor-defined,
|
|
21
|
+
* evolve independently, and a strict list would break the first time
|
|
22
|
+
* MiniMax/DeepSeek/GLM/etc. ships a new variant. This catches the obvious
|
|
23
|
+
* user-side typos (`--model " claude-3 " `, `--model ""`) without
|
|
24
|
+
* over-restricting legitimate values. Vendor-side model resolution
|
|
25
|
+
* (defaultCodexModelForRuntime etc.) already validates its own contract.
|
|
26
|
+
*/
|
|
27
|
+
export declare function validateModel(raw: string): string;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface PathModeFacts {
|
|
2
|
+
/** Owner uid of the path. */
|
|
3
|
+
uid: number;
|
|
4
|
+
/** Permission bits (st_mode & 0o777). */
|
|
5
|
+
mode: number;
|
|
6
|
+
/** uid of the process doing the check. */
|
|
7
|
+
processUid: number;
|
|
8
|
+
}
|
|
9
|
+
export type UnsafePathReason = "owner" | "group-writable" | "world-writable" | null;
|
|
10
|
+
/** Which condition makes this path unsafe to execute from, if any. */
|
|
11
|
+
export declare function classifyUnsafePath(facts: PathModeFacts): UnsafePathReason;
|
|
12
|
+
export declare function describeUnsafePath(path: string, facts: PathModeFacts): string;
|
|
13
|
+
export interface DirectoryModeFacts {
|
|
14
|
+
uid: number;
|
|
15
|
+
/** Full st_mode (the sticky bit 0o1000 matters here). */
|
|
16
|
+
mode: number;
|
|
17
|
+
processUid: number;
|
|
18
|
+
/** Is this the package root itself or one of its ancestors? Only changes the wording. */
|
|
19
|
+
ancestorOf?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* #535 (audit P1-2) — the DIRECTORY branch of the agent-node package check used
|
|
23
|
+
* to throw a bare "unsafe ownership or mode" with no path at all. In the audit
|
|
24
|
+
* the offender was an ANCESTOR, `/tmp` (1777), because the npx cache lived
|
|
25
|
+
* under a HOME in /tmp — and nothing in the message said so.
|
|
26
|
+
*
|
|
27
|
+
* Names the exact directory, what is wrong with it, and the command that fixes
|
|
28
|
+
* it. For a sticky world-writable directory (/tmp-like) the fix is NOT chmod —
|
|
29
|
+
* changing /tmp breaks the machine — but moving the npm cache out from under it.
|
|
30
|
+
*/
|
|
31
|
+
export declare function describeUnsafeDirectory(path: string, facts: DirectoryModeFacts): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type ReleaseChannel = "preview" | "latest";
|
|
2
|
+
export interface DistTags {
|
|
3
|
+
latest?: string | null;
|
|
4
|
+
preview?: string | null;
|
|
5
|
+
}
|
|
6
|
+
export type ChannelResolution = {
|
|
7
|
+
ok: true;
|
|
8
|
+
channel: ReleaseChannel;
|
|
9
|
+
source: "flag" | "detected";
|
|
10
|
+
reason: string;
|
|
11
|
+
} | {
|
|
12
|
+
ok: false;
|
|
13
|
+
error: string;
|
|
14
|
+
};
|
|
15
|
+
export interface ResolveUpgradeChannelInput {
|
|
16
|
+
/** Installed anet version (full string, prerelease preserved). */
|
|
17
|
+
installed: string | null | undefined;
|
|
18
|
+
/** Value of `--channel`. `"true"` means the flag was given without a value. */
|
|
19
|
+
flag?: string | null;
|
|
20
|
+
/** dist-tags of @sleep2agi/agent-network, or null when the lookup failed. */
|
|
21
|
+
distTags: DistTags | null;
|
|
22
|
+
}
|
|
23
|
+
interface ParsedSemver {
|
|
24
|
+
core: [number, number, number];
|
|
25
|
+
pre: string[];
|
|
26
|
+
}
|
|
27
|
+
export declare function parseSemver(version: string | null | undefined): ParsedSemver | null;
|
|
28
|
+
/** semver §11 precedence. Returns <0, 0, >0. */
|
|
29
|
+
export declare function compareSemver(a: ParsedSemver, b: ParsedSemver): number;
|
|
30
|
+
export declare function resolveUpgradeChannel(input: ResolveUpgradeChannelInput): ChannelResolution;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ExecFileSyncOptions, type ExecFileSyncOptionsWithStringEncoding, type SpawnOptions } from "child_process";
|
|
2
|
+
/** Windows needs a command interpreter to run a .cmd; POSIX runs the file. */
|
|
3
|
+
export declare function launcherNeedsShell(platform?: NodeJS.Platform): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Quote one argument for `cmd.exe /c`.
|
|
6
|
+
*
|
|
7
|
+
* cmd's rules are not the shell's: a double quote is escaped by doubling it,
|
|
8
|
+
* and the metacharacters below must be quoted or cmd will act on them. Anything
|
|
9
|
+
* safe is left bare, so the common case stays readable in a process listing.
|
|
10
|
+
*/
|
|
11
|
+
export declare function quoteForCmd(arg: string): string;
|
|
12
|
+
/** The argv to hand to execFile/spawn so `cmd args…` runs on this platform. */
|
|
13
|
+
export declare function launcherArgv(cmd: string, args: readonly string[], platform?: NodeJS.Platform, comspec?: string | undefined): {
|
|
14
|
+
file: string;
|
|
15
|
+
argv: string[];
|
|
16
|
+
};
|
|
17
|
+
export declare function runLauncherSync(cmd: string, args: readonly string[], options: ExecFileSyncOptionsWithStringEncoding): string;
|
|
18
|
+
export declare function runLauncherSync(cmd: string, args: readonly string[], options?: ExecFileSyncOptions): Buffer;
|
|
19
|
+
/** spawn for a launcher, correct on Windows. */
|
|
20
|
+
export declare function spawnLauncher(cmd: string, args: readonly string[], options?: SpawnOptions): import("node:child_process").ChildProcess;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
export type WindowsCopresenceRole = "appsrv" | "bridge";
|
|
2
|
+
export interface WindowsManagedProcess {
|
|
3
|
+
role: WindowsCopresenceRole;
|
|
4
|
+
pid: number;
|
|
5
|
+
creationDate: string;
|
|
6
|
+
logPath: string;
|
|
7
|
+
}
|
|
8
|
+
export interface WindowsCopresenceRecord {
|
|
9
|
+
version: 1 | 2;
|
|
10
|
+
nodeId: string;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
marker?: string;
|
|
13
|
+
processes: WindowsManagedProcess[];
|
|
14
|
+
}
|
|
15
|
+
export declare function windowsCopresenceRecordPath(nodesDir: string, nodeId: string): string;
|
|
16
|
+
export declare function windowsCopresenceLogPath(nodesDir: string, nodeId: string, role: WindowsCopresenceRole): string;
|
|
17
|
+
export declare function openPrivateAppendLog(path: string): number;
|
|
18
|
+
/** Protect credential-bearing state with native Windows ACLs. */
|
|
19
|
+
export declare function ensureWindowsPrivateDirectory(path: string): void;
|
|
20
|
+
export declare function closeLog(fd: number): void;
|
|
21
|
+
export type CreationDateProbe = (pid: number) => string | null;
|
|
22
|
+
/** Uses CIM instead of locale-dependent tasklist output. */
|
|
23
|
+
export declare function probeWindowsCreationDate(pid: number): string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Attribute an ESTABLISHED loopback connection to the launched TUI process
|
|
26
|
+
* tree. This is deliberately stronger than counting listeners/connections:
|
|
27
|
+
* an unrelated local client cannot satisfy it.
|
|
28
|
+
*/
|
|
29
|
+
export declare function probeWindowsOwnedLoopbackConnection(rootPid: number, expectedCreationDate: string, port: number, runPowerShell?: (script: string) => string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* #1342 —— 只在健康检查**即将失败**时跑一次,用来回答一个此前没人量过的问题:
|
|
32
|
+
* 那 10.5 秒到底花在 **PowerShell 启动**上,还是花在 `Get-CimInstance Win32_Process`
|
|
33
|
+
* 这个全表查询上?
|
|
34
|
+
*
|
|
35
|
+
* 实测背景(由 #1628/#1637 加的 probeMs 量到,2026-08-31):
|
|
36
|
+
* probes=1 waited=10897ms probeMsLast=10490 ← 单次探测吃掉 96% 的预算
|
|
37
|
+
* 而 #1636 把全表枚举提到循环外之后这个数**没有变小**(9963 → 10490),
|
|
38
|
+
* 说明成本不在"重复枚举",而在那一次调用本身。但"那一次调用"包含两段:
|
|
39
|
+
* 起一个 powershell 进程,和在里面跑 CIM 查询。**这两段要查的东西完全不同** ——
|
|
40
|
+
* 前者是 runner/镜像的问题,后者是查询写法的问题。
|
|
41
|
+
*
|
|
42
|
+
* 🔴 这里跑的是一个**什么都不做**的脚本(`'x'`),所以它测到的就是启动那一段的下界。
|
|
43
|
+
* 只在失败路径调用一次,不进探测循环 —— 不给正常路径增加任何成本,
|
|
44
|
+
* 也**不可能**改变探测的返回值。
|
|
45
|
+
*
|
|
46
|
+
* 拿不到就返回 null(未知),不返回 0 —— 0 会被读成「启动不花时间」。
|
|
47
|
+
*/
|
|
48
|
+
export declare function measurePowerShellStartupMs(): number | null;
|
|
49
|
+
export declare function writeWindowsCopresenceRecord(nodesDir: string, nodeId: string, processes: WindowsManagedProcess[], marker?: string): void;
|
|
50
|
+
export declare function readWindowsCopresenceRecord(nodesDir: string, nodeId: string): WindowsCopresenceRecord | null;
|
|
51
|
+
export interface WindowsStopDecision {
|
|
52
|
+
safe: WindowsManagedProcess[];
|
|
53
|
+
refused: Array<{
|
|
54
|
+
process: WindowsManagedProcess;
|
|
55
|
+
reason: "missing" | "pid-reused";
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
/** PID alone is never authority: Windows reuses PIDs, so CreationDate must match. */
|
|
59
|
+
export declare function decideWindowsManagedStop(record: WindowsCopresenceRecord, probe: CreationDateProbe): WindowsStopDecision;
|
|
60
|
+
export declare function taskkillWindowsProcessTree(pid: number): void;
|
|
61
|
+
export interface TaskkillOutcome {
|
|
62
|
+
status: number | null;
|
|
63
|
+
signal: string | null;
|
|
64
|
+
/** 受控摘要:仅保留 taskkill 自身固定形状的行,≤4 行 / 400 字符。 */
|
|
65
|
+
stderrSummary: string;
|
|
66
|
+
/** 被丢弃的 stderr 字节数——保留「有输出但形状不识别」这一事实,不泄露文本。 */
|
|
67
|
+
stderrDroppedBytes: number;
|
|
68
|
+
}
|
|
69
|
+
/** 受控诊断:只放行已知形状(`ERROR:` / `Reason:` …),其余只记字节数。 */
|
|
70
|
+
export declare function summarizeTaskkillStderr(raw: string): {
|
|
71
|
+
summary: string;
|
|
72
|
+
droppedBytes: number;
|
|
73
|
+
};
|
|
74
|
+
/** 非零**不再**丢弃诊断:拿回 status/signal 与受控 stderr,交给身份裁决。 */
|
|
75
|
+
export declare function runTaskkillWindowsProcessTree(pid: number): TaskkillOutcome;
|
|
76
|
+
export type WindowsIdentityState = "alive" | "gone" | "pid-reused" | "unknown";
|
|
77
|
+
/** 结构化协议:判定只读这个协议,**不**读本地化的错误文案。 */
|
|
78
|
+
export declare const WINDOWS_IDENTITY_PROTOCOL = "IDSTATE:";
|
|
79
|
+
/** gone 用 .NET 的 `ArgumentException`(进程不存在)辨认——**异常类型**不随语言变化。 */
|
|
80
|
+
export declare function windowsIdentityProbeScript(pid: number): string;
|
|
81
|
+
export type WindowsIdentityRead = {
|
|
82
|
+
kind: "ticks";
|
|
83
|
+
ticks: string;
|
|
84
|
+
} | {
|
|
85
|
+
kind: "absent";
|
|
86
|
+
} | {
|
|
87
|
+
kind: "unknown";
|
|
88
|
+
};
|
|
89
|
+
/** 空输出 / 多行 / 非法形状 / 异常 ⇒ unknown(**不能**折成 gone)。 */
|
|
90
|
+
export declare function readWindowsIdentity(pid: number, runPowerShell?: (script: string) => string): WindowsIdentityRead;
|
|
91
|
+
/** 三向:alive(出生身份仍在) / gone(该身份已不存在) / pid-reused(同 PID 已被无关进程占用) / unknown。 */
|
|
92
|
+
export declare function probeWindowsIdentity(pid: number, expectedCreationDate: string, runPowerShell?: (script: string) => string, kind?: WindowsIdentityKind): WindowsIdentityState;
|
|
93
|
+
export type WindowsIdentityKind = "ticks" | "creation";
|
|
94
|
+
export interface WindowsManagedIdentity {
|
|
95
|
+
role: string;
|
|
96
|
+
pid: number;
|
|
97
|
+
creationDate: string;
|
|
98
|
+
/** `ticks`(根,`[Diagnostics.Process]::StartTime` 的 .NET ticks)或
|
|
99
|
+
* `creation`(后代,**同一份 CIM 枚举快照**里的 `CreationDate`)。两者**不混用**、各自精确相等比较。 */
|
|
100
|
+
kind?: WindowsIdentityKind;
|
|
101
|
+
}
|
|
102
|
+
export declare const WINDOWS_CAPTURE_PROTOCOL = "CAP:";
|
|
103
|
+
/**
|
|
104
|
+
* 一次 PowerShell 里完成**绑定根身份**的取证:先核根出生身份 == 期望,再枚举后代并在
|
|
105
|
+
* **同一次枚举**中读它们的出生身份,最后**再核一次**根身份。根代际漂移 ⇒ 整次取证作废。
|
|
106
|
+
* 只用于取证,**不**用于杀进程。
|
|
107
|
+
*/
|
|
108
|
+
export declare function windowsCaptureScript(rootPid: number, expectedCreationDate: string): string;
|
|
109
|
+
export interface WindowsDescendantCapture {
|
|
110
|
+
identities: WindowsManagedIdentity[];
|
|
111
|
+
rootBefore?: string;
|
|
112
|
+
rootAfter?: string;
|
|
113
|
+
/** 非空 ⇒ 取证不完整/根代际漂移,调用方**必须**按 unknown 处理,不得当成功。 */
|
|
114
|
+
unknownReason?: string;
|
|
115
|
+
}
|
|
116
|
+
export declare function parseWindowsCapture(raw: string): {
|
|
117
|
+
rootBefore: string;
|
|
118
|
+
rootAfter: string;
|
|
119
|
+
descendants: Array<{
|
|
120
|
+
pid: number;
|
|
121
|
+
ticks: string;
|
|
122
|
+
}>;
|
|
123
|
+
gaps: number[];
|
|
124
|
+
} | null;
|
|
125
|
+
/**
|
|
126
|
+
* 绑定**期望根身份**的取证:根在取证前/后都必须仍是期望代际;后代出生身份取自**同一次枚举**。
|
|
127
|
+
* 任何漂移/缺口 ⇒ unknownReason(不猜)。只用于**验证**;杀进程仍走根 PID 的既存出生身份。
|
|
128
|
+
*/
|
|
129
|
+
export declare function captureWindowsDescendantIdentities(root: WindowsManagedIdentity, opts?: {
|
|
130
|
+
cap?: number;
|
|
131
|
+
runPowerShell?: (script: string) => string;
|
|
132
|
+
}): WindowsDescendantCapture;
|
|
133
|
+
export declare const WINDOWS_CIM_PROTOCOL = "CIMSTATE:";
|
|
134
|
+
/** 后代身份协议:**同一份快照**里的 CIM `CreationDate`(`ToString('o')`),精确相等比较。 */
|
|
135
|
+
export declare function cimIdentityProbeScript(pid: number): string;
|
|
136
|
+
/** Validate the complete text without rounding the identity's fractional digits. */
|
|
137
|
+
export declare function isCompleteCimCreationDate(value: string): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* 🔴 只有**期望值与读回值均为合法完整** `CreationDate`,且二者**精确不等**时才是 `pid-reused`;
|
|
140
|
+
* 任何一侧非法(格式/日期/多行/空白畸形)⇒ **unknown** —— 不得因"读不懂"而放宽成"已退出/被复用"。
|
|
141
|
+
* 比较保留全部精度:不做 `Date.parse`、不截断、不近似。
|
|
142
|
+
*/
|
|
143
|
+
export declare function parseCimIdentityState(raw: string, expectedCreationDate: string): WindowsIdentityState;
|
|
144
|
+
export declare function probeWindowsCimIdentity(pid: number, expectedCreationDate: string, runPowerShell?: (script: string) => string): WindowsIdentityState;
|
|
145
|
+
export interface WindowsStopOrchestrationDeps {
|
|
146
|
+
runPowerShell?: (script: string) => string;
|
|
147
|
+
runTaskkill?: (pid: number) => TaskkillOutcome;
|
|
148
|
+
}
|
|
149
|
+
export interface WindowsStopOrchestration {
|
|
150
|
+
verdict: WindowsStopVerdict;
|
|
151
|
+
/** 实际发出 taskkill 的根 PID —— 负控可断言为 **0**。 */
|
|
152
|
+
killedPids: number[];
|
|
153
|
+
identities: WindowsManagedIdentity[];
|
|
154
|
+
/** 非 `stopped` 时调用方**必须**保留记录、**不得**通知 Hub 离线。 */
|
|
155
|
+
mustKeepRecord: boolean;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* 停止编排(CLI 实际使用的那一份,注入 runner/executor 以便见证):
|
|
159
|
+
* ① 对每个受管根做**绑定根身份**的取证(含后代出生身份与前后根代际核对);
|
|
160
|
+
* ② 每个根在**终止紧前**重验 PID+CreationDate —— `gone`/`pid-reused`/`unknown` 一律**不发**终止命令;
|
|
161
|
+
* ③ 按精确身份裁决 gone/alive/unknown。过期 `safe` **不**构成终止授权。
|
|
162
|
+
*/
|
|
163
|
+
export declare function orchestrateWindowsManagedStop(roots: WindowsManagedIdentity[], deps?: WindowsStopOrchestrationDeps): WindowsStopOrchestration;
|
|
164
|
+
export declare const WINDOWS_SNAPSHOT_PROTOCOL = "SNAP:";
|
|
165
|
+
/**
|
|
166
|
+
* 终止**之后**的进程快照:**只**返回现存进程的 (pid, ppid) 对,不在脚本里做遍历、不下结论。
|
|
167
|
+
* 🔴 遍历刻意放在 JS 侧:这样「祖先链上的存活后代」这条判据**本身**可被单测见证,
|
|
168
|
+
* 而不是只往编排里注入一个已经算好的结果。
|
|
169
|
+
*/
|
|
170
|
+
export declare function windowsProcessSnapshotScript(): string;
|
|
171
|
+
export declare function parseWindowsProcessSnapshot(raw: string): Array<{
|
|
172
|
+
pid: number;
|
|
173
|
+
ppid: number;
|
|
174
|
+
}> | null;
|
|
175
|
+
/**
|
|
176
|
+
* 🔴 **完整性判据(不看根是否可达)**:以**全部已捕获身份**(根 + 后代)为种子,
|
|
177
|
+
* 在终止后快照里沿 `ParentProcessId` 向下闭包;任何**可达且不属于已捕获身份**的现存进程,
|
|
178
|
+
* 都是「未被记账的存活后代」。
|
|
179
|
+
*
|
|
180
|
+
* 这修掉的是这个反例:捕获 8100→8744 后,8744 又生出 9999;非零 kill 使 8100/8744 退出而
|
|
181
|
+
* 9999 存活(快照里 `9999=8744`)。旧实现只从 8100 出发 BFS ⇒ 根已不可达 ⇒ 得空 ⇒ 误判 stopped。
|
|
182
|
+
* 现在 8744 也在种子里 ⇒ 9999 可达 ⇒ 必须 `unknown`。
|
|
183
|
+
*
|
|
184
|
+
* ⚠️ **保证范围(有界)**:这是**单次有限快照**上的可达性判据,**不是**"历史后代完整性证明"。
|
|
185
|
+
* 若某个中间节点**从未被捕获**且已退出,有限 pid/ppid 快照里**没有那条历史边**,本条判据
|
|
186
|
+
* 看不到它;因此本片**不承诺**全时段/任意树零残留。超出该范围需要启动屏障/Job Object 一类
|
|
187
|
+
* 机制,**不在本片引入**。
|
|
188
|
+
*/
|
|
189
|
+
export declare function findUnaccountedDescendants(snapshot: Array<{
|
|
190
|
+
pid: number;
|
|
191
|
+
ppid: number;
|
|
192
|
+
}>, capturedPids: number[]): number[];
|
|
193
|
+
export interface WindowsStopContinuation<TStopResult> {
|
|
194
|
+
/** 删除 Windows 归属记录(`rmSync(windowsCopresenceRecordPath(…))`)。 */
|
|
195
|
+
removeRecord: () => void;
|
|
196
|
+
/** CLI 的 `stopNode(resolved.id)` —— **只是停止节点并返回其结果**。 */
|
|
197
|
+
stopNode: () => Promise<TStopResult>;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* 🔴 停止收尾的**唯一门控**(CLI 与见证共用):只有 `stopped` 才删记录、才调用 `stopNode`;
|
|
201
|
+
* `survived`/`unverifiable` 两者都不做;nodeStopInvoked 只表示回调被调用,停止成功与否仍由 stopResult 裁决。
|
|
202
|
+
* 便于用 spy 观测**实际发生了什么调用**(而不是只看一个布尔)。
|
|
203
|
+
*
|
|
204
|
+
* ⚠️ **不含 Hub 离线通知**:真正的 `notifyServerOffline` 在 `stopNode` 之后、由 CLI 自行调用,
|
|
205
|
+
* **不在**本门控内;因此「Hub 未收到离线通知」在本片**仍是欠项(未验)**。
|
|
206
|
+
*/
|
|
207
|
+
export declare function settleWindowsManagedStop<TStopResult>(outcome: WindowsStopOrchestration, continuation: WindowsStopContinuation<TStopResult>): Promise<{
|
|
208
|
+
kept: boolean;
|
|
209
|
+
nodeStopInvoked: boolean;
|
|
210
|
+
stopResult?: TStopResult;
|
|
211
|
+
}>;
|
|
212
|
+
export type WindowsStopVerdict = {
|
|
213
|
+
kind: "stopped";
|
|
214
|
+
retainedDiagnostics: string[];
|
|
215
|
+
} | {
|
|
216
|
+
kind: "survived";
|
|
217
|
+
alive: string[];
|
|
218
|
+
retainedDiagnostics: string[];
|
|
219
|
+
} | {
|
|
220
|
+
kind: "unverifiable";
|
|
221
|
+
unknown: string[];
|
|
222
|
+
retainedDiagnostics: string[];
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* 成败只由**精确身份**裁决(不解析 taskkill 文案):任一 `alive` ⇒ survived;否则任一
|
|
226
|
+
* `unknown`(含取证缺口)⇒ unverifiable(两者**都不得绿**);全部 gone 或 pid-reused
|
|
227
|
+
* ⇒ stopped,并把非零 taskkill 的 status/signal/受控 stderr 作为**保留诊断**带出。
|
|
228
|
+
*/
|
|
229
|
+
export declare function decideWindowsStopVerdict(opts: {
|
|
230
|
+
identities: WindowsManagedIdentity[];
|
|
231
|
+
kills: Array<{
|
|
232
|
+
label: string;
|
|
233
|
+
outcome: TaskkillOutcome;
|
|
234
|
+
}>;
|
|
235
|
+
probe: (identity: WindowsManagedIdentity) => WindowsIdentityState;
|
|
236
|
+
captureUnknown?: string[];
|
|
237
|
+
notes?: string[];
|
|
238
|
+
}): WindowsStopVerdict;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Windows: 覆盖一个**正被别的句柄打开**的目标会失败(EPERM/EBUSY/EACCES),而 POSIX 的 rename 会成功 ——
|
|
3
|
+
* 所以同一个"写临时文件再 rename"的原子写在 Linux 上永远绿、在 Windows 上偶发红(#2222 实测在
|
|
4
|
+
* windows-copresence.json 上红过一次,CI 上看起来像随机红)。
|
|
5
|
+
*
|
|
6
|
+
* 这里只做**有界重试**:仅 win32、仅这三种"别人暂时开着"的错误码,退避 10/25/50/100/200ms
|
|
7
|
+
* (最多 5 次,总上限约 385ms);其它错误与重试耗尽一律照原样抛 —— 不吞错,也不把原子写降级成
|
|
8
|
+
* "原地覆盖"(那会让读者读到半个文件)。
|
|
9
|
+
*
|
|
10
|
+
* 为什么不复用 @sleep2agi/agent-network 里那份:agent-node 与 agent-network 是**分别发布**的两个包,
|
|
11
|
+
* 彼此没有依赖;跨包相对路径 import 在发布后会断。语义必须一致,两边的单测都要钉住同一组数字。
|
|
12
|
+
*/
|
|
13
|
+
export declare function renameOverExistingSync(temp: string, path: string, rename?: (from: string, to: string) => void, sleep?: (ms: number) => void, platform?: string): void;
|