@cotal-ai/delivery 0.48.2 → 0.50.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/dist/delivery.d.ts +87 -1
- package/dist/delivery.d.ts.map +1 -1
- package/dist/delivery.js +783 -33
- package/dist/delivery.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/watchdog.d.ts +313 -0
- package/dist/watchdog.d.ts.map +1 -0
- package/dist/watchdog.js +374 -0
- package/dist/watchdog.js.map +1 -0
- package/package.json +3 -3
package/dist/delivery.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ParsedArgs, type SecretStore } from "@cotal-ai/core";
|
|
1
|
+
import { type ParsedArgs, type SecretStore, type SecretStoreIdentity } from "@cotal-ai/core";
|
|
2
2
|
import { DELIVERY_CREDS_KIND, deliveryCredsKey } from "@cotal-ai/workspace";
|
|
3
3
|
/** Re-exported for hosted compositions: the daemon cred's KIND, and the builder that turns it into
|
|
4
4
|
* the {@link SecretStore} key for a space. Defined once in workspace (the layout is the workspace's)
|
|
@@ -6,6 +6,92 @@ import { DELIVERY_CREDS_KIND, deliveryCredsKey } from "@cotal-ai/workspace";
|
|
|
6
6
|
* the key — the key is per-space — so a hosted store must be keyed with the builder; the flat kind
|
|
7
7
|
* is the pre-P7 key and putting there leaves this daemon reading an empty location. */
|
|
8
8
|
export { DELIVERY_CREDS_KIND, deliveryCredsKey };
|
|
9
|
+
type CredsSource = {
|
|
10
|
+
store: SecretStore;
|
|
11
|
+
key: string;
|
|
12
|
+
where: string;
|
|
13
|
+
injected: boolean;
|
|
14
|
+
identity: SecretStoreIdentity;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The store identity THIS daemon will re-read on `reloadCreds`. It is the same store
|
|
18
|
+
* `resolveCredsStore` returns: an injected coordinate, a `--creds` file that is
|
|
19
|
+
* exactly `<root>/.cotal/<spaceSegment(space)>/delivery.creds` (named as the
|
|
20
|
+
* workstation root, matching the canonical arm), a `--creds` file that is not
|
|
21
|
+
* that file (named as the file's own directory), or the workstation root.
|
|
22
|
+
* Naming an ancestor via `findCotalRoot` would certify a two-root composition
|
|
23
|
+
* as a same-store proof.
|
|
24
|
+
*/
|
|
25
|
+
export declare function reloadStoreIdentityOf(src: Pick<CredsSource, "injected" | "identity"> & {
|
|
26
|
+
store?: SecretStore;
|
|
27
|
+
}): SecretStoreIdentity;
|
|
28
|
+
/**
|
|
29
|
+
* Identity of the store a `--creds` file is reloaded from.
|
|
30
|
+
*
|
|
31
|
+
* With `--creds` the store object is deliberately FLAT (root = the file's own
|
|
32
|
+
* directory, key = basename). The canonical store is `<root>/.cotal` with a
|
|
33
|
+
* segmented key. Different store objects, but when `--creds` names THE FILE THE
|
|
34
|
+
* MANAGER WRITES they resolve THE SAME FILE, so they are the same authority.
|
|
35
|
+
* Identity names that authority, not the store object's root.
|
|
36
|
+
*
|
|
37
|
+
* The manager remints only `segmentedKey(DELIVERY_CREDS_KIND, space)` under
|
|
38
|
+
* `<root>/.cotal`. Collapse only that exact path: basename is `delivery.creds`,
|
|
39
|
+
* parent of the file dir is `.cotal`, and the file dir is `spaceSegment(space)`
|
|
40
|
+
* for THIS space. Another space's segment, a decoy basename, `.cotal/auth/...`,
|
|
41
|
+
* or a legacy `<root>/.cotal/delivery.creds` keep `dirname`. Never
|
|
42
|
+
* `spaceFromSegment` ("a valid segment") and never `findCotalRoot`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function reloadStoreIdentityFromCredsPath(credsPath: string, space: string): SecretStoreIdentity;
|
|
45
|
+
/**
|
|
46
|
+
* Workstation root implied by a `--creds` path: the parent of the enclosing
|
|
47
|
+
* `.cotal` directory. A path that is not under any `.cotal` tree names no
|
|
48
|
+
* workstation (a flat mount, a container file) and returns undefined.
|
|
49
|
+
*
|
|
50
|
+
* Distinct from {@link reloadStoreIdentityFromCredsPath}, which names the
|
|
51
|
+
* SecretStore the manager challenges. That identity stays the file's own
|
|
52
|
+
* directory for a legacy shallow path; this helper answers a different
|
|
53
|
+
* question so the cwd guard can compare two workspace roots.
|
|
54
|
+
*/
|
|
55
|
+
export declare function workspaceRootFromCredsPath(credsPath: string): string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Uninjected `--creds` that names one real workstation root while process cwd
|
|
58
|
+
* resolves another is a false same-store proof: membership-rw still resolves
|
|
59
|
+
* via `findCotalRoot()` (cwd), not the `--creds` file. Fire only when BOTH
|
|
60
|
+
* sides resolve real workstation roots and those differ. A path that is not
|
|
61
|
+
* under a `.cotal` tree names no workstation, so this check does not fire
|
|
62
|
+
* (the manager challenge already diverges on that composition). Injected
|
|
63
|
+
* compositions skip this: both rails take the injected store. Never silently
|
|
64
|
+
* prefer either root.
|
|
65
|
+
*/
|
|
66
|
+
export declare function assertUninjectedCredsSharesCwdRoot(opts: {
|
|
67
|
+
injected: boolean;
|
|
68
|
+
credsPath: string;
|
|
69
|
+
cwdRoot?: string;
|
|
70
|
+
}): void;
|
|
71
|
+
/**
|
|
72
|
+
* RECORD THIS PROCESS as the space's delivery daemon, and un-record it on a clean exit (#1528).
|
|
73
|
+
*
|
|
74
|
+
* The daemon writes its OWN record because it is the only participant that always knows it is
|
|
75
|
+
* running. Until now `delivery.<space>.pid` was written ONLY by the CLI launcher
|
|
76
|
+
* (`startDeliveryDetached`), so every other route to a live daemon — a container entrypoint,
|
|
77
|
+
* systemd, an operator typing `cotal deliver --space …`, a hosted composition calling
|
|
78
|
+
* {@link runDelivery} — left whatever was on disk untouched and readers believed it. A record naming
|
|
79
|
+
* a pid that died days ago does not merely under-report: `down`'s `mayBeRunning` guard exists to
|
|
80
|
+
* fail CLOSED so `cotal down nats` cannot pull the broker out from under a live dependant, and a
|
|
81
|
+
* stale record supplies exactly the proof-of-death that guard requires.
|
|
82
|
+
*
|
|
83
|
+
* The launcher's shape is followed rather than re-invented: the CANONICAL path (never a pre-upgrade
|
|
84
|
+
* name), a provably dead pre-upgrade record reclaimed first so an upgraded root never holds both
|
|
85
|
+
* spellings, then the #969 identity pin beside it. The pin goes with the record on the way out.
|
|
86
|
+
*
|
|
87
|
+
* The removal is pid-CHECKED, like the manager's: a daemon that exits must not delete a record that
|
|
88
|
+
* already belongs to its successor (a fast restart writes the new pid before the old process has
|
|
89
|
+
* finished unwinding), so the record goes only while it still names this process.
|
|
90
|
+
*
|
|
91
|
+
* A root with no `.cotal/` is not a workstation and gets no record — a hosted composition has none,
|
|
92
|
+
* and creating one here would plant a stray workspace root wherever the daemon happened to run.
|
|
93
|
+
*/
|
|
94
|
+
export declare function recordDeliveryPid(root: string, space: string): () => void;
|
|
9
95
|
/**
|
|
10
96
|
* Run the delivery daemon: the server-side Plane-3 durable backstop. A thin composition root that
|
|
11
97
|
* builds a scoped `delivery` endpoint, acquires the single-flight lease, and runs the existing
|
package/dist/delivery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery.d.ts","sourceRoot":"","sources":["../src/delivery.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"delivery.d.ts","sourceRoot":"","sources":["../src/delivery.ts"],"names":[],"mappings":"AAEA,OAAO,EAkBL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,mBAAmB,EAEzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAuE,gBAAgB,EAAiK,MAAM,qBAAqB,CAAC;AAOhT;;;;wFAIwF;AACxF,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,CAAC;AAEjD,KAAK,WAAW,GAAG;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAExH;;;;;;;;GAQG;AACH,wB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