salt-agent-sdk 0.25.0 → 0.27.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 +16 -0
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/work.d.ts +66 -0
- package/dist/work.d.ts.map +1 -1
- package/dist/work.js +149 -3
- package/dist/work.js.map +1 -1
- package/package.json +1 -1
- package/dist/lattice.d.ts +0 -206
- package/dist/lattice.d.ts.map +0 -1
- package/dist/lattice.js +0 -366
- package/dist/lattice.js.map +0 -1
package/README.md
CHANGED
|
@@ -522,6 +522,22 @@ Asking @weather
|
|
|
522
522
|
Forecast for Lisbon tomorrow?
|
|
523
523
|
```
|
|
524
524
|
|
|
525
|
+
A report may carry one more line after the title, `advantage: {json}`: what
|
|
526
|
+
has been shown to work (`{"edges":[{"label","edge","n"}],"open":[],"settled":[],
|
|
527
|
+
"testing":[],"kept":[],"dropped":[],"explore":0.2}`, at most 8 edges, highest
|
|
528
|
+
first, 4000 characters). Pass `advantage: {edges, explore}` on the report and
|
|
529
|
+
`formatWorkReport` writes it (dropping the lowest-n edges if it ever runs over);
|
|
530
|
+
`parseWorkReport` and `parseAdvantage` read it back, and a missing or malformed
|
|
531
|
+
line is simply no advantage. Salt's plan sheet shows the edges under "What's
|
|
532
|
+
working". From 0.27.0 the line also carries `open` (`{q, by}`), `settled`
|
|
533
|
+
(`{q, verdict, lift}`), `testing` and `kept` (`{id, text, lift}`) and `dropped`
|
|
534
|
+
(`{text, lift, why}`), and an edge may carry its `arm_key`. The owner's two taps
|
|
535
|
+
in that sheet reach the agent as whole messages in the same lane, which
|
|
536
|
+
`parseAdvantageTap` detects (`formatAdvantageTap` writes one):
|
|
537
|
+
`[[SALT-ADV-NEVER kind=arm key=<arm_key>]]`, `[[SALT-ADV-NEVER kind=lens id=<lens_id>]]`
|
|
538
|
+
and `[[SALT-ADV-KEEP kind=lens id=<lens_id>]]`. Act on a tap only when its sender
|
|
539
|
+
is the owner or the person the plan serves, and never show the marker in a reply.
|
|
540
|
+
|
|
525
541
|
Reports are sent `quiet` (no push notification) except `waiting`. Build one
|
|
526
542
|
yourself with `createWorkReporter(client).report(identity, {chatId,
|
|
527
543
|
requesterId}, {id, status, title, detail})`; it never throws, so a report that
|
package/dist/client.d.ts
CHANGED
|
@@ -1072,7 +1072,7 @@ type RequestFn = <T>(method: string, path: string, apiKey: string, body?: unknow
|
|
|
1072
1072
|
idempotencyKey?: string;
|
|
1073
1073
|
}) => Promise<T>;
|
|
1074
1074
|
/** Sent as `X-Salt-Client` on every request. Kept equal to package.json's version (a test checks). */
|
|
1075
|
-
export declare const SDK_VERSION = "0.
|
|
1075
|
+
export declare const SDK_VERSION = "0.27.0";
|
|
1076
1076
|
export declare function createSaltClient(options: SaltClientOptions): {
|
|
1077
1077
|
actFor: (principalId: SaltId, opts?: ActForOptions) => { [K in keyof ReturnType<(request: RequestFn) => {
|
|
1078
1078
|
/** A chat's members (with public keys), for encrypting a reply to everyone who should read it. */
|
package/dist/client.js
CHANGED
|
@@ -135,7 +135,7 @@ class RecipientContactsOnlyError extends SaltApiError {
|
|
|
135
135
|
}
|
|
136
136
|
exports.RecipientContactsOnlyError = RecipientContactsOnlyError;
|
|
137
137
|
/** Sent as `X-Salt-Client` on every request. Kept equal to package.json's version (a test checks). */
|
|
138
|
-
exports.SDK_VERSION = "0.
|
|
138
|
+
exports.SDK_VERSION = "0.27.0";
|
|
139
139
|
const CLIENT_HEADER = `salt-agent-sdk/${exports.SDK_VERSION}`;
|
|
140
140
|
function createSaltClient(options) {
|
|
141
141
|
const host = options.host.replace(/\/$/, "");
|
package/dist/work.d.ts
CHANGED
|
@@ -9,6 +9,52 @@ export declare const WORK_KINDS: readonly WorkKind[];
|
|
|
9
9
|
export declare const WORK_REPEATS: readonly WorkRepeat[];
|
|
10
10
|
export declare const MAX_WORK_TITLE = 140;
|
|
11
11
|
export declare const MAX_WORK_DETAIL = 500;
|
|
12
|
+
export declare const MAX_ADVANTAGE_CHARS = 4000;
|
|
13
|
+
export declare const MAX_ADVANTAGE_EDGES = 8;
|
|
14
|
+
export interface AdvantageEdge {
|
|
15
|
+
/** The kind of move, in words or snake_case labels ("post_to_profile · hacker_news · founders"). */
|
|
16
|
+
label: string;
|
|
17
|
+
/** How many times the agent's average result it earns (1.8 = 1.8x). */
|
|
18
|
+
edge: number;
|
|
19
|
+
/** Moves behind it. */
|
|
20
|
+
n: number;
|
|
21
|
+
/** The kind of move's key; lets "Never this" (SALT-ADV-NEVER kind=arm) name it. */
|
|
22
|
+
arm_key?: string;
|
|
23
|
+
}
|
|
24
|
+
export type AdvantageVerdict = "supported" | "refuted" | "inconclusive";
|
|
25
|
+
/** An open question: what is being asked and by when it will be answered. */
|
|
26
|
+
export interface AdvantageQuestion {
|
|
27
|
+
q: string;
|
|
28
|
+
by?: string;
|
|
29
|
+
}
|
|
30
|
+
/** A settled question and what the test said. */
|
|
31
|
+
export interface AdvantageSettled {
|
|
32
|
+
q: string;
|
|
33
|
+
verdict: AdvantageVerdict;
|
|
34
|
+
lift?: number;
|
|
35
|
+
}
|
|
36
|
+
/** A way of thinking being tried or kept; `id` lets the taps name it. */
|
|
37
|
+
export interface AdvantageLens {
|
|
38
|
+
id?: string;
|
|
39
|
+
text: string;
|
|
40
|
+
lift?: number;
|
|
41
|
+
}
|
|
42
|
+
/** A dropped way of thinking and why. */
|
|
43
|
+
export interface AdvantageDropped {
|
|
44
|
+
text: string;
|
|
45
|
+
lift?: number;
|
|
46
|
+
why?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface Advantage {
|
|
49
|
+
edges: AdvantageEdge[];
|
|
50
|
+
open?: AdvantageQuestion[];
|
|
51
|
+
settled?: AdvantageSettled[];
|
|
52
|
+
testing?: AdvantageLens[];
|
|
53
|
+
kept?: AdvantageLens[];
|
|
54
|
+
dropped?: AdvantageDropped[];
|
|
55
|
+
/** Share of effort spent trying new things, 0 to 1. */
|
|
56
|
+
explore?: number;
|
|
57
|
+
}
|
|
12
58
|
export interface WorkReport {
|
|
13
59
|
id: string;
|
|
14
60
|
status: WorkStatus;
|
|
@@ -23,9 +69,29 @@ export interface WorkReport {
|
|
|
23
69
|
repeat?: WorkRepeat;
|
|
24
70
|
/** The confirmed transfer behind money work (`transfer=<id>`); salt-fe reads the receipt row from it. */
|
|
25
71
|
transfer?: string;
|
|
72
|
+
/** What has been shown to work, as the `advantage:` line after the title. */
|
|
73
|
+
advantage?: Advantage;
|
|
26
74
|
}
|
|
27
75
|
/** A fresh id for one piece of work. */
|
|
28
76
|
export declare function newWorkId(): string;
|
|
77
|
+
/** The `advantage:` JSON for a report: edges sorted by edge (highest first),
|
|
78
|
+
* at most 8, every list present (empty when unused), and 4000 characters at
|
|
79
|
+
* most -- when it runs over, the lowest-n edge goes first, then the oldest
|
|
80
|
+
* row of the longest other list. Null when the input has no usable shape. */
|
|
81
|
+
export declare function formatAdvantage(advantage: Advantage | null | undefined): string | null;
|
|
82
|
+
/** The value of an `advantage:` line, as an Advantage, or null (bad JSON, wrong shape, over the cap). */
|
|
83
|
+
export declare function parseAdvantage(value: string): Advantage | null;
|
|
84
|
+
export type AdvantageTapAction = "never" | "keep";
|
|
85
|
+
export type AdvantageTapKind = "arm" | "lens";
|
|
86
|
+
export interface AdvantageTap {
|
|
87
|
+
action: AdvantageTapAction;
|
|
88
|
+
kind: AdvantageTapKind;
|
|
89
|
+
ref: string;
|
|
90
|
+
}
|
|
91
|
+
/** The wire message for a tap. Throws on a combination the protocol does not have (keep goes with a lens only) or a bad ref. */
|
|
92
|
+
export declare function formatAdvantageTap(tap: AdvantageTap): string;
|
|
93
|
+
/** The tap in a whole message, or null when the text is not exactly one. */
|
|
94
|
+
export declare function parseAdvantageTap(plaintext: string): AdvantageTap | null;
|
|
29
95
|
/** The plaintext of one report. Throws on a malformed id or status. */
|
|
30
96
|
export declare function formatWorkReport(report: WorkReport): string;
|
|
31
97
|
/** The report in a plaintext, or null when it is not one. */
|
package/dist/work.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work.d.ts","sourceRoot":"","sources":["../src/work.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"work.d.ts","sourceRoot":"","sources":["../src/work.ts"],"names":[],"mappings":"AAmDA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAU,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,CAAC;AAC/F,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,MAAM,CAAC;AAC7C,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhF,eAAO,MAAM,aAAa,EAAE,SAAS,UAAU,EAAuE,CAAC;AACvH,eAAO,MAAM,UAAU,EAAE,SAAS,QAAQ,EAA2B,CAAC;AACtE,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EAAyD,CAAC;AAExG,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,eAAO,MAAM,mBAAmB,OAAO,CAAC;AACxC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,MAAM,WAAW,aAAa;IAC5B,oGAAoG;IACpG,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,mFAAmF;IACnF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,SAAS,GAAG,cAAc,CAAC;AAExE,6EAA6E;AAC7E,MAAM,WAAW,iBAA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,KAAG,OAAO,CAAC,OAAO,CAAC;;EAgB3G;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
package/dist/work.js
CHANGED
|
@@ -28,6 +28,18 @@
|
|
|
28
28
|
// after is detail. The web app's parser lives in salt-fe
|
|
29
29
|
// `src/utilities/work.js`; keep the two in step.
|
|
30
30
|
//
|
|
31
|
+
// An optional `advantage: {json}` line may follow the title (DYNAMIC_ADVANTAGE
|
|
32
|
+
// phase 1): what has been shown to work, `{"edges":[{"label","edge","n"}],
|
|
33
|
+
// "open":[],"settled":[],"testing":[],"kept":[],"dropped":[],"explore":0.2}`,
|
|
34
|
+
// at most 8 edges sorted by edge, 4000 characters (formatAdvantage drops the
|
|
35
|
+
// lowest-n edges, then the oldest rows, until it fits). Phase 2 fills the
|
|
36
|
+
// lists: open [{q, by}], settled [{q, verdict, lift}], testing and kept
|
|
37
|
+
// [{id, text, lift}], dropped [{text, lift, why}]; an edge may carry its
|
|
38
|
+
// `arm_key` and a lens its `id` so the owner's taps can name them (see
|
|
39
|
+
// formatAdvantageTap below).
|
|
40
|
+
// salt-fe reads it in `parseAdvantage`; Grains writes the same line into the
|
|
41
|
+
// reports it makes.
|
|
42
|
+
//
|
|
31
43
|
// Cancel (person -> agent), a WHOLE message on its own, sent into the same
|
|
32
44
|
// lane a `scheduled` report came from:
|
|
33
45
|
//
|
|
@@ -70,8 +82,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
70
82
|
};
|
|
71
83
|
})();
|
|
72
84
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
|
-
exports.MAX_WORK_DETAIL = exports.MAX_WORK_TITLE = exports.WORK_REPEATS = exports.WORK_KINDS = exports.WORK_STATUSES = void 0;
|
|
85
|
+
exports.MAX_ADVANTAGE_EDGES = exports.MAX_ADVANTAGE_CHARS = exports.MAX_WORK_DETAIL = exports.MAX_WORK_TITLE = exports.WORK_REPEATS = exports.WORK_KINDS = exports.WORK_STATUSES = void 0;
|
|
74
86
|
exports.newWorkId = newWorkId;
|
|
87
|
+
exports.formatAdvantage = formatAdvantage;
|
|
88
|
+
exports.parseAdvantage = parseAdvantage;
|
|
89
|
+
exports.formatAdvantageTap = formatAdvantageTap;
|
|
90
|
+
exports.parseAdvantageTap = parseAdvantageTap;
|
|
75
91
|
exports.formatWorkReport = formatWorkReport;
|
|
76
92
|
exports.parseWorkReport = parseWorkReport;
|
|
77
93
|
exports.parseWorkCancel = parseWorkCancel;
|
|
@@ -84,6 +100,12 @@ exports.WORK_KINDS = ["delegation", "task"];
|
|
|
84
100
|
exports.WORK_REPEATS = ["hourly", "daily", "weekdays", "weekly", "monthly"];
|
|
85
101
|
exports.MAX_WORK_TITLE = 140;
|
|
86
102
|
exports.MAX_WORK_DETAIL = 500;
|
|
103
|
+
exports.MAX_ADVANTAGE_CHARS = 4000;
|
|
104
|
+
exports.MAX_ADVANTAGE_EDGES = 8;
|
|
105
|
+
const ADVANTAGE_LISTS = ["open", "settled", "testing", "kept", "dropped"];
|
|
106
|
+
const ADVANTAGE_LIST_MAX = 10;
|
|
107
|
+
const ADV_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
108
|
+
const ADV_VERDICTS = ["supported", "refuted", "inconclusive"];
|
|
87
109
|
const ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
88
110
|
const HANDLE_RE = /^[A-Za-z0-9_.-]{1,40}$/;
|
|
89
111
|
const MARKER_RE = /^\[\[SALT-WORK ([^\]\n]*)\]\]\n?/;
|
|
@@ -94,6 +116,118 @@ function newWorkId() {
|
|
|
94
116
|
return `w_${(0, node_crypto_1.randomBytes)(6).toString("hex")}`;
|
|
95
117
|
}
|
|
96
118
|
const oneLine = (text, max) => (text || "").replace(/\s+/g, " ").trim().slice(0, max);
|
|
119
|
+
const posNum = (v) => {
|
|
120
|
+
const n = Number(v);
|
|
121
|
+
return v != null && Number.isFinite(n) && n > 0 ? n : undefined;
|
|
122
|
+
};
|
|
123
|
+
const advId = (v) => (typeof v === "string" && ADV_ID_RE.test(v) ? v : undefined);
|
|
124
|
+
// One normaliser for both directions: bad rows dropped, text one line and capped, lists capped.
|
|
125
|
+
function normaliseAdvantage(raw) {
|
|
126
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw) || !Array.isArray(raw.edges))
|
|
127
|
+
return null;
|
|
128
|
+
const list = (v) => (Array.isArray(v) ? v.slice(0, ADVANTAGE_LIST_MAX) : []);
|
|
129
|
+
const edges = raw.edges
|
|
130
|
+
.map((e) => {
|
|
131
|
+
const edge = { label: oneLine(e && e.label, 120), edge: Number(e && e.edge), n: Number(e && e.n) };
|
|
132
|
+
const key = advId(e && e.arm_key);
|
|
133
|
+
if (key)
|
|
134
|
+
edge.arm_key = key;
|
|
135
|
+
return edge;
|
|
136
|
+
})
|
|
137
|
+
.filter((e) => e.label && Number.isFinite(e.edge) && e.edge > 0 && Number.isFinite(e.n) && e.n >= 0);
|
|
138
|
+
const lens = (x) => {
|
|
139
|
+
const out = { text: oneLine(x && (x.text || x.label), 160) };
|
|
140
|
+
const id = advId(x && x.id);
|
|
141
|
+
if (id)
|
|
142
|
+
out.id = id;
|
|
143
|
+
const lift = posNum(x && x.lift);
|
|
144
|
+
if (lift !== undefined)
|
|
145
|
+
out.lift = lift;
|
|
146
|
+
return out;
|
|
147
|
+
};
|
|
148
|
+
const advantage = {
|
|
149
|
+
edges,
|
|
150
|
+
open: list(raw.open).map((x) => ({ q: oneLine(x && x.q, 200), by: oneLine(x && x.by, 40) || undefined })).filter((x) => x.q),
|
|
151
|
+
settled: list(raw.settled)
|
|
152
|
+
.map((x) => ({ q: oneLine(x && x.q, 200), verdict: x && x.verdict, lift: posNum(x && x.lift) }))
|
|
153
|
+
.filter((x) => x.q && ADV_VERDICTS.includes(x.verdict)),
|
|
154
|
+
testing: list(raw.testing).map(lens).filter((x) => x.text),
|
|
155
|
+
kept: list(raw.kept).map(lens).filter((x) => x.text),
|
|
156
|
+
dropped: list(raw.dropped)
|
|
157
|
+
.map((x) => ({ text: oneLine(x && (x.text || x.label), 160), lift: posNum(x && x.lift), why: oneLine(x && x.why, 200) || undefined }))
|
|
158
|
+
.filter((x) => x.text),
|
|
159
|
+
};
|
|
160
|
+
const explore = Number(raw.explore);
|
|
161
|
+
if (raw.explore != null && Number.isFinite(explore))
|
|
162
|
+
advantage.explore = explore;
|
|
163
|
+
return advantage;
|
|
164
|
+
}
|
|
165
|
+
/** The `advantage:` JSON for a report: edges sorted by edge (highest first),
|
|
166
|
+
* at most 8, every list present (empty when unused), and 4000 characters at
|
|
167
|
+
* most -- when it runs over, the lowest-n edge goes first, then the oldest
|
|
168
|
+
* row of the longest other list. Null when the input has no usable shape. */
|
|
169
|
+
function formatAdvantage(advantage) {
|
|
170
|
+
const a = normaliseAdvantage(advantage);
|
|
171
|
+
if (!a)
|
|
172
|
+
return null;
|
|
173
|
+
a.edges = a.edges.sort((x, y) => y.edge - x.edge).slice(0, exports.MAX_ADVANTAGE_EDGES);
|
|
174
|
+
const build = () => JSON.stringify({ ...a, explore: a.explore ?? 0 });
|
|
175
|
+
let json = build();
|
|
176
|
+
while (json.length > exports.MAX_ADVANTAGE_CHARS) {
|
|
177
|
+
if (a.edges.length) {
|
|
178
|
+
let lowest = 0;
|
|
179
|
+
a.edges.forEach((e, i) => { if (e.n < a.edges[lowest].n)
|
|
180
|
+
lowest = i; });
|
|
181
|
+
a.edges.splice(lowest, 1);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
const longest = ADVANTAGE_LISTS.reduce((best, k) => (a[k].length > a[best].length ? k : best), ADVANTAGE_LISTS[0]);
|
|
185
|
+
if (!a[longest].length)
|
|
186
|
+
break;
|
|
187
|
+
a[longest].shift();
|
|
188
|
+
}
|
|
189
|
+
json = build();
|
|
190
|
+
}
|
|
191
|
+
return json.length > exports.MAX_ADVANTAGE_CHARS ? null : json;
|
|
192
|
+
}
|
|
193
|
+
/** The value of an `advantage:` line, as an Advantage, or null (bad JSON, wrong shape, over the cap). */
|
|
194
|
+
function parseAdvantage(value) {
|
|
195
|
+
if (!value || value.length > exports.MAX_ADVANTAGE_CHARS)
|
|
196
|
+
return null;
|
|
197
|
+
let raw;
|
|
198
|
+
try {
|
|
199
|
+
raw = JSON.parse(value);
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
const advantage = normaliseAdvantage(raw);
|
|
205
|
+
if (advantage)
|
|
206
|
+
advantage.edges = advantage.edges.slice(0, exports.MAX_ADVANTAGE_EDGES);
|
|
207
|
+
return advantage;
|
|
208
|
+
}
|
|
209
|
+
const ADV_TAP_RE = /^\[\[SALT-ADV-(NEVER|KEEP) kind=(arm key|lens id)=([A-Za-z0-9_-]{1,64})\]\]$/;
|
|
210
|
+
/** The wire message for a tap. Throws on a combination the protocol does not have (keep goes with a lens only) or a bad ref. */
|
|
211
|
+
function formatAdvantageTap(tap) {
|
|
212
|
+
if (!ADV_ID_RE.test(tap.ref || ""))
|
|
213
|
+
throw new Error("A tap needs a key or id of letters, digits, _ or -.");
|
|
214
|
+
if (tap.action !== "never" && tap.action !== "keep")
|
|
215
|
+
throw new Error("action must be never or keep.");
|
|
216
|
+
if (tap.kind !== "arm" && tap.kind !== "lens")
|
|
217
|
+
throw new Error("kind must be arm or lens.");
|
|
218
|
+
if (tap.action === "keep" && tap.kind !== "lens")
|
|
219
|
+
throw new Error("Keep going names a lens.");
|
|
220
|
+
return `[[SALT-ADV-${tap.action.toUpperCase()} kind=${tap.kind} ${tap.kind === "arm" ? "key" : "id"}=${tap.ref}]]`;
|
|
221
|
+
}
|
|
222
|
+
/** The tap in a whole message, or null when the text is not exactly one. */
|
|
223
|
+
function parseAdvantageTap(plaintext) {
|
|
224
|
+
const m = ADV_TAP_RE.exec((plaintext || "").trim());
|
|
225
|
+
if (!m)
|
|
226
|
+
return null;
|
|
227
|
+
const tap = { action: m[1].toLowerCase(), kind: m[2].split(" ")[0], ref: m[3] };
|
|
228
|
+
return tap.action === "keep" && tap.kind !== "lens" ? null : tap;
|
|
229
|
+
}
|
|
230
|
+
const ADVANTAGE_LINE_RE = /^advantage:[ \t]*(.*)$/;
|
|
97
231
|
/** The plaintext of one report. Throws on a malformed id or status. */
|
|
98
232
|
function formatWorkReport(report) {
|
|
99
233
|
if (!ID_RE.test(report.id || ""))
|
|
@@ -116,7 +250,8 @@ function formatWorkReport(report) {
|
|
|
116
250
|
if (!title)
|
|
117
251
|
throw new Error("A work report needs a title.");
|
|
118
252
|
const detail = (report.detail || "").trim().slice(0, exports.MAX_WORK_DETAIL);
|
|
119
|
-
|
|
253
|
+
const advantage = formatAdvantage(report.advantage);
|
|
254
|
+
return `[[SALT-WORK ${attrs.join(" ")}]]\n${title}${advantage ? `\nadvantage: ${advantage}` : ""}${detail ? `\n${detail}` : ""}`;
|
|
120
255
|
}
|
|
121
256
|
/** The report in a plaintext, or null when it is not one. */
|
|
122
257
|
function parseWorkReport(plaintext) {
|
|
@@ -144,7 +279,18 @@ function parseWorkReport(plaintext) {
|
|
|
144
279
|
report.repeat = attrs.repeat;
|
|
145
280
|
if (attrs.transfer && ID_RE.test(attrs.transfer))
|
|
146
281
|
report.transfer = attrs.transfer;
|
|
147
|
-
const
|
|
282
|
+
const kept = [];
|
|
283
|
+
rest.forEach((line) => {
|
|
284
|
+
const m = ADVANTAGE_LINE_RE.exec(line.trim());
|
|
285
|
+
if (!m) {
|
|
286
|
+
kept.push(line);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const advantage = parseAdvantage(m[1].trim());
|
|
290
|
+
if (advantage)
|
|
291
|
+
report.advantage = advantage;
|
|
292
|
+
});
|
|
293
|
+
const detail = kept.join("\n").trim();
|
|
148
294
|
if (detail)
|
|
149
295
|
report.detail = detail;
|
|
150
296
|
return report;
|
package/dist/work.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work.js","sourceRoot":"","sources":["../src/work.ts"],"names":[],"mapp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AE,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC/E,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,UAAU,MAAM,CAAC,MAAqB,EAAE,MAAkB,EAAE,UAAsB;QACrF,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;YAC/C,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC3C,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAC3D,MAAM,aAAa,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;YAC1E,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE;gBAC7F,KAAK,EAAE,UAAU,CAAC,MAAM,KAAK,SAAS;aACvC,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;AACjD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "salt-agent-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Plumbing for building Salt (saltapp.ai) agents: webhook receiving/routing, PGP encrypt/decrypt, a typed REST client, and card builders. Bring your own agent logic -- this handles everything Salt-protocol-specific.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "0x0000F8 <0000F8@proton.me>",
|
package/dist/lattice.d.ts
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { type SaltId } from "./ids.js";
|
|
2
|
-
/**
|
|
3
|
-
* How long request_personal_data waits for a release before reporting
|
|
4
|
-
* "pending" instead of "released". This bounds how long ONE chat turn keeps
|
|
5
|
-
* whoever's waiting on the agent hanging -- it is NOT protecting against
|
|
6
|
-
* Salt's own webhook delivery timeout: webhook.ts acknowledges salt-api's
|
|
7
|
-
* POST before ever calling dispatch(), so nothing here is on the clock for
|
|
8
|
-
* that deadline. A "pending" result past this is the normal case, not an
|
|
9
|
-
* error -- see actions.ts's request_personal_data and onRelease/
|
|
10
|
-
* onLatticeRelease for what happens when the answer arrives afterward.
|
|
11
|
-
*/
|
|
12
|
-
export declare const LATTICE_REQUEST_TIMEOUT_MS = 15000;
|
|
13
|
-
export declare const REQUEST_MARKER_RE: RegExp;
|
|
14
|
-
export declare const RELEASE_MARKER_RE: RegExp;
|
|
15
|
-
export declare const PROPOSE_MARKER_RE: RegExp;
|
|
16
|
-
export interface LatticeFact {
|
|
17
|
-
path: string;
|
|
18
|
-
type: string;
|
|
19
|
-
field: string;
|
|
20
|
-
/** A JSON primitive (string/number/boolean/null) -- normalizeFact rejects an object or array here. */
|
|
21
|
-
value: string | number | boolean | null;
|
|
22
|
-
/** "you" or "agent" -- WHICH agent wrote it is deliberately never disclosed (PROTOCOL.md). */
|
|
23
|
-
author: "you" | "agent";
|
|
24
|
-
updated: number;
|
|
25
|
-
}
|
|
26
|
-
/** The JSON body of a [[SALT-LATTICE-RELEASE]] message, either shape (a
|
|
27
|
-
* reply to one request, or a standing push -- see the module comment). */
|
|
28
|
-
export interface ReleaseBody {
|
|
29
|
-
facts: LatticeFact[];
|
|
30
|
-
/** Present on an ordinary reply to a request; absent on a standing push. */
|
|
31
|
-
request_id?: string;
|
|
32
|
-
/** Present only on a standing push. */
|
|
33
|
-
grant_id?: string;
|
|
34
|
-
/** Present only on a standing push: facts changed since this sequence number. */
|
|
35
|
-
since_seq?: number;
|
|
36
|
-
}
|
|
37
|
-
export interface LatticeRelease {
|
|
38
|
-
/** The release message's own id (for the disclosure log) -- NOT the request id it answers. */
|
|
39
|
-
id: string;
|
|
40
|
-
/** Set to a grant id for a standing push; absent for an ordinary reply. */
|
|
41
|
-
standing?: string;
|
|
42
|
-
/** The chat and sender this release actually arrived from (Salt-authenticated, not attacker-controlled). */
|
|
43
|
-
chatId: SaltId;
|
|
44
|
-
senderId: SaltId;
|
|
45
|
-
body: ReleaseBody;
|
|
46
|
-
}
|
|
47
|
-
export interface BuildRequestInput {
|
|
48
|
-
/** One plain sentence, shown to the person before they decide -- PROTOCOL.md's Request. */
|
|
49
|
-
purpose: string;
|
|
50
|
-
/** Selectors, e.g. "preferences.food.cuisine.*" -- only what the agent's grant names is ever released; asking for more is not an error. */
|
|
51
|
-
asks: string[];
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Mints a fresh request id and its wire text. Send `text` as an ordinary
|
|
55
|
-
* encrypted chat message into the current chat (or the agent's private
|
|
56
|
-
* lane); the phone answers it -- in a group, inside a sidechain it opens
|
|
57
|
-
* with this agent, never in the room (PROTOCOL.md R6).
|
|
58
|
-
*/
|
|
59
|
-
export declare function buildRequest(input: BuildRequestInput): {
|
|
60
|
-
id: string;
|
|
61
|
-
text: string;
|
|
62
|
-
};
|
|
63
|
-
export interface LatticeProposalInput {
|
|
64
|
-
/** A closed-schema type name (PROTOCOL.md) -- an unknown type or field is silently dropped on the phone, never an error here or there. */
|
|
65
|
-
type: string;
|
|
66
|
-
parent_name?: string;
|
|
67
|
-
fields: Record<string, unknown>;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Builds a [[SALT-LATTICE-PROPOSE]] message suggesting new facts. Always
|
|
71
|
-
* lands `pending` on the phone unless the agent's grant trusts its writes
|
|
72
|
-
* to that compartment (PROTOCOL.md R3) -- there is no reply to wait for,
|
|
73
|
-
* so unlike buildRequest this returns only the wire text.
|
|
74
|
-
*/
|
|
75
|
-
export declare function buildProposal(proposals: LatticeProposalInput[]): string;
|
|
76
|
-
/** A single release's fact count is capped here -- not rejected outright,
|
|
77
|
-
* just bounded, since an over-long but otherwise well-formed release isn't
|
|
78
|
-
* a protocol violation the way a malformed entry is (see normalizeFact). */
|
|
79
|
-
export declare const MAX_FACTS_PER_RELEASE = 200;
|
|
80
|
-
/** A fact's string value is capped to this many characters, after marker
|
|
81
|
-
* stripping (see sanitizeFactValue) -- bounds how much untrusted text from
|
|
82
|
-
* the other end of the wire can reach a model in one fact. */
|
|
83
|
-
export declare const MAX_FACT_VALUE_LENGTH = 2000;
|
|
84
|
-
/**
|
|
85
|
-
* Splits an incoming plaintext into its release marker's id, optional
|
|
86
|
-
* standing grant id, and parsed JSON body -- or null when `plaintext` isn't
|
|
87
|
-
* a (well-formed, in-protocol) lattice release at all. Returns null for an
|
|
88
|
-
* unparseable or malformed body, and also for a body that is neither an
|
|
89
|
-
* ordinary reply (`request_id`) nor a standing push (`standing=` on the
|
|
90
|
-
* marker line AND `grant_id` in the body) -- PROTOCOL.md says a release is
|
|
91
|
-
* "always a reply to a request id" unless it's a standing push, so anything
|
|
92
|
-
* else is out-of-protocol. Deliberate in all these cases: it's safer to let
|
|
93
|
-
* a corrupt or nonsensical release fall through as ordinary (harmless)
|
|
94
|
-
* message text than to silently act on it. A standing push's marker-line
|
|
95
|
-
* `standing=<grant id>` and its body's `grant_id` must name the SAME grant
|
|
96
|
-
* -- PROTOCOL.md's own example shows them matching, and disagreeing values
|
|
97
|
-
* are simply invalid rather than a case to guess between (whoever
|
|
98
|
-
* eventually checks `grant_id` against this agent's actual grants -- see
|
|
99
|
-
* webhook.ts's onLatticeRelease verification -- must be checking the one
|
|
100
|
-
* value the marker itself also claims).
|
|
101
|
-
*/
|
|
102
|
-
export declare function parseRelease(plaintext: string): {
|
|
103
|
-
id: string;
|
|
104
|
-
standing?: string;
|
|
105
|
-
body: ReleaseBody;
|
|
106
|
-
} | null;
|
|
107
|
-
export declare function hasPending(id: string): boolean;
|
|
108
|
-
export interface RegisterBinding {
|
|
109
|
-
/** The chat the request was actually sent into. */
|
|
110
|
-
chatId: SaltId;
|
|
111
|
-
/** The person the request was actually addressed to -- see actions.ts's request_personal_data, which resolves this to one specific chat member even in a group. */
|
|
112
|
-
senderId: SaltId;
|
|
113
|
-
timeoutMs: number;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Registers a wait for the release answering request `id`, bound to the
|
|
117
|
-
* exact chat and person it was sent to. Only a release arriving from THAT
|
|
118
|
-
* chat and THAT sender can resolve it (see classifyRelease) -- a request's
|
|
119
|
-
* plaintext id is visible to every current member of the chat it's sent
|
|
120
|
-
* into (see actions.ts), so the id alone must never be sufficient to claim
|
|
121
|
-
* a release.
|
|
122
|
-
*
|
|
123
|
-
* Resolves with that release's parsed body, or rejects once `timeoutMs`
|
|
124
|
-
* elapses -- rejecting is an expected outcome, not a protocol error:
|
|
125
|
-
* PROTOCOL.md says the phone only answers when the app is next open, which
|
|
126
|
-
* routinely outlasts one webhook round-trip. Throws synchronously (before
|
|
127
|
-
* any caller does anything else) if `id` already has a pending wait.
|
|
128
|
-
*/
|
|
129
|
-
export declare function register(id: string, binding: RegisterBinding): Promise<ReleaseBody>;
|
|
130
|
-
/**
|
|
131
|
-
* Clears a pending wait without settling its promise -- used when sending
|
|
132
|
-
* the request message itself fails right after register() ran, so the
|
|
133
|
-
* registry entry doesn't leak (the caller throws its own error instead).
|
|
134
|
-
*/
|
|
135
|
-
export declare function cancel(id: string): void;
|
|
136
|
-
type ReleaseHandler = (release: LatticeRelease) => void | Promise<void>;
|
|
137
|
-
/**
|
|
138
|
-
* Subscribes to releases that arrive with nothing waiting on them: a late
|
|
139
|
-
* reply (the request already timed out) or a standing push (there was
|
|
140
|
-
* never a request to begin with). Returns an unsubscribe function.
|
|
141
|
-
*
|
|
142
|
-
* UNVERIFIED: lattice.ts has no REST client and no concept of a grant, so a
|
|
143
|
-
* handler here fires for ANY sender in ANY chat with no check that they
|
|
144
|
-
* actually hold a live grant to this agent. webhook.ts's `onLatticeRelease`
|
|
145
|
-
* option is the verified, recommended path for exactly this case (it
|
|
146
|
-
* fetches this agent's live grants and checks the sender is human and,
|
|
147
|
-
* for a standing push, that `grant_id` names one, before ever calling your
|
|
148
|
-
* handler) -- reach for this lower-level hook only if you're bypassing
|
|
149
|
-
* webhook.ts entirely, and do your own equivalent check.
|
|
150
|
-
*
|
|
151
|
-
* A handler may be async. Either a synchronous throw or a rejected promise
|
|
152
|
-
* is swallowed -- like every other fire-and-forget hook in this SDK, a bug
|
|
153
|
-
* in a consumer's handler must not take down webhook processing (an
|
|
154
|
-
* unhandled rejection crashes the process on modern Node defaults).
|
|
155
|
-
*/
|
|
156
|
-
export declare function onRelease(handler: ReleaseHandler): () => void;
|
|
157
|
-
export type ReleaseOutcome = {
|
|
158
|
-
kind: "not-a-release";
|
|
159
|
-
} | {
|
|
160
|
-
kind: "matched";
|
|
161
|
-
} | {
|
|
162
|
-
kind: "refused";
|
|
163
|
-
} | {
|
|
164
|
-
kind: "unmatched";
|
|
165
|
-
release: LatticeRelease;
|
|
166
|
-
};
|
|
167
|
-
/**
|
|
168
|
-
* Call right after decrypting an inbound message, before deciding whether
|
|
169
|
-
* to run a fresh reply cycle -- the same spot webhook.ts calls
|
|
170
|
-
* delegations.resolveIfPending (and what webhook.ts itself calls, to also
|
|
171
|
-
* learn about an "unmatched" release for its onLatticeRelease option).
|
|
172
|
-
*
|
|
173
|
-
* - "not-a-release": `plaintext` isn't lattice wire protocol at all --
|
|
174
|
-
* including this identity's own outgoing requests/proposals, which never
|
|
175
|
-
* match RELEASE_MARKER_RE, and any genuinely unrelated message.
|
|
176
|
-
* - "matched": `chatId`/`senderId` agree with a live register() wait for
|
|
177
|
-
* this release's `request_id` -- that wait's promise is resolved directly;
|
|
178
|
-
* there is nothing further for a caller to do.
|
|
179
|
-
* - "refused": this release names a request id a wait IS pending for, but
|
|
180
|
-
* `chatId`/`senderId` don't match what register() bound it to -- e.g. a
|
|
181
|
-
* bystander who merely saw the plaintext request id (see
|
|
182
|
-
* RegisterBinding's doc comment) replaying it as a forged release. The
|
|
183
|
-
* live wait is untouched (still running, still resolvable by the real
|
|
184
|
-
* answer); this message is left for the caller to process as ordinary,
|
|
185
|
-
* harmless text -- it must NOT be treated as Lattice traffic.
|
|
186
|
-
* - "unmatched": a genuine late reply or standing push -- fired to
|
|
187
|
-
* onRelease() before this returns.
|
|
188
|
-
*/
|
|
189
|
-
export declare function classifyRelease(chatId: SaltId, senderId: SaltId, plaintext: string): ReleaseOutcome;
|
|
190
|
-
/**
|
|
191
|
-
* Boolean convenience wrapper over classifyRelease, mirroring
|
|
192
|
-
* delegations.resolveIfPending(chatId, senderId, plaintext)'s shape for a
|
|
193
|
-
* simple caller that doesn't need an "unmatched" release's details (e.g. a
|
|
194
|
-
* custom integration built directly on lattice.ts, without webhook.ts).
|
|
195
|
-
* True for "matched" and "unmatched" (don't treat `plaintext` as a fresh
|
|
196
|
-
* prompt); false for "not-a-release" AND "refused" (a forged/misdirected
|
|
197
|
-
* release is left to fall through exactly like ordinary text, same as
|
|
198
|
-
* "not-a-release" -- see classifyRelease's doc comment).
|
|
199
|
-
*
|
|
200
|
-
* webhook.ts itself calls classifyRelease directly instead of this, since
|
|
201
|
-
* it also needs an "unmatched" release's details (chat/sender/body) to
|
|
202
|
-
* offer to its own onLatticeRelease option.
|
|
203
|
-
*/
|
|
204
|
-
export declare function resolveIfPending(chatId: SaltId, senderId: SaltId, plaintext: string): boolean;
|
|
205
|
-
export {};
|
|
206
|
-
//# sourceMappingURL=lattice.d.ts.map
|
package/dist/lattice.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lattice.d.ts","sourceRoot":"","sources":["../src/lattice.ts"],"names":[],"mappings":"AAgDA,OAAO,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AM,cAAc,GACtB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,cAAc,CAAA;CAAE,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,cAAc,CAqBnG;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAG7F"}
|
package/dist/lattice.js
DELETED
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Lets a hosted identity ask the person it's chatting with for personal
|
|
3
|
-
// facts from Lattice -- their private, on-device knowledge graph -- and get
|
|
4
|
-
// an answer back over a real Salt message, the same way delegations.ts gets
|
|
5
|
-
// a reply from another agent. See ../../salt-lattice/docs/PROTOCOL.md for
|
|
6
|
-
// the wire contract this implements; nothing here decides WHETHER a fact is
|
|
7
|
-
// released (that is entirely the phone's own grant evaluation, offline and
|
|
8
|
-
// invisible to the server) -- this module only builds the outgoing
|
|
9
|
-
// markers, parses the incoming one, and matches a release back to the
|
|
10
|
-
// request it answers.
|
|
11
|
-
//
|
|
12
|
-
// Three message shapes ride inside encrypted plaintext, one line then a
|
|
13
|
-
// JSON body, exactly like [[SALT-DELEGATION]]:
|
|
14
|
-
// [[SALT-LATTICE-REQUEST id=<ulid>]] agent -> person, asking
|
|
15
|
-
// [[SALT-LATTICE-RELEASE id=<ulid> [standing=<grant id>]]] person's phone -> agent, answering
|
|
16
|
-
// [[SALT-LATTICE-PROPOSE id=<ulid>]] agent -> person's phone, suggesting a fact
|
|
17
|
-
//
|
|
18
|
-
// A release is matched back to its request by `request_id` IN ITS JSON BODY
|
|
19
|
-
// -- never by the release's own `id`, which only identifies that one
|
|
20
|
-
// disclosure for the log -- AND by the chat and sender it was actually
|
|
21
|
-
// registered against (see register()/classifyRelease()). A request's
|
|
22
|
-
// plaintext id is visible to every current member of whatever chat it was
|
|
23
|
-
// sent into (see actions.ts's request_personal_data), so a request id alone
|
|
24
|
-
// is not a secret; the chat+sender binding is what stops a bystander who
|
|
25
|
-
// merely SAW that id from forging a release and having it accepted as the
|
|
26
|
-
// real recipient's answer.
|
|
27
|
-
//
|
|
28
|
-
// Three outcomes a release-shaped message can produce, besides "not a
|
|
29
|
-
// release at all" (see ReleaseOutcome/classifyRelease):
|
|
30
|
-
// - matched: chat and sender agree with what register() bound to this
|
|
31
|
-
// request id. Resolves that wait's promise directly; nothing else to do.
|
|
32
|
-
// - refused: names a request id this process really is waiting on, but
|
|
33
|
-
// the chat or the sender don't match the binding -- a forged or
|
|
34
|
-
// misdirected release. The live wait keeps waiting; this message is
|
|
35
|
-
// left for the caller to fall through as ordinary (harmless) text.
|
|
36
|
-
// - unmatched (late or standing): a release-shaped message with no live
|
|
37
|
-
// wait to resolve -- either a genuinely late reply (the request already
|
|
38
|
-
// timed out; the phone only answers when the app is next open, which
|
|
39
|
-
// routinely outlasts one webhook round-trip) or an opted-in standing
|
|
40
|
-
// push, which never had a request to begin with. Unlike "matched",
|
|
41
|
-
// THIS module never authenticates who sent it -- lattice.ts has no
|
|
42
|
-
// REST client and no concept of a grant. Reaches onRelease() (raw,
|
|
43
|
-
// unverified) and, via webhook.ts's onLatticeRelease option, a
|
|
44
|
-
// consumer's own follow-up logic -- webhook.ts is what verifies the
|
|
45
|
-
// sender is human and holds a live grant (and, for standing, that it's
|
|
46
|
-
// the grant named) before that option ever fires, dropping and logging
|
|
47
|
-
// otherwise. Reaching onRelease/onLatticeRelease at all is not itself a
|
|
48
|
-
// trust signal.
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.MAX_FACT_VALUE_LENGTH = exports.MAX_FACTS_PER_RELEASE = exports.PROPOSE_MARKER_RE = exports.RELEASE_MARKER_RE = exports.REQUEST_MARKER_RE = exports.LATTICE_REQUEST_TIMEOUT_MS = void 0;
|
|
51
|
-
exports.buildRequest = buildRequest;
|
|
52
|
-
exports.buildProposal = buildProposal;
|
|
53
|
-
exports.parseRelease = parseRelease;
|
|
54
|
-
exports.hasPending = hasPending;
|
|
55
|
-
exports.register = register;
|
|
56
|
-
exports.cancel = cancel;
|
|
57
|
-
exports.onRelease = onRelease;
|
|
58
|
-
exports.classifyRelease = classifyRelease;
|
|
59
|
-
exports.resolveIfPending = resolveIfPending;
|
|
60
|
-
const ids_js_1 = require("./ids.js");
|
|
61
|
-
/**
|
|
62
|
-
* How long request_personal_data waits for a release before reporting
|
|
63
|
-
* "pending" instead of "released". This bounds how long ONE chat turn keeps
|
|
64
|
-
* whoever's waiting on the agent hanging -- it is NOT protecting against
|
|
65
|
-
* Salt's own webhook delivery timeout: webhook.ts acknowledges salt-api's
|
|
66
|
-
* POST before ever calling dispatch(), so nothing here is on the clock for
|
|
67
|
-
* that deadline. A "pending" result past this is the normal case, not an
|
|
68
|
-
* error -- see actions.ts's request_personal_data and onRelease/
|
|
69
|
-
* onLatticeRelease for what happens when the answer arrives afterward.
|
|
70
|
-
*/
|
|
71
|
-
exports.LATTICE_REQUEST_TIMEOUT_MS = 15_000;
|
|
72
|
-
// Embed ULID_RE's character class without its ^...$ anchors, so the id
|
|
73
|
-
// group inside each marker regex stays in lock-step with what newUlid()
|
|
74
|
-
// actually produces.
|
|
75
|
-
const ULID_SRC = ids_js_1.ULID_RE.source.slice(1, -1);
|
|
76
|
-
exports.REQUEST_MARKER_RE = new RegExp(`^\\[\\[SALT-LATTICE-REQUEST id=(${ULID_SRC})\\]\\]\\n`, "i");
|
|
77
|
-
exports.RELEASE_MARKER_RE = new RegExp(`^\\[\\[SALT-LATTICE-RELEASE id=(${ULID_SRC})(?: standing=(\\S+))?\\]\\]\\n`, "i");
|
|
78
|
-
exports.PROPOSE_MARKER_RE = new RegExp(`^\\[\\[SALT-LATTICE-PROPOSE id=(${ULID_SRC})\\]\\]\\n`, "i");
|
|
79
|
-
/**
|
|
80
|
-
* Mints a fresh request id and its wire text. Send `text` as an ordinary
|
|
81
|
-
* encrypted chat message into the current chat (or the agent's private
|
|
82
|
-
* lane); the phone answers it -- in a group, inside a sidechain it opens
|
|
83
|
-
* with this agent, never in the room (PROTOCOL.md R6).
|
|
84
|
-
*/
|
|
85
|
-
function buildRequest(input) {
|
|
86
|
-
const id = (0, ids_js_1.newUlid)();
|
|
87
|
-
const body = JSON.stringify({ purpose: input.purpose, asks: input.asks });
|
|
88
|
-
return { id, text: `[[SALT-LATTICE-REQUEST id=${id}]]\n${body}` };
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Builds a [[SALT-LATTICE-PROPOSE]] message suggesting new facts. Always
|
|
92
|
-
* lands `pending` on the phone unless the agent's grant trusts its writes
|
|
93
|
-
* to that compartment (PROTOCOL.md R3) -- there is no reply to wait for,
|
|
94
|
-
* so unlike buildRequest this returns only the wire text.
|
|
95
|
-
*/
|
|
96
|
-
function buildProposal(proposals) {
|
|
97
|
-
const id = (0, ids_js_1.newUlid)();
|
|
98
|
-
const body = JSON.stringify({ proposals });
|
|
99
|
-
return `[[SALT-LATTICE-PROPOSE id=${id}]]\n${body}`;
|
|
100
|
-
}
|
|
101
|
-
const FACT_AUTHORS = new Set(["you", "agent"]);
|
|
102
|
-
// PROTOCOL.md's exact fact shape. Validated field-by-field, not just "facts
|
|
103
|
-
// is an array": a forged or buggy release could otherwise hand a model
|
|
104
|
-
// whatever shape it likes under `facts[]`, and (pre-binding-fix) that used
|
|
105
|
-
// to reach a calling tool's "released" result unfiltered. One malformed
|
|
106
|
-
// entry rejects the WHOLE body (returns null), the same fail-closed
|
|
107
|
-
// convention as an unparseable body -- a partially-trusted release is worse
|
|
108
|
-
// than a dropped one.
|
|
109
|
-
function isPrimitive(value) {
|
|
110
|
-
return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
111
|
-
}
|
|
112
|
-
/** A single release's fact count is capped here -- not rejected outright,
|
|
113
|
-
* just bounded, since an over-long but otherwise well-formed release isn't
|
|
114
|
-
* a protocol violation the way a malformed entry is (see normalizeFact). */
|
|
115
|
-
exports.MAX_FACTS_PER_RELEASE = 200;
|
|
116
|
-
/** A fact's string value is capped to this many characters, after marker
|
|
117
|
-
* stripping (see sanitizeFactValue) -- bounds how much untrusted text from
|
|
118
|
-
* the other end of the wire can reach a model in one fact. */
|
|
119
|
-
exports.MAX_FACT_VALUE_LENGTH = 2_000;
|
|
120
|
-
// Every wire marker this SDK recognizes starts with this exact two-bracket
|
|
121
|
-
// prefix, anchored at the very start of a plaintext (see the *_MARKER_RE
|
|
122
|
-
// definitions above -- none of them carry the `m` flag). A fact's value is
|
|
123
|
-
// untrusted content from the other end of the wire; without this, a value
|
|
124
|
-
// containing literal "[[SALT-...]]" text could later start some OTHER
|
|
125
|
-
// outbound message built by echoing the fact back (e.g. "the person's
|
|
126
|
-
// favorite cuisine is <value>") and be mistaken for a genuine protocol
|
|
127
|
-
// marker by whatever receives it. Breaks the bracket pair rather than
|
|
128
|
-
// deleting the text outright, so the value stays legible.
|
|
129
|
-
const MARKER_TEXT_RE = /\[\[SALT-/g;
|
|
130
|
-
function sanitizeFactValue(value) {
|
|
131
|
-
if (typeof value !== "string")
|
|
132
|
-
return value;
|
|
133
|
-
const stripped = value.replace(MARKER_TEXT_RE, "[SALT-");
|
|
134
|
-
return stripped.length > exports.MAX_FACT_VALUE_LENGTH ? stripped.slice(0, exports.MAX_FACT_VALUE_LENGTH) : stripped;
|
|
135
|
-
}
|
|
136
|
-
function normalizeFact(raw) {
|
|
137
|
-
if (!raw || typeof raw !== "object")
|
|
138
|
-
return null;
|
|
139
|
-
const f = raw;
|
|
140
|
-
if (typeof f.path !== "string" || typeof f.type !== "string" || typeof f.field !== "string")
|
|
141
|
-
return null;
|
|
142
|
-
if (typeof f.author !== "string" || !FACT_AUTHORS.has(f.author))
|
|
143
|
-
return null;
|
|
144
|
-
if (typeof f.updated !== "number")
|
|
145
|
-
return null;
|
|
146
|
-
if (!isPrimitive(f.value))
|
|
147
|
-
return null;
|
|
148
|
-
return { path: f.path, type: f.type, field: f.field, value: sanitizeFactValue(f.value), author: f.author, updated: f.updated };
|
|
149
|
-
}
|
|
150
|
-
function normalizeReleaseBody(parsed) {
|
|
151
|
-
if (!parsed || typeof parsed !== "object")
|
|
152
|
-
return null;
|
|
153
|
-
const obj = parsed;
|
|
154
|
-
if (!Array.isArray(obj.facts))
|
|
155
|
-
return null;
|
|
156
|
-
const facts = [];
|
|
157
|
-
for (const raw of obj.facts) {
|
|
158
|
-
const fact = normalizeFact(raw);
|
|
159
|
-
if (!fact)
|
|
160
|
-
return null;
|
|
161
|
-
facts.push(fact);
|
|
162
|
-
}
|
|
163
|
-
const body = { facts: facts.slice(0, exports.MAX_FACTS_PER_RELEASE) };
|
|
164
|
-
if (typeof obj.request_id === "string")
|
|
165
|
-
body.request_id = obj.request_id;
|
|
166
|
-
if (typeof obj.grant_id === "string")
|
|
167
|
-
body.grant_id = obj.grant_id;
|
|
168
|
-
if (typeof obj.since_seq === "number")
|
|
169
|
-
body.since_seq = obj.since_seq;
|
|
170
|
-
return body;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Splits an incoming plaintext into its release marker's id, optional
|
|
174
|
-
* standing grant id, and parsed JSON body -- or null when `plaintext` isn't
|
|
175
|
-
* a (well-formed, in-protocol) lattice release at all. Returns null for an
|
|
176
|
-
* unparseable or malformed body, and also for a body that is neither an
|
|
177
|
-
* ordinary reply (`request_id`) nor a standing push (`standing=` on the
|
|
178
|
-
* marker line AND `grant_id` in the body) -- PROTOCOL.md says a release is
|
|
179
|
-
* "always a reply to a request id" unless it's a standing push, so anything
|
|
180
|
-
* else is out-of-protocol. Deliberate in all these cases: it's safer to let
|
|
181
|
-
* a corrupt or nonsensical release fall through as ordinary (harmless)
|
|
182
|
-
* message text than to silently act on it. A standing push's marker-line
|
|
183
|
-
* `standing=<grant id>` and its body's `grant_id` must name the SAME grant
|
|
184
|
-
* -- PROTOCOL.md's own example shows them matching, and disagreeing values
|
|
185
|
-
* are simply invalid rather than a case to guess between (whoever
|
|
186
|
-
* eventually checks `grant_id` against this agent's actual grants -- see
|
|
187
|
-
* webhook.ts's onLatticeRelease verification -- must be checking the one
|
|
188
|
-
* value the marker itself also claims).
|
|
189
|
-
*/
|
|
190
|
-
function parseRelease(plaintext) {
|
|
191
|
-
const match = exports.RELEASE_MARKER_RE.exec(plaintext);
|
|
192
|
-
if (!match)
|
|
193
|
-
return null;
|
|
194
|
-
const [full, id, standing] = match;
|
|
195
|
-
let parsed;
|
|
196
|
-
try {
|
|
197
|
-
parsed = JSON.parse(plaintext.slice(full.length));
|
|
198
|
-
}
|
|
199
|
-
catch {
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
const body = normalizeReleaseBody(parsed);
|
|
203
|
-
if (!body)
|
|
204
|
-
return null;
|
|
205
|
-
if (standing) {
|
|
206
|
-
if (!body.grant_id || !(0, ids_js_1.sameId)(body.grant_id, standing))
|
|
207
|
-
return null;
|
|
208
|
-
return { id, standing, body };
|
|
209
|
-
}
|
|
210
|
-
if (!body.request_id)
|
|
211
|
-
return null;
|
|
212
|
-
return { id, body };
|
|
213
|
-
}
|
|
214
|
-
// Keyed by REQUEST id (the id a request_personal_data call minted and put
|
|
215
|
-
// in the marker it sent) -- NOT by chat, unlike delegations.ts's registry,
|
|
216
|
-
// which is chat-scoped because a chat can only be mid-delegation with one
|
|
217
|
-
// target at a time. A person can plausibly be asked several independent
|
|
218
|
-
// things in parallel (different tool calls, possibly from different hosted
|
|
219
|
-
// identities sharing this process), so the request id is what safely tells
|
|
220
|
-
// two pending waits apart.
|
|
221
|
-
//
|
|
222
|
-
// Lowercased on every store/lookup -- like delegations.ts's own `mapKey` and
|
|
223
|
-
// ids.ts's `sameId`, whose comments say why: an id can cross this SDK's
|
|
224
|
-
// boundary (webhook body, REST response, a phone's own JSON) without a
|
|
225
|
-
// casing guarantee, and RELEASE_MARKER_RE already matches either case
|
|
226
|
-
// (ULID_RE's `/i` flag), so the map lookup that follows it must too.
|
|
227
|
-
const pending = new Map();
|
|
228
|
-
const mapKey = (id) => id.toLowerCase();
|
|
229
|
-
function hasPending(id) {
|
|
230
|
-
return pending.has(mapKey(id));
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Registers a wait for the release answering request `id`, bound to the
|
|
234
|
-
* exact chat and person it was sent to. Only a release arriving from THAT
|
|
235
|
-
* chat and THAT sender can resolve it (see classifyRelease) -- a request's
|
|
236
|
-
* plaintext id is visible to every current member of the chat it's sent
|
|
237
|
-
* into (see actions.ts), so the id alone must never be sufficient to claim
|
|
238
|
-
* a release.
|
|
239
|
-
*
|
|
240
|
-
* Resolves with that release's parsed body, or rejects once `timeoutMs`
|
|
241
|
-
* elapses -- rejecting is an expected outcome, not a protocol error:
|
|
242
|
-
* PROTOCOL.md says the phone only answers when the app is next open, which
|
|
243
|
-
* routinely outlasts one webhook round-trip. Throws synchronously (before
|
|
244
|
-
* any caller does anything else) if `id` already has a pending wait.
|
|
245
|
-
*/
|
|
246
|
-
function register(id, binding) {
|
|
247
|
-
const key = mapKey(id);
|
|
248
|
-
if (pending.has(key)) {
|
|
249
|
-
throw new Error("Already waiting on a release for this request.");
|
|
250
|
-
}
|
|
251
|
-
return new Promise((resolve, reject) => {
|
|
252
|
-
const timer = setTimeout(() => {
|
|
253
|
-
pending.delete(key);
|
|
254
|
-
reject(new Error(`No release within ${Math.round(binding.timeoutMs / 1000)}s.`));
|
|
255
|
-
}, binding.timeoutMs);
|
|
256
|
-
pending.set(key, { chatId: binding.chatId, senderId: binding.senderId, resolve, reject, timer });
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Clears a pending wait without settling its promise -- used when sending
|
|
261
|
-
* the request message itself fails right after register() ran, so the
|
|
262
|
-
* registry entry doesn't leak (the caller throws its own error instead).
|
|
263
|
-
*/
|
|
264
|
-
function cancel(id) {
|
|
265
|
-
const key = mapKey(id);
|
|
266
|
-
const entry = pending.get(key);
|
|
267
|
-
if (!entry)
|
|
268
|
-
return;
|
|
269
|
-
clearTimeout(entry.timer);
|
|
270
|
-
pending.delete(key);
|
|
271
|
-
}
|
|
272
|
-
const releaseHandlers = new Set();
|
|
273
|
-
/**
|
|
274
|
-
* Subscribes to releases that arrive with nothing waiting on them: a late
|
|
275
|
-
* reply (the request already timed out) or a standing push (there was
|
|
276
|
-
* never a request to begin with). Returns an unsubscribe function.
|
|
277
|
-
*
|
|
278
|
-
* UNVERIFIED: lattice.ts has no REST client and no concept of a grant, so a
|
|
279
|
-
* handler here fires for ANY sender in ANY chat with no check that they
|
|
280
|
-
* actually hold a live grant to this agent. webhook.ts's `onLatticeRelease`
|
|
281
|
-
* option is the verified, recommended path for exactly this case (it
|
|
282
|
-
* fetches this agent's live grants and checks the sender is human and,
|
|
283
|
-
* for a standing push, that `grant_id` names one, before ever calling your
|
|
284
|
-
* handler) -- reach for this lower-level hook only if you're bypassing
|
|
285
|
-
* webhook.ts entirely, and do your own equivalent check.
|
|
286
|
-
*
|
|
287
|
-
* A handler may be async. Either a synchronous throw or a rejected promise
|
|
288
|
-
* is swallowed -- like every other fire-and-forget hook in this SDK, a bug
|
|
289
|
-
* in a consumer's handler must not take down webhook processing (an
|
|
290
|
-
* unhandled rejection crashes the process on modern Node defaults).
|
|
291
|
-
*/
|
|
292
|
-
function onRelease(handler) {
|
|
293
|
-
releaseHandlers.add(handler);
|
|
294
|
-
return () => releaseHandlers.delete(handler);
|
|
295
|
-
}
|
|
296
|
-
function fireOnRelease(release) {
|
|
297
|
-
for (const handler of releaseHandlers) {
|
|
298
|
-
Promise.resolve()
|
|
299
|
-
.then(() => handler(release))
|
|
300
|
-
.catch(() => {
|
|
301
|
-
// see onRelease's doc comment
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Call right after decrypting an inbound message, before deciding whether
|
|
307
|
-
* to run a fresh reply cycle -- the same spot webhook.ts calls
|
|
308
|
-
* delegations.resolveIfPending (and what webhook.ts itself calls, to also
|
|
309
|
-
* learn about an "unmatched" release for its onLatticeRelease option).
|
|
310
|
-
*
|
|
311
|
-
* - "not-a-release": `plaintext` isn't lattice wire protocol at all --
|
|
312
|
-
* including this identity's own outgoing requests/proposals, which never
|
|
313
|
-
* match RELEASE_MARKER_RE, and any genuinely unrelated message.
|
|
314
|
-
* - "matched": `chatId`/`senderId` agree with a live register() wait for
|
|
315
|
-
* this release's `request_id` -- that wait's promise is resolved directly;
|
|
316
|
-
* there is nothing further for a caller to do.
|
|
317
|
-
* - "refused": this release names a request id a wait IS pending for, but
|
|
318
|
-
* `chatId`/`senderId` don't match what register() bound it to -- e.g. a
|
|
319
|
-
* bystander who merely saw the plaintext request id (see
|
|
320
|
-
* RegisterBinding's doc comment) replaying it as a forged release. The
|
|
321
|
-
* live wait is untouched (still running, still resolvable by the real
|
|
322
|
-
* answer); this message is left for the caller to process as ordinary,
|
|
323
|
-
* harmless text -- it must NOT be treated as Lattice traffic.
|
|
324
|
-
* - "unmatched": a genuine late reply or standing push -- fired to
|
|
325
|
-
* onRelease() before this returns.
|
|
326
|
-
*/
|
|
327
|
-
function classifyRelease(chatId, senderId, plaintext) {
|
|
328
|
-
const parsed = parseRelease(plaintext);
|
|
329
|
-
if (!parsed)
|
|
330
|
-
return { kind: "not-a-release" };
|
|
331
|
-
if (!parsed.standing) {
|
|
332
|
-
const key = mapKey(parsed.body.request_id); // parseRelease guarantees request_id is set for a non-standing release
|
|
333
|
-
const entry = pending.get(key);
|
|
334
|
-
if (entry) {
|
|
335
|
-
if ((0, ids_js_1.sameId)(entry.chatId, chatId) && (0, ids_js_1.sameId)(entry.senderId, senderId)) {
|
|
336
|
-
clearTimeout(entry.timer);
|
|
337
|
-
pending.delete(key);
|
|
338
|
-
entry.resolve(parsed.body);
|
|
339
|
-
return { kind: "matched" };
|
|
340
|
-
}
|
|
341
|
-
return { kind: "refused" };
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
const release = { id: parsed.id, standing: parsed.standing, chatId, senderId, body: parsed.body };
|
|
345
|
-
fireOnRelease(release);
|
|
346
|
-
return { kind: "unmatched", release };
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Boolean convenience wrapper over classifyRelease, mirroring
|
|
350
|
-
* delegations.resolveIfPending(chatId, senderId, plaintext)'s shape for a
|
|
351
|
-
* simple caller that doesn't need an "unmatched" release's details (e.g. a
|
|
352
|
-
* custom integration built directly on lattice.ts, without webhook.ts).
|
|
353
|
-
* True for "matched" and "unmatched" (don't treat `plaintext` as a fresh
|
|
354
|
-
* prompt); false for "not-a-release" AND "refused" (a forged/misdirected
|
|
355
|
-
* release is left to fall through exactly like ordinary text, same as
|
|
356
|
-
* "not-a-release" -- see classifyRelease's doc comment).
|
|
357
|
-
*
|
|
358
|
-
* webhook.ts itself calls classifyRelease directly instead of this, since
|
|
359
|
-
* it also needs an "unmatched" release's details (chat/sender/body) to
|
|
360
|
-
* offer to its own onLatticeRelease option.
|
|
361
|
-
*/
|
|
362
|
-
function resolveIfPending(chatId, senderId, plaintext) {
|
|
363
|
-
const outcome = classifyRelease(chatId, senderId, plaintext);
|
|
364
|
-
return outcome.kind === "matched" || outcome.kind === "unmatched";
|
|
365
|
-
}
|
|
366
|
-
//# sourceMappingURL=lattice.js.map
|
package/dist/lattice.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lattice.js","sourceRoot":"","sources":["../src/lattice.ts"],"names":[],"mappings":";AAAA,wEAAwE;AACxE,4EAA4E;AAC5E,4EAA4E;AAC5E,0EAA0E;AAC1E,4EAA4E;AAC5E,2EAA2E;AAC3E,m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