@cleocode/core 2026.9.25 → 2026.10.1
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/dist/admin/import-tasks.d.ts.map +1 -1
- package/dist/admin/import-tasks.js +5 -2
- package/dist/admin/import-tasks.js.map +1 -1
- package/dist/admin/import.d.ts.map +1 -1
- package/dist/admin/import.js +7 -2
- package/dist/admin/import.js.map +1 -1
- package/dist/build-provenance.json +2 -2
- package/dist/cloud/index.d.ts +1 -0
- package/dist/cloud/index.d.ts.map +1 -1
- package/dist/cloud/index.js +1 -0
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/nexus-attach.d.ts +94 -0
- package/dist/cloud/nexus-attach.d.ts.map +1 -0
- package/dist/cloud/nexus-attach.js +192 -0
- package/dist/cloud/nexus-attach.js.map +1 -0
- package/dist/cloud/nexus-auth.d.ts +41 -4
- package/dist/cloud/nexus-auth.d.ts.map +1 -1
- package/dist/cloud/nexus-auth.js +151 -38
- package/dist/cloud/nexus-auth.js.map +1 -1
- package/dist/cloud/nexus-cloud-status.d.ts +132 -0
- package/dist/cloud/nexus-cloud-status.d.ts.map +1 -0
- package/dist/cloud/nexus-cloud-status.js +440 -0
- package/dist/cloud/nexus-cloud-status.js.map +1 -0
- package/dist/cloud/nexus-cloud.d.ts +179 -0
- package/dist/cloud/nexus-cloud.d.ts.map +1 -0
- package/dist/cloud/nexus-cloud.js +296 -0
- package/dist/cloud/nexus-cloud.js.map +1 -0
- package/dist/cloud/nexus-credentials.js +2 -2
- package/dist/cloud/nexus-credentials.js.map +1 -1
- package/dist/cloud/nexus-device.d.ts +834 -0
- package/dist/cloud/nexus-device.d.ts.map +1 -0
- package/dist/cloud/nexus-device.js +1727 -0
- package/dist/cloud/nexus-device.js.map +1 -0
- package/dist/cloud/nexus-enrol.d.ts +241 -0
- package/dist/cloud/nexus-enrol.d.ts.map +1 -0
- package/dist/cloud/nexus-enrol.js +1163 -0
- package/dist/cloud/nexus-enrol.js.map +1 -0
- package/dist/cloud/nexus-link.d.ts +10 -0
- package/dist/cloud/nexus-link.d.ts.map +1 -1
- package/dist/cloud/nexus-link.js +172 -11
- package/dist/cloud/nexus-link.js.map +1 -1
- package/dist/cloud/nexus-logout.d.ts +114 -0
- package/dist/cloud/nexus-logout.d.ts.map +1 -0
- package/dist/cloud/nexus-logout.js +429 -0
- package/dist/cloud/nexus-logout.js.map +1 -0
- package/dist/cloud/signing.d.ts +20 -0
- package/dist/cloud/signing.d.ts.map +1 -1
- package/dist/cloud/signing.js +14 -0
- package/dist/cloud/signing.js.map +1 -1
- package/dist/crypto/credentials.d.ts +61 -0
- package/dist/crypto/credentials.d.ts.map +1 -1
- package/dist/crypto/credentials.js +154 -58
- package/dist/crypto/credentials.js.map +1 -1
- package/dist/docs/export-document.js +1072 -227
- package/dist/docs/export-document.js.map +3 -3
- package/dist/doctor/dependency-cycles.d.ts +41 -0
- package/dist/doctor/dependency-cycles.d.ts.map +1 -0
- package/dist/doctor/dependency-cycles.js +39 -0
- package/dist/doctor/dependency-cycles.js.map +1 -0
- package/dist/doctor/index.d.ts +2 -0
- package/dist/doctor/index.d.ts.map +1 -1
- package/dist/doctor/index.js +1 -0
- package/dist/doctor/index.js.map +1 -1
- package/dist/doctor/row-identity.d.ts +11 -0
- package/dist/doctor/row-identity.d.ts.map +1 -1
- package/dist/doctor/row-identity.js +67 -9
- package/dist/doctor/row-identity.js.map +1 -1
- package/dist/error-catalog.d.ts.map +1 -1
- package/dist/error-catalog.js +4 -0
- package/dist/error-catalog.js.map +1 -1
- package/dist/error-registry.d.ts.map +1 -1
- package/dist/error-registry.js +8 -0
- package/dist/error-registry.js.map +1 -1
- package/dist/llm/plugin-facade.js +1200 -355
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/nexus/workspace.d.ts.map +1 -1
- package/dist/nexus/workspace.js +54 -4
- package/dist/nexus/workspace.js.map +1 -1
- package/dist/orchestrate/lifecycle-ops.js +1 -1
- package/dist/orchestrate/lifecycle-ops.js.map +1 -1
- package/dist/orchestrate/pivot.d.ts.map +1 -1
- package/dist/orchestrate/pivot.js +4 -2
- package/dist/orchestrate/pivot.js.map +1 -1
- package/dist/orchestrate/query-ops.d.ts.map +1 -1
- package/dist/orchestrate/query-ops.js +3 -3
- package/dist/orchestrate/query-ops.js.map +1 -1
- package/dist/orchestrate/spawn-ops.js +1 -1
- package/dist/orchestrate/spawn-ops.js.map +1 -1
- package/dist/orchestration/index.js +1 -1
- package/dist/orchestration/index.js.map +1 -1
- package/dist/orchestration/lead-rollup.d.ts.map +1 -1
- package/dist/orchestration/lead-rollup.js +3 -3
- package/dist/orchestration/lead-rollup.js.map +1 -1
- package/dist/orchestration/parallel.js +1 -1
- package/dist/orchestration/parallel.js.map +1 -1
- package/dist/orchestration/wave-topic.d.ts +4 -2
- package/dist/orchestration/wave-topic.d.ts.map +1 -1
- package/dist/orchestration/wave-topic.js +6 -4
- package/dist/orchestration/wave-topic.js.map +1 -1
- package/dist/orchestration/waves.d.ts +2 -1
- package/dist/orchestration/waves.d.ts.map +1 -1
- package/dist/orchestration/waves.js +4 -3
- package/dist/orchestration/waves.js.map +1 -1
- package/dist/phases/index.d.ts.map +1 -1
- package/dist/phases/index.js +4 -2
- package/dist/phases/index.js.map +1 -1
- package/dist/selfimprove/fix-gen.js +1203 -358
- package/dist/selfimprove/fix-gen.js.map +3 -3
- package/dist/session/engine-ops.d.ts.map +1 -1
- package/dist/session/engine-ops.js +77 -49
- package/dist/session/engine-ops.js.map +1 -1
- package/dist/sessions/focus-state-store.d.ts +69 -23
- package/dist/sessions/focus-state-store.d.ts.map +1 -1
- package/dist/sessions/focus-state-store.js +113 -27
- package/dist/sessions/focus-state-store.js.map +1 -1
- package/dist/sessions/handoff.js +1 -1
- package/dist/sessions/handoff.js.map +1 -1
- package/dist/sessions/index.d.ts.map +1 -1
- package/dist/sessions/index.js +24 -13
- package/dist/sessions/index.js.map +1 -1
- package/dist/sessions/terminal-identity.d.ts +165 -17
- package/dist/sessions/terminal-identity.d.ts.map +1 -1
- package/dist/sessions/terminal-identity.js +341 -32
- package/dist/sessions/terminal-identity.js.map +1 -1
- package/dist/setup/sections/nexus-account.d.ts +8 -6
- package/dist/setup/sections/nexus-account.d.ts.map +1 -1
- package/dist/setup/sections/nexus-account.js +53 -9
- package/dist/setup/sections/nexus-account.js.map +1 -1
- package/dist/skills/orchestrator/startup.js +2 -2
- package/dist/skills/orchestrator/startup.js.map +1 -1
- package/dist/snapshot/index.d.ts +4 -0
- package/dist/snapshot/index.d.ts.map +1 -1
- package/dist/snapshot/index.js +50 -3
- package/dist/snapshot/index.js.map +1 -1
- package/dist/store/db-helpers.d.ts +15 -2
- package/dist/store/db-helpers.d.ts.map +1 -1
- package/dist/store/db-helpers.js +84 -3
- package/dist/store/db-helpers.js.map +1 -1
- package/dist/store/dependency-cycles.d.ts +164 -0
- package/dist/store/dependency-cycles.d.ts.map +1 -0
- package/dist/store/dependency-cycles.js +360 -0
- package/dist/store/dependency-cycles.js.map +1 -0
- package/dist/store/display-id-alias.d.ts +93 -37
- package/dist/store/display-id-alias.d.ts.map +1 -1
- package/dist/store/display-id-alias.js +590 -115
- package/dist/store/display-id-alias.js.map +1 -1
- package/dist/store/dual-scope-db.d.ts.map +1 -1
- package/dist/store/dual-scope-db.js +34 -7
- package/dist/store/dual-scope-db.js.map +1 -1
- package/dist/store/exodus/migrate.d.ts.map +1 -1
- package/dist/store/exodus/migrate.js +8 -1
- package/dist/store/exodus/migrate.js.map +1 -1
- package/dist/store/global-salt.d.ts +35 -0
- package/dist/store/global-salt.d.ts.map +1 -1
- package/dist/store/global-salt.js +136 -16
- package/dist/store/global-salt.js.map +1 -1
- package/dist/store/migration-sqlite.d.ts.map +1 -1
- package/dist/store/migration-sqlite.js +19 -11
- package/dist/store/migration-sqlite.js.map +1 -1
- package/dist/store/portable-bundle-scan.d.ts.map +1 -1
- package/dist/store/portable-bundle-scan.js +6 -0
- package/dist/store/portable-bundle-scan.js.map +1 -1
- package/dist/store/row-identity-registry.d.ts.map +1 -1
- package/dist/store/row-identity-registry.js +11 -3
- package/dist/store/row-identity-registry.js.map +1 -1
- package/dist/store/row-identity.d.ts +91 -1
- package/dist/store/row-identity.d.ts.map +1 -1
- package/dist/store/row-identity.js +276 -7
- package/dist/store/row-identity.js.map +1 -1
- package/dist/store/safety-data-accessor.d.ts +3 -2
- package/dist/store/safety-data-accessor.d.ts.map +1 -1
- package/dist/store/safety-data-accessor.js +5 -2
- package/dist/store/safety-data-accessor.js.map +1 -1
- package/dist/store/session-store.d.ts +63 -3
- package/dist/store/session-store.d.ts.map +1 -1
- package/dist/store/session-store.js +121 -8
- package/dist/store/session-store.js.map +1 -1
- package/dist/store/split-brain-import.d.ts.map +1 -1
- package/dist/store/split-brain-import.js +36 -0
- package/dist/store/split-brain-import.js.map +1 -1
- package/dist/store/sqlite-data-accessor.d.ts +50 -3
- package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
- package/dist/store/sqlite-data-accessor.js +246 -13
- package/dist/store/sqlite-data-accessor.js.map +1 -1
- package/dist/store/sync/replica.d.ts +34 -3
- package/dist/store/sync/replica.d.ts.map +1 -1
- package/dist/store/sync/replica.js +39 -2
- package/dist/store/sync/replica.js.map +1 -1
- package/dist/store/sync/schema.d.ts +6 -3
- package/dist/store/sync/schema.d.ts.map +1 -1
- package/dist/store/sync/schema.js +6 -3
- package/dist/store/sync/schema.js.map +1 -1
- package/dist/store/tasks-sqlite.d.ts.map +1 -1
- package/dist/store/tasks-sqlite.js +14 -2
- package/dist/store/tasks-sqlite.js.map +1 -1
- package/dist/store/umbrella-data-accessor.d.ts +3 -2
- package/dist/store/umbrella-data-accessor.d.ts.map +1 -1
- package/dist/store/umbrella-data-accessor.js +5 -2
- package/dist/store/umbrella-data-accessor.js.map +1 -1
- package/dist/system/health.d.ts +2 -0
- package/dist/system/health.d.ts.map +1 -1
- package/dist/system/health.js +54 -0
- package/dist/system/health.js.map +1 -1
- package/dist/task-work/index.d.ts.map +1 -1
- package/dist/task-work/index.js +9 -6
- package/dist/task-work/index.js.map +1 -1
- package/dist/tasks/analyze.d.ts.map +1 -1
- package/dist/tasks/analyze.js +3 -2
- package/dist/tasks/analyze.js.map +1 -1
- package/dist/tasks/evidence.d.ts +19 -1
- package/dist/tasks/evidence.d.ts.map +1 -1
- package/dist/tasks/evidence.js +79 -18
- package/dist/tasks/evidence.js.map +1 -1
- package/dist/tasks/infer-add-params.js +1 -1
- package/dist/tasks/infer-add-params.js.map +1 -1
- package/dist/tasks/task-context.d.ts.map +1 -1
- package/dist/tasks/task-context.js +3 -1
- package/dist/tasks/task-context.js.map +1 -1
- package/dist/tasks/task-import.d.ts.map +1 -1
- package/dist/tasks/task-import.js +11 -3
- package/dist/tasks/task-import.js.map +1 -1
- package/dist/tasks/task-next.d.ts +5 -1
- package/dist/tasks/task-next.d.ts.map +1 -1
- package/dist/tasks/task-next.js +7 -2
- package/dist/tasks/task-next.js.map +1 -1
- package/dist/validation/engine-ops.d.ts.map +1 -1
- package/dist/validation/engine-ops.js +3 -2
- package/dist/validation/engine-ops.js.map +1 -1
- package/dist/workgraph/scaffold-apply.d.ts.map +1 -1
- package/dist/workgraph/scaffold-apply.js +14 -5
- package/dist/workgraph/scaffold-apply.js.map +1 -1
- package/migrations/drizzle-cleo-project/20260930160000_t12886-dependency-cycle-guard/migration.sql +76 -0
- package/migrations/drizzle-cleo-project/20260930160000_t12886-dependency-cycle-guard/revert.sql +7 -0
- package/package.json +13 -13
- package/templates/CLEO-INJECTION.md +2 -2
- package/templates/CLEO-REFERENCE.md +1 -1
|
@@ -22,24 +22,40 @@
|
|
|
22
22
|
* in `session-id.ts`, whose values ARE CLEO ids). They are opaque identities
|
|
23
23
|
* that only mean something through a persisted binding.
|
|
24
24
|
*
|
|
25
|
-
* ##
|
|
25
|
+
* ## Harness-ancestor fallback (T12864)
|
|
26
26
|
*
|
|
27
27
|
* When no environment key is present, the identity falls back to the nearest
|
|
28
|
-
* ancestor
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
28
|
+
* ancestor that identifies ONE caller ({@link resolveAncestor}): a long-lived
|
|
29
|
+
* interactive or script shell (the terminal tab's shell, a CI step or cron
|
|
30
|
+
* script), or — past throwaway `sh -c` / `bash -c` layers — a KNOWN agent
|
|
31
|
+
* harness process ({@link KNOWN_HARNESSES}: Kimi, aider, …). Such harnesses run every tool call in a fresh `bash -c`, so the
|
|
32
|
+
* immediate parent changes on each call; the harness process does not. Any
|
|
33
|
+
* other process (a node / python host that may run several agents, a daemon
|
|
34
|
+
* spawning `cleo` directly) identifies nobody unless `CLEO_AGENT_ID` names the
|
|
35
|
+
* agent. Pid 1 / launchd / systemd / init, an unreadable shell command line or
|
|
36
|
+
* depth exhaustion also yield no key: the caller keeps the single-session guard.
|
|
37
|
+
*
|
|
38
|
+
* Env tab keys are inherited by every descendant, so when a harness (or a
|
|
39
|
+
* `CLEO_AGENT_ID` agent) runs below one, its anchor is appended as a more
|
|
40
|
+
* specific key — two harnesses in one ssh login or CI step stay apart.
|
|
41
|
+
*
|
|
42
|
+
* Before T12864 the fallback stopped at the first non-launcher ancestor, which
|
|
43
|
+
* for a harness is the per-call `bash -c` — a new key on every call, so a
|
|
44
|
+
* session started in one call was invisible to the next (T12530 therefore
|
|
45
|
+
* stopped treating it as identity).
|
|
35
46
|
*
|
|
36
47
|
* @module
|
|
37
48
|
* @task T12499
|
|
38
49
|
* @epic T12497
|
|
39
50
|
*/
|
|
40
51
|
import { PS_STABLE_ENV } from '@cleocode/contracts';
|
|
41
|
-
/**
|
|
42
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Where a terminal key comes from. `process` is a long-lived ancestor shell
|
|
54
|
+
* (tab tier) and `harness` one agent below it or anywhere (pane tier) — both
|
|
55
|
+
* T12864; `ppid` is the pre-T12864 per-call fallback, never produced any more
|
|
56
|
+
* and kept only so rows written before it still type-check.
|
|
57
|
+
*/
|
|
58
|
+
export type TerminalKeyKind = 'provider' | 'multiplexer' | 'terminal' | 'process' | 'harness' | 'ppid';
|
|
43
59
|
/**
|
|
44
60
|
* One row of the provider/terminal key map: an environment variable whose value
|
|
45
61
|
* identifies a single harness session, multiplexer pane or terminal tab.
|
|
@@ -48,7 +64,7 @@ export interface TerminalKeySource {
|
|
|
48
64
|
/** Environment variable carrying the identity value. */
|
|
49
65
|
readonly envVar: string;
|
|
50
66
|
/** Category of identity (drives precedence documentation only). */
|
|
51
|
-
readonly kind: Exclude<TerminalKeyKind, 'ppid'>;
|
|
67
|
+
readonly kind: Exclude<TerminalKeyKind, 'ppid' | 'process' | 'harness'>;
|
|
52
68
|
/** Harness / terminal that exports the variable. */
|
|
53
69
|
readonly origin: string;
|
|
54
70
|
/**
|
|
@@ -57,6 +73,12 @@ export interface TerminalKeySource {
|
|
|
57
73
|
* pid, session index) to stay unique across servers.
|
|
58
74
|
*/
|
|
59
75
|
readonly qualifierEnvVar?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Further qualifiers, applied after {@link qualifierEnvVar} (T12864). A
|
|
78
|
+
* GitHub Actions run id alone is shared by every job of the run, so it is
|
|
79
|
+
* qualified by the attempt and the job id.
|
|
80
|
+
*/
|
|
81
|
+
readonly extraQualifierEnvVars?: readonly string[];
|
|
60
82
|
}
|
|
61
83
|
/**
|
|
62
84
|
* The provider/terminal key map, in precedence order (T12499).
|
|
@@ -83,13 +105,48 @@ export declare const PPID_CHAIN_LAUNCHERS: ReadonlySet<string>;
|
|
|
83
105
|
* lock (T12506) renders start times identically.
|
|
84
106
|
*/
|
|
85
107
|
export { PS_STABLE_ENV };
|
|
86
|
-
/** Maximum number of ancestors the
|
|
87
|
-
export declare const PPID_CHAIN_MAX_DEPTH:
|
|
108
|
+
/** Maximum number of ancestors the harness-ancestor walk inspects (T12864). */
|
|
109
|
+
export declare const PPID_CHAIN_MAX_DEPTH: 12;
|
|
110
|
+
/**
|
|
111
|
+
* Agent harnesses recognised by the ancestor walk (T12864), by PROGRAM name:
|
|
112
|
+
* the executable, or the script / `-m` module a `node` / `python` runtime runs
|
|
113
|
+
* (see {@link programName}). A listed process becomes a caller identity, even
|
|
114
|
+
* though it runs every tool call in a fresh `bash -c`.
|
|
115
|
+
*
|
|
116
|
+
* List ONLY processes that host exactly ONE agent session for their whole
|
|
117
|
+
* life. A process that hosts several (an IDE extension host, CrewAI,
|
|
118
|
+
* LangGraph, OpenHands, a server that clients attach to) must NOT be listed:
|
|
119
|
+
* its agents would share one session. Such hosts set `CLEO_AGENT_ID` per agent.
|
|
120
|
+
* Avoid names that other common tools also use.
|
|
121
|
+
*
|
|
122
|
+
* To add a harness: append the program name its process shows (check with
|
|
123
|
+
* `ps -o args= -p <pid>` while it runs a tool call), after confirming it is
|
|
124
|
+
* single-agent.
|
|
125
|
+
*
|
|
126
|
+
* Deliberately NOT listed:
|
|
127
|
+
* - `opencode`: `opencode serve` / `opencode web` run one server process that
|
|
128
|
+
* hosts many sessions and clients (`opencode attach`, `opencode run
|
|
129
|
+
* --attach`, `GET /session/status` for all sessions; opencode.ai/docs/server),
|
|
130
|
+
* and tools run in that server process.
|
|
131
|
+
* - `goose`: collides with pressly/goose, the database migration tool.
|
|
132
|
+
*/
|
|
133
|
+
export declare const KNOWN_HARNESSES: ReadonlySet<string>;
|
|
134
|
+
/**
|
|
135
|
+
* Thin wrappers between a caller and `cleo` (T12864). They live exactly as long
|
|
136
|
+
* as the command they wrap, so the walk skips them. Matched on program name, so
|
|
137
|
+
* `npm exec …` (npx's process title) and `node …/npm-cli.js` both match.
|
|
138
|
+
*/
|
|
139
|
+
export declare const ANCESTOR_WRAPPERS: ReadonlySet<string>;
|
|
140
|
+
/**
|
|
141
|
+
* The system's init / service manager (T12864). An ancestor walk that reaches
|
|
142
|
+
* one of these (or pid 1) found no caller-owned process.
|
|
143
|
+
*/
|
|
144
|
+
export declare const INIT_PROCESSES: ReadonlySet<string>;
|
|
88
145
|
/** One resolved identity key for the calling terminal. */
|
|
89
146
|
export interface TerminalKey {
|
|
90
|
-
/** Opaque, stable binding key (`env:<VAR>=<value
|
|
147
|
+
/** Opaque, stable binding key (`env:<VAR>=<value>`, `proc:<pid>@<start>` or `harness:…`). */
|
|
91
148
|
readonly key: string;
|
|
92
|
-
/** Environment variable name, or `'
|
|
149
|
+
/** Environment variable name, or `'process'` for the harness-ancestor fallback. */
|
|
93
150
|
readonly source: string;
|
|
94
151
|
/** Identity category. */
|
|
95
152
|
readonly kind: TerminalKeyKind;
|
|
@@ -107,6 +164,8 @@ export interface ProcessAncestor {
|
|
|
107
164
|
}
|
|
108
165
|
/** Reads one process-table entry; returns `null` when the pid is unknown. */
|
|
109
166
|
export type ProcessLookup = (pid: number) => ProcessAncestor | null;
|
|
167
|
+
/** Reads a process's full command line; returns `null` when it cannot be read (T12864). */
|
|
168
|
+
export type ProcessArgsLookup = (pid: number) => string | null;
|
|
110
169
|
/** Inputs for {@link resolveTerminalKeys}; every field defaults to the live process. */
|
|
111
170
|
export interface ResolveTerminalKeysOptions {
|
|
112
171
|
/** Environment to read (defaults to `process.env`). */
|
|
@@ -115,6 +174,8 @@ export interface ResolveTerminalKeysOptions {
|
|
|
115
174
|
readonly ppid?: number;
|
|
116
175
|
/** Process-table reader (defaults to {@link readProcessEntry}). */
|
|
117
176
|
readonly lookupProcess?: ProcessLookup;
|
|
177
|
+
/** Command-line reader for shells (defaults to {@link readProcessArgs}). */
|
|
178
|
+
readonly lookupArgs?: ProcessArgsLookup;
|
|
118
179
|
}
|
|
119
180
|
/**
|
|
120
181
|
* Read one entry from the OS process table via `ps` (POSIX only).
|
|
@@ -126,6 +187,91 @@ export interface ResolveTerminalKeysOptions {
|
|
|
126
187
|
* @returns The process entry, or `null`.
|
|
127
188
|
*/
|
|
128
189
|
export declare function readProcessEntry(pid: number): ProcessAncestor | null;
|
|
190
|
+
/**
|
|
191
|
+
* Read a process's command line via `ps -o args=` (POSIX only, T12864).
|
|
192
|
+
*
|
|
193
|
+
* Tells a throwaway `sh -c '…'` from a long-lived shell, and names the program
|
|
194
|
+
* a runtime runs. Returns `null` on Windows, for an unknown pid, or when `ps`
|
|
195
|
+
* fails.
|
|
196
|
+
*
|
|
197
|
+
* @param pid - Process id to inspect.
|
|
198
|
+
* @returns The command line, or `null`.
|
|
199
|
+
*/
|
|
200
|
+
export declare function readProcessArgs(pid: number): string | null;
|
|
201
|
+
/**
|
|
202
|
+
* The program a process runs, from its command line (T12864): the executable's
|
|
203
|
+
* base name, or — for a language runtime ({@link RUNTIME_PATTERN}) — the
|
|
204
|
+
* `-m` module or script it runs (extension stripped). Matches on the FIRST
|
|
205
|
+
* word, so a process title such as `npm exec cleo` is `npm`.
|
|
206
|
+
*
|
|
207
|
+
* @param commandLine - `ps -o args=` output (or the bare command name).
|
|
208
|
+
* @returns The program name.
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* programName('/usr/bin/python3.12 -m aider --yes'); // 'aider'
|
|
212
|
+
* programName('npm exec cleo start T1'); // 'npm'
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
export declare function programName(commandLine: string): string;
|
|
216
|
+
/**
|
|
217
|
+
* Whether a shell's command line runs a single command string (`sh -c '…'`,
|
|
218
|
+
* `bash -lc '…'`, `pwsh -Command …`) — a throwaway shell that exits with the
|
|
219
|
+
* command — rather than an interactive or script shell that outlives it (T12864).
|
|
220
|
+
*
|
|
221
|
+
* POSIX-style shells: options are read up to the first operand. `-c`,
|
|
222
|
+
* `--command` / `--commands` (fish, nu), or a short-option cluster containing
|
|
223
|
+
* `c` means command mode; the arguments of `-o` / `+o` / `-O` / `+O` /
|
|
224
|
+
* `--rcfile` / `--init-file` are skipped rather than read as the operand.
|
|
225
|
+
* PowerShell: any `-Command` / `-c` / `-EncodedCommand` / `-CommandWithArgs`.
|
|
226
|
+
*
|
|
227
|
+
* @param args - The shell's full command line.
|
|
228
|
+
* @returns `true` for a command-string shell.
|
|
229
|
+
*/
|
|
230
|
+
export declare function isCommandStringShell(args: string): boolean;
|
|
231
|
+
/** What the ancestor walk anchored on (T12864). */
|
|
232
|
+
export interface AncestorAnchor {
|
|
233
|
+
/** The anchoring process. */
|
|
234
|
+
readonly entry: ProcessAncestor;
|
|
235
|
+
/** Its program name ({@link programName}). */
|
|
236
|
+
readonly program: string;
|
|
237
|
+
/**
|
|
238
|
+
* `shell` — a long-lived interactive / login / script shell (the terminal's
|
|
239
|
+
* own identity); `harness` — a {@link KNOWN_HARNESSES} process; `host` — any
|
|
240
|
+
* other process, anchored ONLY because `CLEO_AGENT_ID` names the agent. Set
|
|
241
|
+
* `CLEO_AGENT_ID` only in a LONG-LIVED host: with it, the first non-harness
|
|
242
|
+
* ancestor anchors, even a short-lived `make`, and the key then changes on
|
|
243
|
+
* every call.
|
|
244
|
+
*/
|
|
245
|
+
readonly type: 'shell' | 'harness' | 'host';
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Walk to the nearest ancestor that identifies ONE caller across its `cleo`
|
|
249
|
+
* calls (T12864).
|
|
250
|
+
*
|
|
251
|
+
* From `cleo`'s parent upwards, by program name ({@link programName}):
|
|
252
|
+
*
|
|
253
|
+
* - wrappers ({@link ANCESTOR_WRAPPERS}) are skipped;
|
|
254
|
+
* - a shell that is not a command-string shell ({@link isCommandStringShell})
|
|
255
|
+
* is long-lived — one per terminal tab, CI step or script: `shell`;
|
|
256
|
+
* - a command-string shell (`bash -c`) is skipped;
|
|
257
|
+
* - a {@link KNOWN_HARNESSES} process is `harness`;
|
|
258
|
+
* - any other process ends the walk: it may host SEVERAL agents (a node or
|
|
259
|
+
* python orchestrator, an IDE extension host, a daemon spawning `cleo`
|
|
260
|
+
* directly), so it identifies nobody — unless `agentId` (`CLEO_AGENT_ID`)
|
|
261
|
+
* names the agent, which makes it a `host` anchor.
|
|
262
|
+
*
|
|
263
|
+
* Returns `null` — no identity, the single-session guard applies — at pid 1 or
|
|
264
|
+
* an init process, when a shell's command line cannot be read, when the
|
|
265
|
+
* process table cannot be read, or past {@link PPID_CHAIN_MAX_DEPTH}.
|
|
266
|
+
*
|
|
267
|
+
* @param ppid - Parent pid to start from.
|
|
268
|
+
* @param lookupProcess - Process-table reader.
|
|
269
|
+
* @param lookupArgs - Command-line reader.
|
|
270
|
+
* @param agentId - `CLEO_AGENT_ID`, when set.
|
|
271
|
+
* @returns The anchor, or `null`.
|
|
272
|
+
* @task T12864
|
|
273
|
+
*/
|
|
274
|
+
export declare function resolveAncestor(ppid: number, lookupProcess: ProcessLookup, lookupArgs: ProcessArgsLookup, agentId?: string | null): AncestorAnchor | null;
|
|
129
275
|
/** Interactive / script shells skipped by {@link resolveOwnerProcess}, beyond the launchers. */
|
|
130
276
|
export declare const OWNER_PROCESS_SHELLS: ReadonlySet<string>;
|
|
131
277
|
/** Maximum number of ancestors {@link resolveOwnerProcess} inspects. */
|
|
@@ -150,8 +296,10 @@ export declare function resolveOwnerProcess(ppid?: number, lookupProcess?: Proce
|
|
|
150
296
|
* Resolve the calling terminal's identity keys, most specific first (T12499).
|
|
151
297
|
*
|
|
152
298
|
* Every {@link TERMINAL_KEY_SOURCES} row whose variable is set contributes one
|
|
153
|
-
* key.
|
|
154
|
-
*
|
|
299
|
+
* key. Unless a provider key is present, the ancestor walk
|
|
300
|
+
* ({@link resolveAncestor}) then runs: with no env key its anchor is the only
|
|
301
|
+
* key; under env keys an agent-level anchor (a harness, or `CLEO_AGENT_ID`) is
|
|
302
|
+
* appended as the most specific key. The walk is memoised per process.
|
|
155
303
|
*
|
|
156
304
|
* Synchronous and database-free; binding persistence and lookup live in
|
|
157
305
|
* `store/session-binding-store.ts`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-identity.d.ts","sourceRoot":"","sources":["../../src/sessions/terminal-identity.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"terminal-identity.d.ts","sourceRoot":"","sources":["../../src/sessions/terminal-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;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