@genkaku/protocol 0.1.14 → 0.1.15

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/index.d.ts CHANGED
@@ -23,6 +23,7 @@ export * from './ollama.ts';
23
23
  export * from './p2pNode.ts';
24
24
  export * from './paywall.ts';
25
25
  export * from './publishOptIn.ts';
26
+ export * from './settleOptIn.ts';
26
27
  export * from './receipts.ts';
27
28
  export * from './registry.ts';
28
29
  export * from './rpc.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AACvB,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AACvB,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA"}
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ export * from "./ollama.js";
23
23
  export * from "./p2pNode.js";
24
24
  export * from "./paywall.js";
25
25
  export * from "./publishOptIn.js";
26
+ export * from "./settleOptIn.js";
26
27
  export * from "./receipts.js";
27
28
  export * from "./registry.js";
28
29
  export * from "./rpc.js";
@@ -0,0 +1,15 @@
1
+ /** File name under the GenKaKu key directory. */
2
+ export declare const SETTLE_OPT_IN_FILE = "settle.json";
3
+ /**
4
+ * Read the user's settlement opt-in.
5
+ * @param keyDir - GenKaKu state directory.
6
+ * @returns true/false when the user chose, or null to keep the profile default.
7
+ */
8
+ export declare function readSettleOptIn(keyDir: string): boolean | null;
9
+ /**
10
+ * Persist the user's settlement opt-in.
11
+ * @param keyDir - GenKaKu state directory.
12
+ * @param settle - whether sessions should open and settle escrows.
13
+ */
14
+ export declare function writeSettleOptIn(keyDir: string, settle: boolean): void;
15
+ //# sourceMappingURL=settleOptIn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settleOptIn.d.ts","sourceRoot":"","sources":["../src/settleOptIn.ts"],"names":[],"mappings":"AAYA,iDAAiD;AACjD,eAAO,MAAM,kBAAkB,gBAAgB,CAAA;AAE/C;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAQ9D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAGtE"}
@@ -0,0 +1,37 @@
1
+ // GENKAKU: user-side settlement opt-in.
2
+ //
3
+ // `config.settle` is the deployment default and is NOT a volatile settings
4
+ // field: writing it into the profile patch is rejected by dsh ("is not
5
+ // volatile") and, because the write was fire-and-forget, it took the whole app
6
+ // down. The panel's Payments switch therefore persists here instead, next to
7
+ // the worker's publish opt-in, and the runtime reads it when it builds the
8
+ // bridge.
9
+ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
10
+ import { join } from 'node:path';
11
+ /** File name under the GenKaKu key directory. */
12
+ export const SETTLE_OPT_IN_FILE = 'settle.json';
13
+ /**
14
+ * Read the user's settlement opt-in.
15
+ * @param keyDir - GenKaKu state directory.
16
+ * @returns true/false when the user chose, or null to keep the profile default.
17
+ */
18
+ export function readSettleOptIn(keyDir) {
19
+ try {
20
+ const value = JSON.parse(readFileSync(join(keyDir, SETTLE_OPT_IN_FILE), 'utf8'));
21
+ const settle = value.settle;
22
+ return typeof settle === 'boolean' ? settle : null;
23
+ }
24
+ catch {
25
+ return null;
26
+ }
27
+ }
28
+ /**
29
+ * Persist the user's settlement opt-in.
30
+ * @param keyDir - GenKaKu state directory.
31
+ * @param settle - whether sessions should open and settle escrows.
32
+ */
33
+ export function writeSettleOptIn(keyDir, settle) {
34
+ mkdirSync(keyDir, { recursive: true, mode: 0o700 });
35
+ writeFileSync(join(keyDir, SETTLE_OPT_IN_FILE), `${JSON.stringify({ settle }, undefined, 2)}\n`, { mode: 0o600 });
36
+ }
37
+ //# sourceMappingURL=settleOptIn.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genkaku/protocol",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "GenKaKu protocol core: on-chain worker directory, USDC escrow billing, libp2p transport, Ollama lifecycle",
5
5
  "license": "MIT",
6
6
  "type": "module",