@h1r-ai/croche 0.5.3 → 0.5.4
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 +2 -2
- package/dist/core-bindgen.js +16 -16
- package/dist/core-runtime.d.ts +8 -2
- package/dist/core-runtime.js +33 -15
- package/dist/core-wasm-bytes.d.ts +3 -3
- package/dist/core-wasm-bytes.js +3 -3
- package/dist/project-core.d.ts +7 -2
- package/dist/project-core.js +50 -21
- package/docs/SKILL.md +2 -2
- package/docs/skills/croche/references/first-turn.md +1 -1
- package/docs/skills/croche-cli/SKILL.md +1 -1
- package/docs/skills/croche-platforms/SKILL.md +2 -2
- package/docs/skills/croche-platforms/references/android.md +2 -2
- package/docs/skills/croche-platforms/references/ios.md +2 -2
- package/docs/skills/croche-platforms/references/react-native.md +1 -1
- package/docs/skills/croche-troubleshoot/references/recovery.md +1 -1
- package/package.json +1 -1
- package/src/core-bindgen.ts +16 -16
- package/src/core-runtime.ts +31 -14
- package/src/core-wasm-bytes.ts +3 -3
- package/src/project-core.ts +53 -23
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ and receives a report of every call in the background. **A Cloud outage does not
|
|
|
33
33
|
The shared Rust Core owns conversations, command routing, receipts, spending and
|
|
34
34
|
Cloud synchronization. This package embeds its WebAssembly build for browsers,
|
|
35
35
|
Node, and WebViews. Native iOS (Swift) and Android (Kotlin) SDKs are published as
|
|
36
|
-
0.5.
|
|
36
|
+
0.5.4, with the same `Croche.open` API.
|
|
37
37
|
For React Native, install `@h1r-ai/croche-react-native` beside this package; it carries
|
|
38
38
|
the native Core ([React Native](#react-native)).
|
|
39
39
|
Your app can choose the model with `model` in the `config` passed to `Croche.open`; if it
|
|
@@ -65,7 +65,7 @@ WASM Core, with no runtime npm dependencies. Consuming apps need no Rust compile
|
|
|
65
65
|
or source checkout. Rust is needed only to rebuild the Core from source. A strict
|
|
66
66
|
browser CSP must include `script-src 'self' 'wasm-unsafe-eval'`; JavaScript `eval`
|
|
67
67
|
and `new Function` remain unnecessary.
|
|
68
|
-
Version 0.5.
|
|
68
|
+
Version 0.5.4 is published on the public npm registry as `@h1r-ai/croche`.
|
|
69
69
|
|
|
70
70
|
## Projects and agents
|
|
71
71
|
|
package/dist/core-bindgen.js
CHANGED
|
@@ -1213,7 +1213,7 @@ function __wbg_get_imports() {
|
|
|
1213
1213
|
return ret;
|
|
1214
1214
|
}, arguments);
|
|
1215
1215
|
};
|
|
1216
|
-
imports.wbg.
|
|
1216
|
+
imports.wbg.__wbg_http_e9b575fe3d265a7a = function (arg0, arg1, arg2, arg3) {
|
|
1217
1217
|
const ret = arg0.http(arg1, WasmSink.__wrap(arg2), WasmCancel.__wrap(arg3));
|
|
1218
1218
|
return ret;
|
|
1219
1219
|
};
|
|
@@ -1236,7 +1236,7 @@ function __wbg_get_imports() {
|
|
|
1236
1236
|
const ret = arg0.length;
|
|
1237
1237
|
return ret;
|
|
1238
1238
|
};
|
|
1239
|
-
imports.wbg.
|
|
1239
|
+
imports.wbg.__wbg_lock_e0eaba7753ddb53e = function (arg0, arg1, arg2) {
|
|
1240
1240
|
const ret = arg0.lock(getStringFromWasm0(arg1, arg2));
|
|
1241
1241
|
return ret;
|
|
1242
1242
|
};
|
|
@@ -1272,7 +1272,7 @@ function __wbg_get_imports() {
|
|
|
1272
1272
|
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
1273
1273
|
return ret;
|
|
1274
1274
|
};
|
|
1275
|
-
imports.wbg.
|
|
1275
|
+
imports.wbg.__wbg_nowMs_1ca5891a40094dae = function (arg0) {
|
|
1276
1276
|
const ret = arg0.nowMs();
|
|
1277
1277
|
return ret;
|
|
1278
1278
|
};
|
|
@@ -1294,26 +1294,26 @@ function __wbg_get_imports() {
|
|
|
1294
1294
|
const ret = arg0.queueMicrotask;
|
|
1295
1295
|
return ret;
|
|
1296
1296
|
};
|
|
1297
|
-
imports.wbg.
|
|
1297
|
+
imports.wbg.__wbg_random_1e43f80205bcda1a = function (arg0, arg1) {
|
|
1298
1298
|
const ret = arg1.random();
|
|
1299
1299
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1300
1300
|
const len1 = WASM_VECTOR_LEN;
|
|
1301
1301
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1302
1302
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1303
1303
|
};
|
|
1304
|
-
imports.wbg.
|
|
1304
|
+
imports.wbg.__wbg_readSecret_54824834e3c0cb53 = function (arg0, arg1, arg2) {
|
|
1305
1305
|
const ret = arg0.readSecret(getStringFromWasm0(arg1, arg2));
|
|
1306
1306
|
return ret;
|
|
1307
1307
|
};
|
|
1308
|
-
imports.wbg.
|
|
1308
|
+
imports.wbg.__wbg_read_9c800ddb8c809500 = function (arg0, arg1, arg2) {
|
|
1309
1309
|
const ret = arg0.read(getStringFromWasm0(arg1, arg2));
|
|
1310
1310
|
return ret;
|
|
1311
1311
|
};
|
|
1312
|
-
imports.wbg.
|
|
1312
|
+
imports.wbg.__wbg_removeSecret_9250e3320cd1ce02 = function (arg0, arg1, arg2) {
|
|
1313
1313
|
const ret = arg0.removeSecret(getStringFromWasm0(arg1, arg2));
|
|
1314
1314
|
return ret;
|
|
1315
1315
|
};
|
|
1316
|
-
imports.wbg.
|
|
1316
|
+
imports.wbg.__wbg_remove_ab1cab75d56111c0 = function (arg0, arg1, arg2) {
|
|
1317
1317
|
const ret = arg0.remove(getStringFromWasm0(arg1, arg2));
|
|
1318
1318
|
return ret;
|
|
1319
1319
|
};
|
|
@@ -1327,7 +1327,7 @@ function __wbg_get_imports() {
|
|
|
1327
1327
|
return ret;
|
|
1328
1328
|
}, arguments);
|
|
1329
1329
|
};
|
|
1330
|
-
imports.wbg.
|
|
1330
|
+
imports.wbg.__wbg_sleep_e48af34a7ce11555 = function (arg0, arg1) {
|
|
1331
1331
|
const ret = arg0.sleep(arg1);
|
|
1332
1332
|
return ret;
|
|
1333
1333
|
};
|
|
@@ -1347,7 +1347,7 @@ function __wbg_get_imports() {
|
|
|
1347
1347
|
const ret = typeof window === 'undefined' ? null : window;
|
|
1348
1348
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1349
1349
|
};
|
|
1350
|
-
imports.wbg.
|
|
1350
|
+
imports.wbg.__wbg_storeIdentity_6d65d77997c4e424 = function (arg0, arg1) {
|
|
1351
1351
|
const ret = arg1.storeIdentity();
|
|
1352
1352
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1353
1353
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -1368,7 +1368,7 @@ function __wbg_get_imports() {
|
|
|
1368
1368
|
const ret = arg0.then(arg1);
|
|
1369
1369
|
return ret;
|
|
1370
1370
|
};
|
|
1371
|
-
imports.wbg.
|
|
1371
|
+
imports.wbg.__wbg_tool_c59f7574a5578ba1 = function (arg0, arg1, arg2, arg3) {
|
|
1372
1372
|
let deferred0_0;
|
|
1373
1373
|
let deferred0_1;
|
|
1374
1374
|
try {
|
|
@@ -1381,15 +1381,15 @@ function __wbg_get_imports() {
|
|
|
1381
1381
|
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
1382
1382
|
}
|
|
1383
1383
|
};
|
|
1384
|
-
imports.wbg.
|
|
1384
|
+
imports.wbg.__wbg_unlock_679023430ed0a7ca = function (arg0, arg1, arg2) {
|
|
1385
1385
|
const ret = arg0.unlock(getStringFromWasm0(arg1, arg2));
|
|
1386
1386
|
return ret;
|
|
1387
1387
|
};
|
|
1388
|
-
imports.wbg.
|
|
1388
|
+
imports.wbg.__wbg_utcOffsetMinutes_0ba1ff47635aea27 = function (arg0, arg1) {
|
|
1389
1389
|
const ret = arg0.utcOffsetMinutes(arg1);
|
|
1390
1390
|
return ret;
|
|
1391
1391
|
};
|
|
1392
|
-
imports.wbg.
|
|
1392
|
+
imports.wbg.__wbg_wake_f83d318227a0c2ab = function (arg0, arg1) {
|
|
1393
1393
|
arg0.wake(arg1);
|
|
1394
1394
|
};
|
|
1395
1395
|
imports.wbg.__wbg_wasmproject_new = function (arg0) {
|
|
@@ -1428,7 +1428,7 @@ function __wbg_get_imports() {
|
|
|
1428
1428
|
imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function (arg0, arg1) {
|
|
1429
1429
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1430
1430
|
};
|
|
1431
|
-
imports.wbg.
|
|
1431
|
+
imports.wbg.__wbg_writeSecret_f07aee1666487fc5 = function (arg0, arg1, arg2, arg3, arg4) {
|
|
1432
1432
|
let deferred0_0;
|
|
1433
1433
|
let deferred0_1;
|
|
1434
1434
|
try {
|
|
@@ -1441,7 +1441,7 @@ function __wbg_get_imports() {
|
|
|
1441
1441
|
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
1442
1442
|
}
|
|
1443
1443
|
};
|
|
1444
|
-
imports.wbg.
|
|
1444
|
+
imports.wbg.__wbg_write_12da9c010f1662f3 = function (arg0, arg1, arg2, arg3, arg4) {
|
|
1445
1445
|
let deferred0_0;
|
|
1446
1446
|
let deferred0_1;
|
|
1447
1447
|
try {
|
package/dist/core-runtime.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { CoreRuntimeOptions, RuntimeTool, RuntimeToolMetadata } from './com
|
|
|
3
3
|
import type { OpenOptions as ProjectOpenOptions } from './project-types.js';
|
|
4
4
|
import { type BudgetAdjustment, type BudgetSnapshot, type DeferredWrite, type DisplayMessage, type RuntimeDebugObserverOptions, type RuntimeStatus, type SendInput, type SendOptions, type TurnResult, type RuntimeMemoryApi, type RuntimeWiki, type UserWikiResult, type WikiDocument } from './types.js';
|
|
5
5
|
export declare const DEFAULT_MODEL = "deepseek/deepseek-v4.1-flash";
|
|
6
|
-
export declare const SDK_VERSION = "0.5.
|
|
6
|
+
export declare const SDK_VERSION = "0.5.4";
|
|
7
7
|
/** What one round of background upkeep did. */
|
|
8
8
|
export interface MaintenanceResult {
|
|
9
9
|
ran: boolean;
|
|
@@ -77,7 +77,13 @@ export declare const receiptSend: unique symbol;
|
|
|
77
77
|
*/
|
|
78
78
|
export declare class CrocheRuntime {
|
|
79
79
|
private readonly options;
|
|
80
|
-
private
|
|
80
|
+
private coreValue?;
|
|
81
|
+
private closing?;
|
|
82
|
+
private get core();
|
|
83
|
+
private set core(value);
|
|
84
|
+
get disposed(): boolean;
|
|
85
|
+
/** Internal PAL/stream cleanup must not call a disposed wasm-bindgen handle. */
|
|
86
|
+
get closed(): boolean;
|
|
81
87
|
private bindings;
|
|
82
88
|
private debugObserver?;
|
|
83
89
|
private usageObserver?;
|
package/dist/core-runtime.js
CHANGED
|
@@ -4,7 +4,7 @@ import { browserCodec, isToolResult, preparable, prepareImage } from './images.j
|
|
|
4
4
|
import { CrocheError, } from './types.js';
|
|
5
5
|
// Mirrors the protocol default; kept standalone so published SDK imports need no workspace.
|
|
6
6
|
export const DEFAULT_MODEL = 'deepseek/deepseek-v4.1-flash';
|
|
7
|
-
export const SDK_VERSION = '0.5.
|
|
7
|
+
export const SDK_VERSION = '0.5.4';
|
|
8
8
|
const DEFAULT_MAINTENANCE_INTERVAL_MS = 60_000;
|
|
9
9
|
const localOwners = new WeakMap();
|
|
10
10
|
/** The longest delay a JS timer holds (2^31 - 1 ms, about 24.8 days); a longer one fires at once.
|
|
@@ -143,7 +143,17 @@ const storeIds = new WeakMap();
|
|
|
143
143
|
*/
|
|
144
144
|
export class CrocheRuntime {
|
|
145
145
|
options;
|
|
146
|
-
|
|
146
|
+
coreValue;
|
|
147
|
+
closing;
|
|
148
|
+
get core() {
|
|
149
|
+
if (!this.coreValue)
|
|
150
|
+
throw new CrocheError('closed', 'The Runtime is closed.');
|
|
151
|
+
return this.coreValue;
|
|
152
|
+
}
|
|
153
|
+
set core(handle) { this.coreValue = handle; }
|
|
154
|
+
get disposed() { return this.coreValue === undefined; }
|
|
155
|
+
/** Internal PAL/stream cleanup must not call a disposed wasm-bindgen handle. */
|
|
156
|
+
get closed() { return this.disposed || this.core.isClosed(); }
|
|
147
157
|
bindings = new Map();
|
|
148
158
|
debugObserver;
|
|
149
159
|
usageObserver;
|
|
@@ -546,27 +556,35 @@ export class CrocheRuntime {
|
|
|
546
556
|
/** Stops the running turn only: messages sent while it ran still go, together, as the next turn
|
|
547
557
|
* (a send's own `signal` drops just that send while it is held; once its turn has started, the
|
|
548
558
|
* turn stops, for every send it carries). */
|
|
549
|
-
cancel() { if (!this.
|
|
559
|
+
cancel() { if (!this.closed)
|
|
550
560
|
void this.core.cancelTurn().catch(() => { }); } // stops at the call
|
|
551
561
|
/** Drops the messages held behind the running turn (each send ends `cancelled`); returns how many. */
|
|
552
562
|
clearQueued() {
|
|
553
|
-
return this.ordered(undefined, async () => (this.
|
|
563
|
+
return this.ordered(undefined, async () => (this.closed ? 0 : Number(await this.core.clearQueued())));
|
|
554
564
|
}
|
|
555
565
|
/** When the Runtime next wants upkeep, in epoch ms (the same unit as the `clock` option), or null.
|
|
556
566
|
* With an injected clock, call maintain() once clock() reaches it. */
|
|
557
|
-
wakeAt() { return this.core.wakeAt() ?? null; }
|
|
567
|
+
wakeAt() { return this.closed ? null : this.core.wakeAt() ?? null; }
|
|
558
568
|
/** The Core projection fence joins its synchronous listener, not buffered SDK/UI consumers.
|
|
559
569
|
* An app callback that waits for work on the closer's thread deadlocks under any
|
|
560
570
|
* wait-for-callback fence. A synchronous Core-listener self-close does not wait on itself. */
|
|
561
|
-
|
|
562
|
-
this.
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
571
|
+
close() {
|
|
572
|
+
return this.closing ??= (async () => {
|
|
573
|
+
this.removeForegroundListener?.();
|
|
574
|
+
this.removeForegroundListener = undefined;
|
|
575
|
+
if (this.wakeTimer)
|
|
576
|
+
clearTimeout(this.wakeTimer);
|
|
577
|
+
this.wakeTimer = undefined;
|
|
578
|
+
this.ready = false;
|
|
579
|
+
this.clearScheduleTimer();
|
|
580
|
+
const handle = this.core;
|
|
581
|
+
await held(handle.close());
|
|
582
|
+
// Rust close drains/unlocks; it cannot drop the exported owner's reference. The PAL
|
|
583
|
+
// and observers point back to this SDK object, so GC cannot break that cross-language
|
|
584
|
+
// cycle. Release our owner once the drain ends, never while it still owns the store.
|
|
585
|
+
this.coreValue = undefined;
|
|
586
|
+
handle.free();
|
|
587
|
+
})();
|
|
570
588
|
}
|
|
571
589
|
now() { try {
|
|
572
590
|
return Date.parse(hostNow(this.options.clock));
|
|
@@ -728,7 +746,7 @@ export class CrocheRuntime {
|
|
|
728
746
|
this.wakeTimer = undefined;
|
|
729
747
|
if (atMs === null)
|
|
730
748
|
return;
|
|
731
|
-
this.wakeTimer = setTimeout(() => { this.wakeTimer = undefined; void this.
|
|
749
|
+
this.wakeTimer = setTimeout(() => { this.wakeTimer = undefined; void this.coreValue?.tick().catch(() => { }); }, Math.max(0, atMs - Date.now()));
|
|
732
750
|
this.wakeTimer.unref?.();
|
|
733
751
|
},
|
|
734
752
|
// The whole pending set, after each durable change and at open. Without a store lock no
|