sessionpipe 0.13.0 → 0.13.1
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 +13 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +803 -343
- package/dist/cli.js.map +4 -4
- package/dist/connect.d.ts +6 -1
- package/dist/connect.d.ts.map +1 -1
- package/dist/control/autoupdate.d.ts +1 -0
- package/dist/control/autoupdate.d.ts.map +1 -1
- package/dist/control/cli.d.ts.map +1 -1
- package/dist/fold.d.ts +29 -0
- package/dist/fold.d.ts.map +1 -0
- package/dist/help.d.ts.map +1 -1
- package/dist/hook.d.ts.map +1 -1
- package/dist/hook.js +2 -2
- package/dist/hook.js.map +2 -2
- package/dist/index.js +480 -146
- package/dist/index.js.map +4 -4
- package/dist/run.d.ts +40 -5
- package/dist/run.d.ts.map +1 -1
- package/dist/secrets.d.ts +14 -4
- package/dist/secrets.d.ts.map +1 -1
- package/dist/wellknown.d.ts +31 -0
- package/dist/wellknown.d.ts.map +1 -0
- package/dist/worker.d.ts +7 -1
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +576 -164
- package/dist/worker.js.map +4 -4
- package/package.json +1 -1
package/dist/run.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare function releaseJob(claimed: string | undefined): void;
|
|
|
29
29
|
* worker lives, `abandonedMs`) goes back to the queue, then every queued job older
|
|
30
30
|
* than `olderThanMs` (younger ones belong to the worker their hook just spawned)
|
|
31
31
|
* is claimed and run. Every worker sweeps before it exits. */
|
|
32
|
-
export declare function sweepJobs(state: string, olderThanMs?: number, limit?: number, abandonedMs?: number): Promise<number>;
|
|
32
|
+
export declare function sweepJobs(state: string, olderThanMs?: number, limit?: number, abandonedMs?: number, o?: DrainLife): Promise<number>;
|
|
33
33
|
export declare function log(state: string, line: string): void;
|
|
34
34
|
/** <state>/facts/<harness>/<session>.json — what the machine learned about a session. */
|
|
35
35
|
export declare function factsState(state: string): FactsState;
|
|
@@ -62,7 +62,11 @@ export declare function runJob(job: Job, opts?: {
|
|
|
62
62
|
now?: number;
|
|
63
63
|
claimed?: string;
|
|
64
64
|
lockWaitMs?: number;
|
|
65
|
-
|
|
65
|
+
/** false: the events go to the outbox and the sinks are left for the caller to drain. */
|
|
66
|
+
drain?: boolean;
|
|
67
|
+
/** The drain's clock (pacing); tests stand in a simulated one. */
|
|
68
|
+
clock?: Clock;
|
|
69
|
+
} & DrainLife): Promise<{
|
|
66
70
|
events: Event[];
|
|
67
71
|
delivered: Record<string, number>;
|
|
68
72
|
requeued?: string;
|
|
@@ -80,6 +84,28 @@ export declare function appendObserved(state: string, harness: string, id: strin
|
|
|
80
84
|
now?: number;
|
|
81
85
|
lockWaitMs?: number;
|
|
82
86
|
}): Promise<Event | null>;
|
|
87
|
+
/** What the drain reads the time from and waits with; tests stand in a simulated one. */
|
|
88
|
+
export interface Clock {
|
|
89
|
+
now(): number;
|
|
90
|
+
sleep(ms: number): Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
/** A pass of the drain starts at least this long after the machine's last request to
|
|
93
|
+
* a receiver (issue #208): under a few hundred subagents a receiver gets one request
|
|
94
|
+
* a second with everything that piled up, not one per hook. A lone event goes at once. */
|
|
95
|
+
export declare const PACE_MS = 1000;
|
|
96
|
+
/** How long a worker's life must still run for a pass of the drain to start: the
|
|
97
|
+
* pace's wait (≤ PACE_MS) and a round trip. A worker that has less leaves the work
|
|
98
|
+
* marked (flush.more) and hands it on (DrainLife.handoff) rather than be ended by its
|
|
99
|
+
* deadline mid-pass, holding events nobody else knows to send. */
|
|
100
|
+
export declare const PASS_BUDGET_MS = 3000;
|
|
101
|
+
/** A worker's remaining life, for the drain and the sweep. Both unset: no limit. */
|
|
102
|
+
export interface DrainLife {
|
|
103
|
+
/** When the process will be ended (epoch ms, on the drain's clock). */
|
|
104
|
+
deadline?: number;
|
|
105
|
+
/** Called, with the flush lock released, when work is left marked for another
|
|
106
|
+
* worker because this one's life is too short for it (worker.ts starts a drainer). */
|
|
107
|
+
handoff?: () => void;
|
|
108
|
+
}
|
|
83
109
|
/** One worker drains a machine's sinks at a time (the `flush` lock). Another whose
|
|
84
110
|
* events are in the outbox meanwhile marks that there is more and leaves them to
|
|
85
111
|
* it (null: nothing sent by this one). The one draining looks for the mark after
|
|
@@ -87,11 +113,17 @@ export declare function appendObserved(state: string, harness: string, id: strin
|
|
|
87
113
|
* in its next pass or with the worker that appended them, never wait for a later
|
|
88
114
|
* hook. Under a flood of hook events this is one uploader sending full batches,
|
|
89
115
|
* not one per event, all refused together (mordast, 2026-10-14: 828 refusals in
|
|
90
|
-
* two minutes, 5 192 jobs queued).
|
|
116
|
+
* two minutes, 5 192 jobs queued). A pass that would follow the machine's last
|
|
117
|
+
* request by less than PACE_MS first waits out the rest, holding the lock: the
|
|
118
|
+
* workers that arrive meanwhile only mark that there is more, and the pass sends
|
|
119
|
+
* everything they appended. A pass starts only while the worker's life has
|
|
120
|
+
* PASS_BUDGET_MS left; otherwise the mark stays and the work is handed on. */
|
|
91
121
|
export declare function drain(state: string, sinkConfigs: SinkConfig[], outbox: Outbox, first?: {
|
|
92
122
|
harness: string;
|
|
93
123
|
session: string;
|
|
94
|
-
}
|
|
124
|
+
}, o?: {
|
|
125
|
+
clock?: Clock;
|
|
126
|
+
} & DrainLife): Promise<Record<string, number> | null>;
|
|
95
127
|
/** HTTP.md §2: a sink that answered 429 isn't tried again before its `retry-after`;
|
|
96
128
|
* one that was unreachable (5xx, a timeout) waits 2 s · 10 s · 60 s · 5 min · 30 min,
|
|
97
129
|
* then every 30 min. Kept in <state>/backoff/<sink>.json, so every worker on the
|
|
@@ -115,7 +147,10 @@ export declare function flush(state: string, sinkConfigs: SinkConfig[], outbox:
|
|
|
115
147
|
harness: string;
|
|
116
148
|
session: string;
|
|
117
149
|
}, o?: {
|
|
118
|
-
force?: boolean;
|
|
150
|
+
/** Try a sink in backoff anyway (`sessionpipe replay`). */ force?: boolean;
|
|
151
|
+
/** Stamps the machine's last request (drain's pace). */ clock?: Clock;
|
|
152
|
+
/** Counts, per sink, the tool events it was configured not to be sent (`replay`). */
|
|
153
|
+
thinned?: Record<string, number>;
|
|
119
154
|
}): Promise<Record<string, number>>;
|
|
120
155
|
export { VERSION };
|
|
121
156
|
export declare const versionLine: () => string;
|
package/dist/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAeA,OAAO,EAKL,KAAK,MAAM,EAEX,KAAK,KAAK,EACV,KAAK,UAAU,EAOf,MAAM,
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAeA,OAAO,EAKL,KAAK,MAAM,EAEX,KAAK,KAAK,EACV,KAAK,UAAU,EAOf,MAAM,EAON,KAAK,IAAI,EACT,KAAK,UAAU,EAKf,KAAK,cAAc,EAKpB,MAAM,mBAAmB,CAAC;AAuC3B,QAAA,MAAM,OAAO,QAAkF,CAAC;AAEhG,MAAM,WAAW,GAAG;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX;0EACsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,SAAS,KAAK,CAAC;AAE5B,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM,CAM1D;AAED;;;gFAGgF;AAChF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE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server its keyring is locked whenever nobody is logged in,
|
|
22
22
|
* which is exactly when the daemon needs its token. */
|
|
23
23
|
export declare function bestStore(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform, run?: Runner): StoreName;
|
|
24
|
-
export declare const storeLabel: (s: StoreName | undefined) => string;
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
|
|
24
|
+
export declare const storeLabel: (s: StoreName | undefined, platform?: NodeJS.Platform) => string;
|
|
25
|
+
/** What keeps a key in the config file private: a mode on POSIX; on Windows, where modes
|
|
26
|
+
* mean nothing, the profile folder's own permissions. */
|
|
27
|
+
export declare const fileKept: (platform?: NodeJS.Platform) => string;
|
|
28
|
+
/** `connect`'s line for keys that stay in the file. */
|
|
29
|
+
export declare function keysFileNote(platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv): string;
|
|
30
|
+
/** The sink with its token and secret filled in from its store: each item the store
|
|
31
|
+
* holds, since a sink has a token, a Webhooks secret, or both (`sink add --secret`
|
|
32
|
+
* with no `--token` signs and sends no bearer). Null when the store can't be read
|
|
33
|
+
* from this process right now (a keychain locked in an ssh session): the caller
|
|
34
|
+
* leaves the events in the outbox rather than sending them unsigned. One item and not
|
|
35
|
+
* the other is not that: the store has just answered a read from this process, so it
|
|
36
|
+
* is readable right now, and the item it didn't give is one it doesn't hold. A locked
|
|
37
|
+
* store fails both reads. */
|
|
28
38
|
export declare function sinkWithSecrets(s: SinkConfig, run?: Runner): SinkConfig | null;
|
|
29
39
|
/** Store a sink's secrets in `to` (or back in the file) and save the config. */
|
|
30
40
|
export declare function moveSinkSecrets(to: StoreName, o?: {
|
package/dist/secrets.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../src/secrets.ts"],"names":[],"mappings":"AAcA,OAAO,EAA0B,KAAK,UAAU,EAAe,MAAM,mBAAmB,CAAC;AAEzF,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,gBAAgB,C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SAAS,aAAY,MAAM,CAAC,QAAQ,KAAsB,MAO7E,CAAC;AAExB;0DAC0D;AAC1D,eAAO,MAAM,QAAQ,cAAc,MAAM,CAAC,QAAQ,KAAsB,MACV,CAAC;AAE/D,uDAAuD;AACvD,wBAAgB,YAAY,CAC1B,QAAQ,GAAE,MAAM,CAAC,QAA2B,EAC5C,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,CAGR;AAED;;;;;;;8BAO8B;AAC9B,wBAAgB,eAAe,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,GAAE,MAAsB,GAAG,UAAU,GAAG,IAAI,CAM7F;AAED,gFAAgF;AAChF,wBAAgB,eAAe,CAC7B,EAAE,EAAE,SAAS,EACb,CAAC,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GACtC;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CA8CrC;AAED,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,GAAE,MAAsB,GAAG,IAAI,CAIhF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Config, type SinkConfig, type Tier } from "@sessionpipe/core";
|
|
2
|
+
import { type ToolsMode } from "./fold.js";
|
|
3
|
+
export interface WellKnownRead {
|
|
4
|
+
max_tier?: number;
|
|
5
|
+
endpoints?: {
|
|
6
|
+
events?: string;
|
|
7
|
+
};
|
|
8
|
+
capabilities?: string[];
|
|
9
|
+
tools?: unknown;
|
|
10
|
+
}
|
|
11
|
+
/** How long what a worker learned stands before it reads the file again. */
|
|
12
|
+
export declare const WELL_KNOWN_MAX_AGE_MS: number;
|
|
13
|
+
export declare const wellKnownUrl: (sinkUrl: string) => string;
|
|
14
|
+
/** The file, parsed; throws with a sentence (`HTTP 404`, the fetch's own words) when it can't be read. */
|
|
15
|
+
export declare function readWellKnown(sinkUrl: string, timeoutMs: number, fetchFn?: typeof fetch): Promise<WellKnownRead>;
|
|
16
|
+
/** What the file says, onto the sink. Returns what changed for the person, in words:
|
|
17
|
+
* a cap below the tier asked for, and the tool events the receiver asked for. */
|
|
18
|
+
export declare function applyWellKnown(s: SinkConfig, wk: WellKnownRead, tier: Tier, now?: Date): string[];
|
|
19
|
+
/** Read again the well-known file of every HTTP sink a worker hasn't looked at for a
|
|
20
|
+
* day, and keep what changed. One short read per sink per day, never on the hook's
|
|
21
|
+
* own path; a failed read is noted as tried, so the next try is a day away. */
|
|
22
|
+
export declare function refreshWellKnown(cfg: Config, o?: {
|
|
23
|
+
now?: () => number;
|
|
24
|
+
fetchFn?: typeof fetch;
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
}): Promise<boolean>;
|
|
27
|
+
/** The worker's call: the config read, refreshed where stale, and written back only when
|
|
28
|
+
* something was learned or tried. Nothing a drain depends on; errors are swallowed. */
|
|
29
|
+
export declare function refreshSinks(o?: Parameters<typeof refreshWellKnown>[1]): Promise<void>;
|
|
30
|
+
export type { ToolsMode };
|
|
31
|
+
//# sourceMappingURL=wellknown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wellknown.d.ts","sourceRoot":"","sources":["../src/wellknown.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,MAAM,EAAc,KAAK,UAAU,EAAE,KAAK,IAAI,EAAe,MAAM,mBAAmB,CAAC;AACrG,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAChC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,4EAA4E;AAC5E,eAAO,MAAM,qBAAqB,QAAmB,CAAC;AAEtD,eAAO,MAAM,YAAY,YAAa,MAAM,KAAG,MAAiE,CAAC;AAEjH,0GAA0G;AAC1G,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,OAAO,KAAa,GAC5B,OAAO,CAAC,aAAa,CAAC,CAIxB;AAED;kFACkF;AAClF,wBAAgB,cAAc,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,OAAa,GAAG,MAAM,EAAE,CAgBvG;AAOD;;gFAEgF;AAChF,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,CAAC,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACzE,OAAO,CAAC,OAAO,CAAC,CAclB;AAED;wFACwF;AACxF,wBAAsB,YAAY,CAAC,CAAC,GAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKhG;AAED,YAAY,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/worker.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/** How long a worker lives. */
|
|
3
|
+
export declare const WORKER_LIFE_MS = 15000;
|
|
4
|
+
/** The argument that starts a worker with no job, to drain what another left marked. */
|
|
5
|
+
export declare const DRAIN_ARG = "--drain";
|
|
2
6
|
/** One worker run over `argv` as node received it ([node, worker.js, job]). Resolves
|
|
3
|
-
* once the job is done and the sweep is over; the process then exits 0.
|
|
7
|
+
* once the job is done and the sweep is over; the process then exits 0. A drain
|
|
8
|
+
* that finds this worker's life too short for another pass leaves the work marked
|
|
9
|
+
* and starts one fresh worker to take it over (at most one per worker). */
|
|
4
10
|
export declare function workerMain(argv: string[]): Promise<void>;
|
|
5
11
|
//# sourceMappingURL=worker.d.ts.map
|
package/dist/worker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":";AAmBA,+BAA+B;AAC/B,eAAO,MAAM,cAAc,QAAS,CAAC;AACrC,wFAAwF;AACxF,eAAO,MAAM,SAAS,YAAY,CAAC;AAQnC;;;4EAG4E;AAC5E,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAwC9D"}
|