aibroker 0.53.5 → 0.55.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 +3 -0
- package/dist/.metadata_never_index +0 -0
- package/dist/a2a/agentish-extension.d.ts +111 -0
- package/dist/a2a/agentish-extension.d.ts.map +1 -0
- package/dist/a2a/agentish-extension.js +124 -0
- package/dist/a2a/agentish-extension.js.map +1 -0
- package/dist/a2a/client.d.ts +45 -0
- package/dist/a2a/client.d.ts.map +1 -0
- package/dist/a2a/client.js +112 -0
- package/dist/a2a/client.js.map +1 -0
- package/dist/a2a/exposure.d.ts +24 -0
- package/dist/a2a/exposure.d.ts.map +1 -0
- package/dist/a2a/exposure.js +70 -0
- package/dist/a2a/exposure.js.map +1 -0
- package/dist/a2a/schema/types.d.ts +153 -0
- package/dist/a2a/schema/types.d.ts.map +1 -0
- package/dist/a2a/schema/types.js +28 -0
- package/dist/a2a/schema/types.js.map +1 -0
- package/dist/a2a/schema/validate.d.ts +27 -0
- package/dist/a2a/schema/validate.d.ts.map +1 -0
- package/dist/a2a/schema/validate.js +190 -0
- package/dist/a2a/schema/validate.js.map +1 -0
- package/dist/a2a/server.d.ts +73 -0
- package/dist/a2a/server.d.ts.map +1 -0
- package/dist/a2a/server.js +325 -0
- package/dist/a2a/server.js.map +1 -0
- package/dist/a2a/tasks.d.ts +81 -0
- package/dist/a2a/tasks.d.ts.map +1 -0
- package/dist/a2a/tasks.js +148 -0
- package/dist/a2a/tasks.js.map +1 -0
- package/dist/agentish/index.d.ts +80 -0
- package/dist/agentish/index.d.ts.map +1 -0
- package/dist/agentish/index.js +263 -0
- package/dist/agentish/index.js.map +1 -0
- package/dist/daemon/a2a-cli.d.ts +46 -0
- package/dist/daemon/a2a-cli.d.ts.map +1 -0
- package/dist/daemon/a2a-cli.js +385 -0
- package/dist/daemon/a2a-cli.js.map +1 -0
- package/dist/daemon/agentish-cli.d.ts +17 -0
- package/dist/daemon/agentish-cli.d.ts.map +1 -0
- package/dist/daemon/agentish-cli.js +137 -0
- package/dist/daemon/agentish-cli.js.map +1 -0
- package/dist/daemon/agentish-stats.d.ts +65 -0
- package/dist/daemon/agentish-stats.d.ts.map +1 -0
- package/dist/daemon/agentish-stats.js +125 -0
- package/dist/daemon/agentish-stats.js.map +1 -0
- package/dist/daemon/agentish.d.ts +13 -0
- package/dist/daemon/agentish.d.ts.map +1 -0
- package/dist/daemon/agentish.js +13 -0
- package/dist/daemon/agentish.js.map +1 -0
- package/dist/daemon/budget-cli.d.ts.map +1 -1
- package/dist/daemon/budget-cli.js +22 -3
- package/dist/daemon/budget-cli.js.map +1 -1
- package/dist/daemon/cli.js +12 -1
- package/dist/daemon/cli.js.map +1 -1
- package/dist/daemon/core-handlers.d.ts.map +1 -1
- package/dist/daemon/core-handlers.js +38 -0
- package/dist/daemon/core-handlers.js.map +1 -1
- package/dist/daemon/manage.d.ts.map +1 -1
- package/dist/daemon/manage.js +10 -1
- package/dist/daemon/manage.js.map +1 -1
- package/dist/daemon/todoist-webhook.d.ts +25 -2
- package/dist/daemon/todoist-webhook.d.ts.map +1 -1
- package/dist/daemon/todoist-webhook.js +136 -17
- package/dist/daemon/todoist-webhook.js.map +1 -1
- package/dist/mcp/index.js +41 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/transport/screen.d.ts +7 -0
- package/dist/transport/screen.d.ts.map +1 -1
- package/dist/transport/screen.js +17 -3
- package/dist/transport/screen.js.map +1 -1
- package/docker/ota/src/landing.ts +22 -24
- package/docker/ota/src/server.ts +5 -1
- package/package.json +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentish/index.ts — Agentish v2 (AG2), the wire format sessions use to
|
|
3
|
+
* talk to each other.
|
|
4
|
+
*
|
|
5
|
+
* A session working a long shift reports to whoever is managing it many
|
|
6
|
+
* times a night, and every one of those reports is budget spent before any
|
|
7
|
+
* work gets done. Prose restates the task to prove it was understood, hedges
|
|
8
|
+
* where a fact would do, and buries the one field a reader actually needs —
|
|
9
|
+
* did the gate pass — in a paragraph. AG2 is the alternative: a kind line
|
|
10
|
+
* plus `k=v` lines with one-letter keys, so a report costs as few tokens as
|
|
11
|
+
* the facts it carries and can be checked by a machine instead of read by
|
|
12
|
+
* one. `check` refuses a report that is missing a required field, uses a key
|
|
13
|
+
* its kind does not have, carries a field of the wrong shape, or claims
|
|
14
|
+
* success (`r=+`) without the proof that success requires; `measure` prints
|
|
15
|
+
* a message's token count beside a prose twin so the saving is a number, not
|
|
16
|
+
* a claim.
|
|
17
|
+
*
|
|
18
|
+
* This module is deliberately dependency-free — no daemon code, no Node API
|
|
19
|
+
* beyond what plain JS already gives it — so a team that wants the validator
|
|
20
|
+
* without AIBroker's daemon can take this one file (or `npm install` it,
|
|
21
|
+
* once it is split into its own package) and get CI checking for free. See
|
|
22
|
+
* `docs/agentish.md`, section "Use in CI".
|
|
23
|
+
*
|
|
24
|
+
* This is a port, not an original design — a sibling project's validator
|
|
25
|
+
* (`tools/agentish.py`) worked out the shape of these checks first. AG2_SPEC
|
|
26
|
+
* is the sibling's wire format, unchanged. `why` (the `y` key) is this
|
|
27
|
+
* project's own addition: it is not in AG2_SPEC, it is documented separately
|
|
28
|
+
* as AG2_EXTENSIONS, and it is accepted only where a report needs room to
|
|
29
|
+
* explain a result that is not a plain pass — R, Q, X. The sibling has not
|
|
30
|
+
* adopted it; until it does, "why" is something this validator alone checks.
|
|
31
|
+
*/
|
|
32
|
+
/** The wire format itself, unmodified, as it is told to every session that
|
|
33
|
+
* must speak it. This is the sibling project's spec — extensions live in
|
|
34
|
+
* AG2_EXTENSIONS instead of being folded in here. */
|
|
35
|
+
export declare const AG2_SPEC = "AG2. msg=kind line+k=v lines. kinds T R S Q A X. keys i id g goal o own n forbid d steps p proof u out l limits r res c changes t tests G gate I inst m images # nums w worst x next z note(<200ch). sep |. outcomes + - ~ ? !. @n=path declared once then reused; @n:12=file:line. tests as Name+ Name-. no prose, no articles, never restate, unknown=?. r=+ only if all t +.";
|
|
36
|
+
/** What this validator accepts beyond AG2_SPEC. Not yet proposed back to the
|
|
37
|
+
* sibling project — see the module comment. */
|
|
38
|
+
export declare const AG2_EXTENSIONS = "y why(\u2264600ch)";
|
|
39
|
+
/** This validator's own identity when it is carried over a channel that
|
|
40
|
+
* needs one — e.g. an A2A extension declaration. Not part of AG2_SPEC. */
|
|
41
|
+
export declare const AGENTISH_URI = "urn:aibroker:a2a:ext:agentish:2";
|
|
42
|
+
export type AgentishKind = "T" | "R" | "S" | "Q" | "A" | "X";
|
|
43
|
+
/**
|
|
44
|
+
* A stable identifier for one failure, so a CI script can branch on `code`
|
|
45
|
+
* instead of grepping `message`. This table is a public contract once
|
|
46
|
+
* published — see docs/agentish.md's "Use in CI" section, which says so.
|
|
47
|
+
*/
|
|
48
|
+
export type AgentishErrorCode = "E_EMPTY" | "E_KIND" | "E_TOO_LONG" | "E_PARSE" | "E_DUP" | "E_REQUIRED" | "E_KEY" | "E_SHAPE" | "E_REF_UNDECLARED" | "E_R_UNPROVEN" | "E_Z_LEN" | "E_Y_LEN" | "E_T_OMITTED" | "E_T_UNREQUESTED";
|
|
49
|
+
export interface AgentishError {
|
|
50
|
+
code: AgentishErrorCode;
|
|
51
|
+
message: string;
|
|
52
|
+
/** 1-based position among this message's own non-blank lines, where known. */
|
|
53
|
+
line?: number;
|
|
54
|
+
}
|
|
55
|
+
export interface AgentishCheckResult {
|
|
56
|
+
kind: AgentishKind | null;
|
|
57
|
+
fields: Record<string, string>;
|
|
58
|
+
symbols: Record<string, string>;
|
|
59
|
+
/** Human-readable messages, in order — the format every existing caller
|
|
60
|
+
* and test in this codebase reads. Same content as `details[].message`. */
|
|
61
|
+
errors: string[];
|
|
62
|
+
/** The same failures, with a stable code and a line where one applies. */
|
|
63
|
+
details: AgentishError[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Validate one Agentish message. `earlier` is the thread's prior messages —
|
|
67
|
+
* read for their `@n=path` declarations, so a reply can reuse a symbol
|
|
68
|
+
* without repeating the line that introduced it, and for a `T` sharing this
|
|
69
|
+
* message's `id`, so an `R` can be held to the tests that `T` asked for.
|
|
70
|
+
*/
|
|
71
|
+
export declare function check(msg: string, earlier?: string[]): AgentishCheckResult;
|
|
72
|
+
export interface AgentishMeasureResult {
|
|
73
|
+
agentish: number;
|
|
74
|
+
prose: number;
|
|
75
|
+
ratio: number;
|
|
76
|
+
valid: boolean;
|
|
77
|
+
}
|
|
78
|
+
/** A message's token cost beside its prose twin, so a saving is a number. */
|
|
79
|
+
export declare function measure(msg: string, proseTwin: string): AgentishMeasureResult;
|
|
80
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agentish/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH;;qDAEqD;AACrD,eAAO,MAAM,QAAQ,oXAC8V,CAAC;AAEpX;+CAC+C;AAC/C,eAAO,MAAM,cAAc,uBAAkB,CAAC;AAE9C;0EAC0E;AAC1E,eAAO,MAAM,YAAY,oCAAoC,CAAC;AAE9D,MAAM,MAAM,YAAY,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AA+C7D;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GACzB,SAAS,GAAG,QAAQ,GAAG,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,YAAY,GACxE,OAAO,GAAG,SAAS,GAAG,kBAAkB,GAAG,cAAc,GAAG,SAAS,GACrE,SAAS,GAAG,aAAa,GAAG,iBAAiB,CAAC;AAElD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC;+EAC2E;IAC3E,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,0EAA0E;IAC1E,OAAO,EAAE,aAAa,EAAE,CAAC;CAC1B;AAoCD;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,EAAO,GAAG,mBAAmB,CA4H9E;AAYD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,6EAA6E;AAC7E,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,qBAAqB,CAK7E"}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentish/index.ts — Agentish v2 (AG2), the wire format sessions use to
|
|
3
|
+
* talk to each other.
|
|
4
|
+
*
|
|
5
|
+
* A session working a long shift reports to whoever is managing it many
|
|
6
|
+
* times a night, and every one of those reports is budget spent before any
|
|
7
|
+
* work gets done. Prose restates the task to prove it was understood, hedges
|
|
8
|
+
* where a fact would do, and buries the one field a reader actually needs —
|
|
9
|
+
* did the gate pass — in a paragraph. AG2 is the alternative: a kind line
|
|
10
|
+
* plus `k=v` lines with one-letter keys, so a report costs as few tokens as
|
|
11
|
+
* the facts it carries and can be checked by a machine instead of read by
|
|
12
|
+
* one. `check` refuses a report that is missing a required field, uses a key
|
|
13
|
+
* its kind does not have, carries a field of the wrong shape, or claims
|
|
14
|
+
* success (`r=+`) without the proof that success requires; `measure` prints
|
|
15
|
+
* a message's token count beside a prose twin so the saving is a number, not
|
|
16
|
+
* a claim.
|
|
17
|
+
*
|
|
18
|
+
* This module is deliberately dependency-free — no daemon code, no Node API
|
|
19
|
+
* beyond what plain JS already gives it — so a team that wants the validator
|
|
20
|
+
* without AIBroker's daemon can take this one file (or `npm install` it,
|
|
21
|
+
* once it is split into its own package) and get CI checking for free. See
|
|
22
|
+
* `docs/agentish.md`, section "Use in CI".
|
|
23
|
+
*
|
|
24
|
+
* This is a port, not an original design — a sibling project's validator
|
|
25
|
+
* (`tools/agentish.py`) worked out the shape of these checks first. AG2_SPEC
|
|
26
|
+
* is the sibling's wire format, unchanged. `why` (the `y` key) is this
|
|
27
|
+
* project's own addition: it is not in AG2_SPEC, it is documented separately
|
|
28
|
+
* as AG2_EXTENSIONS, and it is accepted only where a report needs room to
|
|
29
|
+
* explain a result that is not a plain pass — R, Q, X. The sibling has not
|
|
30
|
+
* adopted it; until it does, "why" is something this validator alone checks.
|
|
31
|
+
*/
|
|
32
|
+
/** The wire format itself, unmodified, as it is told to every session that
|
|
33
|
+
* must speak it. This is the sibling project's spec — extensions live in
|
|
34
|
+
* AG2_EXTENSIONS instead of being folded in here. */
|
|
35
|
+
export const AG2_SPEC = "AG2. msg=kind line+k=v lines. kinds T R S Q A X. keys i id g goal o own n forbid d steps p proof u out l limits r res c changes t tests G gate I inst m images # nums w worst x next z note(<200ch). sep |. outcomes + - ~ ? !. @n=path declared once then reused; @n:12=file:line. tests as Name+ Name-. no prose, no articles, never restate, unknown=?. r=+ only if all t +.";
|
|
36
|
+
/** What this validator accepts beyond AG2_SPEC. Not yet proposed back to the
|
|
37
|
+
* sibling project — see the module comment. */
|
|
38
|
+
export const AG2_EXTENSIONS = "y why(≤600ch)";
|
|
39
|
+
/** This validator's own identity when it is carried over a channel that
|
|
40
|
+
* needs one — e.g. an A2A extension declaration. Not part of AG2_SPEC. */
|
|
41
|
+
export const AGENTISH_URI = "urn:aibroker:a2a:ext:agentish:2";
|
|
42
|
+
/** One-letter key → canonical field name. */
|
|
43
|
+
const KEYS = {
|
|
44
|
+
i: "id", g: "goal", o: "own", n: "no", d: "do", p: "prove",
|
|
45
|
+
u: "out", l: "lim", r: "res", c: "chg", t: "test", G: "gate",
|
|
46
|
+
I: "inst", m: "img", "#": "num", w: "worst", x: "next", z: "note",
|
|
47
|
+
a: "a", q: "q", b: "blk", e: "eta", y: "why", s: "at",
|
|
48
|
+
};
|
|
49
|
+
/** The one or two fields each kind cannot be validated without, by their
|
|
50
|
+
* short letter — so a missing one is reported the way it is written. */
|
|
51
|
+
const REQUIRED = {
|
|
52
|
+
T: ["i", "g", "d", "t"],
|
|
53
|
+
R: ["i", "r", "t", "c"],
|
|
54
|
+
A: ["i", "r"],
|
|
55
|
+
Q: ["i", "z"],
|
|
56
|
+
S: ["i"],
|
|
57
|
+
X: ["i", "z"],
|
|
58
|
+
};
|
|
59
|
+
/** Everything else a kind may carry, by canonical name. `why` (the
|
|
60
|
+
* AG2_EXTENSIONS field) is deliberately absent from T, S and A: a task or a
|
|
61
|
+
* status has nothing yet to explain, and an answer either is one or is not. */
|
|
62
|
+
const OPTIONAL = {
|
|
63
|
+
T: ["own", "no", "prove", "out", "lim", "gate", "note"],
|
|
64
|
+
R: ["inst", "img", "num", "worst", "next", "note", "gate", "prove", "why"],
|
|
65
|
+
S: ["at", "res", "blk", "eta", "note"],
|
|
66
|
+
Q: ["q", "dflt", "opts", "why"],
|
|
67
|
+
A: ["a", "note"],
|
|
68
|
+
X: ["why"],
|
|
69
|
+
};
|
|
70
|
+
/** Canonical name → the short symbol a "bad shape" error names it by. */
|
|
71
|
+
const SHAPE_SYMBOL = {
|
|
72
|
+
id: "i", res: "r", gate: "G", num: "#", img: "m", chg: "c",
|
|
73
|
+
};
|
|
74
|
+
const OUTCOMES = new Set(["+", "-", "~", "?", "!"]);
|
|
75
|
+
const MAX_LINES = 25;
|
|
76
|
+
const NOTE_MAX_CHARS = 200;
|
|
77
|
+
const WHY_MAX_CHARS = 600;
|
|
78
|
+
const ID_SHAPE = /^[a-z0-9][\w.-]*$/;
|
|
79
|
+
const NUM_SHAPE = /^[\d,. ]*$/;
|
|
80
|
+
const IMG_SHAPE = /\.(png|jpe?g|pdf)$/i;
|
|
81
|
+
const AT_REF = /@[A-Za-z0-9_]+(?::\d+)?/;
|
|
82
|
+
function splitOnce(s, sep) {
|
|
83
|
+
const i = s.indexOf(sep);
|
|
84
|
+
return i < 0 ? [s, ""] : [s.slice(0, i), s.slice(i + 1)];
|
|
85
|
+
}
|
|
86
|
+
/** `Name+` → `+`, `Name=+` → `+`, bare `+` → `+`. */
|
|
87
|
+
function outcomeOf(entry) {
|
|
88
|
+
const e = entry.trim();
|
|
89
|
+
if (!e)
|
|
90
|
+
return "";
|
|
91
|
+
return e.includes("=") ? e.split("=").pop() : e.slice(-1);
|
|
92
|
+
}
|
|
93
|
+
/** `Name+` → `Name`, `Name=+` → `Name`. Used to compare test sets by name,
|
|
94
|
+
* ignoring the outcome each side attached to that name. */
|
|
95
|
+
function nameOf(entry) {
|
|
96
|
+
const e = entry.trim();
|
|
97
|
+
if (!e)
|
|
98
|
+
return "";
|
|
99
|
+
if (e.includes("="))
|
|
100
|
+
return e.split("=")[0];
|
|
101
|
+
return OUTCOMES.has(e.slice(-1)) ? e.slice(0, -1) : e;
|
|
102
|
+
}
|
|
103
|
+
function tokenNames(field) {
|
|
104
|
+
const names = (field ?? "").trim().split(/\s+/).filter(Boolean).map(nameOf).filter(Boolean);
|
|
105
|
+
return new Set(names);
|
|
106
|
+
}
|
|
107
|
+
function lines(text) {
|
|
108
|
+
return text
|
|
109
|
+
.trim()
|
|
110
|
+
.split(/\r\n|\r|\n/)
|
|
111
|
+
.map((l) => l.trimEnd())
|
|
112
|
+
.filter((l) => l.trim().length > 0);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Validate one Agentish message. `earlier` is the thread's prior messages —
|
|
116
|
+
* read for their `@n=path` declarations, so a reply can reuse a symbol
|
|
117
|
+
* without repeating the line that introduced it, and for a `T` sharing this
|
|
118
|
+
* message's `id`, so an `R` can be held to the tests that `T` asked for.
|
|
119
|
+
*/
|
|
120
|
+
export function check(msg, earlier = []) {
|
|
121
|
+
const details = [];
|
|
122
|
+
const errors = [];
|
|
123
|
+
const fail = (code, message, line) => {
|
|
124
|
+
details.push(line === undefined ? { code, message } : { code, message, line });
|
|
125
|
+
errors.push(message);
|
|
126
|
+
};
|
|
127
|
+
const ls = lines(msg);
|
|
128
|
+
if (ls.length === 0) {
|
|
129
|
+
fail("E_EMPTY", "empty message");
|
|
130
|
+
return { kind: null, fields: {}, symbols: {}, errors, details };
|
|
131
|
+
}
|
|
132
|
+
const kind = ls[0].trim();
|
|
133
|
+
const fields = {};
|
|
134
|
+
const fieldLine = {};
|
|
135
|
+
const symbols = {};
|
|
136
|
+
if (!(kind in REQUIRED)) {
|
|
137
|
+
fail("E_KIND", `unknown kind ${JSON.stringify(ls[0].trim())}; one of ${Object.keys(REQUIRED).join(" ")}`, 1);
|
|
138
|
+
return { kind: null, fields, symbols, errors, details };
|
|
139
|
+
}
|
|
140
|
+
if (ls.length > MAX_LINES) {
|
|
141
|
+
fail("E_TOO_LONG", `${ls.length} lines > ${MAX_LINES}`, 1);
|
|
142
|
+
}
|
|
143
|
+
const earlierParsed = earlier.map((e) => check(e));
|
|
144
|
+
for (const parsed of earlierParsed)
|
|
145
|
+
Object.assign(symbols, parsed.symbols);
|
|
146
|
+
for (let i = 1; i < ls.length; i++) {
|
|
147
|
+
const l = ls[i];
|
|
148
|
+
const lineNo = i + 1;
|
|
149
|
+
if (l.startsWith("@") && l.includes("=")) {
|
|
150
|
+
const [sym, path] = splitOnce(l.slice(1), "=");
|
|
151
|
+
symbols[sym.trim()] = path.trim();
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
const eq = l.indexOf("=");
|
|
155
|
+
const colon = l.indexOf(":");
|
|
156
|
+
const sep = eq >= 0 && (colon < 0 || eq < colon) ? "=" : ":";
|
|
157
|
+
if (l.indexOf(sep) < 0) {
|
|
158
|
+
fail("E_PARSE", `not k=v: ${JSON.stringify(l.slice(0, 40))}`, lineNo);
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const [rawKey, rawValue] = splitOnce(l, sep);
|
|
162
|
+
const k = KEYS[rawKey.trim()] ?? rawKey.trim();
|
|
163
|
+
if (k in fields)
|
|
164
|
+
fail("E_DUP", `duplicate key ${k}`, lineNo);
|
|
165
|
+
fields[k] = rawValue.trim();
|
|
166
|
+
fieldLine[k] = lineNo;
|
|
167
|
+
}
|
|
168
|
+
for (const short of REQUIRED[kind]) {
|
|
169
|
+
if (!(KEYS[short] in fields))
|
|
170
|
+
fail("E_REQUIRED", `${kind} requires ${short}`, 1);
|
|
171
|
+
}
|
|
172
|
+
const allowed = new Set([...REQUIRED[kind].map((s) => KEYS[s]), ...OPTIONAL[kind]]);
|
|
173
|
+
for (const k of Object.keys(fields)) {
|
|
174
|
+
if (!allowed.has(k))
|
|
175
|
+
fail("E_KEY", `unknown key ${k}`, fieldLine[k]);
|
|
176
|
+
}
|
|
177
|
+
// Value shapes. Run whenever the field is present, independent of whether
|
|
178
|
+
// this kind accepts it — a malformed value is worth reporting even when
|
|
179
|
+
// "unknown key" already covers the field not belonging here at all.
|
|
180
|
+
if ("id" in fields && !ID_SHAPE.test(fields.id))
|
|
181
|
+
fail("E_SHAPE", `${SHAPE_SYMBOL.id}: bad shape`, fieldLine.id);
|
|
182
|
+
if ("res" in fields && !OUTCOMES.has(fields.res))
|
|
183
|
+
fail("E_SHAPE", `${SHAPE_SYMBOL.res}: bad shape`, fieldLine.res);
|
|
184
|
+
if ("gate" in fields && !OUTCOMES.has(fields.gate))
|
|
185
|
+
fail("E_SHAPE", `${SHAPE_SYMBOL.gate}: bad shape`, fieldLine.gate);
|
|
186
|
+
if ("num" in fields && !NUM_SHAPE.test(fields.num))
|
|
187
|
+
fail("E_SHAPE", `${SHAPE_SYMBOL.num}: bad shape`, fieldLine.num);
|
|
188
|
+
if ("img" in fields) {
|
|
189
|
+
const bad = fields.img.split("|").some((p) => {
|
|
190
|
+
const e = p.trim();
|
|
191
|
+
return e !== "" && !e.includes("/") && !IMG_SHAPE.test(e);
|
|
192
|
+
});
|
|
193
|
+
if (bad)
|
|
194
|
+
fail("E_SHAPE", `${SHAPE_SYMBOL.img}: bad shape`, fieldLine.img);
|
|
195
|
+
}
|
|
196
|
+
if (kind === "R") {
|
|
197
|
+
const test = fields.test ?? "";
|
|
198
|
+
if (test && !test.trim().split(/\s+/).filter(Boolean).every((tk) => OUTCOMES.has(outcomeOf(tk)))) {
|
|
199
|
+
fail("E_SHAPE", "test: every entry ends with + - ~ ?", fieldLine.test);
|
|
200
|
+
}
|
|
201
|
+
if ("chg" in fields) {
|
|
202
|
+
const entries = fields.chg.split("|").map((p) => p.trim()).filter(Boolean);
|
|
203
|
+
if (entries.some((e) => !AT_REF.test(e) && !e.includes("/"))) {
|
|
204
|
+
fail("E_SHAPE", `${SHAPE_SYMBOL.chg}: bad shape`, fieldLine.chg);
|
|
205
|
+
}
|
|
206
|
+
for (const entry of entries) {
|
|
207
|
+
const head = entry.split(" ")[0].split(":")[0];
|
|
208
|
+
if (head.startsWith("@") && !(head.slice(1) in symbols)) {
|
|
209
|
+
fail("E_REF_UNDECLARED", `chg uses undeclared symbol ${head}`, fieldLine.chg);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
// Success is a claim this validator holds a message to, not a tone: all
|
|
214
|
+
// three of the gate, the proof, and every named test have to say so.
|
|
215
|
+
if (fields.res === "+") {
|
|
216
|
+
const gatePassed = fields.gate === "+";
|
|
217
|
+
const hasProof = (fields.prove ?? "").trim().length > 0;
|
|
218
|
+
const testsPassed = test.trim().split(/\s+/).filter(Boolean).every((tk) => outcomeOf(tk) === "+");
|
|
219
|
+
if (!gatePassed || !hasProof || !testsPassed)
|
|
220
|
+
fail("E_R_UNPROVEN", "r=+ without proof", fieldLine.res);
|
|
221
|
+
}
|
|
222
|
+
// Anything short of a clean pass, or a named worst-remaining issue, owes
|
|
223
|
+
// a reason — otherwise "~" and "-" read exactly like "didn't get to it".
|
|
224
|
+
const needsWhy = fields.res === "-" || fields.res === "~" || "worst" in fields;
|
|
225
|
+
if (needsWhy && !(fields.why ?? "").trim())
|
|
226
|
+
fail("E_REQUIRED", "R requires y", fieldLine.res ?? 1);
|
|
227
|
+
const priorT = [...earlierParsed].reverse().find((p) => p.kind === "T" && p.fields.id === fields.id);
|
|
228
|
+
if (priorT) {
|
|
229
|
+
const wanted = tokenNames(priorT.fields.test);
|
|
230
|
+
const got = tokenNames(fields.test);
|
|
231
|
+
for (const name of wanted)
|
|
232
|
+
if (!got.has(name))
|
|
233
|
+
fail("E_T_OMITTED", `t omitted: ${name}`, fieldLine.test);
|
|
234
|
+
for (const name of got)
|
|
235
|
+
if (!wanted.has(name))
|
|
236
|
+
fail("E_T_UNREQUESTED", `t unrequested: ${name}`, fieldLine.test);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if ((fields.why ?? "").length > WHY_MAX_CHARS) {
|
|
240
|
+
fail("E_Y_LEN", `y > ${WHY_MAX_CHARS} chars (extension field too long)`, fieldLine.why);
|
|
241
|
+
}
|
|
242
|
+
if ((fields.note ?? "").length > NOTE_MAX_CHARS) {
|
|
243
|
+
fail("E_Z_LEN", `note > ${NOTE_MAX_CHARS} chars (restating the task)`, fieldLine.note);
|
|
244
|
+
}
|
|
245
|
+
return { kind, fields, symbols, errors, details };
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Tokens ≈ words + punctuation. The sibling project counts with tiktoken;
|
|
249
|
+
* this repo takes on no tokenizer dependency for a number that only needs to
|
|
250
|
+
* land on the same conclusion as that one, not match it digit for digit.
|
|
251
|
+
*/
|
|
252
|
+
function approxTokens(text) {
|
|
253
|
+
const found = text.match(/[\p{L}\p{N}_]+|[^\s\p{L}\p{N}_]/gu);
|
|
254
|
+
return found ? found.length : 0;
|
|
255
|
+
}
|
|
256
|
+
/** A message's token cost beside its prose twin, so a saving is a number. */
|
|
257
|
+
export function measure(msg, proseTwin) {
|
|
258
|
+
const agentish = approxTokens(msg);
|
|
259
|
+
const prose = approxTokens(proseTwin);
|
|
260
|
+
const { errors } = check(msg);
|
|
261
|
+
return { agentish, prose, ratio: prose === 0 ? 0 : agentish / prose, valid: errors.length === 0 };
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agentish/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH;;qDAEqD;AACrD,MAAM,CAAC,MAAM,QAAQ,GACnB,iXAAiX,CAAC;AAEpX;+CAC+C;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;AAE9C;0EAC0E;AAC1E,MAAM,CAAC,MAAM,YAAY,GAAG,iCAAiC,CAAC;AAI9D,6CAA6C;AAC7C,MAAM,IAAI,GAA2B;IACnC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO;IAC1D,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAC5D,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IACjE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI;CACtD,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AK,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IACtC,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;AACpG,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* daemon/a2a-cli.ts — `aibroker a2a`, from a shell rather than an MCP tool.
|
|
3
|
+
*
|
|
4
|
+
* Two families of verb. `card`, `send`, `get`, `cancel`, `check` are pure
|
|
5
|
+
* A2A CLIENT operations — they speak to ANY A2A v0.3.0 agent over the
|
|
6
|
+
* network and need no daemon running locally; `check` in particular is
|
|
7
|
+
* generic interoperability tooling, not a self-test, and is meant to be
|
|
8
|
+
* pointed at agents this project did not write.
|
|
9
|
+
*
|
|
10
|
+
* `expose`, `unexpose`, `exposed`, `tasks`, `setup` operate on THIS
|
|
11
|
+
* machine's A2A server: which sessions it publishes as skills, what
|
|
12
|
+
* tasks are on file, and how the endpoint is exposed to the internet.
|
|
13
|
+
* `reply` goes through the daemon (`WatcherClient`), the same reason
|
|
14
|
+
* `aibroker issue` does — the calling session's identity and the audit
|
|
15
|
+
* record both live there, and a CLI that mutated the task file directly
|
|
16
|
+
* would bypass both.
|
|
17
|
+
*/
|
|
18
|
+
/** AIBROKER_A2A_URL wins whole; otherwise https://<public host>/a2a. Exported for tests. */
|
|
19
|
+
export declare function resolveOwnA2AUrl(): string;
|
|
20
|
+
export interface EnsureTokenResult {
|
|
21
|
+
token: string;
|
|
22
|
+
/** False when a token was already set — nothing was generated or written. */
|
|
23
|
+
generated: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* `AIBROKER_A2A_TOKEN` if already set; otherwise a fresh 32-byte token,
|
|
27
|
+
* written to `envFile` unless `printOnly`. Never overwrites an existing
|
|
28
|
+
* token — mirrors inbound.ts's secret handling: generated once, shown once.
|
|
29
|
+
* Pulled out of `runSetup` so the generate-once / keep-existing behaviour
|
|
30
|
+
* is testable without touching a real `tailscale` binary or the network.
|
|
31
|
+
*/
|
|
32
|
+
export declare function ensureA2AToken(envFile: string, printOnly: boolean): EnsureTokenResult;
|
|
33
|
+
export interface VerifyResult {
|
|
34
|
+
ok: boolean;
|
|
35
|
+
detail: string;
|
|
36
|
+
skillCount?: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Fetch `<publicBase>/.well-known/agent-card.json` and report what came
|
|
40
|
+
* back. Pulled out of `runSetup` so `setup`'s pass/fail reporting is
|
|
41
|
+
* testable against an arbitrary URL, without going through DNS, Tailscale,
|
|
42
|
+
* or this machine's own configured public host.
|
|
43
|
+
*/
|
|
44
|
+
export declare function verifyPublicCard(publicBase: string, timeoutMs?: number): Promise<VerifyResult>;
|
|
45
|
+
export declare function runA2A(args: string[]): Promise<void>;
|
|
46
|
+
//# sourceMappingURL=a2a-cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2a-cli.d.ts","sourceRoot":"","sources":["../../src/daemon/a2a-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAmDH,4FAA4F;AAC5F,wBAAgB,gBAAgB,IAAI,MAAM,CAKzC;AAsID,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,iBAAiB,CASrF;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,CASpG;AAsED,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB1D"}
|