agent-first-data 0.15.0 → 0.16.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 +18 -22
- package/assets/protocol-v1.schema.json +84 -0
- package/assets/registry.json +260 -0
- package/assets/skills/agent-first-data/SKILL.md +64 -0
- package/assets/skills/agent-first-data/references/protocol-v1.schema.json +66 -0
- package/assets/skills/agent-first-data/references/registry.json +260 -0
- package/assets/skills/agent-first-data/references/rules.md +347 -0
- package/dist/cli.d.ts +48 -14
- package/dist/cli.js +134 -36
- package/dist/format.d.ts +152 -55
- package/dist/format.js +652 -144
- package/dist/index.d.ts +2 -5
- package/dist/index.js +2 -5
- package/dist/stream_redirect.js +17 -3
- package/package.json +9 -8
- package/dist/afdata_logging.d.ts +0 -44
- package/dist/afdata_logging.js +0 -90
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent-First Data (AFDATA) — suffix-driven output formatting and protocol templates.
|
|
3
3
|
*/
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export { type OutputFormat, cliParseOutput, cliParseLogFilters, cliOutput, cliOutputWithOptions, buildCliError, buildCliVersion, cliRenderVersion, cliHandleVersionOrContinue, } from "./cli.js";
|
|
7
|
-
export { type SkillSpec, type SkillAction, type SkillScope, type SkillAgentSelection, type SkillAgent, type SkillOptions, type SkillTargetStatus, type SkillUninstallStatus, type SkillReport, SkillError, runSkillAdmin, } from "./skill.js";
|
|
8
|
-
export { STDOUT_FILE_ARG, STDERR_FILE_ARG, type StreamRedirectConfig, type InstalledStreamRedirect, configFromRawArgs as streamRedirectConfigFromRawArgs, installStreamRedirect, installStreamRedirectFromRawArgs, } from "./stream_redirect.js";
|
|
4
|
+
export { jsonResult, jsonError, jsonProgress, jsonLog, Event, EventBuildError, JsonResultBuilder, JsonErrorBuilder, JsonProgressBuilder, JsonLogBuilder, type LogLevel, validateProtocolEvent, validateProtocolStream, decodeProtocolEvent, type DecodedEvent, type DecodedResult, type DecodedError, type DecodedProgress, type DecodedLog, EventDecodeError, type JsonValue, RedactionPolicy, OutputStyle, type OutputOptions, outputOptionsForPolicy, outputJson, outputYaml, outputPlain, redactedValue, redactUrlSecrets, parseSize, normalizeUtcOffset, isValidRfc3339Date, isValidRfc3339Time, } from "./format.js";
|
|
5
|
+
export { type OutputFormat, type CliEventWriter, CliEmitter, LogFilters, cliParseOutput, cliParseLogFilters, cliOutput, buildCliError, buildCliVersion, cliRenderVersion, cliHandleVersionOrContinue, } from "./cli.js";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent-First Data (AFDATA) — suffix-driven output formatting and protocol templates.
|
|
3
3
|
*/
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export { cliParseOutput, cliParseLogFilters, cliOutput, cliOutputWithOptions, buildCliError, buildCliVersion, cliRenderVersion, cliHandleVersionOrContinue, } from "./cli.js";
|
|
7
|
-
export { SkillError, runSkillAdmin, } from "./skill.js";
|
|
8
|
-
export { STDOUT_FILE_ARG, STDERR_FILE_ARG, configFromRawArgs as streamRedirectConfigFromRawArgs, installStreamRedirect, installStreamRedirectFromRawArgs, } from "./stream_redirect.js";
|
|
4
|
+
export { jsonResult, jsonError, jsonProgress, jsonLog, Event, EventBuildError, JsonResultBuilder, JsonErrorBuilder, JsonProgressBuilder, JsonLogBuilder, validateProtocolEvent, validateProtocolStream, decodeProtocolEvent, EventDecodeError, RedactionPolicy, OutputStyle, outputOptionsForPolicy, outputJson, outputYaml, outputPlain, redactedValue, redactUrlSecrets, parseSize, normalizeUtcOffset, isValidRfc3339Date, isValidRfc3339Time, } from "./format.js";
|
|
5
|
+
export { CliEmitter, LogFilters, cliParseOutput, cliParseLogFilters, cliOutput, buildCliError, buildCliVersion, cliRenderVersion, cliHandleVersionOrContinue, } from "./cli.js";
|
package/dist/stream_redirect.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* files. It is not an AFDATA formatter and does not convert stderr diagnostics
|
|
6
6
|
* into JSON.
|
|
7
7
|
*/
|
|
8
|
-
import { closeSync, openSync } from "node:fs";
|
|
8
|
+
import { closeSync, constants, existsSync, lstatSync, openSync } from "node:fs";
|
|
9
9
|
export const STDOUT_FILE_ARG = "--stdout-file";
|
|
10
10
|
export const STDERR_FILE_ARG = "--stderr-file";
|
|
11
11
|
let installed = false;
|
|
@@ -81,7 +81,7 @@ function takeValue(args, idx, flag) {
|
|
|
81
81
|
function validateWritable(path) {
|
|
82
82
|
if (path === undefined)
|
|
83
83
|
return;
|
|
84
|
-
const fd =
|
|
84
|
+
const fd = openAppendSecure(path);
|
|
85
85
|
closeSync(fd);
|
|
86
86
|
}
|
|
87
87
|
function redirectFd(targetFd, path) {
|
|
@@ -94,12 +94,26 @@ function redirectFd(targetFd, path) {
|
|
|
94
94
|
catch {
|
|
95
95
|
// The target fd may already be closed in unusual embedding environments.
|
|
96
96
|
}
|
|
97
|
-
const fd =
|
|
97
|
+
const fd = openAppendSecure(path);
|
|
98
98
|
if (fd !== targetFd) {
|
|
99
99
|
closeSync(fd);
|
|
100
100
|
throw new Error(`failed to redirect fd ${targetFd} to ${path}`);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
+
function openAppendSecure(path) {
|
|
104
|
+
const nofollow = constants.O_NOFOLLOW ?? 0;
|
|
105
|
+
if (existsSync(path)) {
|
|
106
|
+
const stat = lstatSync(path);
|
|
107
|
+
if (stat.isSymbolicLink()) {
|
|
108
|
+
throw new Error("stream redirection target must not be a symbolic link");
|
|
109
|
+
}
|
|
110
|
+
if (!stat.isFile()) {
|
|
111
|
+
throw new Error("stream redirection target must be a regular file");
|
|
112
|
+
}
|
|
113
|
+
return openSync(path, constants.O_WRONLY | constants.O_APPEND | nofollow);
|
|
114
|
+
}
|
|
115
|
+
return openSync(path, constants.O_WRONLY | constants.O_APPEND | constants.O_CREAT | constants.O_EXCL | nofollow, 0o600);
|
|
116
|
+
}
|
|
103
117
|
function fillLowerFds(targetFd) {
|
|
104
118
|
const nullDevice = process.platform === "win32" ? "NUL" : "/dev/null";
|
|
105
119
|
while (true) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-first-data",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "A naming convention that lets AI agents understand your data without being told what it means.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -15,17 +15,18 @@
|
|
|
15
15
|
"import": "./dist/index.js",
|
|
16
16
|
"types": "./dist/index.d.ts"
|
|
17
17
|
},
|
|
18
|
-
"./
|
|
19
|
-
"import": "./dist/
|
|
20
|
-
"types": "./dist/
|
|
18
|
+
"./skill": {
|
|
19
|
+
"import": "./dist/skill.js",
|
|
20
|
+
"types": "./dist/skill.d.ts"
|
|
21
21
|
},
|
|
22
|
-
"./
|
|
22
|
+
"./stream-redirect": {
|
|
23
23
|
"import": "./dist/stream_redirect.js",
|
|
24
24
|
"types": "./dist/stream_redirect.d.ts"
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"dist",
|
|
29
|
+
"assets",
|
|
29
30
|
"README.md"
|
|
30
31
|
],
|
|
31
32
|
"scripts": {
|
|
@@ -34,8 +35,8 @@
|
|
|
34
35
|
"test": "tsx --test src/*.test.ts examples/agent_cli.ts"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@types/node": "^26.1.
|
|
38
|
-
"tsx": "^4.
|
|
39
|
-
"typescript": "^
|
|
38
|
+
"@types/node": "^26.1.1",
|
|
39
|
+
"tsx": "^4.23.0",
|
|
40
|
+
"typescript": "^7.0.2"
|
|
40
41
|
}
|
|
41
42
|
}
|
package/dist/afdata_logging.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AFDATA-compliant structured logging.
|
|
3
|
-
*
|
|
4
|
-
* Outputs log events using agent-first-data formatting functions:
|
|
5
|
-
* - JSON: single-line JSONL via outputJson (secrets redacted, original keys)
|
|
6
|
-
* - Plain: single-line logfmt via outputPlain (keys stripped, values formatted)
|
|
7
|
-
* - YAML: multi-line via outputYaml (keys stripped, values formatted)
|
|
8
|
-
*
|
|
9
|
-
* Span fields are carried via AsyncLocalStorage (async-safe).
|
|
10
|
-
*
|
|
11
|
-
* Usage:
|
|
12
|
-
* import { log, span, initJson, initPlain, initYaml } from "agent-first-data/afdata_logging";
|
|
13
|
-
* initJson(); // or initPlain() or initYaml()
|
|
14
|
-
* log.info("Server started");
|
|
15
|
-
* await span({ request_id: "abc" }, async () => {
|
|
16
|
-
* log.info("Processing", { domain: "example.com" });
|
|
17
|
-
* });
|
|
18
|
-
*/
|
|
19
|
-
type LoggingRedactionOptions = {
|
|
20
|
-
secretNames?: readonly string[];
|
|
21
|
-
};
|
|
22
|
-
/** Set log output to single-line JSONL (secrets redacted, original keys). */
|
|
23
|
-
export declare function initJson(options?: LoggingRedactionOptions): void;
|
|
24
|
-
/** Set log output to single-line logfmt (keys stripped, values formatted). */
|
|
25
|
-
export declare function initPlain(options?: LoggingRedactionOptions): void;
|
|
26
|
-
/** Set log output to multi-line YAML (keys stripped, values formatted). */
|
|
27
|
-
export declare function initYaml(options?: LoggingRedactionOptions): void;
|
|
28
|
-
/**
|
|
29
|
-
* AFDATA logger. Each method outputs a single log line to stdout.
|
|
30
|
-
* Format is controlled by initJson/initPlain/initYaml (default: JSON).
|
|
31
|
-
*/
|
|
32
|
-
export declare const log: {
|
|
33
|
-
trace: (msg: string, fields?: Record<string, unknown>) => void;
|
|
34
|
-
debug: (msg: string, fields?: Record<string, unknown>) => void;
|
|
35
|
-
info: (msg: string, fields?: Record<string, unknown>) => void;
|
|
36
|
-
warn: (msg: string, fields?: Record<string, unknown>) => void;
|
|
37
|
-
error: (msg: string, fields?: Record<string, unknown>) => void;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Run fn within a span that adds fields to all log events.
|
|
41
|
-
* Spans nest: inner spans inherit and can override outer span fields.
|
|
42
|
-
*/
|
|
43
|
-
export declare function span<T>(fields: Record<string, unknown>, fn: () => T): T;
|
|
44
|
-
export {};
|
package/dist/afdata_logging.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AFDATA-compliant structured logging.
|
|
3
|
-
*
|
|
4
|
-
* Outputs log events using agent-first-data formatting functions:
|
|
5
|
-
* - JSON: single-line JSONL via outputJson (secrets redacted, original keys)
|
|
6
|
-
* - Plain: single-line logfmt via outputPlain (keys stripped, values formatted)
|
|
7
|
-
* - YAML: multi-line via outputYaml (keys stripped, values formatted)
|
|
8
|
-
*
|
|
9
|
-
* Span fields are carried via AsyncLocalStorage (async-safe).
|
|
10
|
-
*
|
|
11
|
-
* Usage:
|
|
12
|
-
* import { log, span, initJson, initPlain, initYaml } from "agent-first-data/afdata_logging";
|
|
13
|
-
* initJson(); // or initPlain() or initYaml()
|
|
14
|
-
* log.info("Server started");
|
|
15
|
-
* await span({ request_id: "abc" }, async () => {
|
|
16
|
-
* log.info("Processing", { domain: "example.com" });
|
|
17
|
-
* });
|
|
18
|
-
*/
|
|
19
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
20
|
-
import { outputJsonWithOptions, outputYamlWithOptions, outputPlainWithOptions, } from "./format.js";
|
|
21
|
-
const spanStore = new AsyncLocalStorage();
|
|
22
|
-
let currentFormat = "json";
|
|
23
|
-
let currentRedaction = {};
|
|
24
|
-
function setFormat(format, options) {
|
|
25
|
-
currentFormat = format;
|
|
26
|
-
currentRedaction = options?.secretNames ? { secretNames: options.secretNames } : {};
|
|
27
|
-
}
|
|
28
|
-
/** Set log output to single-line JSONL (secrets redacted, original keys). */
|
|
29
|
-
export function initJson(options) { setFormat("json", options); }
|
|
30
|
-
/** Set log output to single-line logfmt (keys stripped, values formatted). */
|
|
31
|
-
export function initPlain(options) { setFormat("plain", options); }
|
|
32
|
-
/** Set log output to multi-line YAML (keys stripped, values formatted). */
|
|
33
|
-
export function initYaml(options) { setFormat("yaml", options); }
|
|
34
|
-
function emit(level, message, fields) {
|
|
35
|
-
const entry = {
|
|
36
|
-
timestamp_epoch_ms: Date.now(),
|
|
37
|
-
message,
|
|
38
|
-
code: "log",
|
|
39
|
-
level,
|
|
40
|
-
};
|
|
41
|
-
// Span fields (from AsyncLocalStorage)
|
|
42
|
-
const spanFields = spanStore.getStore();
|
|
43
|
-
if (spanFields) {
|
|
44
|
-
for (const [k, v] of Object.entries(spanFields)) {
|
|
45
|
-
entry[k] = v;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
// Event fields override span fields, except protocol code is always "log".
|
|
49
|
-
if (fields) {
|
|
50
|
-
for (const [k, v] of Object.entries(fields)) {
|
|
51
|
-
if (k === "code")
|
|
52
|
-
continue;
|
|
53
|
-
entry[k] = v;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// Format using the library's own output functions
|
|
57
|
-
const value = entry;
|
|
58
|
-
let line;
|
|
59
|
-
switch (currentFormat) {
|
|
60
|
-
case "plain":
|
|
61
|
-
line = outputPlainWithOptions(value, { redaction: currentRedaction });
|
|
62
|
-
break;
|
|
63
|
-
case "yaml":
|
|
64
|
-
line = outputYamlWithOptions(value, { redaction: currentRedaction });
|
|
65
|
-
break;
|
|
66
|
-
default:
|
|
67
|
-
line = outputJsonWithOptions(value, { redaction: currentRedaction });
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
process.stdout.write(line + "\n");
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* AFDATA logger. Each method outputs a single log line to stdout.
|
|
74
|
-
* Format is controlled by initJson/initPlain/initYaml (default: JSON).
|
|
75
|
-
*/
|
|
76
|
-
export const log = {
|
|
77
|
-
trace: (msg, fields) => emit("trace", msg, fields),
|
|
78
|
-
debug: (msg, fields) => emit("debug", msg, fields),
|
|
79
|
-
info: (msg, fields) => emit("info", msg, fields),
|
|
80
|
-
warn: (msg, fields) => emit("warn", msg, fields),
|
|
81
|
-
error: (msg, fields) => emit("error", msg, fields),
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* Run fn within a span that adds fields to all log events.
|
|
85
|
-
* Spans nest: inner spans inherit and can override outer span fields.
|
|
86
|
-
*/
|
|
87
|
-
export function span(fields, fn) {
|
|
88
|
-
const parent = spanStore.getStore() ?? {};
|
|
89
|
-
return spanStore.run({ ...parent, ...fields }, fn);
|
|
90
|
-
}
|