agent-first-data 0.5.0 → 0.6.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/README.md +7 -4
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +5 -2
- package/dist/format.d.ts +2 -2
- package/dist/format.js +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,8 +75,8 @@ type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string
|
|
|
75
75
|
// Success (result)
|
|
76
76
|
buildJsonOk(result: JsonValue, trace?: JsonValue): JsonValue
|
|
77
77
|
|
|
78
|
-
// Error (simple message)
|
|
79
|
-
buildJsonError(message: string, trace?: JsonValue): JsonValue
|
|
78
|
+
// Error (simple message, optional hint)
|
|
79
|
+
buildJsonError(message: string, hint?: string, trace?: JsonValue): JsonValue
|
|
80
80
|
|
|
81
81
|
// Generic (any code + fields)
|
|
82
82
|
buildJson(code: string, fields: JsonValue, trace?: JsonValue): JsonValue
|
|
@@ -106,7 +106,10 @@ const response = buildJsonOk(
|
|
|
106
106
|
);
|
|
107
107
|
|
|
108
108
|
// Error
|
|
109
|
-
const error = buildJsonError("user not found", { duration_ms: 5 });
|
|
109
|
+
const error = buildJsonError("user not found", undefined, { duration_ms: 5 });
|
|
110
|
+
|
|
111
|
+
// Error with hint
|
|
112
|
+
const errorHint = buildJsonError("wallet not found", "list wallets with: afpay wallet list", { duration_ms: 5 });
|
|
110
113
|
|
|
111
114
|
// Specific error code
|
|
112
115
|
const notFound = buildJson(
|
|
@@ -197,7 +200,7 @@ type OutputFormat = "json" | "yaml" | "plain"
|
|
|
197
200
|
cliParseOutput(s: string): OutputFormat // Parse --output flag; throws on unknown
|
|
198
201
|
cliParseLogFilters(entries: string[]): string[] // Normalize --log: trim, lowercase, dedup, remove empty
|
|
199
202
|
cliOutput(value: JsonValue, format: OutputFormat): string // Dispatch to outputJson/Yaml/Plain
|
|
200
|
-
buildCliError(message: string): JsonValue
|
|
203
|
+
buildCliError(message: string, hint?: string): JsonValue // {code:"error", error_code:"invalid_request", hint?, retryable:false, trace:{duration_ms:0}}
|
|
201
204
|
```
|
|
202
205
|
|
|
203
206
|
**Canonical pattern** — parse all flags before doing work, emit JSONL errors to stdout:
|
package/dist/cli.d.ts
CHANGED
|
@@ -39,4 +39,4 @@ export declare function cliOutput(value: JsonValue, format: OutputFormat): strin
|
|
|
39
39
|
* console.log(outputJson(err));
|
|
40
40
|
* process.exit(2);
|
|
41
41
|
*/
|
|
42
|
-
export declare function buildCliError(message: string): JsonValue;
|
|
42
|
+
export declare function buildCliError(message: string, hint?: string): JsonValue;
|
package/dist/cli.js
CHANGED
|
@@ -57,12 +57,15 @@ export function cliOutput(value, format) {
|
|
|
57
57
|
* console.log(outputJson(err));
|
|
58
58
|
* process.exit(2);
|
|
59
59
|
*/
|
|
60
|
-
export function buildCliError(message) {
|
|
61
|
-
|
|
60
|
+
export function buildCliError(message, hint) {
|
|
61
|
+
const m = {
|
|
62
62
|
code: "error",
|
|
63
63
|
error_code: "invalid_request",
|
|
64
64
|
error: message,
|
|
65
65
|
retryable: false,
|
|
66
66
|
trace: { duration_ms: 0 },
|
|
67
67
|
};
|
|
68
|
+
if (hint !== undefined)
|
|
69
|
+
m.hint = hint;
|
|
70
|
+
return m;
|
|
68
71
|
}
|
package/dist/format.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
|
8
8
|
};
|
|
9
9
|
/** Build {code: "ok", result, trace?}. */
|
|
10
10
|
export declare function buildJsonOk(result: JsonValue, trace?: JsonValue): JsonValue;
|
|
11
|
-
/** Build {code: "error", error: message, trace?}. */
|
|
12
|
-
export declare function buildJsonError(message: string, trace?: JsonValue): JsonValue;
|
|
11
|
+
/** Build {code: "error", error: message, hint?, trace?}. */
|
|
12
|
+
export declare function buildJsonError(message: string, hint?: string, trace?: JsonValue): JsonValue;
|
|
13
13
|
/** Build {code: "<custom>", ...fields, trace?}. */
|
|
14
14
|
export declare function buildJson(code: string, fields: JsonValue, trace?: JsonValue): JsonValue;
|
|
15
15
|
export declare enum RedactionPolicy {
|
package/dist/format.js
CHANGED
|
@@ -13,9 +13,11 @@ export function buildJsonOk(result, trace) {
|
|
|
13
13
|
m.trace = trace;
|
|
14
14
|
return m;
|
|
15
15
|
}
|
|
16
|
-
/** Build {code: "error", error: message, trace?}. */
|
|
17
|
-
export function buildJsonError(message, trace) {
|
|
16
|
+
/** Build {code: "error", error: message, hint?, trace?}. */
|
|
17
|
+
export function buildJsonError(message, hint, trace) {
|
|
18
18
|
const m = { code: "error", error: message };
|
|
19
|
+
if (hint !== undefined)
|
|
20
|
+
m.hint = hint;
|
|
19
21
|
if (trace !== undefined)
|
|
20
22
|
m.trace = trace;
|
|
21
23
|
return m;
|