@steerable/agent-protocol 0.8.4 → 0.9.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/dist/index.d.ts +2 -0
- package/dist/index.js +4 -0
- package/dist/runtime-target.d.ts +43 -0
- package/dist/runtime-target.js +60 -0
- package/dist/turn-failure-kind.d.ts +54 -0
- package/dist/turn-failure-kind.js +92 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export * from "./generated/ChatMessage.js";
|
|
|
5
5
|
export * from "./generated/ContentPart.js";
|
|
6
6
|
export * from "./generated/ChatAgent.js";
|
|
7
7
|
export * from "./generated/CommandSafetyPattern.js";
|
|
8
|
+
export * from "./runtime-target.js";
|
|
9
|
+
export * from "./turn-failure-kind.js";
|
|
8
10
|
export * from "./generated/AgentSession.js";
|
|
9
11
|
export * from "./generated/HarnessTrace.js";
|
|
10
12
|
export * from "./generated/TraceSpan.js";
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,10 @@ export * from "./generated/ChatMessage.js";
|
|
|
5
5
|
export * from "./generated/ContentPart.js";
|
|
6
6
|
export * from "./generated/ChatAgent.js";
|
|
7
7
|
export * from "./generated/CommandSafetyPattern.js";
|
|
8
|
+
// Host platform identifiers shared by the runtime resolvers and release tooling
|
|
9
|
+
export * from "./runtime-target.js";
|
|
10
|
+
// Failure vocabulary shared by the host shell and the command line
|
|
11
|
+
export * from "./turn-failure-kind.js";
|
|
8
12
|
// Tier 3 runtime models
|
|
9
13
|
export * from "./generated/AgentSession.js";
|
|
10
14
|
export * from "./generated/HarnessTrace.js";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host platform identifiers for the published runtime bundles.
|
|
3
|
+
*
|
|
4
|
+
* The same five names key the sidecar bundles (`build_sidecar.py`), the
|
|
5
|
+
* platform npm packages (`@steerable/runtime-<target>`), and the egress proxy
|
|
6
|
+
* release assets, so a mismatch between them is a compile-time typo rather
|
|
7
|
+
* than a runtime miss.
|
|
8
|
+
*/
|
|
9
|
+
/** One platform the framework publishes a runtime bundle for. */
|
|
10
|
+
export type RuntimeTarget = 'darwin-arm64' | 'darwin-x64' | 'linux-x64' | 'linux-arm64' | 'win32-x64';
|
|
11
|
+
/** Every published target, in the order the release tooling builds them. */
|
|
12
|
+
export declare const RUNTIME_TARGETS: readonly RuntimeTarget[];
|
|
13
|
+
/**
|
|
14
|
+
* Maps a Node platform/arch pair to a published target.
|
|
15
|
+
*
|
|
16
|
+
* @param platform `process.platform` value.
|
|
17
|
+
* @param arch `process.arch` value.
|
|
18
|
+
* @returns The matching target, or `null` when the framework publishes no bundle for it.
|
|
19
|
+
*/
|
|
20
|
+
export declare function runtimeTargetFor(platform: string, arch: string): RuntimeTarget | null;
|
|
21
|
+
/**
|
|
22
|
+
* Target for the running host.
|
|
23
|
+
*
|
|
24
|
+
* Takes the pair explicitly: this package is pure data types with no Node
|
|
25
|
+
* globals, so callers pass `process.platform` and `process.arch`.
|
|
26
|
+
*
|
|
27
|
+
* @param platform `process.platform` value.
|
|
28
|
+
* @param arch `process.arch` value.
|
|
29
|
+
* @returns The running host's target, or `null` on an unpublished platform.
|
|
30
|
+
*/
|
|
31
|
+
export declare function hostRuntimeTarget(platform: string, arch: string): RuntimeTarget | null;
|
|
32
|
+
/**
|
|
33
|
+
* Platform tag used by the in-repo `python-runtime/` bundle layout.
|
|
34
|
+
*
|
|
35
|
+
* Only these four directories exist in packaged desktop resources, so this
|
|
36
|
+
* stays narrower than {@link RuntimeTarget}: a Linux arm64 desktop build has
|
|
37
|
+
* no bundled layout and falls through to the platform npm package.
|
|
38
|
+
*
|
|
39
|
+
* @param platform `process.platform` value.
|
|
40
|
+
* @param arch `process.arch` value.
|
|
41
|
+
* @returns The bundled-directory tag, or `null`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function bundledRuntimeTag(platform: string, arch: string): 'darwin-arm64' | 'darwin-x64' | 'linux-x64' | 'win32-x64' | null;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host platform identifiers for the published runtime bundles.
|
|
3
|
+
*
|
|
4
|
+
* The same five names key the sidecar bundles (`build_sidecar.py`), the
|
|
5
|
+
* platform npm packages (`@steerable/runtime-<target>`), and the egress proxy
|
|
6
|
+
* release assets, so a mismatch between them is a compile-time typo rather
|
|
7
|
+
* than a runtime miss.
|
|
8
|
+
*/
|
|
9
|
+
/** Every published target, in the order the release tooling builds them. */
|
|
10
|
+
export const RUNTIME_TARGETS = [
|
|
11
|
+
'darwin-arm64',
|
|
12
|
+
'darwin-x64',
|
|
13
|
+
'linux-x64',
|
|
14
|
+
'linux-arm64',
|
|
15
|
+
'win32-x64',
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* Maps a Node platform/arch pair to a published target.
|
|
19
|
+
*
|
|
20
|
+
* @param platform `process.platform` value.
|
|
21
|
+
* @param arch `process.arch` value.
|
|
22
|
+
* @returns The matching target, or `null` when the framework publishes no bundle for it.
|
|
23
|
+
*/
|
|
24
|
+
export function runtimeTargetFor(platform, arch) {
|
|
25
|
+
const candidate = `${platform}-${arch}`;
|
|
26
|
+
return RUNTIME_TARGETS.includes(candidate) ? candidate : null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Target for the running host.
|
|
30
|
+
*
|
|
31
|
+
* Takes the pair explicitly: this package is pure data types with no Node
|
|
32
|
+
* globals, so callers pass `process.platform` and `process.arch`.
|
|
33
|
+
*
|
|
34
|
+
* @param platform `process.platform` value.
|
|
35
|
+
* @param arch `process.arch` value.
|
|
36
|
+
* @returns The running host's target, or `null` on an unpublished platform.
|
|
37
|
+
*/
|
|
38
|
+
export function hostRuntimeTarget(platform, arch) {
|
|
39
|
+
return runtimeTargetFor(platform, arch);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Platform tag used by the in-repo `python-runtime/` bundle layout.
|
|
43
|
+
*
|
|
44
|
+
* Only these four directories exist in packaged desktop resources, so this
|
|
45
|
+
* stays narrower than {@link RuntimeTarget}: a Linux arm64 desktop build has
|
|
46
|
+
* no bundled layout and falls through to the platform npm package.
|
|
47
|
+
*
|
|
48
|
+
* @param platform `process.platform` value.
|
|
49
|
+
* @param arch `process.arch` value.
|
|
50
|
+
* @returns The bundled-directory tag, or `null`.
|
|
51
|
+
*/
|
|
52
|
+
export function bundledRuntimeTag(platform, arch) {
|
|
53
|
+
if (platform === 'darwin')
|
|
54
|
+
return arch === 'arm64' ? 'darwin-arm64' : 'darwin-x64';
|
|
55
|
+
if (platform === 'win32')
|
|
56
|
+
return arch === 'x64' ? 'win32-x64' : null;
|
|
57
|
+
if (platform === 'linux')
|
|
58
|
+
return arch === 'x64' ? 'linux-x64' : null;
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Failure classification shared by every surface that has to explain a failed
|
|
3
|
+
* turn: the web failure card and the command line.
|
|
4
|
+
*
|
|
5
|
+
* Lives in Tier 1 because the browser bundle cannot import the host client,
|
|
6
|
+
* and both surfaces must classify a failure the same way.
|
|
7
|
+
*
|
|
8
|
+
* The backend classifies provider failures (`LLMError.kind`) and records the
|
|
9
|
+
* value with the turn. Matching on that field — never on message text — keeps
|
|
10
|
+
* wording stable while error strings change. Each surface owns its own copy;
|
|
11
|
+
* this module owns only the vocabulary and the reader.
|
|
12
|
+
*/
|
|
13
|
+
/** One provider failure class the backend can record. */
|
|
14
|
+
export type TurnFailureKind = 'transport' | 'rate_limit' | 'server' | 'auth' | 'invalid_request' | 'context_overflow' | 'unknown';
|
|
15
|
+
/** Every kind, in the order diagnostics list them. */
|
|
16
|
+
export declare const TURN_FAILURE_KINDS: readonly TurnFailureKind[];
|
|
17
|
+
/** Structured failure detail persisted with a turn (`messageMetadata.failure`). */
|
|
18
|
+
export interface TurnFailureDetail {
|
|
19
|
+
kind: TurnFailureKind;
|
|
20
|
+
/** Proxy the failing request used, credentials already stripped. */
|
|
21
|
+
proxy?: string;
|
|
22
|
+
/** Provider attempts spent on the request, including the last. */
|
|
23
|
+
attempts?: number;
|
|
24
|
+
statusCode?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Narrows an unknown metadata value to a failure kind.
|
|
28
|
+
*
|
|
29
|
+
* Returns undefined for anything unrecognized — an older sidecar that sent
|
|
30
|
+
* nothing, a value from a newer one, a corrupted record — so the caller can
|
|
31
|
+
* fall back to a generic message instead of inventing a cause.
|
|
32
|
+
*
|
|
33
|
+
* @param value Raw `errorKind` metadata.
|
|
34
|
+
* @returns The kind, or undefined.
|
|
35
|
+
*/
|
|
36
|
+
export declare function readTurnFailureKind(value: unknown): TurnFailureKind | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Reads the persisted failure block, dropping fields of the wrong type.
|
|
39
|
+
*
|
|
40
|
+
* @param value Raw `messageMetadata.failure`.
|
|
41
|
+
* @returns The detail, or undefined when no usable kind is present.
|
|
42
|
+
*/
|
|
43
|
+
export declare function readTurnFailureDetail(value: unknown): TurnFailureDetail | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Classifies a raw error message that arrived without backend metadata.
|
|
46
|
+
*
|
|
47
|
+
* Only the command line needs this: the sidecar reports some failures as a
|
|
48
|
+
* plain message (a transport error before the turn starts), and a wall of
|
|
49
|
+
* provider text is not an answer. Web cards always have metadata.
|
|
50
|
+
*
|
|
51
|
+
* @param message Raw error text.
|
|
52
|
+
* @returns The best kind for that text; `unknown` when nothing matches.
|
|
53
|
+
*/
|
|
54
|
+
export declare function classifyErrorMessage(message: string): TurnFailureKind;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Failure classification shared by every surface that has to explain a failed
|
|
3
|
+
* turn: the web failure card and the command line.
|
|
4
|
+
*
|
|
5
|
+
* Lives in Tier 1 because the browser bundle cannot import the host client,
|
|
6
|
+
* and both surfaces must classify a failure the same way.
|
|
7
|
+
*
|
|
8
|
+
* The backend classifies provider failures (`LLMError.kind`) and records the
|
|
9
|
+
* value with the turn. Matching on that field — never on message text — keeps
|
|
10
|
+
* wording stable while error strings change. Each surface owns its own copy;
|
|
11
|
+
* this module owns only the vocabulary and the reader.
|
|
12
|
+
*/
|
|
13
|
+
/** Every kind, in the order diagnostics list them. */
|
|
14
|
+
export const TURN_FAILURE_KINDS = [
|
|
15
|
+
'transport',
|
|
16
|
+
'rate_limit',
|
|
17
|
+
'server',
|
|
18
|
+
'auth',
|
|
19
|
+
'invalid_request',
|
|
20
|
+
'context_overflow',
|
|
21
|
+
'unknown',
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Narrows an unknown metadata value to a failure kind.
|
|
25
|
+
*
|
|
26
|
+
* Returns undefined for anything unrecognized — an older sidecar that sent
|
|
27
|
+
* nothing, a value from a newer one, a corrupted record — so the caller can
|
|
28
|
+
* fall back to a generic message instead of inventing a cause.
|
|
29
|
+
*
|
|
30
|
+
* @param value Raw `errorKind` metadata.
|
|
31
|
+
* @returns The kind, or undefined.
|
|
32
|
+
*/
|
|
33
|
+
export function readTurnFailureKind(value) {
|
|
34
|
+
return typeof value === 'string' && TURN_FAILURE_KINDS.includes(value)
|
|
35
|
+
? value
|
|
36
|
+
: undefined;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Reads the persisted failure block, dropping fields of the wrong type.
|
|
40
|
+
*
|
|
41
|
+
* @param value Raw `messageMetadata.failure`.
|
|
42
|
+
* @returns The detail, or undefined when no usable kind is present.
|
|
43
|
+
*/
|
|
44
|
+
export function readTurnFailureDetail(value) {
|
|
45
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
46
|
+
return undefined;
|
|
47
|
+
const record = value;
|
|
48
|
+
const kind = readTurnFailureKind(record.errorKind);
|
|
49
|
+
if (!kind)
|
|
50
|
+
return undefined;
|
|
51
|
+
const proxy = typeof record.proxy === 'string' && record.proxy ? record.proxy : undefined;
|
|
52
|
+
const attempts = typeof record.attempts === 'number' && Number.isFinite(record.attempts) ? record.attempts : undefined;
|
|
53
|
+
const statusCode = typeof record.statusCode === 'number' && Number.isFinite(record.statusCode)
|
|
54
|
+
? record.statusCode
|
|
55
|
+
: undefined;
|
|
56
|
+
return {
|
|
57
|
+
kind,
|
|
58
|
+
...(proxy ? { proxy } : {}),
|
|
59
|
+
...(attempts !== undefined ? { attempts } : {}),
|
|
60
|
+
...(statusCode !== undefined ? { statusCode } : {}),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Classifies a raw error message that arrived without backend metadata.
|
|
65
|
+
*
|
|
66
|
+
* Only the command line needs this: the sidecar reports some failures as a
|
|
67
|
+
* plain message (a transport error before the turn starts), and a wall of
|
|
68
|
+
* provider text is not an answer. Web cards always have metadata.
|
|
69
|
+
*
|
|
70
|
+
* @param message Raw error text.
|
|
71
|
+
* @returns The best kind for that text; `unknown` when nothing matches.
|
|
72
|
+
*/
|
|
73
|
+
export function classifyErrorMessage(message) {
|
|
74
|
+
const text = message.toLowerCase();
|
|
75
|
+
if (/\b(401|403)\b|unauthor|invalid[ _-]?api[ _-]?key|authentication fail|incorrect api key/.test(text)) {
|
|
76
|
+
return 'auth';
|
|
77
|
+
}
|
|
78
|
+
if (/\b429\b|rate[ _-]?limit|too many requests|quota exceeded/.test(text))
|
|
79
|
+
return 'rate_limit';
|
|
80
|
+
if (/context[ _-]?(length|window)|too many tokens|maximum context/.test(text))
|
|
81
|
+
return 'context_overflow';
|
|
82
|
+
if (/\b(400|404|422)\b|invalid[ _-]?request|bad request/.test(text))
|
|
83
|
+
return 'invalid_request';
|
|
84
|
+
if (/\b5\d\d\b|internal server|bad gateway|service unavailable/.test(text))
|
|
85
|
+
return 'server';
|
|
86
|
+
if (/econnrefused|econnreset|enotfound|etimedout|socket hang up|network|fetch failed|connection (kept )?(dropping|reset|refused)/.test(text)) {
|
|
87
|
+
return 'transport';
|
|
88
|
+
}
|
|
89
|
+
if (/overloaded|governor/.test(text))
|
|
90
|
+
return 'server';
|
|
91
|
+
return 'unknown';
|
|
92
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steerable/agent-protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Steerable framework Tier 1 — wire-format types (SSEEvent, ChatMessage, ToolCall, ToolResult, AgentSession, HarnessTrace, sidecar JSON-RPC) shared by every Steerable client and server.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://steerableframework.com/",
|