@claxedo/agent-runtime-contract 0.8.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/LICENSE +21 -0
- package/README.md +37 -0
- package/dist/availability.d.ts +42 -0
- package/dist/capabilities.d.ts +31 -0
- package/dist/claims.d.ts +31 -0
- package/dist/connections.d.ts +21 -0
- package/dist/content.d.ts +411 -0
- package/dist/credential-broker-errors.d.ts +80 -0
- package/dist/errors.d.ts +43 -0
- package/dist/events.d.ts +460 -0
- package/dist/files.d.ts +52 -0
- package/dist/harness-effort.d.ts +56 -0
- package/dist/harness-table.d.ts +56 -0
- package/dist/harnesses.d.ts +96 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.mjs +815 -0
- package/dist/question-answers.d.ts +13 -0
- package/dist/session-group.d.ts +37 -0
- package/dist/sessions.d.ts +166 -0
- package/dist/tool-names.d.ts +3 -0
- package/dist/usage-windows.d.ts +23 -0
- package/dist/values.d.ts +10 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Claxedo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# `@claxedo/agent-runtime-contract`
|
|
2
|
+
|
|
3
|
+
Dependency-free canonical contracts for Claxedo agent sessions: execution
|
|
4
|
+
bindings, content and message shapes, capabilities, connection descriptors,
|
|
5
|
+
errors, file references, and the runtime event model. Every Claxedo runtime
|
|
6
|
+
package (`@claxedo/agent-event-runtime`, `@claxedo/agent-sdk-runtime`,
|
|
7
|
+
`@claxedo/workspace-runtime`) and every client that speaks to them imports
|
|
8
|
+
these types from here, so the wire contract has exactly one owner.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install @claxedo/agent-runtime-contract
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { assertAgentExecutionBinding, AGENT_RUNTIME_CONTRACT_VERSION } from "@claxedo/agent-runtime-contract"
|
|
20
|
+
|
|
21
|
+
const binding = assertAgentExecutionBinding({
|
|
22
|
+
scope: "central",
|
|
23
|
+
directory: "",
|
|
24
|
+
sessionId: "central-1",
|
|
25
|
+
connectionId: "native:pi",
|
|
26
|
+
upstreamSessionId: "pi-1",
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The package ships plain ESM plus type declarations and has no runtime
|
|
31
|
+
dependencies, so it loads under Node without a TypeScript loader.
|
|
32
|
+
|
|
33
|
+
## Versioning
|
|
34
|
+
|
|
35
|
+
`agent-runtime-contract` rides the runtime version track with the other
|
|
36
|
+
runtime packages (see `script/PUBLISH-ORDER.md` in the repository). A contract
|
|
37
|
+
change that consumers must react to bumps `AGENT_RUNTIME_CONTRACT_VERSION`.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type ExecutionAvailability = {
|
|
2
|
+
status: "available";
|
|
3
|
+
} | {
|
|
4
|
+
status: "selection-required";
|
|
5
|
+
selection: "harness" | "model";
|
|
6
|
+
} | {
|
|
7
|
+
status: "offline";
|
|
8
|
+
message: string;
|
|
9
|
+
} | {
|
|
10
|
+
status: "unsupported";
|
|
11
|
+
operation: string;
|
|
12
|
+
} | {
|
|
13
|
+
status: "unavailable";
|
|
14
|
+
message: string;
|
|
15
|
+
connectionId?: string;
|
|
16
|
+
} | {
|
|
17
|
+
status: "upstream-error";
|
|
18
|
+
message: string;
|
|
19
|
+
connectionId?: string;
|
|
20
|
+
};
|
|
21
|
+
export type AgentRuntimeStatus = {
|
|
22
|
+
type: "idle";
|
|
23
|
+
} | {
|
|
24
|
+
type: "busy";
|
|
25
|
+
} | {
|
|
26
|
+
type: "retry";
|
|
27
|
+
attempt: number;
|
|
28
|
+
message: string;
|
|
29
|
+
next: number;
|
|
30
|
+
action?: {
|
|
31
|
+
reason: string;
|
|
32
|
+
provider: string;
|
|
33
|
+
title: string;
|
|
34
|
+
message: string;
|
|
35
|
+
label: string;
|
|
36
|
+
link?: string;
|
|
37
|
+
};
|
|
38
|
+
} | {
|
|
39
|
+
type: "recovering";
|
|
40
|
+
kind: "process_restart";
|
|
41
|
+
message: string;
|
|
42
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type AgentModel = {
|
|
2
|
+
providerId: string;
|
|
3
|
+
modelId: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
};
|
|
7
|
+
export type ModelSelection = {
|
|
8
|
+
status: "required";
|
|
9
|
+
models: AgentModel[];
|
|
10
|
+
} | {
|
|
11
|
+
status: "optional";
|
|
12
|
+
models?: AgentModel[];
|
|
13
|
+
} | {
|
|
14
|
+
status: "unsupported";
|
|
15
|
+
};
|
|
16
|
+
export type AgentCapabilities = {
|
|
17
|
+
harness: string;
|
|
18
|
+
modelSelection: ModelSelection;
|
|
19
|
+
abort: boolean;
|
|
20
|
+
reconnect: boolean;
|
|
21
|
+
replay: boolean;
|
|
22
|
+
permissions: boolean;
|
|
23
|
+
questions: boolean;
|
|
24
|
+
todos: boolean;
|
|
25
|
+
commands: boolean;
|
|
26
|
+
fork: boolean;
|
|
27
|
+
revert: boolean;
|
|
28
|
+
unrevert: boolean;
|
|
29
|
+
configOptions: boolean;
|
|
30
|
+
subagents: boolean;
|
|
31
|
+
};
|
package/dist/claims.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a vendor's login document says about the account it belongs to.
|
|
3
|
+
*
|
|
4
|
+
* Pure parsing over a JWT's claims, and here rather than beside either reader:
|
|
5
|
+
* the credential authority asks it to name a stored account, and the Codex
|
|
6
|
+
* harness asks it of the auth file the CLI wrote. Two copies drifted on which
|
|
7
|
+
* claim they would accept, and an account id read one way and written the other
|
|
8
|
+
* spends one subscription's token against another's plan.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The account's email address out of a login document's claims.
|
|
12
|
+
*
|
|
13
|
+
* Which claim holds it depends on the issuer and on which token is present: a
|
|
14
|
+
* ChatGPT `id_token` carries `email`, an access token often carries only
|
|
15
|
+
* `preferred_username`, and the `https://api.openai.com/auth` namespace keeps
|
|
16
|
+
* its own copy. The `@` test is what separates an address from a bare
|
|
17
|
+
* username, which `preferred_username` is free to be.
|
|
18
|
+
*
|
|
19
|
+
* A secret that is not a JWT names no account — never an error, because a
|
|
20
|
+
* credential without an email is ordinary.
|
|
21
|
+
*/
|
|
22
|
+
export declare function emailFromClaims(input: Record<string, unknown> | undefined): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* The ChatGPT account a login document names.
|
|
25
|
+
*
|
|
26
|
+
* This is what tells the Codex backend which plan a token spends, and a login
|
|
27
|
+
* often carries it only inside the `id_token`. An organization list is the last
|
|
28
|
+
* resort: a login that names no account id still belongs to the first
|
|
29
|
+
* organization its claims list.
|
|
30
|
+
*/
|
|
31
|
+
export declare function accountIdFromClaims(input: Record<string, unknown> | undefined): string | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AgentCapabilities, ModelSelection } from "./capabilities";
|
|
2
|
+
export type ConnectionReadiness = "ready" | "unavailable" | "disabled";
|
|
3
|
+
export type HarnessConnectionCapabilities = Omit<AgentCapabilities, "harness" | "modelSelection">;
|
|
4
|
+
/** Public discovery metadata. Provider configuration and credentials stay on the host. */
|
|
5
|
+
export type HarnessConnectionRef = {
|
|
6
|
+
connectionId: string;
|
|
7
|
+
label: string;
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
readiness: ConnectionReadiness;
|
|
10
|
+
capabilities: HarnessConnectionCapabilities;
|
|
11
|
+
modelSelection?: ModelSelection;
|
|
12
|
+
};
|
|
13
|
+
export type HarnessConnectionsCatalog = {
|
|
14
|
+
status: "supported";
|
|
15
|
+
connections: HarnessConnectionRef[];
|
|
16
|
+
} | {
|
|
17
|
+
status: "unsupported";
|
|
18
|
+
reason: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function decodeHarnessConnectionsCatalog(value: unknown): HarnessConnectionsCatalog;
|
|
21
|
+
export declare function decodeModelSelection(value: unknown): ModelSelection;
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import type { AgentMessageAuthor } from "./sessions";
|
|
2
|
+
/** Token accounting, reported identically by assistant messages and step-finish parts. */
|
|
3
|
+
export type AgentTokenUsage = {
|
|
4
|
+
total?: number;
|
|
5
|
+
input: number;
|
|
6
|
+
output: number;
|
|
7
|
+
reasoning: number;
|
|
8
|
+
cache: {
|
|
9
|
+
read: number;
|
|
10
|
+
write: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
/** The provider/model pair a message was produced with. */
|
|
14
|
+
export type AgentModelRef = {
|
|
15
|
+
providerID: string;
|
|
16
|
+
modelID: string;
|
|
17
|
+
variant?: string;
|
|
18
|
+
};
|
|
19
|
+
export type AgentMessageError = {
|
|
20
|
+
name: string;
|
|
21
|
+
data: Record<string, unknown> & {
|
|
22
|
+
message?: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export type AgentOutputFormat = {
|
|
26
|
+
type: "text";
|
|
27
|
+
} | {
|
|
28
|
+
type: "json_schema";
|
|
29
|
+
schema: Record<string, unknown>;
|
|
30
|
+
retryCount?: number;
|
|
31
|
+
};
|
|
32
|
+
export type AgentUserMessage = {
|
|
33
|
+
id: string;
|
|
34
|
+
sessionID: string;
|
|
35
|
+
role: "user";
|
|
36
|
+
time: {
|
|
37
|
+
created: number;
|
|
38
|
+
};
|
|
39
|
+
format?: AgentOutputFormat;
|
|
40
|
+
summary?: {
|
|
41
|
+
title?: string;
|
|
42
|
+
body?: string;
|
|
43
|
+
diffs: AgentSnapshotFileDiff[];
|
|
44
|
+
};
|
|
45
|
+
agent: string;
|
|
46
|
+
model: AgentModelRef;
|
|
47
|
+
system?: string;
|
|
48
|
+
tools?: Record<string, boolean>;
|
|
49
|
+
claxedo?: {
|
|
50
|
+
author: AgentMessageAuthor;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export type AgentAssistantMessage = {
|
|
54
|
+
id: string;
|
|
55
|
+
sessionID: string;
|
|
56
|
+
role: "assistant";
|
|
57
|
+
time: {
|
|
58
|
+
created: number;
|
|
59
|
+
completed?: number;
|
|
60
|
+
};
|
|
61
|
+
error?: AgentMessageError;
|
|
62
|
+
parentID: string;
|
|
63
|
+
modelID: string;
|
|
64
|
+
providerID: string;
|
|
65
|
+
mode: string;
|
|
66
|
+
agent: string;
|
|
67
|
+
path: {
|
|
68
|
+
cwd: string;
|
|
69
|
+
root: string;
|
|
70
|
+
};
|
|
71
|
+
summary?: boolean;
|
|
72
|
+
cost: number;
|
|
73
|
+
tokens: AgentTokenUsage;
|
|
74
|
+
structured?: unknown;
|
|
75
|
+
variant?: string;
|
|
76
|
+
finish?: string;
|
|
77
|
+
};
|
|
78
|
+
/** Message information rendered by transcript and navigation surfaces. */
|
|
79
|
+
export type AgentPresentationMessage = AgentUserMessage | AgentAssistantMessage;
|
|
80
|
+
export type AgentMessageInfo = {
|
|
81
|
+
id: string;
|
|
82
|
+
role: string;
|
|
83
|
+
sessionID: string;
|
|
84
|
+
parentID?: string;
|
|
85
|
+
time?: {
|
|
86
|
+
created: number;
|
|
87
|
+
completed?: number;
|
|
88
|
+
};
|
|
89
|
+
providerID?: string;
|
|
90
|
+
modelID?: string;
|
|
91
|
+
model?: AgentModelRef;
|
|
92
|
+
agent?: string;
|
|
93
|
+
mode?: string;
|
|
94
|
+
path?: {
|
|
95
|
+
cwd: string;
|
|
96
|
+
root: string;
|
|
97
|
+
};
|
|
98
|
+
cost?: number;
|
|
99
|
+
tokens?: AgentTokenUsage;
|
|
100
|
+
tools?: Record<string, boolean>;
|
|
101
|
+
system?: string;
|
|
102
|
+
variant?: string;
|
|
103
|
+
format?: unknown;
|
|
104
|
+
finish?: string;
|
|
105
|
+
error?: AgentMessageError;
|
|
106
|
+
claxedo?: {
|
|
107
|
+
author: AgentMessageAuthor;
|
|
108
|
+
};
|
|
109
|
+
harnessPayload?: unknown;
|
|
110
|
+
[key: string]: unknown;
|
|
111
|
+
};
|
|
112
|
+
export type AgentMessage = {
|
|
113
|
+
info: AgentMessageInfo;
|
|
114
|
+
parts: AgentContentPart[];
|
|
115
|
+
harnessPayload?: unknown;
|
|
116
|
+
};
|
|
117
|
+
type AgentPartBase<Type extends string> = {
|
|
118
|
+
id: string;
|
|
119
|
+
sessionID: string;
|
|
120
|
+
messageID: string;
|
|
121
|
+
type: Type;
|
|
122
|
+
};
|
|
123
|
+
export type AgentTextPart = AgentPartBase<"text"> & {
|
|
124
|
+
text: string;
|
|
125
|
+
synthetic?: boolean;
|
|
126
|
+
ignored?: boolean;
|
|
127
|
+
time?: {
|
|
128
|
+
start: number;
|
|
129
|
+
end?: number;
|
|
130
|
+
};
|
|
131
|
+
metadata?: Record<string, unknown>;
|
|
132
|
+
};
|
|
133
|
+
export type AgentReasoningPart = AgentPartBase<"reasoning"> & {
|
|
134
|
+
text: string;
|
|
135
|
+
time: {
|
|
136
|
+
start: number;
|
|
137
|
+
end?: number;
|
|
138
|
+
};
|
|
139
|
+
metadata?: Record<string, unknown>;
|
|
140
|
+
};
|
|
141
|
+
export type AgentFilePartSourceText = {
|
|
142
|
+
value: string;
|
|
143
|
+
start: number;
|
|
144
|
+
end: number;
|
|
145
|
+
};
|
|
146
|
+
export type AgentFilePartRange = {
|
|
147
|
+
start: {
|
|
148
|
+
line: number;
|
|
149
|
+
character: number;
|
|
150
|
+
};
|
|
151
|
+
end: {
|
|
152
|
+
line: number;
|
|
153
|
+
character: number;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
export type AgentFileSource = {
|
|
157
|
+
type: "file";
|
|
158
|
+
text: AgentFilePartSourceText;
|
|
159
|
+
path: string;
|
|
160
|
+
};
|
|
161
|
+
export type AgentSymbolSource = {
|
|
162
|
+
type: "symbol";
|
|
163
|
+
text: AgentFilePartSourceText;
|
|
164
|
+
path: string;
|
|
165
|
+
range: AgentFilePartRange;
|
|
166
|
+
name: string;
|
|
167
|
+
kind: number;
|
|
168
|
+
};
|
|
169
|
+
export type AgentResourceSource = {
|
|
170
|
+
type: "resource";
|
|
171
|
+
text: AgentFilePartSourceText;
|
|
172
|
+
clientName: string;
|
|
173
|
+
uri: string;
|
|
174
|
+
};
|
|
175
|
+
export type AgentFilePartSource = AgentFileSource | AgentSymbolSource | AgentResourceSource;
|
|
176
|
+
/**
|
|
177
|
+
* Where a file part's bytes are when `url` does not carry them. A workspace
|
|
178
|
+
* file is read by path when the view needs it; unretained bytes were dropped
|
|
179
|
+
* at capture and only their size survives, so a view can say how large the
|
|
180
|
+
* image was instead of rendering a broken one.
|
|
181
|
+
*/
|
|
182
|
+
export type AgentFileLocation = {
|
|
183
|
+
kind: "workspace-file";
|
|
184
|
+
path: string;
|
|
185
|
+
} | {
|
|
186
|
+
kind: "unretained";
|
|
187
|
+
bytes: number;
|
|
188
|
+
};
|
|
189
|
+
export type AgentFilePart = AgentPartBase<"file"> & {
|
|
190
|
+
mime: string;
|
|
191
|
+
filename?: string;
|
|
192
|
+
url: string;
|
|
193
|
+
location?: AgentFileLocation;
|
|
194
|
+
source?: AgentFilePartSource;
|
|
195
|
+
};
|
|
196
|
+
export type AgentTextPartInput = Omit<AgentTextPart, "id" | "sessionID" | "messageID"> & {
|
|
197
|
+
id?: string;
|
|
198
|
+
};
|
|
199
|
+
export type AgentFilePartInput = Omit<AgentFilePart, "id" | "sessionID" | "messageID"> & {
|
|
200
|
+
id?: string;
|
|
201
|
+
};
|
|
202
|
+
export type AgentAgentPartInput = Omit<AgentAgentPart, "id" | "sessionID" | "messageID"> & {
|
|
203
|
+
id?: string;
|
|
204
|
+
};
|
|
205
|
+
export type AgentToolState = {
|
|
206
|
+
status: "pending";
|
|
207
|
+
input: Record<string, unknown>;
|
|
208
|
+
raw: string;
|
|
209
|
+
} | {
|
|
210
|
+
status: "running";
|
|
211
|
+
input: Record<string, unknown>;
|
|
212
|
+
title?: string;
|
|
213
|
+
metadata?: Record<string, unknown>;
|
|
214
|
+
time: {
|
|
215
|
+
start: number;
|
|
216
|
+
};
|
|
217
|
+
} | {
|
|
218
|
+
status: "completed";
|
|
219
|
+
input: Record<string, unknown>;
|
|
220
|
+
output: string;
|
|
221
|
+
title: string;
|
|
222
|
+
metadata: Record<string, unknown>;
|
|
223
|
+
time: {
|
|
224
|
+
start: number;
|
|
225
|
+
end: number;
|
|
226
|
+
compacted?: number;
|
|
227
|
+
};
|
|
228
|
+
attachments?: AgentFilePart[];
|
|
229
|
+
} | {
|
|
230
|
+
status: "error";
|
|
231
|
+
input: Record<string, unknown>;
|
|
232
|
+
error: string;
|
|
233
|
+
metadata?: Record<string, unknown>;
|
|
234
|
+
time: {
|
|
235
|
+
start: number;
|
|
236
|
+
end: number;
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
export type AgentToolPart = AgentPartBase<"tool"> & {
|
|
240
|
+
callID: string;
|
|
241
|
+
tool: string;
|
|
242
|
+
state: AgentToolState;
|
|
243
|
+
metadata?: Record<string, unknown>;
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Whether a tool name spawns a subagent. Every harness spelling — Claude's `Agent`,
|
|
247
|
+
* the runtime's own `create_subagent`, bare or MCP-prefixed — canonicalises to `task`,
|
|
248
|
+
* so the alias table is the one place a new spelling is added. Both the event runtime's
|
|
249
|
+
* tool-intent mapping and the transcript's grouping ask this question here, because a
|
|
250
|
+
* name known to only one of them is a subagent that renders as a generic tool row.
|
|
251
|
+
*
|
|
252
|
+
* Callers pass the tool name as the part carries it; matching is case-insensitive
|
|
253
|
+
* because only the client-presentation projection canonicalises case.
|
|
254
|
+
*/
|
|
255
|
+
export declare function isSubagentSpawnToolName(toolName: string): boolean;
|
|
256
|
+
export type AgentSubtaskPart = AgentPartBase<"subtask"> & {
|
|
257
|
+
prompt: string;
|
|
258
|
+
description: string;
|
|
259
|
+
agent: string;
|
|
260
|
+
model?: {
|
|
261
|
+
providerID: string;
|
|
262
|
+
modelID: string;
|
|
263
|
+
};
|
|
264
|
+
command?: string;
|
|
265
|
+
};
|
|
266
|
+
export type AgentStepStartPart = AgentPartBase<"step-start"> & {
|
|
267
|
+
snapshot?: string;
|
|
268
|
+
};
|
|
269
|
+
export type AgentStepFinishPart = AgentPartBase<"step-finish"> & {
|
|
270
|
+
reason: string;
|
|
271
|
+
snapshot?: string;
|
|
272
|
+
cost: number;
|
|
273
|
+
tokens: AgentTokenUsage;
|
|
274
|
+
};
|
|
275
|
+
export type AgentSnapshotPart = AgentPartBase<"snapshot"> & {
|
|
276
|
+
snapshot: string;
|
|
277
|
+
};
|
|
278
|
+
export type AgentPatchPart = AgentPartBase<"patch"> & {
|
|
279
|
+
hash: string;
|
|
280
|
+
files: string[];
|
|
281
|
+
};
|
|
282
|
+
export type AgentAgentPart = AgentPartBase<"agent"> & {
|
|
283
|
+
name: string;
|
|
284
|
+
source?: {
|
|
285
|
+
value: string;
|
|
286
|
+
start: number;
|
|
287
|
+
end: number;
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
export type AgentRetryPart = AgentPartBase<"retry"> & {
|
|
291
|
+
attempt: number;
|
|
292
|
+
error: AgentMessageError;
|
|
293
|
+
time: {
|
|
294
|
+
created: number;
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
export type AgentCompactionPart = AgentPartBase<"compaction"> & {
|
|
298
|
+
auto: boolean;
|
|
299
|
+
overflow?: boolean;
|
|
300
|
+
tail_start_id?: string;
|
|
301
|
+
};
|
|
302
|
+
export type AgentHandoffPart = AgentPartBase<"handoff"> & {
|
|
303
|
+
from: {
|
|
304
|
+
id: string;
|
|
305
|
+
access: string;
|
|
306
|
+
connection?: unknown;
|
|
307
|
+
};
|
|
308
|
+
to: {
|
|
309
|
+
id: string;
|
|
310
|
+
access: string;
|
|
311
|
+
connection?: unknown;
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
export type AgentContentPart = AgentTextPart | AgentReasoningPart | AgentFilePart | AgentToolPart | AgentSubtaskPart | AgentStepStartPart | AgentStepFinishPart | AgentSnapshotPart | AgentPatchPart | AgentAgentPart | AgentRetryPart | AgentCompactionPart | AgentHandoffPart;
|
|
315
|
+
export type AgentPromptResponse = {
|
|
316
|
+
info: AgentAssistantMessage;
|
|
317
|
+
parts: AgentContentPart[];
|
|
318
|
+
};
|
|
319
|
+
export type AgentTodo = {
|
|
320
|
+
/** Provider-issued task identity, retained for incremental native updates. */
|
|
321
|
+
id?: string;
|
|
322
|
+
content: string;
|
|
323
|
+
status: string;
|
|
324
|
+
priority: string;
|
|
325
|
+
};
|
|
326
|
+
export type AgentQuestionOption = {
|
|
327
|
+
label: string;
|
|
328
|
+
description: string;
|
|
329
|
+
};
|
|
330
|
+
export type AgentQuestionInfo = {
|
|
331
|
+
question: string;
|
|
332
|
+
header: string;
|
|
333
|
+
options: AgentQuestionOption[];
|
|
334
|
+
multiple?: boolean;
|
|
335
|
+
custom?: boolean;
|
|
336
|
+
};
|
|
337
|
+
export type AgentQuestionAnswer = string[];
|
|
338
|
+
export type AgentPermission = {
|
|
339
|
+
id: string;
|
|
340
|
+
sessionID: string;
|
|
341
|
+
tool?: {
|
|
342
|
+
messageID: string;
|
|
343
|
+
callID: string;
|
|
344
|
+
};
|
|
345
|
+
title?: string;
|
|
346
|
+
permission: string;
|
|
347
|
+
patterns: string[];
|
|
348
|
+
always: string[];
|
|
349
|
+
metadata: Record<string, unknown>;
|
|
350
|
+
time?: {
|
|
351
|
+
created?: number;
|
|
352
|
+
};
|
|
353
|
+
harnessPayload?: unknown;
|
|
354
|
+
};
|
|
355
|
+
export type AgentQuestion = {
|
|
356
|
+
id: string;
|
|
357
|
+
sessionID: string;
|
|
358
|
+
questions: AgentQuestionInfo[];
|
|
359
|
+
tool?: {
|
|
360
|
+
messageID: string;
|
|
361
|
+
callID: string;
|
|
362
|
+
};
|
|
363
|
+
harnessPayload?: unknown;
|
|
364
|
+
};
|
|
365
|
+
export type AgentCommand = {
|
|
366
|
+
name: string;
|
|
367
|
+
content?: string;
|
|
368
|
+
description?: string;
|
|
369
|
+
harnessPayload?: unknown;
|
|
370
|
+
};
|
|
371
|
+
export type AgentAgent = {
|
|
372
|
+
name: string;
|
|
373
|
+
description?: string;
|
|
374
|
+
mode?: string;
|
|
375
|
+
harnessPayload?: unknown;
|
|
376
|
+
};
|
|
377
|
+
export type AgentConfigOption = {
|
|
378
|
+
id: string;
|
|
379
|
+
name?: string;
|
|
380
|
+
type?: string;
|
|
381
|
+
category?: string;
|
|
382
|
+
currentValue?: unknown;
|
|
383
|
+
description?: string;
|
|
384
|
+
selectOptions?: Array<{
|
|
385
|
+
id: string;
|
|
386
|
+
name?: string;
|
|
387
|
+
description?: string;
|
|
388
|
+
value?: unknown;
|
|
389
|
+
connected?: boolean;
|
|
390
|
+
harnessPayload?: unknown;
|
|
391
|
+
}>;
|
|
392
|
+
harnessPayload?: unknown;
|
|
393
|
+
};
|
|
394
|
+
export type AgentSnapshotFileDiff = {
|
|
395
|
+
file?: string;
|
|
396
|
+
patch?: string;
|
|
397
|
+
additions: number;
|
|
398
|
+
deletions: number;
|
|
399
|
+
status?: "added" | "deleted" | "modified";
|
|
400
|
+
};
|
|
401
|
+
/** Is `value` one of the content parts the contract declares? */
|
|
402
|
+
export declare function isAgentContentPart(value: unknown): value is AgentContentPart;
|
|
403
|
+
/** The content part `value` holds, or `undefined` when it is not one. */
|
|
404
|
+
export declare function parseAgentContentPart(value: unknown): AgentContentPart | undefined;
|
|
405
|
+
/** Is `value` the identifying header every message carries? */
|
|
406
|
+
export declare function isAgentMessageInfo(value: unknown): value is AgentMessageInfo;
|
|
407
|
+
/** Is `value` a message — a valid header and a list of parts the contract declares? */
|
|
408
|
+
export declare function isAgentMessage(value: unknown): value is AgentMessage;
|
|
409
|
+
/** The message `value` holds, or `undefined` when it is not one. */
|
|
410
|
+
export declare function parseAgentMessage(value: unknown): AgentMessage | undefined;
|
|
411
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every refusal Claxedo's credential broker answers with: the one line each
|
|
3
|
+
* says, and which side of the turn it blames.
|
|
4
|
+
*
|
|
5
|
+
* One table because two readers act on these codes — the broker writes them,
|
|
6
|
+
* and the runtime that classifies a failed turn decides from them what to tell
|
|
7
|
+
* the operator. A second hand-kept copy could only disagree, and disagreeing
|
|
8
|
+
* here means telling someone to replace a working account for a request their
|
|
9
|
+
* harness should never have made.
|
|
10
|
+
*
|
|
11
|
+
* `fault` is that decision. The HTTP status cannot stand in for it: 403 is the
|
|
12
|
+
* answer both for a credential the broker will not serve and for a route the
|
|
13
|
+
* binding does not allow.
|
|
14
|
+
*/
|
|
15
|
+
export declare const CREDENTIAL_BROKER_ERRORS: {
|
|
16
|
+
readonly binding_route_required: {
|
|
17
|
+
readonly fault: "harness";
|
|
18
|
+
readonly message: "The credential broker serves binding paths only";
|
|
19
|
+
};
|
|
20
|
+
readonly runtime_token_required: {
|
|
21
|
+
readonly fault: "harness";
|
|
22
|
+
readonly message: "The request carried no runtime token, or two that disagree";
|
|
23
|
+
};
|
|
24
|
+
readonly runtime_token_invalid: {
|
|
25
|
+
readonly fault: "credential";
|
|
26
|
+
readonly message: "The runtime token could not be verified";
|
|
27
|
+
};
|
|
28
|
+
readonly binding_not_permitted: {
|
|
29
|
+
readonly fault: "harness";
|
|
30
|
+
readonly message: "This runtime token does not name that binding";
|
|
31
|
+
};
|
|
32
|
+
readonly binding_unavailable: {
|
|
33
|
+
readonly fault: "credential";
|
|
34
|
+
readonly message: "The binding names no account this runtime can spend";
|
|
35
|
+
};
|
|
36
|
+
readonly credential_unavailable: {
|
|
37
|
+
readonly fault: "credential";
|
|
38
|
+
readonly message: "The account behind this binding has no readable value";
|
|
39
|
+
};
|
|
40
|
+
readonly binding_destination_invalid: {
|
|
41
|
+
readonly fault: "harness";
|
|
42
|
+
readonly message: "The binding's destination is not a usable vendor origin";
|
|
43
|
+
};
|
|
44
|
+
readonly binding_injection_invalid: {
|
|
45
|
+
readonly fault: "harness";
|
|
46
|
+
readonly message: "The binding names a header the broker cannot set";
|
|
47
|
+
};
|
|
48
|
+
readonly request_outside_policy: {
|
|
49
|
+
readonly fault: "harness";
|
|
50
|
+
readonly message: "The request is outside the routes this binding allows";
|
|
51
|
+
};
|
|
52
|
+
readonly upstream_unavailable: {
|
|
53
|
+
readonly fault: "model";
|
|
54
|
+
readonly message: "The vendor could not be reached";
|
|
55
|
+
};
|
|
56
|
+
readonly upstream_redirect_refused: {
|
|
57
|
+
readonly fault: "model";
|
|
58
|
+
readonly message: "The vendor answered with a redirect, which the broker does not follow";
|
|
59
|
+
};
|
|
60
|
+
readonly broker_authority_unavailable: {
|
|
61
|
+
readonly fault: "harness";
|
|
62
|
+
readonly message: "The credential authority could not be reached";
|
|
63
|
+
};
|
|
64
|
+
/** Answered by the mounts in front of the broker, in the broker's vocabulary. */
|
|
65
|
+
readonly loopback_required: {
|
|
66
|
+
readonly fault: "harness";
|
|
67
|
+
readonly message: "The credential broker answers loopback callers only";
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export type CredentialBrokerErrorCode = keyof typeof CREDENTIAL_BROKER_ERRORS;
|
|
71
|
+
/**
|
|
72
|
+
* The code a message carries.
|
|
73
|
+
*
|
|
74
|
+
* The JSON body a harness echoed first: one that retried names its earlier
|
|
75
|
+
* failure in its own prose, and the verdict belongs to the response it gave up
|
|
76
|
+
* on. The bare code in that prose is the fallback, for a harness that
|
|
77
|
+
* summarises the body rather than quoting it.
|
|
78
|
+
*/
|
|
79
|
+
export declare function credentialBrokerErrorCode(message: string): CredentialBrokerErrorCode | undefined;
|
|
80
|
+
export declare function isCredentialBrokerErrorCode(value: string): value is CredentialBrokerErrorCode;
|