@0gfoundation/0g-agentdna 0.4.0 → 0.5.0
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/GUIDE.md +190 -40
- package/OPERATORS.md +164 -0
- package/OPERATORS.zh.md +141 -0
- package/PROVIDERS.md +6 -0
- package/PROVIDERS.zh.md +3 -1
- package/README.md +84 -11
- package/dist/AgentClient.d.ts +374 -26
- package/dist/AgentClient.d.ts.map +1 -1
- package/dist/AgentClient.js +323 -40
- package/dist/AgentClient.js.map +1 -1
- package/dist/AgenticID.d.ts +170 -80
- package/dist/AgenticID.d.ts.map +1 -1
- package/dist/AgenticID.js +300 -42
- package/dist/AgenticID.js.map +1 -1
- package/dist/AttestorClient.d.ts +115 -31
- package/dist/AttestorClient.d.ts.map +1 -1
- package/dist/AttestorClient.js +276 -56
- package/dist/AttestorClient.js.map +1 -1
- package/dist/Credentials.d.ts +574 -0
- package/dist/Credentials.d.ts.map +1 -0
- package/dist/Credentials.js +838 -0
- package/dist/Credentials.js.map +1 -0
- package/dist/Operators.d.ts +60 -0
- package/dist/Operators.d.ts.map +1 -0
- package/dist/Operators.js +38 -0
- package/dist/Operators.js.map +1 -0
- package/dist/Providers.d.ts +13 -0
- package/dist/Providers.d.ts.map +1 -1
- package/dist/Providers.js +20 -1
- package/dist/Providers.js.map +1 -1
- package/dist/Releases.d.ts +51 -0
- package/dist/Releases.d.ts.map +1 -0
- package/dist/Releases.js +72 -0
- package/dist/Releases.js.map +1 -0
- package/dist/ReputationClient.d.ts +47 -3
- package/dist/ReputationClient.d.ts.map +1 -1
- package/dist/ReputationClient.js +204 -78
- package/dist/ReputationClient.js.map +1 -1
- package/dist/ServeProof.d.ts +70 -23
- package/dist/ServeProof.d.ts.map +1 -1
- package/dist/ServeProof.js +94 -35
- package/dist/ServeProof.js.map +1 -1
- package/dist/ServeSession.d.ts +17 -2
- package/dist/ServeSession.d.ts.map +1 -1
- package/dist/ServeSession.js +77 -9
- package/dist/ServeSession.js.map +1 -1
- package/dist/Settings.d.ts +25 -1
- package/dist/Settings.d.ts.map +1 -1
- package/dist/Settings.js +53 -1
- package/dist/Settings.js.map +1 -1
- package/dist/TrustRegistry.d.ts +28 -0
- package/dist/TrustRegistry.d.ts.map +1 -0
- package/dist/TrustRegistry.js +67 -0
- package/dist/TrustRegistry.js.map +1 -0
- package/dist/abi.d.ts +346 -34
- package/dist/abi.d.ts.map +1 -1
- package/dist/abi.js +150 -30
- package/dist/abi.js.map +1 -1
- package/dist/cli/attach.d.ts +79 -0
- package/dist/cli/attach.d.ts.map +1 -0
- package/dist/cli/attach.js +253 -0
- package/dist/cli/attach.js.map +1 -0
- package/dist/cli/commands/cells.d.ts +45 -0
- package/dist/cli/commands/cells.d.ts.map +1 -1
- package/dist/cli/commands/cells.js +77 -0
- package/dist/cli/commands/cells.js.map +1 -1
- package/dist/cli/commands/cred.d.ts +12 -0
- package/dist/cli/commands/cred.d.ts.map +1 -0
- package/dist/cli/commands/cred.js +43 -0
- package/dist/cli/commands/cred.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- package/dist/cli/commands/doctor.js +44 -35
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/interactive.d.ts +597 -21
- package/dist/cli/commands/interactive.d.ts.map +1 -1
- package/dist/cli/commands/interactive.js +5082 -1323
- package/dist/cli/commands/interactive.js.map +1 -1
- package/dist/cli/commands/list.d.ts +5 -5
- package/dist/cli/commands/list.d.ts.map +1 -1
- package/dist/cli/commands/list.js +21 -26
- package/dist/cli/commands/list.js.map +1 -1
- package/dist/cli/commands/providers.d.ts +4 -0
- package/dist/cli/commands/providers.d.ts.map +1 -1
- package/dist/cli/commands/providers.js +19 -5
- package/dist/cli/commands/providers.js.map +1 -1
- package/dist/cli/commands/releases.d.ts +13 -0
- package/dist/cli/commands/releases.d.ts.map +1 -0
- package/dist/cli/commands/releases.js +65 -0
- package/dist/cli/commands/releases.js.map +1 -0
- package/dist/cli/commands/settings.d.ts +5 -0
- package/dist/cli/commands/settings.d.ts.map +1 -1
- package/dist/cli/commands/settings.js +70 -24
- package/dist/cli/commands/settings.js.map +1 -1
- package/dist/cli/commands/status.d.ts +2 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +22 -19
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/config.d.ts +48 -1
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +114 -5
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/credentials.d.ts +179 -0
- package/dist/cli/credentials.d.ts.map +1 -0
- package/dist/cli/credentials.js +1443 -0
- package/dist/cli/credentials.js.map +1 -0
- package/dist/cli/download.d.ts +21 -0
- package/dist/cli/download.d.ts.map +1 -0
- package/dist/cli/download.js +89 -0
- package/dist/cli/download.js.map +1 -0
- package/dist/cli/env.d.ts +6 -0
- package/dist/cli/env.d.ts.map +1 -1
- package/dist/cli/env.js +18 -6
- package/dist/cli/env.js.map +1 -1
- package/dist/cli/envelope.d.ts +4 -2
- package/dist/cli/envelope.d.ts.map +1 -1
- package/dist/cli/envelope.js +10 -6
- package/dist/cli/envelope.js.map +1 -1
- package/dist/cli/errors.d.ts +45 -1
- package/dist/cli/errors.d.ts.map +1 -1
- package/dist/cli/errors.js +77 -0
- package/dist/cli/errors.js.map +1 -1
- package/dist/cli/inference.d.ts.map +1 -1
- package/dist/cli/inference.js +7 -0
- package/dist/cli/inference.js.map +1 -1
- package/dist/cli/inkView.d.ts +341 -0
- package/dist/cli/inkView.d.ts.map +1 -0
- package/dist/cli/inkView.js +1019 -0
- package/dist/cli/inkView.js.map +1 -0
- package/dist/cli/legacy/modelKey.d.ts +24 -0
- package/dist/cli/legacy/modelKey.d.ts.map +1 -0
- package/dist/cli/legacy/modelKey.js +32 -0
- package/dist/cli/legacy/modelKey.js.map +1 -0
- package/dist/cli/livePrompt.d.ts +212 -0
- package/dist/cli/livePrompt.d.ts.map +1 -0
- package/dist/cli/livePrompt.js +576 -0
- package/dist/cli/livePrompt.js.map +1 -0
- package/dist/cli/main.js +206 -72
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/modelkey.d.ts +64 -0
- package/dist/cli/modelkey.d.ts.map +1 -0
- package/dist/cli/modelkey.js +113 -0
- package/dist/cli/modelkey.js.map +1 -0
- package/dist/cli/outboxSync.d.ts +51 -0
- package/dist/cli/outboxSync.d.ts.map +1 -0
- package/dist/cli/outboxSync.js +210 -0
- package/dist/cli/outboxSync.js.map +1 -0
- package/dist/cli/plain.d.ts +46 -0
- package/dist/cli/plain.d.ts.map +1 -0
- package/dist/cli/plain.js +260 -0
- package/dist/cli/plain.js.map +1 -0
- package/dist/cli/proofs.d.ts +5 -0
- package/dist/cli/proofs.d.ts.map +1 -1
- package/dist/cli/proofs.js +20 -0
- package/dist/cli/proofs.js.map +1 -1
- package/dist/cli/ref.d.ts.map +1 -1
- package/dist/cli/ref.js +3 -2
- package/dist/cli/ref.js.map +1 -1
- package/dist/cli/releaseNotice.d.ts +64 -0
- package/dist/cli/releaseNotice.d.ts.map +1 -0
- package/dist/cli/releaseNotice.js +194 -0
- package/dist/cli/releaseNotice.js.map +1 -0
- package/dist/cli/sdk.d.ts +18 -0
- package/dist/cli/sdk.d.ts.map +1 -1
- package/dist/cli/sdk.js +99 -1
- package/dist/cli/sdk.js.map +1 -1
- package/dist/cli/settings.d.ts +87 -6
- package/dist/cli/settings.d.ts.map +1 -1
- package/dist/cli/settings.js +270 -18
- package/dist/cli/settings.js.map +1 -1
- package/dist/cli/textfit.d.ts +28 -0
- package/dist/cli/textfit.d.ts.map +1 -0
- package/dist/cli/textfit.js +111 -0
- package/dist/cli/textfit.js.map +1 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/context.d.ts +26 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -0
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +19 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -2
- package/dist/index.js.map +1 -1
- package/dist/legacy/modelKey.d.ts +67 -0
- package/dist/legacy/modelKey.d.ts.map +1 -0
- package/dist/legacy/modelKey.js +80 -0
- package/dist/legacy/modelKey.js.map +1 -0
- package/dist/legacy/serveProofV1.d.ts +56 -0
- package/dist/legacy/serveProofV1.d.ts.map +1 -0
- package/dist/legacy/serveProofV1.js +91 -0
- package/dist/legacy/serveProofV1.js.map +1 -0
- package/dist/provider-catalog.json +3 -2
- package/dist/secretEnv.d.ts +18 -3
- package/dist/secretEnv.d.ts.map +1 -1
- package/dist/secretEnv.js +16 -2
- package/dist/secretEnv.js.map +1 -1
- package/dist/types.d.ts +63 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/viemErrors.d.ts +30 -0
- package/dist/viemErrors.d.ts.map +1 -0
- package/dist/viemErrors.js +36 -0
- package/dist/viemErrors.js.map +1 -0
- package/package.json +5 -1
- package/src/AgentClient.ts +622 -68
- package/src/AgenticID.ts +345 -56
- package/src/AttestorClient.ts +330 -83
- package/src/Credentials.ts +1027 -0
- package/src/Operators.ts +71 -0
- package/src/Providers.ts +20 -0
- package/src/Releases.ts +95 -0
- package/src/ReputationClient.ts +231 -79
- package/src/ServeProof.ts +123 -39
- package/src/ServeSession.ts +91 -9
- package/src/Settings.ts +61 -1
- package/src/TrustRegistry.ts +75 -0
- package/src/abi.ts +153 -30
- package/src/cli/attach.ts +257 -0
- package/src/cli/commands/cells.ts +104 -0
- package/src/cli/commands/cred.ts +44 -0
- package/src/cli/commands/doctor.ts +45 -37
- package/src/cli/commands/interactive.ts +4120 -664
- package/src/cli/commands/list.ts +21 -30
- package/src/cli/commands/providers.ts +17 -4
- package/src/cli/commands/releases.ts +60 -0
- package/src/cli/commands/settings.ts +75 -28
- package/src/cli/commands/status.ts +24 -21
- package/src/cli/config.ts +119 -4
- package/src/cli/credentials.ts +1379 -0
- package/src/cli/download.ts +80 -0
- package/src/cli/env.ts +22 -7
- package/src/cli/envelope.ts +10 -6
- package/src/cli/errors.ts +92 -0
- package/src/cli/inference.ts +8 -1
- package/src/cli/inkView.ts +969 -0
- package/src/cli/legacy/modelKey.ts +35 -0
- package/src/cli/livePrompt.ts +615 -0
- package/src/cli/main.ts +206 -76
- package/src/cli/modelkey.ts +124 -0
- package/src/cli/outboxSync.ts +231 -0
- package/src/cli/plain.ts +260 -0
- package/src/cli/proofs.ts +27 -0
- package/src/cli/ref.ts +5 -4
- package/src/cli/releaseNotice.ts +200 -0
- package/src/cli/sdk.ts +87 -7
- package/src/cli/settings.ts +272 -22
- package/src/cli/textfit.ts +95 -0
- package/src/constants.ts +1 -1
- package/src/context.ts +28 -0
- package/src/index.ts +50 -7
- package/src/legacy/modelKey.ts +80 -0
- package/src/legacy/serveProofV1.ts +124 -0
- package/src/provider-catalog.json +3 -2
- package/src/secretEnv.ts +18 -3
- package/src/types.ts +60 -1
- package/src/viemErrors.ts +39 -0
|
@@ -13,7 +13,10 @@
|
|
|
13
13
|
* check for a key and point you at `login` if it's missing.
|
|
14
14
|
*/
|
|
15
15
|
import * as readline from 'node:readline';
|
|
16
|
-
import type {
|
|
16
|
+
import type { AgenticID } from '../../AgenticID';
|
|
17
|
+
import type { AgentClient, AgentInboxMessage, AgentSession, AgentSchedule, AgentActivityInfo, HarnessTask, HarnessTaskRecord, HarnessTaskSummary, SteerState } from '../../AgentClient';
|
|
18
|
+
import type { SignatureRecord } from '../../types';
|
|
19
|
+
import { type Staged } from '../attach';
|
|
17
20
|
/** -1/0/1 numeric dot-compare ("0.1.9" < "0.1.10"). Exported for tests —
|
|
18
21
|
* a wrong compare either nags forever or never hints. */
|
|
19
22
|
export declare function compareVersions(a: string, b: string): number;
|
|
@@ -60,6 +63,12 @@ export declare function makeBrake(getClient: () => {
|
|
|
60
63
|
}>;
|
|
61
64
|
} | null | undefined, print: (line: string) => void, seat: (failure: string, reclaimedHint: string, leavesWhat?: string) => Promise<'reclaimed' | 'left' | null>, seatPromptPending: () => boolean): () => void;
|
|
62
65
|
export declare function brakeInterruptLine(e: unknown): string;
|
|
66
|
+
/**
|
|
67
|
+
* An error in the words a person reads: viem's first line (its short
|
|
68
|
+
* message), an HTTP error's message without the request detail; no stack,
|
|
69
|
+
* no raw call arguments. Exported for the tests.
|
|
70
|
+
*/
|
|
71
|
+
export declare function plainError(e: unknown): string;
|
|
63
72
|
/**
|
|
64
73
|
* The shared catch for a gated-POST failure: displaced → the seat handler
|
|
65
74
|
* (which prompts and may reclaim); anything else → the caller's raw line.
|
|
@@ -83,44 +92,132 @@ export declare function inFlightIds(rows: Array<{
|
|
|
83
92
|
id: string;
|
|
84
93
|
status: string;
|
|
85
94
|
}>): string[];
|
|
95
|
+
/** A span of seconds, short: 12s, 4m, 3h, 2d. */
|
|
96
|
+
/** One line for a record of the agent's sign socket (`/signatures`). */
|
|
97
|
+
export declare function renderSignature(r: SignatureRecord): string;
|
|
86
98
|
/**
|
|
87
|
-
* The /
|
|
99
|
+
* The /activities table over the agent's activity list: BY is who does the work
|
|
88
100
|
* (the main agent or a subagent), FOR is who asked (you, a finished job, a
|
|
89
101
|
* reminder, the agent itself). Ids print whole: they are what /result and
|
|
90
102
|
* /cancel take. Exported for the tests.
|
|
91
103
|
*/
|
|
92
|
-
export declare function renderTaskTable(tasks: AgentTaskInfo[], nowMs: number): string[];
|
|
93
104
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
105
|
+
* Who asked for an activity, as /activities' FOR column says it. A command
|
|
106
|
+
* or subagent: `you` when the turn that started it was the owner's
|
|
107
|
+
* (`parent_trigger: user`, 0g-harness #12 on), `agent` otherwise. An older
|
|
108
|
+
* harness names no parent turn; there one started while only the owner's
|
|
109
|
+
* turns ran (by their start and end) counts as the owner's. Exported for the tests.
|
|
96
110
|
*/
|
|
111
|
+
export declare function askedFor(t: AgentActivityInfo, all: readonly AgentActivityInfo[], nowSec: number): string;
|
|
112
|
+
/** Ids as a list shows them: a long one (a uuid in it) by its first 13
|
|
113
|
+
* characters (`resp_4702745b`, `bash-c917aa00`), longer where two would read
|
|
114
|
+
* the same; one of 20 characters or fewer (`task-weekly-report`) whole.
|
|
115
|
+
* /result, /cancel and /tasks take a unique start of an id. Exported for the tests. */
|
|
116
|
+
export declare function shortIds(ids: readonly string[]): string[];
|
|
117
|
+
export declare function renderActivityTable(tasks: AgentActivityInfo[], nowMs: number, width?: number): string[];
|
|
118
|
+
/** The /tasks list: id, state, open records, age, title. Exported for the tests. */
|
|
119
|
+
export declare function renderTaskTable(tasks: HarnessTask[], nowMs: number, width?: number): string[];
|
|
120
|
+
/**
|
|
121
|
+
* One outcome record as the CLI shows it: a question with its options (the
|
|
122
|
+
* recommended one starred), an action as steps, or a report. Every field is
|
|
123
|
+
* the agent's text, cleaned for the terminal. Exported for the tests.
|
|
124
|
+
*/
|
|
125
|
+
export declare function renderTaskRecord(r: HarnessTaskRecord): string[];
|
|
126
|
+
/** /tasks show: the task's state, its last run and its records. Exported for the tests. */
|
|
127
|
+
export declare function renderTask(t: HarnessTask): string[];
|
|
97
128
|
export declare function renderInboxMessage(m: AgentInboxMessage): string;
|
|
98
129
|
/** The /schedules lines: id, how often, when next, the reminder's text.
|
|
99
130
|
* Exported for the tests. */
|
|
131
|
+
/** "just now", "5 min ago", "3 h ago", "2 d ago": how long since `atMs`. */
|
|
132
|
+
export declare function agoText(atMs: number, nowMs: number): string;
|
|
133
|
+
/**
|
|
134
|
+
* What Tab offers after `/sessions`: its subcommands, and `switch <short id>`
|
|
135
|
+
* and `switch <title>` for each session in `list` (as {@link orderSessions}
|
|
136
|
+
* orders them).
|
|
137
|
+
*/
|
|
138
|
+
export declare function sessionCompletions(list: readonly AgentSession[], rest?: string, shown?: readonly ShownSession[] | null): string[];
|
|
139
|
+
/** One row of a `/sessions` listing as shown: its id, and its title as the list prints it. */
|
|
140
|
+
export interface ShownSession {
|
|
141
|
+
id: string;
|
|
142
|
+
title: string;
|
|
143
|
+
}
|
|
144
|
+
/** The listing's rows in the order `/sessions` numbers them. */
|
|
145
|
+
export declare function shownSessions(list: readonly AgentSession[]): ShownSession[];
|
|
146
|
+
/** Sessions as `/sessions` numbers them: the most recently active first. */
|
|
147
|
+
export declare function orderSessions(list: readonly AgentSession[]): AgentSession[];
|
|
148
|
+
/** A session's id as the list shows it: owner-chat whole, others their first 13 characters (`sess-5d25f787`). */
|
|
149
|
+
export declare function shortSessionId(id: string): string;
|
|
150
|
+
/**
|
|
151
|
+
* The `/sessions` listing: a number to switch by, the short id, its state,
|
|
152
|
+
* when it was last active, and its title (the harness names a session after
|
|
153
|
+
* its first message), `*` on the one chat goes to.
|
|
154
|
+
*/
|
|
155
|
+
export declare function renderSessionList(list: readonly AgentSession[], current: string, nowMs: number, width?: number): string[];
|
|
156
|
+
/**
|
|
157
|
+
* The session `/sessions switch <arg>` means: a number counts in the list
|
|
158
|
+
* the owner last saw (`shown`; the title Tab adds after it is ignored),
|
|
159
|
+
* else an id, id prefix or words of a title. `number` without `shown`: no
|
|
160
|
+
* list was shown yet; `gone`: the one shown under that number is no more.
|
|
161
|
+
*/
|
|
162
|
+
export declare function pickSession(list: readonly AgentSession[], arg: string, shown?: readonly ShownSession[] | null): {
|
|
163
|
+
hit?: AgentSession;
|
|
164
|
+
number?: number;
|
|
165
|
+
gone?: ShownSession;
|
|
166
|
+
};
|
|
100
167
|
export declare function renderSchedules(list: AgentSchedule[], nowMs: number): string[];
|
|
101
168
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
169
|
+
* A task's run ending, as the session prints it between prompts: where the
|
|
170
|
+
* task rests and what its last record says. Only runs ending somewhere the
|
|
171
|
+
* owner acts on (a question, an action, a report, a failure) are shown.
|
|
172
|
+
* Exported for the tests.
|
|
173
|
+
*/
|
|
174
|
+
export declare function renderTaskNotice(t: HarnessTaskSummary): string | null;
|
|
175
|
+
/** What /inbox (or /notices) says when there is nothing to show; all: `/inbox all`. */
|
|
176
|
+
export declare function noNoticesText(all: boolean): string;
|
|
177
|
+
/** /files' heading for a listing (empty: what it says instead). */
|
|
178
|
+
export declare function filesText(dir: 'outbox' | 'inbox', empty: boolean, savedTo?: string, saved?: readonly string[]): string;
|
|
179
|
+
/**
|
|
180
|
+
* Follows one agent's notices (its inbox) for a session: first the messages
|
|
181
|
+
* that came in while nobody was looking, then each new one as the agent's
|
|
182
|
+
* live feed announces it. `show` prints a rendered message, now or at the
|
|
183
|
+
* next prompt, and calls `shown` once it is on screen (`count`: how many
|
|
184
|
+
* notices the text holds); the message is acked then, so
|
|
106
185
|
* another window does not show it again. A message is shown once per feed.
|
|
107
186
|
* `follow` is called with the session's current client before every prompt
|
|
108
187
|
* and restarts the feed when the client changed (/start, /reset); an agent
|
|
109
188
|
* without an inbox gets no feed. Exported for the tests.
|
|
110
189
|
*/
|
|
111
|
-
export declare function makeInboxFeed(show: (text: string, shown: () => void) => void): {
|
|
190
|
+
export declare function makeInboxFeed(show: (text: string, shown: () => void, count: number) => void): {
|
|
112
191
|
follow(client: AgentClient | undefined): void;
|
|
113
192
|
stop(): void;
|
|
114
193
|
};
|
|
194
|
+
/**
|
|
195
|
+
* Completes the words after `cred <agent>` or `/cred`: the subcommand, then
|
|
196
|
+
* an entry name (`model` included), then `k=v` options with their known
|
|
197
|
+
* values. `words` ends with the word being typed; `names` are the entries
|
|
198
|
+
* the last read of this agent's set returned.
|
|
199
|
+
*/
|
|
200
|
+
export declare function completeCred(words: string[], names: string[], providers: string[]): string[];
|
|
115
201
|
export declare function completeTail(cmd: string, word: string, models: string[], providers?: string[]): string[];
|
|
116
202
|
export declare function completeLine(line: string, state: {
|
|
117
203
|
completions: string[];
|
|
118
|
-
args: Record<string, string[] | (() => string[])>;
|
|
204
|
+
args: Record<string, string[] | ((rest: string) => string[])>;
|
|
119
205
|
models: string[];
|
|
120
206
|
provider?: string;
|
|
121
207
|
providerModels?: Record<string, string[]>;
|
|
122
208
|
providers?: string[];
|
|
209
|
+
credNames?: (agent?: string) => string[];
|
|
123
210
|
}): [string[], string];
|
|
211
|
+
/**
|
|
212
|
+
* Set readline's command history aside until the returned function is
|
|
213
|
+
* called: a question's answer and a wait are no place for a recalled command
|
|
214
|
+
* (↑ at a question put an old command into the answer; ↑ during a wait drew
|
|
215
|
+
* one under the wait's output, a line nothing would take). `keepNew`: lines
|
|
216
|
+
* entered meanwhile stay, newest first (type-ahead during a wait); without
|
|
217
|
+
* it they are dropped (a question's answer). null when there is no history.
|
|
218
|
+
* Exported for the tests.
|
|
219
|
+
*/
|
|
220
|
+
export declare function historyAside(rl: object | null | undefined): ((keepNew: boolean) => void) | null;
|
|
124
221
|
/**
|
|
125
222
|
* Print a block above the live prompt, keeping what the user has typed. The
|
|
126
223
|
* prompt and its input are erased from their first row down, the block is
|
|
@@ -133,18 +230,28 @@ export declare function completeLine(line: string, state: {
|
|
|
133
230
|
*/
|
|
134
231
|
export declare function printAbovePrompt(text: string, rl?: readline.Interface | null, output?: NodeJS.WritableStream): void;
|
|
135
232
|
import type { CommandContext } from '../types';
|
|
233
|
+
import { type ListLayout } from './cells';
|
|
234
|
+
import { type TurnView } from '../livePrompt';
|
|
235
|
+
import { type Key as InkKey } from '../inkView';
|
|
236
|
+
/**
|
|
237
|
+
* whoami's providers: the ones this machine has a model key for (`login`
|
|
238
|
+
* saved them; `hasKey` reads that store, never a value), the default for new
|
|
239
|
+
* agents first — marked when it has no key — then the others in registry
|
|
240
|
+
* order. The platform's whole list is the `providers` command; an agent's own
|
|
241
|
+
* keys are `cred <agent>`. Exported for the tests.
|
|
242
|
+
*/
|
|
243
|
+
export declare function configuredProvidersText(dflt: string, ids: readonly string[], hasKey: (id: string) => boolean): string;
|
|
136
244
|
/** The REPL listing's header line, aligned with {@link renderListRow}. */
|
|
137
|
-
export declare function renderListHeader(): string;
|
|
245
|
+
export declare function renderListHeader(layout?: ListLayout): string;
|
|
138
246
|
/**
|
|
139
247
|
* One row of the REPL's agent listing. Exported for the tests: this IS the
|
|
140
248
|
* renderer the interactive loop prints. Its cells go through ./cells, shared
|
|
141
249
|
* with `list`: a name cannot forge rows in this listing either, and an
|
|
142
250
|
* agent-owned agent reads the same way — its OWNER is another row's
|
|
143
251
|
* AGENTSEAL, annotated `⇄ #<agentId>` (`sealToAgent`, from the full listing).
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* AGENTSEAL is the agent's on-chain signing address.
|
|
252
|
+
* An unminted row shows its sealId PREFIX (`0x` + 10 hex) as its id, the form
|
|
253
|
+
* commands accept as a reference (F12). AGENTSEAL is the agent's on-chain
|
|
254
|
+
* signing address. `layout` fits the columns to the terminal (./cells).
|
|
148
255
|
*/
|
|
149
256
|
export declare function renderListRow(r: {
|
|
150
257
|
agentId: bigint | number | null;
|
|
@@ -153,7 +260,345 @@ export declare function renderListRow(r: {
|
|
|
153
260
|
name?: string | null;
|
|
154
261
|
framework?: string | null;
|
|
155
262
|
agentSeal?: string | null;
|
|
156
|
-
}, owner: string | null | undefined, owned?: string, sealToAgent?: ReadonlyMap<string, string
|
|
263
|
+
}, owner: string | null | undefined, owned?: string, sealToAgent?: ReadonlyMap<string, string>, layout?: ListLayout): string;
|
|
264
|
+
/** The shell's question: the answer to q. fresh asks for a line typed after
|
|
265
|
+
* q is shown (see run); main is the shell's own prompt; message is the agent
|
|
266
|
+
* prompt, whose answer may span lines; cancel rejects the question waiting,
|
|
267
|
+
* if any other than a prompt, and says whether it did. */
|
|
268
|
+
type Ask = ((q: string) => Promise<string>) & {
|
|
269
|
+
fresh?: (q: string) => Promise<string>;
|
|
270
|
+
main?: (q: string) => Promise<string>;
|
|
271
|
+
message?: (q: string) => Promise<Entry>;
|
|
272
|
+
cancel?: () => boolean;
|
|
273
|
+
/** While no question is up (a turn runs), hand each finished entry to
|
|
274
|
+
* `take` first: true means it took it, false that it waits for the next
|
|
275
|
+
* prompt as before. null stops. */
|
|
276
|
+
whileBusy?: (take: ((e: Entry) => boolean) | null) => void;
|
|
277
|
+
/** Put an entry back to wait for the next prompt. */
|
|
278
|
+
later?: (e: Entry) => void;
|
|
279
|
+
/** Entries already handed to the agent (taken as new messages, queued on
|
|
280
|
+
* its side): ↑ takes the newest back only by cancelling the agent's copy
|
|
281
|
+
* first. Set while a turn runs. */
|
|
282
|
+
held?: {
|
|
283
|
+
count(): number;
|
|
284
|
+
takeBack(): boolean;
|
|
285
|
+
} | null;
|
|
286
|
+
/** A message taken back from the agent, into the empty box (or, when
|
|
287
|
+
* something is being edited, to wait for the next prompt). */
|
|
288
|
+
putBack?: (text: string) => void;
|
|
289
|
+
/** The lines of a message begun and not sent yet (during a turn). */
|
|
290
|
+
drafting?: () => string[];
|
|
291
|
+
/** Entries waiting for the next prompt, oldest first. */
|
|
292
|
+
queued?: () => Entry[];
|
|
293
|
+
/** Take the newest waiting entry back to be edited (its last line on the
|
|
294
|
+
* line being edited, the others as the message's earlier lines); false
|
|
295
|
+
* when none waits or something is being edited. */
|
|
296
|
+
recall?: () => boolean;
|
|
297
|
+
/** What is being edited (earlier lines and the line) waits for the next
|
|
298
|
+
* prompt as an entry; false when there is nothing. */
|
|
299
|
+
queueEdit?: () => boolean;
|
|
300
|
+
/** Every waiting entry back to be edited, as one message ahead of what is
|
|
301
|
+
* being edited (a turn was interrupted: nothing goes on its own); how
|
|
302
|
+
* many there were. */
|
|
303
|
+
recallAll?: (extra?: readonly string[], form?: (text: string) => string) => number;
|
|
304
|
+
/** Empty the message being typed (its earlier lines too); false when there is nothing. */
|
|
305
|
+
clearBox?: () => boolean;
|
|
306
|
+
/** Backspace at the start of a message's line: it joins the line before; false when there is none. */
|
|
307
|
+
unwind?: () => boolean;
|
|
308
|
+
/** The shell's prompt now says q (its status changed): redrawn in place
|
|
309
|
+
* when it is up, used from the next prompt otherwise. */
|
|
310
|
+
retitle?: (q: string) => void;
|
|
311
|
+
/** The question up, if any: its kind and its text. */
|
|
312
|
+
waiting?: () => {
|
|
313
|
+
kind: 'q' | 'main' | 'message';
|
|
314
|
+
q: string;
|
|
315
|
+
} | null;
|
|
316
|
+
/** Take every entry waiting for the next prompt out of the queue. */
|
|
317
|
+
drain?: () => Entry[];
|
|
318
|
+
};
|
|
319
|
+
/** What the owner entered: its text (newlines kept), whether it spans lines,
|
|
320
|
+
* and whether any of it was pasted. An agent message that spans lines or was
|
|
321
|
+
* pasted is never a command. */
|
|
322
|
+
export type Entry = {
|
|
323
|
+
text: string;
|
|
324
|
+
multi: boolean;
|
|
325
|
+
pasted: boolean;
|
|
326
|
+
/** Entered while a turn ran (queued, put back, or a command that waits for
|
|
327
|
+
* its end): never the answer to a question asked after it. */
|
|
328
|
+
during?: boolean;
|
|
329
|
+
};
|
|
330
|
+
/** Whether an entry finished during a turn goes into that turn (steer): any
|
|
331
|
+
* message, but not an empty line or a command typed alone on its line —
|
|
332
|
+
* those wait for the next prompt, as before. */
|
|
333
|
+
export declare function steerable(e: Entry): boolean;
|
|
334
|
+
type Key = {
|
|
335
|
+
name?: string;
|
|
336
|
+
meta?: boolean;
|
|
337
|
+
ctrl?: boolean;
|
|
338
|
+
sequence?: string;
|
|
339
|
+
};
|
|
340
|
+
type KeySource = {
|
|
341
|
+
on(ev: 'keypress', f: (s: string | undefined, key: Key | undefined) => void): unknown;
|
|
342
|
+
prependListener?(ev: 'keypress', f: (s: string | undefined, key: Key | undefined) => void): unknown;
|
|
343
|
+
};
|
|
344
|
+
/**
|
|
345
|
+
* The shell's `ask` as a QUEUE, not rl.question: lines that arrive while no
|
|
346
|
+
* question is pending (piped input racing the ~4s async banner) used to be
|
|
347
|
+
* consumed by readline with no listener and silently dropped — commands
|
|
348
|
+
* vanished with exit 0 (feedback.md F5). Buffer them instead.
|
|
349
|
+
*
|
|
350
|
+
* ask.fresh is for a question whose answer signs something: on a terminal
|
|
351
|
+
* (tty), what was typed before it is shown (during a turn, say) is not its
|
|
352
|
+
* answer — neither a whole line, nor keys not yet sent with Enter, nor a line
|
|
353
|
+
* that comes in too soon after it to have been typed for it, nor a paste. A
|
|
354
|
+
* terminal whose line editing the shell does not do (its output is
|
|
355
|
+
* redirected) holds such keys itself, so there it is not asked at all.
|
|
356
|
+
*
|
|
357
|
+
* Several lines, on a terminal (keys, the session's keypresses: given, the
|
|
358
|
+
* shell does it): ask.message (the agent prompt) takes a message of several
|
|
359
|
+
* lines. A paste is one block, newlines kept, sent with the next Enter: the
|
|
360
|
+
* terminal marks it (bracketed paste, which run turns on), or, where it does
|
|
361
|
+
* not, lines that come in one read, or reads close behind a pasted one, are
|
|
362
|
+
* one. A line ending in \ and Option/Alt+Enter go on to a new line. Lines
|
|
363
|
+
* already entered are not edited again (readline edits one line). Every other
|
|
364
|
+
* question takes one line: several pasted lines are not its answer, and a
|
|
365
|
+
* paste does not answer a yes/no question. Without keys (piped input) every
|
|
366
|
+
* line is one answer, as before.
|
|
367
|
+
*
|
|
368
|
+
* `boxed`: the line being edited is drawn by the Ink session view
|
|
369
|
+
* (inkView.ts), which shows the message's earlier lines itself, so nothing
|
|
370
|
+
* readline would need to show them is written; `echo` puts what a question
|
|
371
|
+
* was given into the transcript (readline leaves it on the screen as typed);
|
|
372
|
+
* `say` is where the queue's own notes go (default: the shell's output).
|
|
373
|
+
*/
|
|
374
|
+
export declare function lineQueue(rl: {
|
|
375
|
+
on(ev: 'line', f: (l: string) => void): unknown;
|
|
376
|
+
on(ev: 'close', f: () => void): unknown;
|
|
377
|
+
setPrompt(q: string): void;
|
|
378
|
+
prompt(preserveCursor?: boolean): void;
|
|
379
|
+
terminal?: boolean;
|
|
380
|
+
}, tty: () => boolean, keys?: KeySource, opts?: {
|
|
381
|
+
boxed?: boolean;
|
|
382
|
+
echo?: (kind: 'q' | 'main' | 'message', q: string, e: Entry) => void;
|
|
383
|
+
say?: (s: string) => void;
|
|
384
|
+
}): Ask;
|
|
385
|
+
/**
|
|
386
|
+
* A help text written for 80 columns (` /cmd …` with its description from
|
|
387
|
+
* column 26, further lines of it indented to there) in rows of at most
|
|
388
|
+
* `width` columns: each description joined back into one and wrapped once,
|
|
389
|
+
* its further rows under the description column; at a width too narrow for
|
|
390
|
+
* that, the description goes under the command. Other lines as they are.
|
|
391
|
+
* Exported for the tests.
|
|
392
|
+
*/
|
|
393
|
+
export declare function helpRows(text: string, width: number): string[];
|
|
394
|
+
/** `/settings`' way to change them: the items after "change with:", in rows
|
|
395
|
+
* of at most `width` columns, further rows under the first item. Exported for the tests. */
|
|
396
|
+
export declare function changeWith(items: readonly string[], width: number): string[];
|
|
397
|
+
interface Session {
|
|
398
|
+
/** What the last failed turn's error pointed at (null after a turn that did not fail). */
|
|
399
|
+
lastFailKind?: FailureKind | null;
|
|
400
|
+
ag: AgenticID;
|
|
401
|
+
attestorUrl: string;
|
|
402
|
+
sealId: `0x${string}`;
|
|
403
|
+
agentId: string;
|
|
404
|
+
agentSeal?: `0x${string}`;
|
|
405
|
+
/** Needed by /reset (which image) and the chat model selector. Not exposed
|
|
406
|
+
* by the attestor post-mint, so it is PICKED by the user when first
|
|
407
|
+
* needed (deploy knows it; use/attach does not). */
|
|
408
|
+
framework?: string;
|
|
409
|
+
phase: string;
|
|
410
|
+
url?: string;
|
|
411
|
+
sandboxId?: string;
|
|
412
|
+
client?: AgentClient;
|
|
413
|
+
/** Tasks started from THIS session on the responses transport (newest
|
|
414
|
+
* last): lets /tasks list them and /result re-attach after a drop. The
|
|
415
|
+
* agent itself keeps the authoritative ring; this is just the ids. */
|
|
416
|
+
tasks?: Array<{
|
|
417
|
+
id: string;
|
|
418
|
+
prompt: string;
|
|
419
|
+
at: number;
|
|
420
|
+
session?: string;
|
|
421
|
+
}>;
|
|
422
|
+
/** The reasoning level /think last wrote to the settings document, mirrored
|
|
423
|
+
* here ONLY as the per-message override for frameworks whose bridge takes
|
|
424
|
+
* one (prime). The durable copy is the document; this is a session echo of
|
|
425
|
+
* it, set after a successful write and never on its own. */
|
|
426
|
+
thinking?: 'low' | 'high' | 'max';
|
|
427
|
+
/** Task id of the chat turn currently in flight (responses transport). */
|
|
428
|
+
currentTask?: string | null;
|
|
429
|
+
/** Files and images `/attach` staged for the next message. */
|
|
430
|
+
attached?: Staged[];
|
|
431
|
+
/** The owner session chat goes to (0g-harness `/sessions`); absent = the
|
|
432
|
+
* default `owner-chat`. */
|
|
433
|
+
sessionId?: string;
|
|
434
|
+
sessionTitle?: string;
|
|
435
|
+
/** The session's prompt and the turn on screen (sessionRepl). */
|
|
436
|
+
screen?: SessionScreen;
|
|
437
|
+
/** Why the container failed, when its last stage did (refreshSession). */
|
|
438
|
+
failure?: string;
|
|
439
|
+
/** The last refresh could not reach the attestor. */
|
|
440
|
+
stale?: boolean;
|
|
441
|
+
}
|
|
442
|
+
/** What a session's turns need from its prompt. */
|
|
443
|
+
interface SessionScreen {
|
|
444
|
+
/** The prompt's text (no leading newline); busy: a turn runs. */
|
|
445
|
+
prompt(busy: boolean): string;
|
|
446
|
+
/** The turn on screen, told when what the prompt counts changes. */
|
|
447
|
+
turn: TurnView | null;
|
|
448
|
+
/** A turn ran since the prompt was last up. */
|
|
449
|
+
turnRan: boolean;
|
|
450
|
+
/** A turn was interrupted: what was queued during it comes back to be
|
|
451
|
+
* edited; what to say about it ('' when nothing was queued). */
|
|
452
|
+
interrupted?: (extra?: readonly string[]) => string;
|
|
453
|
+
}
|
|
454
|
+
/** What the session prompt counts: notices waiting to be shown, new files. */
|
|
455
|
+
export interface PromptCounts {
|
|
456
|
+
notices: number;
|
|
457
|
+
files: number;
|
|
458
|
+
}
|
|
459
|
+
/** The prompt's status: ` · 2 notices · 1 new file`, nothing for zeros. */
|
|
460
|
+
export declare function promptStatus(c: PromptCounts): string;
|
|
461
|
+
/** The session prompt without its leading newline, e.g.
|
|
462
|
+
* `agent 625 (replying, Esc stops) · 1 notice › `. busy: a turn runs. */
|
|
463
|
+
export declare function sessionPromptText(agentId: string, label: string, busy: boolean, c: PromptCounts): string;
|
|
464
|
+
/** A message of many lines as it is echoed back: its first lines and how many more. Exported for the tests. */
|
|
465
|
+
export declare function collapsed(text: string, keep?: number): string;
|
|
466
|
+
/** A word that names a path rather than a command: a second `/` in it, or a
|
|
467
|
+
* file extension. Exported for the tests. */
|
|
468
|
+
export declare function looksLikePath(word: string): boolean;
|
|
469
|
+
/** The live prompt's lines for what the owner sent during a turn: inserted
|
|
470
|
+
* into it with Enter and waiting for the agent to read it, and what waits
|
|
471
|
+
* for the next turn (Tab, or a command). Exported for the tests. */
|
|
472
|
+
export declare function turnNotes(steered: readonly string[], queued: ReadonlyArray<{
|
|
473
|
+
text: string;
|
|
474
|
+
}>): string[];
|
|
475
|
+
/**
|
|
476
|
+
* Whether a command typed while a turn runs only reads, and so runs at once
|
|
477
|
+
* (its output above the prompt) rather than when the turn ends: it neither
|
|
478
|
+
* touches the running turn nor asks anything. Exported for the tests.
|
|
479
|
+
*/
|
|
480
|
+
export declare function readOnlyCommand(line: string): boolean;
|
|
481
|
+
/** A turn the agent runs for messages the owner inserted into another one:
|
|
482
|
+
* ones it finished before reading (`unread`), or one it took as a new
|
|
483
|
+
* message as nothing was running (`idle`). One turn may answer several. */
|
|
484
|
+
export interface FollowUp {
|
|
485
|
+
id: string;
|
|
486
|
+
texts: string[];
|
|
487
|
+
why: 'unread' | 'idle';
|
|
488
|
+
/** idle: why the agent took it as a new message (its steer reason). */
|
|
489
|
+
reason?: string;
|
|
490
|
+
/** unread: the turn it went into failed before the agent read it. */
|
|
491
|
+
failed?: boolean;
|
|
492
|
+
}
|
|
493
|
+
/** The inserted messages not read when Esc cancelled their turn, by what
|
|
494
|
+
* the agent says became of each. */
|
|
495
|
+
export interface StoppedSteers {
|
|
496
|
+
/** Dropped with the turn: back to the box. */
|
|
497
|
+
back: string[];
|
|
498
|
+
/** Read after all, before the stop. */
|
|
499
|
+
read: string[];
|
|
500
|
+
/** Still held by the agent (an older 0g-harness keeps them pending and
|
|
501
|
+
* gives them to its next turn), or not known: not put back, so they are
|
|
502
|
+
* not sent twice. */
|
|
503
|
+
kept: string[];
|
|
504
|
+
/** Answered in a turn of their own, which the stop cancels too: back to
|
|
505
|
+
* the box with that turn's other texts. */
|
|
506
|
+
turns: Array<{
|
|
507
|
+
turn: string;
|
|
508
|
+
text: string;
|
|
509
|
+
}>;
|
|
510
|
+
}
|
|
511
|
+
/** Sort the inserted messages not read at a cancel by their steer states,
|
|
512
|
+
* read after the cancel (`null`: not known). A dropped one comes back as the
|
|
513
|
+
* agent sends it back (`text`, 0g-harness #12 on), else as it was typed.
|
|
514
|
+
* Exported for the tests. */
|
|
515
|
+
export declare function stoppedSteers(left: ReadonlyArray<{
|
|
516
|
+
text: string;
|
|
517
|
+
turn?: string;
|
|
518
|
+
}>, states: ReadonlyArray<SteerState | null>): StoppedSteers;
|
|
519
|
+
/** The line for inserted messages the agent may still read (an older
|
|
520
|
+
* 0g-harness keeps them for its next turn): not put back. Exported for the tests. */
|
|
521
|
+
export declare function keptNote(kept: readonly string[]): string;
|
|
522
|
+
/**
|
|
523
|
+
* Which turn answers a message inserted into turn `inserted` and not read
|
|
524
|
+
* there, from its steer state: the turn it opened (`turn`), or the one it
|
|
525
|
+
* joined when the agent answers several in one follow-up (`merged` into a
|
|
526
|
+
* turn other than the one it went into). null: read where it went, dropped,
|
|
527
|
+
* or not known yet. Exported for the tests.
|
|
528
|
+
*/
|
|
529
|
+
export declare function steerFollowUp(inserted: string | undefined, st: SteerState | null): string | null;
|
|
530
|
+
/** Add `text` to the follow-up turn `id`, or start it: several inserted
|
|
531
|
+
* messages the agent answers in one turn are followed once. Exported for the tests. */
|
|
532
|
+
export declare function addFollowUp(list: FollowUp[], id: string, text: string, why: FollowUp['why'], more?: {
|
|
533
|
+
reason?: string;
|
|
534
|
+
failed?: boolean;
|
|
535
|
+
}): void;
|
|
536
|
+
/** What the shell says before it follows a follow-up turn, in the owner's
|
|
537
|
+
* words; an id only where a command takes it. Exported for the tests. */
|
|
538
|
+
export declare function followUpNote(f: FollowUp, canFollow: boolean): string;
|
|
539
|
+
/** What a failed turn's error points at: the model service (5xx, the
|
|
540
|
+
* provider's own error), an overloaded model (429), the agent's model
|
|
541
|
+
* settings (unknown model, a key, a bad request), or none of these. */
|
|
542
|
+
export type FailureKind = 'service' | 'overloaded' | 'config' | 'other';
|
|
543
|
+
/** Sort a failed turn's error (the agent's text for it) by what it points
|
|
544
|
+
* at. Exported for the tests. */
|
|
545
|
+
export declare function failureKind(message: string): FailureKind;
|
|
546
|
+
/** The line for a failed turn, by what its error points at. `model`: the
|
|
547
|
+
* agent's model and provider, when known; `repeated`: the turn before
|
|
548
|
+
* failed the same way. Exported for the tests. */
|
|
549
|
+
export declare function failureText(message: string, opts?: {
|
|
550
|
+
model?: string;
|
|
551
|
+
provider?: string;
|
|
552
|
+
repeated?: boolean;
|
|
553
|
+
}): string;
|
|
554
|
+
/** A turn that ended without text because the model's output budget ran out. */
|
|
555
|
+
export declare const NO_ANSWER_MAX_TOKENS = "no answer: the model's thinking used the whole output budget \u2014 ask again or /think high";
|
|
556
|
+
/** The line for a turn that ended with no text (`err`, when given, says
|
|
557
|
+
* so) because it ran out of output budget: its activity record (0g-harness)
|
|
558
|
+
* says `max-tokens`. null for anything else. Exported for the tests. */
|
|
559
|
+
export declare function emptyTurnText(client: AgentClient | undefined, id: string | null | undefined, err?: unknown): Promise<string | null>;
|
|
560
|
+
/** A writer that puts `agent> ` before the turn's first text, not before
|
|
561
|
+
* it: a status line may come first, and a turn with no text shows none. */
|
|
562
|
+
/** Exported for the tests. */
|
|
563
|
+
export declare function sayer(view: TurnView): (text: string) => void;
|
|
564
|
+
/** What the agent is doing, in plain words, from an activity label as the
|
|
565
|
+
* frameworks report it ("tool/call bash", "tool_execution_start — bash",
|
|
566
|
+
* "tool/result", "thinking"). */
|
|
567
|
+
export declare function activityText(label: string): string;
|
|
568
|
+
/**
|
|
569
|
+
* One run of the agent's tool calls in plain words, as the Ink view's
|
|
570
|
+
* transcript shows it: "ran 3 commands, read a file". Only the calls count
|
|
571
|
+
* (a tool's result, thinking and the like do not); '' when there were none.
|
|
572
|
+
*/
|
|
573
|
+
export declare function activitySummary(labels: readonly string[]): string;
|
|
574
|
+
/** The agent's phase on one line, with why the container failed when it did. */
|
|
575
|
+
export declare function phaseLine(phase: string, failure?: string): string;
|
|
576
|
+
/** What the Ink view's footer says about an agent that is not running, with
|
|
577
|
+
* the way out ('' while it runs). */
|
|
578
|
+
export declare function phaseNote(phase: string, failure?: string): string;
|
|
579
|
+
/**
|
|
580
|
+
* Re-read the deployment row and resync the session: the phase; the
|
|
581
|
+
* container URL as soon as a sandbox exists (the sealed runtime serves /log
|
|
582
|
+
* while still `deploying`), kept for the session's own requests and never
|
|
583
|
+
* printed; the chat client only when running (and dropped again when not,
|
|
584
|
+
* so a stale connection can't linger). What it says: the phase on one line,
|
|
585
|
+
* every time (`always`) or when it moved (`moved`); under the Ink view
|
|
586
|
+
* (`view`) nothing, as its footer shows the phase. Exported for the tests.
|
|
587
|
+
*/
|
|
588
|
+
export declare function refreshSession(s: Session, say?: 'always' | 'moved' | 'never', view?: {
|
|
589
|
+
refresh(): void;
|
|
590
|
+
} | null): Promise<void>;
|
|
591
|
+
/** How often an idle session re-reads the phase of an agent it believes running. */
|
|
592
|
+
export declare const PHASE_WATCH_MS = 30000;
|
|
593
|
+
/** What an answer to a yes/no question says: y/yes, n/no, Enter (the
|
|
594
|
+
* default); null for anything else (asked again). Exported for the tests. */
|
|
595
|
+
export declare function yesNo(answer: string, dflt: boolean): boolean | null;
|
|
596
|
+
/** The wait before the next phase read: the base one after a read that
|
|
597
|
+
* worked, doubling after each that failed, up to five minutes. Exported for the tests. */
|
|
598
|
+
export declare function nextPhaseWait(prev: number, ok: boolean): number;
|
|
599
|
+
/** The line for an agent the session believed running that is not any
|
|
600
|
+
* more, with the way back. Exported for the tests. */
|
|
601
|
+
export declare function phaseMovedText(phase: string): string;
|
|
157
602
|
/** An agent's container state just before a lifecycle request was sent. */
|
|
158
603
|
export interface LifecycleBaseline {
|
|
159
604
|
/** The container stage's `at`, in ms (server clock); undefined when it has none. */
|
|
@@ -174,11 +619,142 @@ export declare function pollRunning(attestorUrl: string, sealId: `0x${string}`,
|
|
|
174
619
|
}): Promise<{
|
|
175
620
|
url: string;
|
|
176
621
|
}>;
|
|
622
|
+
type KeyFn = (s: string | undefined, key: InkKey | undefined) => void | false;
|
|
623
|
+
type WaitIO = Pick<NonNullable<typeof shellIO>, 'keys' | 'onEscape' | 'cancelWait'> & {
|
|
624
|
+
ask?: Ask;
|
|
625
|
+
};
|
|
626
|
+
/**
|
|
627
|
+
* Set the plain prompt's keyboard aside while a command runs (the shell does
|
|
628
|
+
* this for every manager command; duringWait for a wait elsewhere): readline
|
|
629
|
+
* would echo a key typed meanwhile onto the command's output (`xyzdeposited
|
|
630
|
+
* 0.1 OG`) and keep it as the start of the next command, which the prompt
|
|
631
|
+
* then showed with the cursor before it. A question the command asks takes
|
|
632
|
+
* keys as usual; Esc and Ctrl-C stop a wait (asideKeys); any other key is
|
|
633
|
+
* dropped, and before the next prompt one line says so (flushDroppedNote).
|
|
634
|
+
* Under the Ink view nothing is set aside: its editor keeps what is typed as
|
|
635
|
+
* an editable line. Returns the function that gives the keys back; null when
|
|
636
|
+
* nothing was set aside (no terminal, the Ink view, already aside).
|
|
637
|
+
* Exported for the tests.
|
|
638
|
+
*/
|
|
639
|
+
export declare function keysAside(io?: WaitIO | null): (() => void) | null;
|
|
640
|
+
/** Runs `f` (a wait) with the keys set aside, as keysAside says. Exported for the tests. */
|
|
641
|
+
export declare function duringWait<T>(f: () => Promise<T>, io?: WaitIO | null): Promise<T>;
|
|
642
|
+
/** The note that keys typed while they were aside were dropped: once, right
|
|
643
|
+
* before the next prompt, after what the command printed last. Exported for the tests. */
|
|
644
|
+
export declare function flushDroppedNote(): void;
|
|
645
|
+
/** What run() sets up that the Ink session view takes over while it is up. */
|
|
646
|
+
declare let shellIO: {
|
|
647
|
+
rl: readline.Interface;
|
|
648
|
+
ask: Ask;
|
|
649
|
+
keys: {
|
|
650
|
+
use(f: KeyFn | null): void;
|
|
651
|
+
} | null;
|
|
652
|
+
rlResize: Array<() => void>;
|
|
653
|
+
onInterrupt(): void;
|
|
654
|
+
onEscape(): void;
|
|
655
|
+
/** Stop the wait under way (a cancellable one); false when there is none. */
|
|
656
|
+
cancelWait(): boolean;
|
|
657
|
+
} | null;
|
|
658
|
+
/** The owner's message as the Ink view's transcript shows it: a file dragged
|
|
659
|
+
* in (attach.ts findDroppedFiles) by its name, `[image: cat.png]`, not its path. */
|
|
660
|
+
export declare function droppedShown(text: string): string;
|
|
177
661
|
export declare function run(ctx: CommandContext): Promise<void>;
|
|
662
|
+
/** A `·`-separated list wrapped to `width` between items, never inside one. */
|
|
663
|
+
export declare function fitItems(text: string, width: number | undefined): string;
|
|
664
|
+
/** The manager's `help`, fitted to a terminal `width` wide (textfit.ts).
|
|
665
|
+
* Exported for the tests. */
|
|
666
|
+
export declare function managerHelp(width?: number): string;
|
|
667
|
+
/** The two capability lists of a /hello body: services (agent-registered
|
|
668
|
+
* endpoints, entry #0 is /hello itself) and routes (framework-declared
|
|
669
|
+
* prefixes, the owner's API). */
|
|
670
|
+
export interface HelloSurface {
|
|
671
|
+
services?: {
|
|
672
|
+
path: string;
|
|
673
|
+
method: string;
|
|
674
|
+
description?: string;
|
|
675
|
+
skill?: string;
|
|
676
|
+
transport?: string;
|
|
677
|
+
}[];
|
|
678
|
+
routes?: {
|
|
679
|
+
prefix: string;
|
|
680
|
+
kind?: string;
|
|
681
|
+
auth?: string;
|
|
682
|
+
signed: boolean;
|
|
683
|
+
description?: string;
|
|
684
|
+
}[];
|
|
685
|
+
}
|
|
178
686
|
/**
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
687
|
+
* The services and routes of a /hello as `/hello` and `hello <id>` print
|
|
688
|
+
* them, one string per line, without the line break. Compact (the default): one line per service,
|
|
689
|
+
* cut to `width`, and the routes folded into one line per auth mode, named by
|
|
690
|
+
* their kinds, then a pointer to `more` (the full form of the command). `full`:
|
|
691
|
+
* every field of every entry, as the agent's runtime sent it. Compact cells
|
|
692
|
+
* go through cleanCell, so nothing the agent wrote can add a line.
|
|
182
693
|
*/
|
|
183
|
-
export declare function
|
|
694
|
+
export declare function renderHelloSurface(body: HelloSurface, opts: {
|
|
695
|
+
full: boolean;
|
|
696
|
+
width: number;
|
|
697
|
+
more: string;
|
|
698
|
+
}): string[];
|
|
699
|
+
/**
|
|
700
|
+
* Where the session sends the agent's owner routes (credentials, settings):
|
|
701
|
+
* the URL the attestor has for the agent now. The agent may be on a new
|
|
702
|
+
* sandbox since this session connected (a reset from elsewhere), and the URL
|
|
703
|
+
* the session holds then reaches nothing. The held one is used when the
|
|
704
|
+
* attestor cannot say; none when the agent is not running here.
|
|
705
|
+
*/
|
|
706
|
+
export declare function ownerRouteUrl(ag: AgenticID, s: Session): Promise<string | undefined>;
|
|
707
|
+
/** Why `a` is not a usable address, for `what` (the buyer, the new owner…).
|
|
708
|
+
* A 40-hex address whose mixed case does not match its checksum is a typo
|
|
709
|
+
* the checksum caught, not a malformed value. Exported for the tests. */
|
|
710
|
+
export declare function addressProblem(a: string, what: string): string;
|
|
711
|
+
/**
|
|
712
|
+
* Which listed option an answer names: Enter is the default, a number is the
|
|
713
|
+
* option shown with it, and otherwise an option's id or name (any case).
|
|
714
|
+
* null for anything else. Exported for the tests.
|
|
715
|
+
*/
|
|
716
|
+
export declare function choiceIndex(answer: string, options: ReadonlyArray<{
|
|
717
|
+
id: string;
|
|
718
|
+
name?: string;
|
|
719
|
+
}>, defaultIndex: number): number | null;
|
|
720
|
+
/**
|
|
721
|
+
* Show `options` numbered under `title` and ask for one (choiceIndex). An
|
|
722
|
+
* answer that names none of them is asked again — never replaced with the
|
|
723
|
+
* default. Returns the chosen option's id. Exported for the tests.
|
|
724
|
+
*/
|
|
725
|
+
export declare function askChoice(ask: (q: string) => Promise<string>, title: string, question: string, options: ReadonlyArray<{
|
|
726
|
+
id: string;
|
|
727
|
+
name?: string;
|
|
728
|
+
}>, defaultIndex: number): Promise<string>;
|
|
729
|
+
export { frameworkNeedsToolModels } from '../settings';
|
|
730
|
+
/** The reason of a container's last `warning` report, cleaned for one line;
|
|
731
|
+
* null for any other report or none. */
|
|
732
|
+
export declare function warningOf(status: {
|
|
733
|
+
level: string;
|
|
734
|
+
reason: string | null;
|
|
735
|
+
} | null | undefined): string | null;
|
|
736
|
+
/**
|
|
737
|
+
* The entry card's lines (beside the avatar): who the agent is, its phase,
|
|
738
|
+
* sealId, gas, a warning, and how to go on. No container URL: that is the
|
|
739
|
+
* session's own address for the agent, not one the owner uses. Exported for
|
|
740
|
+
* the tests.
|
|
741
|
+
*/
|
|
742
|
+
export declare function sessionCardFields(c: {
|
|
743
|
+
agentId: string;
|
|
744
|
+
name?: string | null;
|
|
745
|
+
phase: string;
|
|
746
|
+
sealId: string;
|
|
747
|
+
gasWei: bigint | null;
|
|
748
|
+
warning: string | null;
|
|
749
|
+
connected: boolean;
|
|
750
|
+
failure?: string;
|
|
751
|
+
/** When the container reported the warning (ISO time); `now` for the tests. */
|
|
752
|
+
warningAt?: string;
|
|
753
|
+
now?: number;
|
|
754
|
+
}): string[];
|
|
755
|
+
/** The entry card's field lines, wrapped at words to `width` columns: a
|
|
756
|
+
* field's further rows line up under its value (`gas 1.2 OG (…`).
|
|
757
|
+
* Exported for the tests. */
|
|
758
|
+
export declare function wrapCard(fields: readonly string[], width: number): string[];
|
|
759
|
+
export declare const L2_HELP_FULL = "session commands\n <anything else> chat with the agent \u2014 Esc or Ctrl-C interrupts the\n turn in flight (the runtime cancels server-side);\n at a question a command asks, they cancel it\n (several lines) a paste stays one message, sent with the next\n Enter and never run as a command; a line ending\n in \\ or Option/Alt+Enter goes on to a new line.\n Backspace at a line's start joins the line before;\n Ctrl-C or Esc with text in the box clears it\n (while it works) the input stays on screen (framed at the bottom,\n a status line above it saying what the agent does\n and Esc to stop); the reply prints above it and\n what you type stays on screen. Enter on 0g-harness\n owner-chat steers: the message goes into the turn,\n read before its next model call (\"waiting for the\n agent\" until then); not in the middle of a long\n command. If the turn ends first, the agent answers\n it next, shown here. Tab queues instead (\"next\n turn\"), sent as the next message when the turn\n ends (Esc puts it back to edit instead); \u2191 on an\n empty prompt takes the newest queued one back to\n edit. A command alone on its line never goes to\n the agent: one that only reads (/files, /tasks,\n /inbox, \u2026) runs at once, any other when the turn\n ends; Tab completes it. A message in another\n session or on another framework waits for the next\n turn. AGENTDNA_INK=off keeps the plain prompt line\n instead of the frame; AGENTDNA_LIVE_PROMPT=off\n prints turns as a plain stream\n (status) 2 notices \u00B7 1 new file: notices waiting to print\n and files the agent left that are not saved yet\n (at the status line's right, or in the prompt)\n (bare Enter) refresh this agent's phase from the attestor (in\n the framed view its footer shows it)\n /hello [full] identity, serve-proof verification, services one\n per line, owner routes on one line by kind; full\n prints every field of every service and route\n /balance this agent's agentSeal gas + the account prepaid\n /topup [og] fund this agent's agentSeal gas (bare: asks how\n much; Enter cancels)\n /start start (only from stopped)\n /stop stop the running container\n /reset recreate the container (uses the recorded framework;\n /reset pick to choose another; asks the key; also\n clears the local chat history)\n /settings [k=v \u2026] the owner's configuration document: which model\n this agent thinks with, and how hard. Bare shows it;\n model=\u2026 provider=\u2026 thinking=low|high|max\n others=<json> merge into it and write it back\n (owner-signed). A running agent takes it at once\n (its runtime restarts with it); a stopped one at its\n next start. On 0g-harness, bare /settings says\n which versions run; /settings versions lists the\n ones the trust registry has, and sealed=<hash>\n harness=<hash> pin them\n /cred [sub \u2026] this agent's credentials \u2014 same as `cred <id>` in\n the manager: bare lists, set <name> [k=v \u2026], rm,\n connect, disconnect, reveal <name> on|off, pending,\n approve|deny [<id>], log [n], presets. The agent\n writes [[credential:<name>]] where a key goes;\n sealed fills it in on the way out.\n A request the agent waits on (to read a value, to get\n a credential, to be connected) comes up here at the\n prompt; your answer goes back to the agent\n /think [low|high|max] reasoning depth for thinking models (glm etc.) \u2014\n shorthand for /settings thinking=\u2026, so it is written\n to the owner's document (owner-signed) and a running\n agent takes it at once, a stopped one at its next\n start. prime also takes it per message.\n No arg shows the level currently stored\n /clear wipe the agent's conversation and start fresh \u2014\n chain-tracked memory (what the agent chose to keep)\n is untouched; that is the difference from /reset\n /compact compact the agent's conversation in place \u2014 older\n history becomes a summary, the newest part stays\n as it is (openclaw ~20K tokens, 0g-harness its\n newest item), and the conversation goes on (unlike\n /clear). One or more model calls; can take\n minutes. 0g-harness, and openclaw 2026.7.1 or later\n /restart harness|sealed restart one layer of the agent's runtime in place:\n the harness process (the conversation stays), or\n sealed itself (the agent is away for about one\n start); either picks up version changes. 0g-harness\n /sessions on 0g-harness: your sessions (* = the one chat goes\n to). /sessions new [title] opens one and switches to\n it; /sessions switch <#|id|title> switches (# from\n the list, newest first); /sessions\n fork [id] copies a session's history into a new one;\n /sessions default goes back to owner-chat. Every\n session shares the agent's memory, skills and\n persona; only the conversation is its own\n /activities on 0g-harness: everything that runs or ran on the\n agent \u2014 your turns, the turns it opened itself,\n background commands and subagents \u2014 with who did\n each (BY) and who asked (FOR)\n /tasks [sub \u2026] on 0g-harness: tasks \u2014 pieces of work the agent\n runs in a session and workspace of their own (at\n most four at once) and ends with a record: a\n question, an action for you, or a report. /tasks\n lists them (all: archived too); new <prompt>\n hands one over; show <id> prints its state and\n records; input <id> [next] <text> answers or\n steers it (next: its next turn); cancel <id>\n stops its run; archive <id> puts it away. An id\n can be a unique start of one\n /tasks elsewhere: this session's long tasks with live\n status \u2014 on agents with the responses transport a\n chat turn survives dropped connections and keeps\n running. On an older 0g-harness the same as\n /activities\n /result [id] re-attach to a task (default: latest): prints a\n finished one, follows a running one live; on\n 0g-harness also a subagent's answer or a command's\n status\n /cancel [id|all] stop tasks \u2014 the brake for orphaned turns: Esc only\n cancels a turn THIS connection started (on\n 0g-harness and prime it interrupts the agent-wide\n current turn), so after a dropped stream /cancel\n is the way to stop what survived. Bare form stops\n everything this session knows to be in flight\n (newest first); with an id, just that one \u2014\n /result <id> adopts an id into the session first.\n Session memory starts empty after a CLI restart or\n /back + use. On 0g-harness an id can be anything\n /activities lists, and /cancel all stops everything\n running on the agent\n /inbox [all] notices: what the agent said on its own\n (0g-harness) \u2014 a background job finished, a\n reminder came due. A notice prints above the\n prompt as it arrives, and what came while you were\n away prints when you enter. Bare: unread ones;\n all: the ones you've seen too. /notices is the same\n /schedules the reminders the agent set for itself\n (0g-harness)\n (drag a file in) a file dragged into the terminal, or a pasted path to\n one, goes with the message you are typing: images in\n it, other files uploaded as below. Only files under\n your home, /Volumes and the temp folders; a path in\n backquotes stays text (0g-harness)\n /attach [path \u2026|clear] files and images for your next message (0g-harness):\n an image goes with the message (when the model takes\n images, as its provider's model list says \u2014 else it\n is saved as a file the agent is told about), any\n other file is uploaded to the agent's ~/inbox first\n and the message names its path. Bare lists what is\n staged. Images: 8 per message, 10 MiB each, 32 MiB\n together; a file: 25 MiB\n /files [inbox] files the agent left for you, in its ~/outbox (or,\n with inbox, files you sent, in its ~/inbox) \u2014\n container-local, lost on a reset (0g-harness). On a\n terminal, new ones are saved to\n ~/agentdna/<agent>/outbox by themselves (checked\n when a turn ends and every 30 s; never over a\n different file; over 50 MiB: skipped and said so)\n /files auto [on|off] whether new files are saved by themselves (this\n CLI's setting, for every agent; on by default)\n /download <name> [path] save one to the current directory (or path); never\n overwrites: a taken name gets -1, -2, \u2026 Names from\n your own files: inbox/<name>. At most 50 MiB\n /agentlog [n] agent process log, last n lines (owner-only)\n /signatures [n] what the agent signed as itself and what the runtime\n refused, last n (owner-only; 0g-harness)\n /startuplog [n] sealed runtime startup log, last n lines\n /back (or /unuse) return to the manager\n /quit exit";
|
|
184
760
|
//# sourceMappingURL=interactive.d.ts.map
|