@amaster.ai/pi-shared 0.1.2-beta.1 → 0.1.2-beta.100
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/__tests__/models.test.d.ts +2 -0
- package/dist/__tests__/models.test.d.ts.map +1 -0
- package/dist/__tests__/models.test.js +68 -0
- package/dist/__tests__/models.test.js.map +1 -0
- package/dist/__tests__/network-transport.test.d.ts +2 -0
- package/dist/__tests__/network-transport.test.d.ts.map +1 -0
- package/dist/__tests__/network-transport.test.js +68 -0
- package/dist/__tests__/network-transport.test.js.map +1 -0
- package/dist/__tests__/network.test.d.ts +2 -0
- package/dist/__tests__/network.test.d.ts.map +1 -0
- package/dist/__tests__/network.test.js +174 -0
- package/dist/__tests__/network.test.js.map +1 -0
- package/dist/__tests__/office-cli.test.d.ts +2 -0
- package/dist/__tests__/office-cli.test.d.ts.map +1 -0
- package/dist/__tests__/office-cli.test.js +473 -0
- package/dist/__tests__/office-cli.test.js.map +1 -0
- package/dist/__tests__/policy-profiles-async.test.d.ts +2 -0
- package/dist/__tests__/policy-profiles-async.test.d.ts.map +1 -0
- package/dist/__tests__/policy-profiles-async.test.js +79 -0
- package/dist/__tests__/policy-profiles-async.test.js.map +1 -0
- package/dist/__tests__/settings-async.test.d.ts +2 -0
- package/dist/__tests__/settings-async.test.d.ts.map +1 -0
- package/dist/__tests__/settings-async.test.js +52 -0
- package/dist/__tests__/settings-async.test.js.map +1 -0
- package/dist/__tests__/settings.test.js +302 -3
- package/dist/__tests__/settings.test.js.map +1 -1
- package/dist/__tests__/tool-errors.test.d.ts +2 -0
- package/dist/__tests__/tool-errors.test.d.ts.map +1 -0
- package/dist/__tests__/tool-errors.test.js +250 -0
- package/dist/__tests__/tool-errors.test.js.map +1 -0
- package/dist/__tests__/tool-output.test.d.ts +2 -0
- package/dist/__tests__/tool-output.test.d.ts.map +1 -0
- package/dist/__tests__/tool-output.test.js +37 -0
- package/dist/__tests__/tool-output.test.js.map +1 -0
- package/dist/index.d.ts +30 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +18 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +23 -0
- package/dist/models.js.map +1 -0
- package/dist/network.d.ts +40 -0
- package/dist/network.d.ts.map +1 -0
- package/dist/network.js +322 -0
- package/dist/network.js.map +1 -0
- package/dist/office-cli.d.ts +13 -0
- package/dist/office-cli.d.ts.map +1 -0
- package/dist/office-cli.js +475 -0
- package/dist/office-cli.js.map +1 -0
- package/dist/settings.d.ts +39 -3
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +218 -17
- package/dist/settings.js.map +1 -1
- package/dist/threat-patterns.d.ts +34 -0
- package/dist/threat-patterns.d.ts.map +1 -0
- package/dist/threat-patterns.js +211 -0
- package/dist/threat-patterns.js.map +1 -0
- package/dist/tool-errors.d.ts +130 -0
- package/dist/tool-errors.d.ts.map +1 -0
- package/dist/tool-errors.js +351 -0
- package/dist/tool-errors.js.map +1 -0
- package/dist/tool-output.d.ts +10 -0
- package/dist/tool-output.d.ts.map +1 -0
- package/dist/tool-output.js +45 -0
- package/dist/tool-output.js.map +1 -0
- package/package.json +23 -2
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { JsonValue } from '@earendil-works/pi-ai';
|
|
2
|
+
export type ErrorCategory = 'timeout' | 'cancelled' | 'http_error' | 'network_error' | 'request_failed' | 'configuration_error' | 'invalid_request' | 'invalid_response';
|
|
3
|
+
export interface ErrorClassification {
|
|
4
|
+
errorCategory: ErrorCategory;
|
|
5
|
+
httpStatus?: number;
|
|
6
|
+
}
|
|
7
|
+
/** Only allowlisted categories and numeric HTTP statuses cross the error boundary. */
|
|
8
|
+
export declare function classifyError(error: unknown): ErrorClassification;
|
|
9
|
+
export declare function describeMcpError(operation: string, result: {
|
|
10
|
+
content?: Array<{
|
|
11
|
+
type: string;
|
|
12
|
+
text?: string;
|
|
13
|
+
}>;
|
|
14
|
+
structuredContent?: Record<string, unknown>;
|
|
15
|
+
}, recoveryHint?: string): {
|
|
16
|
+
errorCategory: ErrorCategory;
|
|
17
|
+
httpStatus?: number;
|
|
18
|
+
error: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function describeToolError(operation: string, error: unknown, recoveryHint?: string): {
|
|
21
|
+
errorCategory: ErrorCategory;
|
|
22
|
+
httpStatus?: number;
|
|
23
|
+
error: string;
|
|
24
|
+
};
|
|
25
|
+
/** A sanitized exception retains classification without retaining the raw cause. */
|
|
26
|
+
export declare class SafeToolError extends Error implements ErrorClassification {
|
|
27
|
+
readonly errorCategory: ErrorCategory;
|
|
28
|
+
readonly httpStatus?: number;
|
|
29
|
+
constructor(operation: string, error: unknown, recoveryHint?: string);
|
|
30
|
+
}
|
|
31
|
+
/** Only use fixed, vetted validation messages here, never raw provider text. */
|
|
32
|
+
export declare class ValidationError extends SafeToolError {
|
|
33
|
+
readonly errorCategory: 'configuration_error' | 'invalid_request' | 'invalid_response';
|
|
34
|
+
constructor(message: string, category?: ValidationError['errorCategory']);
|
|
35
|
+
}
|
|
36
|
+
/** Recover only the surviving category from an Agent terminal message. */
|
|
37
|
+
export declare function modelResponseError(operation: string, message: {
|
|
38
|
+
stopReason?: string;
|
|
39
|
+
errorMessage?: string;
|
|
40
|
+
}, recoveryHint?: string): SafeToolError;
|
|
41
|
+
/** Keep only verified transport metadata before a provider serializes its exception. */
|
|
42
|
+
export declare function createModelErrorCapture(): {
|
|
43
|
+
run<T>(request: () => T): T;
|
|
44
|
+
fetchOptions(api: unknown, fetchImpl?: typeof globalThis.fetch): {
|
|
45
|
+
fetch?: never;
|
|
46
|
+
} | {
|
|
47
|
+
fetch: (input: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
48
|
+
};
|
|
49
|
+
error(operation: string, message: {
|
|
50
|
+
stopReason?: string;
|
|
51
|
+
errorMessage?: string;
|
|
52
|
+
}, recoveryHint?: string): SafeToolError;
|
|
53
|
+
};
|
|
54
|
+
export type AgentToolError = {
|
|
55
|
+
code: string;
|
|
56
|
+
message: string;
|
|
57
|
+
cause?: {
|
|
58
|
+
message: string;
|
|
59
|
+
source?: string;
|
|
60
|
+
code?: string;
|
|
61
|
+
};
|
|
62
|
+
recovery?: string;
|
|
63
|
+
};
|
|
64
|
+
export declare const agentToolErrorSchema: {
|
|
65
|
+
readonly type: "object";
|
|
66
|
+
readonly required: readonly ["code", "message"];
|
|
67
|
+
readonly properties: {
|
|
68
|
+
readonly code: {
|
|
69
|
+
readonly type: "string";
|
|
70
|
+
};
|
|
71
|
+
readonly message: {
|
|
72
|
+
readonly type: "string";
|
|
73
|
+
};
|
|
74
|
+
readonly cause: {
|
|
75
|
+
readonly type: "object";
|
|
76
|
+
readonly required: readonly ["message"];
|
|
77
|
+
readonly properties: {
|
|
78
|
+
readonly message: {
|
|
79
|
+
readonly type: "string";
|
|
80
|
+
};
|
|
81
|
+
readonly source: {
|
|
82
|
+
readonly type: "string";
|
|
83
|
+
};
|
|
84
|
+
readonly code: {
|
|
85
|
+
readonly type: "string";
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
readonly recovery: {
|
|
90
|
+
readonly type: "string";
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
/** Accept only diagnostics already vetted by the plugin's error boundary. */
|
|
95
|
+
export declare function agentToolErrorResult(error: AgentToolError): {
|
|
96
|
+
content: {
|
|
97
|
+
type: "text";
|
|
98
|
+
text: string;
|
|
99
|
+
}[];
|
|
100
|
+
structuredContent: {
|
|
101
|
+
error: AgentToolError;
|
|
102
|
+
};
|
|
103
|
+
isError: true;
|
|
104
|
+
};
|
|
105
|
+
type ToolResult = {
|
|
106
|
+
content: Array<{
|
|
107
|
+
type: string;
|
|
108
|
+
text?: string;
|
|
109
|
+
}>;
|
|
110
|
+
details?: unknown;
|
|
111
|
+
structuredContent?: JsonValue;
|
|
112
|
+
isError?: boolean;
|
|
113
|
+
};
|
|
114
|
+
/** Apply the agent error format at registration. CLI results and UI details may have other contracts. */
|
|
115
|
+
export declare function withAgentToolErrors<Args extends unknown[], Result extends ToolResult>(tool: {
|
|
116
|
+
name: string;
|
|
117
|
+
execute(...args: Args): Promise<Result>;
|
|
118
|
+
}, host: object | undefined, packageName: string, recoveryHint?: string): (...args: Args) => Promise<Result | {
|
|
119
|
+
structuredContent: {
|
|
120
|
+
error: AgentToolError;
|
|
121
|
+
};
|
|
122
|
+
content: {
|
|
123
|
+
type: "text";
|
|
124
|
+
text: string;
|
|
125
|
+
}[];
|
|
126
|
+
isError: true;
|
|
127
|
+
details: undefined;
|
|
128
|
+
}>;
|
|
129
|
+
export {};
|
|
130
|
+
//# sourceMappingURL=tool-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-errors.d.ts","sourceRoot":"","sources":["../src/tool-errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,WAAW,GACX,YAAY,GACZ,eAAe,GACf,gBAAgB,GAChB,qBAAqB,GACrB,iBAAiB,GACjB,kBAAkB,CAAC;AACvB,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,sFAAsF;AACtF,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,CAyEjE;AAED,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE;IACN,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C,EACD,YAAY,CA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AC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiBvB,CAAC;AASX,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc;;;;;;;;;EA0BzD;AAED,KAAK,UAAU,GAAG;IAChB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,SAAS,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,yGAAyG;AACzG,wBAAgB,mBAAmB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,SAAS,UAAU,EACnF,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,GAAG,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CAAE,EAC/D,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,WAAW,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,MAAM,IAOP,GAAG,MAAM,IAAI;;;;;;;;;aAIV,SAAS;GAoE3B"}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/** Only allowlisted categories and numeric HTTP statuses cross the error boundary. */
|
|
2
|
+
export function classifyError(error) {
|
|
3
|
+
let value = error;
|
|
4
|
+
let fallback = 'request_failed';
|
|
5
|
+
for (let depth = 0; depth < 4 && value instanceof Error; depth++, value = value.cause) {
|
|
6
|
+
const tagged = value;
|
|
7
|
+
if ([
|
|
8
|
+
'timeout',
|
|
9
|
+
'cancelled',
|
|
10
|
+
'http_error',
|
|
11
|
+
'network_error',
|
|
12
|
+
'request_failed',
|
|
13
|
+
'configuration_error',
|
|
14
|
+
'invalid_request',
|
|
15
|
+
'invalid_response',
|
|
16
|
+
].includes(tagged.errorCategory ?? '')) {
|
|
17
|
+
return {
|
|
18
|
+
errorCategory: tagged.errorCategory,
|
|
19
|
+
...(typeof tagged.httpStatus === 'number' &&
|
|
20
|
+
Number.isInteger(tagged.httpStatus) &&
|
|
21
|
+
tagged.httpStatus >= 400 &&
|
|
22
|
+
tagged.httpStatus < 600
|
|
23
|
+
? { httpStatus: tagged.httpStatus }
|
|
24
|
+
: {}),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const code = value.code;
|
|
28
|
+
if (value.name === 'TimeoutError' ||
|
|
29
|
+
code === -32001 ||
|
|
30
|
+
[
|
|
31
|
+
'ETIMEDOUT',
|
|
32
|
+
'UND_ERR_CONNECT_TIMEOUT',
|
|
33
|
+
'UND_ERR_HEADERS_TIMEOUT',
|
|
34
|
+
'UND_ERR_BODY_TIMEOUT',
|
|
35
|
+
].includes(code ?? ''))
|
|
36
|
+
return { errorCategory: 'timeout' };
|
|
37
|
+
if (value.name === 'AbortError')
|
|
38
|
+
fallback = 'cancelled';
|
|
39
|
+
const status = value.status ??
|
|
40
|
+
value.statusCode;
|
|
41
|
+
const message = typeof value.message === 'string' ? value.message.slice(0, 1024) : '';
|
|
42
|
+
// Providers can serialize exceptions before Agent sees them; retain only recognizable categories.
|
|
43
|
+
if (/^(?:Error:\s*)?(?:TimeoutError\b|Timed out\b|Navigation timeout of \d+ ms exceeded\b|(?:the )?(?:request|operation|connection) (?:was )?(?:timed out|aborted due to timeout)\b)/i.test(message))
|
|
44
|
+
return { errorCategory: 'timeout' };
|
|
45
|
+
if (/^(?:Error:\s*)?(?:AbortError\b|(?:(?:the|this) )?(?:request|operation) (?:was )?(?:aborted|cancelled|canceled)\b)/i.test(message))
|
|
46
|
+
fallback = 'cancelled';
|
|
47
|
+
const httpStatus = typeof status === 'number' && Number.isInteger(status) && status >= 400 && status < 600
|
|
48
|
+
? status
|
|
49
|
+
: Number(message.match(/(?:^|HTTP[ :]+|API error[ :]+)([45]\d{2})\b/)?.[1] ??
|
|
50
|
+
message.match(/^Mem0 request failed \(([45]\d{2})\)\.$/)?.[1]);
|
|
51
|
+
if (httpStatus)
|
|
52
|
+
return { errorCategory: 'http_error', httpStatus };
|
|
53
|
+
if (['ENOTFOUND', 'EAI_AGAIN', 'ECONNREFUSED', 'ECONNRESET', 'EPIPE', 'UND_ERR_SOCKET'].includes(code ?? ''))
|
|
54
|
+
return { errorCategory: 'network_error' };
|
|
55
|
+
}
|
|
56
|
+
return { errorCategory: fallback };
|
|
57
|
+
}
|
|
58
|
+
export function describeMcpError(operation, result, recoveryHint) {
|
|
59
|
+
const message = (result.content ?? [])
|
|
60
|
+
.slice(0, 4)
|
|
61
|
+
.filter((item) => item.type === 'text')
|
|
62
|
+
.map((item) => item.text?.slice(0, 1024) ?? '')
|
|
63
|
+
.join('\n')
|
|
64
|
+
.slice(0, 1024);
|
|
65
|
+
return describeToolError(operation, Object.assign(new Error(message), {
|
|
66
|
+
errorCategory: result.structuredContent?.errorCategory,
|
|
67
|
+
httpStatus: result.structuredContent?.httpStatus,
|
|
68
|
+
status: result.structuredContent?.httpStatus,
|
|
69
|
+
}), recoveryHint);
|
|
70
|
+
}
|
|
71
|
+
export function describeToolError(operation, error, recoveryHint) {
|
|
72
|
+
const classification = classifyError(error);
|
|
73
|
+
if (error instanceof SafeToolError)
|
|
74
|
+
return { error: error.message, ...classification };
|
|
75
|
+
const { errorCategory, httpStatus } = classification;
|
|
76
|
+
const reason = errorCategory === 'timeout'
|
|
77
|
+
? 'timed out'
|
|
78
|
+
: errorCategory === 'cancelled'
|
|
79
|
+
? 'was cancelled'
|
|
80
|
+
: errorCategory === 'network_error'
|
|
81
|
+
? 'failed because of a network error'
|
|
82
|
+
: `failed${httpStatus ? ` (HTTP ${httpStatus})` : ''}`;
|
|
83
|
+
const hint = recoveryHint ??
|
|
84
|
+
(httpStatus === 401 || httpStatus === 403
|
|
85
|
+
? 'Check the provider credentials and permissions.'
|
|
86
|
+
: httpStatus === 429
|
|
87
|
+
? 'Rate limited; wait before retrying.'
|
|
88
|
+
: 'Check provider availability and the request before retrying.');
|
|
89
|
+
return { error: `${operation} ${reason}. ${hint}`, ...classification };
|
|
90
|
+
}
|
|
91
|
+
/** A sanitized exception retains classification without retaining the raw cause. */
|
|
92
|
+
export class SafeToolError extends Error {
|
|
93
|
+
errorCategory;
|
|
94
|
+
httpStatus;
|
|
95
|
+
constructor(operation, error, recoveryHint) {
|
|
96
|
+
const failure = describeToolError(operation, error, recoveryHint);
|
|
97
|
+
super(failure.error);
|
|
98
|
+
this.name = 'SafeToolError';
|
|
99
|
+
this.errorCategory = failure.errorCategory;
|
|
100
|
+
if (failure.httpStatus)
|
|
101
|
+
this.httpStatus = failure.httpStatus;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** Only use fixed, vetted validation messages here, never raw provider text. */
|
|
105
|
+
export class ValidationError extends SafeToolError {
|
|
106
|
+
errorCategory;
|
|
107
|
+
constructor(message, category = 'invalid_request') {
|
|
108
|
+
super('Validation', undefined);
|
|
109
|
+
this.name = 'ValidationError';
|
|
110
|
+
this.message = message;
|
|
111
|
+
this.errorCategory = category;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/** Recover only the surviving category from an Agent terminal message. */
|
|
115
|
+
export function modelResponseError(operation, message, recoveryHint) {
|
|
116
|
+
const error = new Error(message.errorMessage?.slice(0, 1024) ?? '');
|
|
117
|
+
if (message.stopReason === 'aborted')
|
|
118
|
+
error.name = 'AbortError';
|
|
119
|
+
return new SafeToolError(operation, error, recoveryHint);
|
|
120
|
+
}
|
|
121
|
+
/** Keep only verified transport metadata before a provider serializes its exception. */
|
|
122
|
+
export function createModelErrorCapture() {
|
|
123
|
+
let failure;
|
|
124
|
+
const record = (error) => {
|
|
125
|
+
const classified = classifyError(error);
|
|
126
|
+
if (classified.errorCategory !== 'request_failed')
|
|
127
|
+
failure = { ...failure, ...classified };
|
|
128
|
+
};
|
|
129
|
+
return {
|
|
130
|
+
run(request) {
|
|
131
|
+
failure = undefined;
|
|
132
|
+
try {
|
|
133
|
+
return request();
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
record(error);
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
fetchOptions(api, fetchImpl = globalThis.fetch) {
|
|
141
|
+
// These SDKs reject or ignore custom fetch; leave their transport unchanged. Pi passes a
|
|
142
|
+
// virtual model's fetch to the model it routes to, which may be one of them.
|
|
143
|
+
if (typeof api !== 'string' ||
|
|
144
|
+
['google-generative-ai', 'google-vertex', 'bedrock-converse-stream', 'pi-virtual'].includes(api))
|
|
145
|
+
return {};
|
|
146
|
+
return {
|
|
147
|
+
fetch: async (...args) => {
|
|
148
|
+
failure = undefined;
|
|
149
|
+
try {
|
|
150
|
+
const response = await fetchImpl(...args);
|
|
151
|
+
failure =
|
|
152
|
+
response.status >= 400 && response.status < 600
|
|
153
|
+
? { errorCategory: 'http_error', httpStatus: response.status }
|
|
154
|
+
: undefined;
|
|
155
|
+
return captureResponseBody(response, record);
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
record(error);
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
},
|
|
164
|
+
error(operation, message, recoveryHint) {
|
|
165
|
+
const surviving = modelResponseError(operation, message, recoveryHint);
|
|
166
|
+
return failure &&
|
|
167
|
+
(failure.errorCategory === 'timeout' || surviving.errorCategory === 'request_failed')
|
|
168
|
+
? new SafeToolError(operation, Object.assign(new Error(), failure), recoveryHint)
|
|
169
|
+
: surviving;
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function captureResponseBody(response, record) {
|
|
174
|
+
if (!response.body || response.status < 200)
|
|
175
|
+
return response;
|
|
176
|
+
const reader = response.body.getReader();
|
|
177
|
+
let stopped = false;
|
|
178
|
+
const body = new ReadableStream({
|
|
179
|
+
async pull(controller) {
|
|
180
|
+
try {
|
|
181
|
+
const chunk = await reader.read();
|
|
182
|
+
if (stopped)
|
|
183
|
+
return;
|
|
184
|
+
if (chunk.done) {
|
|
185
|
+
stopped = true;
|
|
186
|
+
controller.close();
|
|
187
|
+
reader.releaseLock();
|
|
188
|
+
}
|
|
189
|
+
else
|
|
190
|
+
controller.enqueue(chunk.value);
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
if (stopped)
|
|
194
|
+
return;
|
|
195
|
+
stopped = true;
|
|
196
|
+
record(error);
|
|
197
|
+
controller.error(error);
|
|
198
|
+
reader.releaseLock();
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
async cancel(reason) {
|
|
202
|
+
stopped = true;
|
|
203
|
+
try {
|
|
204
|
+
await reader.cancel(reason);
|
|
205
|
+
}
|
|
206
|
+
finally {
|
|
207
|
+
reader.releaseLock();
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
const wrapped = new Response(body, {
|
|
212
|
+
status: response.status,
|
|
213
|
+
statusText: response.statusText,
|
|
214
|
+
headers: response.headers,
|
|
215
|
+
});
|
|
216
|
+
const preserveMetadata = (target) => {
|
|
217
|
+
Object.defineProperties(target, {
|
|
218
|
+
url: { value: response.url },
|
|
219
|
+
redirected: { value: response.redirected },
|
|
220
|
+
type: { value: response.type },
|
|
221
|
+
clone: { value: () => preserveMetadata(Response.prototype.clone.call(target)) },
|
|
222
|
+
});
|
|
223
|
+
return target;
|
|
224
|
+
};
|
|
225
|
+
return preserveMetadata(wrapped);
|
|
226
|
+
}
|
|
227
|
+
export const agentToolErrorSchema = {
|
|
228
|
+
type: 'object',
|
|
229
|
+
required: ['code', 'message'],
|
|
230
|
+
properties: {
|
|
231
|
+
code: { type: 'string' },
|
|
232
|
+
message: { type: 'string' },
|
|
233
|
+
cause: {
|
|
234
|
+
type: 'object',
|
|
235
|
+
required: ['message'],
|
|
236
|
+
properties: {
|
|
237
|
+
message: { type: 'string' },
|
|
238
|
+
source: { type: 'string' },
|
|
239
|
+
code: { type: 'string' },
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
recovery: { type: 'string' },
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
function errorLine(text, limit = 2048) {
|
|
246
|
+
return text
|
|
247
|
+
.slice(0, limit)
|
|
248
|
+
.replace(/[\r\n]+/g, ' ')
|
|
249
|
+
.trim();
|
|
250
|
+
}
|
|
251
|
+
/** Accept only diagnostics already vetted by the plugin's error boundary. */
|
|
252
|
+
export function agentToolErrorResult(error) {
|
|
253
|
+
const safe = {
|
|
254
|
+
code: /^[a-z0-9_]{1,128}$/i.test(error.code) ? error.code : 'tool_failed',
|
|
255
|
+
message: errorLine(error.message) || 'Tool operation failed.',
|
|
256
|
+
...(error.cause
|
|
257
|
+
? {
|
|
258
|
+
cause: {
|
|
259
|
+
message: errorLine(error.cause.message),
|
|
260
|
+
...(error.cause.source ? { source: errorLine(error.cause.source, 128) } : {}),
|
|
261
|
+
...(error.cause.code ? { code: errorLine(error.cause.code, 128) } : {}),
|
|
262
|
+
},
|
|
263
|
+
}
|
|
264
|
+
: {}),
|
|
265
|
+
...(error.recovery ? { recovery: errorLine(error.recovery) } : {}),
|
|
266
|
+
};
|
|
267
|
+
const lines = [`[${safe.code}] ${safe.message}`];
|
|
268
|
+
if (safe.cause) {
|
|
269
|
+
const source = safe.cause.source ? ` (${safe.cause.source})` : '';
|
|
270
|
+
lines.push(`Cause${source}: ${safe.cause.message}`);
|
|
271
|
+
}
|
|
272
|
+
if (safe.recovery)
|
|
273
|
+
lines.push(`Recovery: ${safe.recovery}`);
|
|
274
|
+
return {
|
|
275
|
+
content: [{ type: 'text', text: lines.join('\n') }],
|
|
276
|
+
structuredContent: { error: safe },
|
|
277
|
+
isError: true,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
/** Apply the agent error format at registration. CLI results and UI details may have other contracts. */
|
|
281
|
+
export function withAgentToolErrors(tool, host, packageName, recoveryHint) {
|
|
282
|
+
// Pi 0.99 introduced both this extension API and resolved tool-error support.
|
|
283
|
+
// Check the running host because an extension can resolve a different peer version.
|
|
284
|
+
const legacy = host !== undefined &&
|
|
285
|
+
!('registerMcpServer' in host && typeof host.registerMcpServer === 'function');
|
|
286
|
+
return async (...args) => {
|
|
287
|
+
let result;
|
|
288
|
+
try {
|
|
289
|
+
result = await tool.execute(...args);
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
if (args[2]?.aborted) {
|
|
293
|
+
throw new DOMException('[cancelled] The tool call was cancelled.', 'AbortError');
|
|
294
|
+
}
|
|
295
|
+
const failure = describeToolError(tool.name, error, recoveryHint);
|
|
296
|
+
const status = failure.httpStatus ? `, HTTP ${failure.httpStatus}` : '';
|
|
297
|
+
console.error(`[${packageName}] ${tool.name} failed (category=${failure.errorCategory}${status})`);
|
|
298
|
+
const formatted = agentToolErrorResult({
|
|
299
|
+
code: failure.errorCategory === 'request_failed'
|
|
300
|
+
? `${tool.name}_failed`
|
|
301
|
+
: failure.errorCategory,
|
|
302
|
+
message: failure.error,
|
|
303
|
+
});
|
|
304
|
+
result = {
|
|
305
|
+
...formatted,
|
|
306
|
+
details: undefined,
|
|
307
|
+
structuredContent: {
|
|
308
|
+
...formatted.structuredContent,
|
|
309
|
+
errorCategory: failure.errorCategory,
|
|
310
|
+
...(failure.httpStatus ? { httpStatus: failure.httpStatus } : {}),
|
|
311
|
+
truncated: false,
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
if (!result.isError)
|
|
316
|
+
return result;
|
|
317
|
+
const structured = result.structuredContent;
|
|
318
|
+
const data = structured && typeof structured === 'object' && !Array.isArray(structured)
|
|
319
|
+
? structured
|
|
320
|
+
: undefined;
|
|
321
|
+
const error = data?.error;
|
|
322
|
+
let formatted;
|
|
323
|
+
if (error &&
|
|
324
|
+
typeof error === 'object' &&
|
|
325
|
+
'code' in error &&
|
|
326
|
+
typeof error.code === 'string' &&
|
|
327
|
+
'message' in error &&
|
|
328
|
+
typeof error.message === 'string') {
|
|
329
|
+
formatted = agentToolErrorResult(error);
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
const fields = data ?? result.details;
|
|
333
|
+
const text = result.content.find((item) => item.type === 'text')?.text;
|
|
334
|
+
const category = fields?.errorCategory;
|
|
335
|
+
formatted = agentToolErrorResult({
|
|
336
|
+
code: typeof category === 'string' && category !== 'request_failed'
|
|
337
|
+
? category
|
|
338
|
+
: `${tool.name}_failed`,
|
|
339
|
+
message: typeof error === 'string' ? error : text || 'Tool operation failed.',
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
if (legacy)
|
|
343
|
+
throw new Error(formatted.content[0].text);
|
|
344
|
+
return {
|
|
345
|
+
...result,
|
|
346
|
+
...formatted,
|
|
347
|
+
structuredContent: { ...data, ...formatted.structuredContent },
|
|
348
|
+
};
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
//# sourceMappingURL=tool-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-errors.js","sourceRoot":"","sources":["../src/tool-errors.ts"],"names":[],"mappings":"AAgBA,sFAAsF;AACtF,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,IAAI,QAAQ,GAAkB,gBAAgB,CAAC;IAC/C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,IAAI,KAAK,YAAY,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;QACtF,MAAM,MAAM,GAAG,KAA6C,CAAC;QAC7D,IACE;YACE,SAAS;YACT,WAAW;YACX,YAAY;YACZ,eAAe;YACf,gBAAgB;YAChB,qBAAqB;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L,CAAC;QACD,IAAI,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAE,CAAC,IAAI,CAAC,CAAC;QACxD,OAAO;YACL,GAAG,MAAM;YACT,GAAG,SAAS;YACZ,iBAAiB,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,SAAS,CAAC,iBAAiB,EAAE;SAC/D,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type OutputValue = null | boolean | number | string | OutputValue[] | {
|
|
2
|
+
[key: string]: OutputValue;
|
|
3
|
+
};
|
|
4
|
+
type OutputObject = {
|
|
5
|
+
[key: string]: OutputValue;
|
|
6
|
+
};
|
|
7
|
+
/** Keep whole records and identifiers; never turn a clipped path into a usable result. */
|
|
8
|
+
export declare function boundStructuredContent(data: object): OutputObject;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=tool-output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-output.d.ts","sourceRoot":"","sources":["../src/tool-output.ts"],"names":[],"mappings":"AAAA,KAAK,WAAW,GACZ,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,WAAW,EAAE,GACb;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAA;CAAE,CAAC;AACnC,KAAK,YAAY,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAA;CAAE,CAAC;AAEnD,0FAA0F;AAC1F,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAiDjE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Keep whole records and identifiers; never turn a clipped path into a usable result. */
|
|
2
|
+
export function boundStructuredContent(data) {
|
|
3
|
+
const output = JSON.parse(JSON.stringify(data));
|
|
4
|
+
output.truncated = output.truncated === true;
|
|
5
|
+
function compactRecord(value) {
|
|
6
|
+
if (!value ||
|
|
7
|
+
Array.isArray(value) ||
|
|
8
|
+
typeof value !== 'object' ||
|
|
9
|
+
typeof value.id !== 'string' ||
|
|
10
|
+
Buffer.byteLength(JSON.stringify(value)) <= 11 * 1024)
|
|
11
|
+
return value;
|
|
12
|
+
output.truncated = true;
|
|
13
|
+
// Reserve room for the envelope; omit large fields, never clip writable content or IDs.
|
|
14
|
+
return {
|
|
15
|
+
...Object.fromEntries(Object.entries(value).filter(([key, field]) => key === 'id' ||
|
|
16
|
+
((!field || typeof field !== 'object') &&
|
|
17
|
+
Buffer.byteLength(JSON.stringify(field)) <= 256))),
|
|
18
|
+
truncated: true,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
for (const [key, value] of Object.entries(output)) {
|
|
22
|
+
if (key === 'truncated')
|
|
23
|
+
continue;
|
|
24
|
+
if (Array.isArray(value) && value.length > 100) {
|
|
25
|
+
value.length = 100;
|
|
26
|
+
output.truncated = true;
|
|
27
|
+
}
|
|
28
|
+
output[key] = Array.isArray(value) ? value.map(compactRecord) : compactRecord(value);
|
|
29
|
+
}
|
|
30
|
+
while (Buffer.byteLength(JSON.stringify(output)) > 12 * 1024) {
|
|
31
|
+
const largest = Object.values(output)
|
|
32
|
+
.filter((value) => Array.isArray(value) && value.length > 0)
|
|
33
|
+
.sort((a, b) => JSON.stringify(b).length - JSON.stringify(a).length)[0];
|
|
34
|
+
if (!Array.isArray(largest)) {
|
|
35
|
+
return {
|
|
36
|
+
error: 'Result exceeds the output limit. The operation may have completed; inspect saved state before retrying.',
|
|
37
|
+
truncated: true,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
largest.pop();
|
|
41
|
+
output.truncated = true;
|
|
42
|
+
}
|
|
43
|
+
return output;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=tool-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-output.js","sourceRoot":"","sources":["../src/tool-output.ts"],"names":[],"mappings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
6
|
"sideEffects": false,
|
|
@@ -15,6 +15,18 @@
|
|
|
15
15
|
"types": "./dist/settings.d.ts",
|
|
16
16
|
"default": "./dist/settings.js"
|
|
17
17
|
},
|
|
18
|
+
"./threat-patterns": {
|
|
19
|
+
"types": "./dist/threat-patterns.d.ts",
|
|
20
|
+
"default": "./dist/threat-patterns.js"
|
|
21
|
+
},
|
|
22
|
+
"./models": {
|
|
23
|
+
"types": "./dist/models.d.ts",
|
|
24
|
+
"default": "./dist/models.js"
|
|
25
|
+
},
|
|
26
|
+
"./office-cli": {
|
|
27
|
+
"types": "./dist/office-cli.d.ts",
|
|
28
|
+
"default": "./dist/office-cli.js"
|
|
29
|
+
},
|
|
18
30
|
"./package.json": {
|
|
19
31
|
"default": "./package.json"
|
|
20
32
|
}
|
|
@@ -30,8 +42,17 @@
|
|
|
30
42
|
"url": "https://github.com/TGYD-helige/pi.git",
|
|
31
43
|
"directory": "packages/shared"
|
|
32
44
|
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@earendil-works/pi-ai": ">=0.80.10"
|
|
47
|
+
},
|
|
48
|
+
"peerDependenciesMeta": {
|
|
49
|
+
"@earendil-works/pi-ai": {
|
|
50
|
+
"optional": true
|
|
51
|
+
}
|
|
52
|
+
},
|
|
33
53
|
"devDependencies": {
|
|
34
|
-
"
|
|
54
|
+
"@earendil-works/pi-ai": "1.7.0",
|
|
55
|
+
"vitest": "^4.1.12"
|
|
35
56
|
},
|
|
36
57
|
"scripts": {
|
|
37
58
|
"build": "tsc -b",
|