stitchkit 0.99.0 → 0.100.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/CHANGELOG.md +44 -0
- package/dist/agent-runtime/contained-darwin.d.ts +0 -17
- package/dist/agent-runtime/contained-darwin.d.ts.map +1 -1
- package/dist/agent-runtime/contained-write.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-attempt.d.ts +22 -0
- package/dist/agent-runtime/invocation-attempt.d.ts.map +1 -0
- package/dist/agent-runtime/invocation-failure.d.ts +6 -0
- package/dist/agent-runtime/invocation-failure.d.ts.map +1 -0
- package/dist/agent-runtime/invocation-payload.d.ts +18 -0
- package/dist/agent-runtime/invocation-payload.d.ts.map +1 -0
- package/dist/agent-runtime/invocation-read.d.ts +131 -0
- package/dist/agent-runtime/invocation-read.d.ts.map +1 -0
- package/dist/agent-runtime/invocation-schema.d.ts +378 -0
- package/dist/agent-runtime/invocation-schema.d.ts.map +1 -0
- package/dist/agent-runtime/invocations.d.ts +46 -0
- package/dist/agent-runtime/invocations.d.ts.map +1 -0
- package/dist/agent-runtime/run-acquisition.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution-state.d.ts +4 -2
- package/dist/agent-runtime/run-execution-state.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/run-failure.d.ts.map +1 -1
- package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -1
- package/dist/agent-runtime/run-operation-lifecycle.d.ts +2 -2
- package/dist/agent-runtime/run-operation-lifecycle.d.ts.map +1 -1
- package/dist/agent-runtime/run-provider-ledger.d.ts +1 -0
- package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +11 -0
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/store-create.d.ts.map +1 -1
- package/dist/agent-runtime/store-event-once.d.ts +29 -0
- package/dist/agent-runtime/store-event-once.d.ts.map +1 -0
- package/dist/agent-runtime/store.d.ts +5 -0
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/application/change-subscription.d.ts +36 -0
- package/dist/application/change-subscription.d.ts.map +1 -0
- package/dist/application/diagnostic-journal-contract.d.ts +3 -6
- package/dist/application/diagnostic-journal-contract.d.ts.map +1 -1
- package/dist/application/notification-delivery.d.ts +32 -0
- package/dist/application/notification-delivery.d.ts.map +1 -0
- package/dist/application/notification-outbox-state.d.ts +37 -0
- package/dist/application/notification-outbox-state.d.ts.map +1 -0
- package/dist/application/notification-outbox.d.ts +7 -1
- package/dist/application/notification-outbox.d.ts.map +1 -1
- package/dist/application/watch-hub-core.d.ts +10 -15
- package/dist/application/watch-hub-core.d.ts.map +1 -1
- package/dist/application/watch-hub.d.ts +10 -2
- package/dist/application/watch-hub.d.ts.map +1 -1
- package/dist/browser/session-credentials.d.ts +20 -0
- package/dist/browser/session-credentials.d.ts.map +1 -0
- package/dist/browser/session.d.ts +31 -0
- package/dist/browser/session.d.ts.map +1 -0
- package/dist/durability/events.d.ts +6 -0
- package/dist/durability/events.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/coding-tools.js +3 -2
- package/dist/entrypoints/agent-runtime/harness.js +5 -3
- package/dist/entrypoints/agent-runtime/sandbox.js +3 -2
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +3 -3
- package/dist/entrypoints/agent-runtime/sqlite/node.js +3 -3
- package/dist/entrypoints/agent-runtime/testing.js +3 -3
- package/dist/entrypoints/agent-runtime.d.ts +3 -0
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +15 -4
- package/dist/entrypoints/application/diagnostic-journal.js +2 -1
- package/dist/entrypoints/application.d.ts +3 -1
- package/dist/entrypoints/application.d.ts.map +1 -1
- package/dist/entrypoints/application.js +629 -189
- package/dist/entrypoints/files.js +2 -1
- package/dist/entrypoints/index.d.ts +2 -0
- package/dist/entrypoints/index.d.ts.map +1 -1
- package/dist/entrypoints/index.js +172 -0
- package/dist/entrypoints/live.js +68 -13
- package/dist/entrypoints/react.d.ts +1 -1
- package/dist/entrypoints/react.d.ts.map +1 -1
- package/dist/entrypoints/react.js +59 -16
- package/dist/{index-wsm5w4ee.js → index-0b1cnze2.js} +35 -3
- package/dist/{index-gxrt5h6v.js → index-cyktc4bp.js} +3 -0
- package/dist/{index-px2gm2jp.js → index-fhwqwxe0.js} +17 -55
- package/dist/{index-e4hkgm5t.js → index-gw8bmyaj.js} +4 -2
- package/dist/{index-8p52kd5p.js → index-js7gqrb1.js} +96 -14
- package/dist/{index-wt743f7f.js → index-k6gpggb9.js} +2 -1
- package/dist/index-q3pyb9n0.js +22 -0
- package/dist/{index-sp1tzwnb.js → index-s84he4v7.js} +2 -2
- package/dist/{index-jhx828hc.js → index-xwhjjw2x.js} +878 -279
- package/dist/{index-1m2thnq0.js → index-y9qn426m.js} +2 -2
- package/dist/index-zjjyynm3.js +42 -0
- package/dist/internal/coalesced-task.d.ts +15 -0
- package/dist/internal/coalesced-task.d.ts.map +1 -0
- package/dist/internal/darwin-binding.d.ts +19 -0
- package/dist/internal/darwin-binding.d.ts.map +1 -0
- package/dist/internal/exclusive-lock.d.ts +20 -7
- package/dist/internal/exclusive-lock.d.ts.map +1 -1
- package/dist/internal/mutation-queue.d.ts +4 -0
- package/dist/internal/mutation-queue.d.ts.map +1 -0
- package/dist/internal/process-identity.d.ts +1 -1
- package/dist/internal/process-identity.d.ts.map +1 -1
- package/dist/internal/process-instance.d.ts +26 -0
- package/dist/internal/process-instance.d.ts.map +1 -0
- package/dist/live/watch-client-state.d.ts +71 -0
- package/dist/live/watch-client-state.d.ts.map +1 -0
- package/dist/live/watch-client.d.ts +5 -1
- package/dist/live/watch-client.d.ts.map +1 -1
- package/dist/live/watch-contract.d.ts +12 -0
- package/dist/live/watch-contract.d.ts.map +1 -1
- package/dist/react/cache-bridge.d.ts +10 -0
- package/dist/react/cache-bridge.d.ts.map +1 -1
- package/llms/agent-runtime.2.txt +94 -0
- package/llms/agent-runtime.3.txt +24 -0
- package/llms/application.2.txt +68 -2
- package/llms/application.txt +32 -2
- package/llms/files.txt +1 -1
- package/llms/live.txt +7 -0
- package/llms/react.txt +8 -0
- package/llms/server.3.txt +35 -0
- package/llms/stitchkit.2.txt +41 -0
- package/llms/stitchkit.3.txt +22 -0
- package/llms/stitchkit.txt +3 -3
- package/llms/upgrading-0.37.0.txt +176 -0
- package/llms/{upgrading-0.37.0-0.58.0.txt → upgrading-0.44.0-0.60.0.txt} +229 -169
- package/llms/{upgrading-0.59.0-0.71.0.txt → upgrading-0.61.0-0.73.0.txt} +122 -229
- package/llms/{upgrading-0.72.0-0.99.0.txt → upgrading-0.74.0-0.100.0.txt} +67 -122
- package/llms/upgrading.txt +4 -3
- package/llms-full.txt +393 -6
- package/llms.txt +10 -9
- package/native/darwin-arm64.node +0 -0
- package/native/darwin-x64.node +0 -0
- package/package.json +1 -1
- package/dist/agent-runtime/run-mutation-queue.d.ts +0 -21
- package/dist/agent-runtime/run-mutation-queue.d.ts.map +0 -1
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
AgentStoredRunSchema,
|
|
11
11
|
appendEventIn,
|
|
12
12
|
createAgentRuntimeStore
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-0b1cnze2.js";
|
|
14
14
|
import {
|
|
15
15
|
AgentRecoverableDescriptorSchema,
|
|
16
16
|
AgentRecoverablePageSchema,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
AgentStoreEventPageSchema,
|
|
19
19
|
AppendAgentStoreEventSchema,
|
|
20
20
|
canonicalAgentJson
|
|
21
|
-
} from "./index-
|
|
21
|
+
} from "./index-cyktc4bp.js";
|
|
22
22
|
import {
|
|
23
23
|
AgentMessageSchema,
|
|
24
24
|
AgentRunSchema
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/internal/darwin-binding.ts
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
function hasFunctions(value, names) {
|
|
7
|
+
return typeof value === "object" && value !== null && names.every((name) => typeof Reflect.get(value, name) === "function");
|
|
8
|
+
}
|
|
9
|
+
var darwinBinding;
|
|
10
|
+
function loadDarwinBinding() {
|
|
11
|
+
if (darwinBinding)
|
|
12
|
+
return darwinBinding;
|
|
13
|
+
const directory = path.dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
const binary = `darwin-${process.arch}.node`;
|
|
15
|
+
const candidates = [
|
|
16
|
+
path.resolve(directory, "../native", binary),
|
|
17
|
+
path.resolve(directory, "../../native", binary)
|
|
18
|
+
];
|
|
19
|
+
const selected = candidates.find((candidate) => existsSync(candidate));
|
|
20
|
+
if (!selected) {
|
|
21
|
+
throw new Error(`Contained filesystem operations need the packaged Darwin ${process.arch} backend`);
|
|
22
|
+
}
|
|
23
|
+
const loaded = createRequire(import.meta.url)(selected);
|
|
24
|
+
const methods = [
|
|
25
|
+
"openDirectoryAt",
|
|
26
|
+
"openFileAt",
|
|
27
|
+
"createFileAt",
|
|
28
|
+
"createDirectoryAt",
|
|
29
|
+
"statAt",
|
|
30
|
+
"listAt",
|
|
31
|
+
"renameAt",
|
|
32
|
+
"unlinkAt",
|
|
33
|
+
"processIdentity"
|
|
34
|
+
];
|
|
35
|
+
if (!hasFunctions(loaded, methods)) {
|
|
36
|
+
throw new Error("The packaged Darwin contained-files backend has an invalid surface");
|
|
37
|
+
}
|
|
38
|
+
darwinBinding = loaded;
|
|
39
|
+
return darwinBinding;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { loadDarwinBinding };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type BackoffPolicy } from './backoff.js';
|
|
2
|
+
export interface CoalescedTask {
|
|
3
|
+
readonly running: boolean;
|
|
4
|
+
trigger(): void;
|
|
5
|
+
pauseRetry(): void;
|
|
6
|
+
close(): void;
|
|
7
|
+
}
|
|
8
|
+
/** One job per key; hints during work become one trailing pass, failures retain retry. */
|
|
9
|
+
export declare function createCoalescedTask(config: {
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
active(): boolean;
|
|
12
|
+
onError(error: unknown): void;
|
|
13
|
+
backoff: BackoffPolicy;
|
|
14
|
+
}): CoalescedTask;
|
|
15
|
+
//# sourceMappingURL=coalesced-task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coalesced-task.d.ts","sourceRoot":"","sources":["../../src/internal/coalesced-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,WAAW,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,OAAO,IAAI,IAAI,CAAC;IAChB,UAAU,IAAI,IAAI,CAAC;IACnB,KAAK,IAAI,IAAI,CAAC;CACf;AAED,0FAA0F;AAC1F,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,MAAM,IAAI,OAAO,CAAC;IAClB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,aAAa,CAAC;CACxB,GAAG,aAAa,CAoDhB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface DarwinEntry {
|
|
2
|
+
name: string;
|
|
3
|
+
mode: number;
|
|
4
|
+
size: number;
|
|
5
|
+
}
|
|
6
|
+
export interface DarwinBinding {
|
|
7
|
+
processIdentity(pid: number): unknown;
|
|
8
|
+
openDirectoryAt(directory: number, name: string): number;
|
|
9
|
+
openFileAt(directory: number, name: string): number;
|
|
10
|
+
createFileAt(directory: number, name: string, mode: number): number;
|
|
11
|
+
createDirectoryAt(directory: number, name: string, mode: number): boolean;
|
|
12
|
+
statAt(directory: number, name: string): Omit<DarwinEntry, 'name'> | null;
|
|
13
|
+
listAt(directory: number): readonly DarwinEntry[];
|
|
14
|
+
renameAt(directory: number, source: string, target: string): void;
|
|
15
|
+
unlinkAt(directory: number, name: string): void;
|
|
16
|
+
}
|
|
17
|
+
export declare function hasFunctions(value: unknown, names: readonly string[]): boolean;
|
|
18
|
+
export declare function loadDarwinBinding(): DarwinBinding;
|
|
19
|
+
//# sourceMappingURL=darwin-binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"darwin-binding.d.ts","sourceRoot":"","sources":["../../src/internal/darwin-binding.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACtC,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACzD,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACpD,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACpE,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1E,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAC1E,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,WAAW,EAAE,CAAC;IAClD,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAClE,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACjD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAM9E;AAID,wBAAgB,iBAAiB,IAAI,aAAa,CAgCjD"}
|
|
@@ -1,15 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type ProcessOwnerEvidence } from './process-instance.js';
|
|
1
3
|
/** Who holds a lock, as its file records it. */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
declare const ExclusiveLockOwnerSchema: z.ZodObject<{
|
|
5
|
+
pid: z.ZodNumber;
|
|
6
|
+
host: z.ZodString;
|
|
7
|
+
acquiredAt: z.ZodString;
|
|
8
|
+
machine: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
9
|
+
process: z.ZodCatch<z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
10
|
+
platform: z.ZodEnum<{
|
|
11
|
+
darwin: "darwin";
|
|
12
|
+
linux: "linux";
|
|
13
|
+
}>;
|
|
14
|
+
bootId: z.ZodString;
|
|
15
|
+
namespace: z.ZodString;
|
|
16
|
+
startId: z.ZodString;
|
|
17
|
+
}, z.core.$strict>>>>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type ExclusiveLockOwner = z.infer<typeof ExclusiveLockOwnerSchema>;
|
|
9
20
|
/** Why a present lock was not taken. */
|
|
10
21
|
export interface ExclusiveLockDiagnosis {
|
|
11
22
|
readonly attribution: 'this-machine' | 'another-machine' | 'unattributable';
|
|
12
23
|
readonly liveness: 'alive' | 'gone' | 'not-probed';
|
|
24
|
+
readonly identity?: ProcessOwnerEvidence['identity'];
|
|
13
25
|
readonly owner: ExclusiveLockOwner | null;
|
|
14
26
|
}
|
|
15
27
|
/** A lock this process holds. */
|
|
@@ -48,4 +60,5 @@ export type ExclusiveLockAttempt = {
|
|
|
48
60
|
export declare function attemptExclusiveLock(path: string, options: ExclusiveLockAttemptOptions): Promise<ExclusiveLockAttempt>;
|
|
49
61
|
/** Read the owner a present lock records, for a refusal that has to name it. */
|
|
50
62
|
export declare function readExclusiveLockOwner(path: string): Promise<ExclusiveLockOwner | null>;
|
|
63
|
+
export {};
|
|
51
64
|
//# sourceMappingURL=exclusive-lock.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exclusive-lock.d.ts","sourceRoot":"","sources":["../../src/internal/exclusive-lock.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"exclusive-lock.d.ts","sourceRoot":"","sources":["../../src/internal/exclusive-lock.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAEL,KAAK,oBAAoB,EAG1B,MAAM,oBAAoB,CAAC;AAK5B,gDAAgD;AAChD,QAAA,MAAM,wBAAwB;;;;;;;;;;;;;;iBAO5B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,wCAAwC;AACxC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,WAAW,EAAE,cAAc,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;IAC5E,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,YAAY,CAAC;IACnD,QAAQ,CAAC,QAAQ,CAAC,EAAE,oBAAoB,CAAC,UAAU,CAAC,CAAC;IACrD,QAAQ,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAC3C;AAED,iCAAiC;AACjC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IACnC,kFAAkF;IAClF,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,uFAAuF;IACvF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED,MAAM,MAAM,oBAAoB,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAA;CAAE,GACpC;IACE,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,6CAA6C;IAC7C,QAAQ,CAAC,SAAS,CAAC,EAAE,sBAAsB,CAAC;CAC7C,CAAC;AAmLN;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,oBAAoB,CAAC,CAe/B;AAED,gFAAgF;AAChF,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAEpC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** FIFO mutations with caller-visible failures and an optional finite admission bound. */
|
|
2
|
+
export type MutationQueue = <T>(mutation: () => Promise<T>) => Promise<T>;
|
|
3
|
+
export declare function createMutationQueue(maxPending?: number): MutationQueue;
|
|
4
|
+
//# sourceMappingURL=mutation-queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutation-queue.d.ts","sourceRoot":"","sources":["../../src/internal/mutation-queue.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAE1E,wBAAgB,mBAAmB,CAAC,UAAU,SAA2B,GAAG,aAAa,CAwBxF"}
|
|
@@ -29,7 +29,7 @@ export declare function machineIdentity(declared: string | undefined): Promise<s
|
|
|
29
29
|
* carries the ordinary doubt about reuse. Found by a consuming application, which measured `Z` and a
|
|
30
30
|
* successful signal on both platforms of its fleet. → ADR 0147.
|
|
31
31
|
*/
|
|
32
|
-
export declare function probeLiveness(pid: number): Promise<'alive' | 'gone'>;
|
|
32
|
+
export declare function probeLiveness(pid: number, reach?: (target: number) => true): Promise<'alive' | 'gone'>;
|
|
33
33
|
/**
|
|
34
34
|
* The state letter of a pid, or `null` where this platform will not say.
|
|
35
35
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-identity.d.ts","sourceRoot":"","sources":["../../src/internal/process-identity.ts"],"names":[],"mappings":"AA8CA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE7D;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,SAAU,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBtF;AAED,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAW1F;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,aAAa,
|
|
1
|
+
{"version":3,"file":"process-identity.d.ts","sourceRoot":"","sources":["../../src/internal/process-identity.ts"],"names":[],"mappings":"AA8CA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE7D;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,SAAU,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBtF;AAED,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAW1F;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,KAAK,YAAY,MAAM,SAA4B,GAClD,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,CAY3B;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,IAAI,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACnD,OAAO,CAAC,OAAO,CAAC,CAuBlB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { probeLiveness } from './process-identity.js';
|
|
3
|
+
export declare const ProcessInstanceSchema: z.ZodObject<{
|
|
4
|
+
platform: z.ZodEnum<{
|
|
5
|
+
darwin: "darwin";
|
|
6
|
+
linux: "linux";
|
|
7
|
+
}>;
|
|
8
|
+
bootId: z.ZodString;
|
|
9
|
+
namespace: z.ZodString;
|
|
10
|
+
startId: z.ZodString;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export type ProcessInstance = z.infer<typeof ProcessInstanceSchema>;
|
|
13
|
+
/** /proc stat field 22 follows a command name that may itself contain spaces and parentheses. */
|
|
14
|
+
export declare function linuxProcessStart(stat: string, pid: number): string | null;
|
|
15
|
+
/** @internal procRoot permits kernel-format fixtures without changing a real process or boot. */
|
|
16
|
+
export declare function readProcessInstance(pid: number, procRoot?: string): Promise<ProcessInstance | null>;
|
|
17
|
+
export interface ProcessOwnerEvidence {
|
|
18
|
+
readonly liveness: 'alive' | 'gone' | 'not-probed';
|
|
19
|
+
readonly identity: 'matched' | 'different-boot' | 'reused-pid' | 'pid-gone' | 'legacy' | 'unavailable';
|
|
20
|
+
}
|
|
21
|
+
/** Compare identities only inside one machine (the caller establishes that boundary). */
|
|
22
|
+
export declare function probeProcessOwner(pid: number, recorded: ProcessInstance | null | undefined, probes?: {
|
|
23
|
+
read: typeof readProcessInstance;
|
|
24
|
+
liveness: typeof probeLiveness;
|
|
25
|
+
}): Promise<ProcessOwnerEvidence>;
|
|
26
|
+
//# sourceMappingURL=process-instance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-instance.d.ts","sourceRoot":"","sources":["../../src/internal/process-instance.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,eAAO,MAAM,qBAAqB;;;;;;;;kBAOvB,CAAC;AACZ,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,iGAAiG;AACjG,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS1E;AAED,iGAAiG;AACjG,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,QAAQ,SAAU,GACjB,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAwCjC;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,YAAY,CAAC;IACnD,QAAQ,CAAC,QAAQ,EACb,SAAS,GACT,gBAAgB,GAChB,YAAY,GACZ,UAAU,GACV,QAAQ,GACR,aAAa,CAAC;CACnB;AAED,yFAAyF;AACzF,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,EAC5C,MAAM;IAAK,IAAI;IAAuB,QAAQ;CAAiB,GAC9D,OAAO,CAAC,oBAAoB,CAAC,CAyB/B"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { WatchClientConfig, WatchListeners } from './watch-client.js';
|
|
2
|
+
import { type WatchKey, type WatchStateFrame, type WatchValueFrame } from './watch-contract.js';
|
|
3
|
+
type Listeners<T> = WatchListeners<T>;
|
|
4
|
+
export interface WatchClientEntry {
|
|
5
|
+
epoch: number;
|
|
6
|
+
released: boolean;
|
|
7
|
+
readonly key: WatchKey;
|
|
8
|
+
readonly args: Record<string, unknown>;
|
|
9
|
+
readonly listeners: Set<Listeners<unknown>>;
|
|
10
|
+
revision: number;
|
|
11
|
+
value?: unknown;
|
|
12
|
+
hasValue: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The server's identity for the value held, carried back on the next `open`.
|
|
15
|
+
*
|
|
16
|
+
* Kept rather than recomputed so that what is offered is what the server
|
|
17
|
+
* actually said, not this client's opinion of the value it built — if those
|
|
18
|
+
* two ever disagree, offering the recomputed one would hide the disagreement
|
|
19
|
+
* and offering the server's one surfaces it as a difference that will not
|
|
20
|
+
* apply.
|
|
21
|
+
*/
|
|
22
|
+
fingerprint?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the **current** connection has been told about this key.
|
|
25
|
+
*
|
|
26
|
+
* On the entry rather than on a handle: two handles asking one question share
|
|
27
|
+
* a subscription, so the second must not send a second `open` — and a
|
|
28
|
+
* reconnect has to clear it for both.
|
|
29
|
+
*/
|
|
30
|
+
opened: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Whether a value frame has answered the latest `open`.
|
|
33
|
+
*
|
|
34
|
+
* A revision is a counter of one hub's life of the key, so it orders frames
|
|
35
|
+
* within one open and says nothing across two: a restarted API starts at 1
|
|
36
|
+
* again. Until the first answer to an open arrives, the held revision is not
|
|
37
|
+
* a floor — without this, a client that held revision 40 from the previous
|
|
38
|
+
* process dropped every full value of the new one as "no newer" until its
|
|
39
|
+
* counter passed 40, while showing itself live.
|
|
40
|
+
*/
|
|
41
|
+
answered: boolean;
|
|
42
|
+
state: WatchStateFrame;
|
|
43
|
+
release?: ReturnType<typeof setTimeout>;
|
|
44
|
+
}
|
|
45
|
+
export declare function publishState(entry: WatchClientEntry, state: WatchStateFrame): void;
|
|
46
|
+
/**
|
|
47
|
+
* Tell the server about a key, and turn every way that can fail into a state.
|
|
48
|
+
*
|
|
49
|
+
* Nothing here rejects. It runs from a subscribe and from a reconnect, neither
|
|
50
|
+
* of which has anywhere to put a rejected promise — and a disconnected socket
|
|
51
|
+
* rejects the request, which is exactly the moment this runs. An unhandled
|
|
52
|
+
* rejection in a console is also the one outcome that tells the subscriber
|
|
53
|
+
* nothing at all.
|
|
54
|
+
*/
|
|
55
|
+
export declare function openWatch(config: WatchClientConfig, openTimeoutMs: number, entry: WatchClientEntry): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* What one value frame does to an entry: a new value, a confirmation of the
|
|
58
|
+
* held one, a late answer to drop, or a reason the key has to start over.
|
|
59
|
+
* The entry's revision, value and fingerprint move here and nowhere else.
|
|
60
|
+
*/
|
|
61
|
+
export declare function applyWatchFrame(entry: WatchClientEntry, frame: WatchValueFrame): {
|
|
62
|
+
kind: 'value';
|
|
63
|
+
value: unknown;
|
|
64
|
+
} | {
|
|
65
|
+
kind: 'confirmed' | 'stale';
|
|
66
|
+
} | {
|
|
67
|
+
kind: 'resync';
|
|
68
|
+
message: string;
|
|
69
|
+
};
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=watch-client-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch-client-state.d.ts","sourceRoot":"","sources":["../../src/live/watch-client-state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,kBAAkB,CAAC;AAG1B,KAAK,SAAS,CAAC,CAAC,IAAI,cAAc,CAAC,CAAC,C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Operation } from '../browser/session.js';
|
|
1
2
|
/**
|
|
2
3
|
* The client half of a watched read.
|
|
3
4
|
*
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
* sense a rendering component can use.
|
|
45
46
|
*/
|
|
46
47
|
import type { ContractDef, EndpointDef } from '../contract/define.js';
|
|
47
|
-
import { WATCH_CLOSE, WATCH_OPEN, WATCH_STATE, WATCH_VALUE, type WatchHave, type WatchKey, type WatchStateFrame, type WatchValueFrame } from './watch-contract.js';
|
|
48
|
+
import { WATCH_CLOSE, type WATCH_OPEN, WATCH_STATE, WATCH_VALUE, type WatchHave, type WatchKey, type WatchStateFrame, type WatchValueFrame } from './watch-contract.js';
|
|
48
49
|
export interface WatchListeners<TValue> {
|
|
49
50
|
value(value: TValue): void;
|
|
50
51
|
/** Phase and, when unhealthy, the read's own code and message. */
|
|
@@ -125,6 +126,9 @@ export interface WatchTransport {
|
|
|
125
126
|
onConnectionChange(listener: (connected: boolean, reason?: string) => void): () => void;
|
|
126
127
|
}
|
|
127
128
|
export interface WatchClientConfig {
|
|
129
|
+
readonly session?: SessionOperation<unknown>;
|
|
130
|
+
readonly maxKeys?: number;
|
|
131
|
+
readonly maxListenersPerKey?: number;
|
|
128
132
|
readonly transport: WatchTransport;
|
|
129
133
|
/** How long a key's value is retained after its last subscriber. Default 0. */
|
|
130
134
|
readonly holdMs?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch-client.d.ts","sourceRoot":"","sources":["../../src/live/watch-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"watch-client.d.ts","sourceRoot":"","sources":["../../src/live/watch-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D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,KAAK,IAAI,CAAC;CAC9D;AAED,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI;KACnE,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,WAAW,CAAC,OAAO,CAAC;CACzE,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACrE,QAAQ,EAAE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,EAChC,MAAM,EAAE,iBAAiB,GACxB,gBAAgB,CAAC,CAAC,CAAC,CAmMrB"}
|
|
@@ -22,6 +22,7 @@ import { z } from 'zod';
|
|
|
22
22
|
/** The identity of one watched read: an operation plus the arguments it was asked with. */
|
|
23
23
|
export declare const WatchKeySchema: z.ZodReadonly<z.ZodObject<{
|
|
24
24
|
service: z.ZodString;
|
|
25
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
25
26
|
action: z.ZodString;
|
|
26
27
|
digest: z.ZodString;
|
|
27
28
|
}, z.core.$strict>>;
|
|
@@ -43,6 +44,7 @@ export type WatchHave = z.infer<typeof WatchHaveSchema>;
|
|
|
43
44
|
export declare const WatchOpenSchema: z.ZodReadonly<z.ZodObject<{
|
|
44
45
|
key: z.ZodReadonly<z.ZodObject<{
|
|
45
46
|
service: z.ZodString;
|
|
47
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
46
48
|
action: z.ZodString;
|
|
47
49
|
digest: z.ZodString;
|
|
48
50
|
}, z.core.$strict>>;
|
|
@@ -59,6 +61,7 @@ export declare const WatchAcceptedSchema: z.ZodReadonly<z.ZodObject<{
|
|
|
59
61
|
export declare const WatchValueSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
|
|
60
62
|
key: z.ZodReadonly<z.ZodObject<{
|
|
61
63
|
service: z.ZodString;
|
|
64
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
62
65
|
action: z.ZodString;
|
|
63
66
|
digest: z.ZodString;
|
|
64
67
|
}, z.core.$strict>>;
|
|
@@ -69,6 +72,7 @@ export declare const WatchValueSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.
|
|
|
69
72
|
}, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
|
|
70
73
|
key: z.ZodReadonly<z.ZodObject<{
|
|
71
74
|
service: z.ZodString;
|
|
75
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
72
76
|
action: z.ZodString;
|
|
73
77
|
digest: z.ZodString;
|
|
74
78
|
}, z.core.$strict>>;
|
|
@@ -80,6 +84,7 @@ export declare const WatchValueSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.
|
|
|
80
84
|
}, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
|
|
81
85
|
key: z.ZodReadonly<z.ZodObject<{
|
|
82
86
|
service: z.ZodString;
|
|
87
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
83
88
|
action: z.ZodString;
|
|
84
89
|
digest: z.ZodString;
|
|
85
90
|
}, z.core.$strict>>;
|
|
@@ -90,6 +95,7 @@ export declare const WatchValueSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.
|
|
|
90
95
|
export declare const WatchStateSchema: z.ZodReadonly<z.ZodObject<{
|
|
91
96
|
key: z.ZodReadonly<z.ZodObject<{
|
|
92
97
|
service: z.ZodString;
|
|
98
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
93
99
|
action: z.ZodString;
|
|
94
100
|
digest: z.ZodString;
|
|
95
101
|
}, z.core.$strict>>;
|
|
@@ -131,6 +137,7 @@ export declare const watchContract: {
|
|
|
131
137
|
readonly args: z.ZodTuple<[z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
|
|
132
138
|
key: z.ZodReadonly<z.ZodObject<{
|
|
133
139
|
service: z.ZodString;
|
|
140
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
134
141
|
action: z.ZodString;
|
|
135
142
|
digest: z.ZodString;
|
|
136
143
|
}, z.core.$strict>>;
|
|
@@ -141,6 +148,7 @@ export declare const watchContract: {
|
|
|
141
148
|
}, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
|
|
142
149
|
key: z.ZodReadonly<z.ZodObject<{
|
|
143
150
|
service: z.ZodString;
|
|
151
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
144
152
|
action: z.ZodString;
|
|
145
153
|
digest: z.ZodString;
|
|
146
154
|
}, z.core.$strict>>;
|
|
@@ -152,6 +160,7 @@ export declare const watchContract: {
|
|
|
152
160
|
}, z.core.$strip>>, z.ZodReadonly<z.ZodObject<{
|
|
153
161
|
key: z.ZodReadonly<z.ZodObject<{
|
|
154
162
|
service: z.ZodString;
|
|
163
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
155
164
|
action: z.ZodString;
|
|
156
165
|
digest: z.ZodString;
|
|
157
166
|
}, z.core.$strict>>;
|
|
@@ -164,6 +173,7 @@ export declare const watchContract: {
|
|
|
164
173
|
readonly args: z.ZodTuple<[z.ZodReadonly<z.ZodObject<{
|
|
165
174
|
key: z.ZodReadonly<z.ZodObject<{
|
|
166
175
|
service: z.ZodString;
|
|
176
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
167
177
|
action: z.ZodString;
|
|
168
178
|
digest: z.ZodString;
|
|
169
179
|
}, z.core.$strict>>;
|
|
@@ -193,6 +203,7 @@ export declare const watchContract: {
|
|
|
193
203
|
readonly args: z.ZodTuple<[z.ZodReadonly<z.ZodObject<{
|
|
194
204
|
key: z.ZodReadonly<z.ZodObject<{
|
|
195
205
|
service: z.ZodString;
|
|
206
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
196
207
|
action: z.ZodString;
|
|
197
208
|
digest: z.ZodString;
|
|
198
209
|
}, z.core.$strict>>;
|
|
@@ -211,6 +222,7 @@ export declare const watchContract: {
|
|
|
211
222
|
readonly args: z.ZodTuple<[z.ZodReadonly<z.ZodObject<{
|
|
212
223
|
key: z.ZodReadonly<z.ZodObject<{
|
|
213
224
|
service: z.ZodString;
|
|
225
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
214
226
|
action: z.ZodString;
|
|
215
227
|
digest: z.ZodString;
|
|
216
228
|
}, z.core.$strict>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch-contract.d.ts","sourceRoot":"","sources":["../../src/live/watch-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,2FAA2F;AAC3F,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"watch-contract.d.ts","sourceRoot":"","sources":["../../src/live/watch-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,2FAA2F;AAC3F,eAAO,MAAM,cAAc;;;;;mBAoBd,CAAC;AACd,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe;;;mBAGf,CAAC;AACd,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,eAAe;;;;;;;;;;;;kBAEf,CAAC;AAEd,eAAO,MAAM,mBAAmB;;;mBAOnB,CAAC;AA6Bd,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAmB3B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;kBAShB,CAAC;AAEd,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC/D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE/D,eAAO,MAAM,UAAU,yBAAyB,CAAC;AACjD,eAAO,MAAM,WAAW,0BAA0B,CAAC;AACnD,eAAO,MAAM,WAAW,0BAA0B,CAAC;AACnD,eAAO,MAAM,WAAW,0BAA0B,CAAC;AAEnD;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;;qBAEL,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBACJ,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAGL,IAAI;;;;;;;;;;;;;qBAA8B,GAAG;;;;;;qBACpC,IAAI;;;;;;;;;;CAKxB,CAAC;AAEF,wEAAwE;AACxE,wBAAgB,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM,CAEpD"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { SessionOperation } from '../browser/session.js';
|
|
2
|
+
import type { WatchHandle } from '../live/watch-client.js';
|
|
3
|
+
import type { WatchStateFrame } from '../live/watch-contract.js';
|
|
1
4
|
/**
|
|
2
5
|
* Cache bridge — wire socket events into the TanStack Query cache.
|
|
3
6
|
*
|
|
@@ -30,7 +33,14 @@ export type CacheBridgeHandler<TPayload> = (data: TPayload, ctx: CacheBridgeCont
|
|
|
30
33
|
export type CacheBridgeHandlers<TEvents> = {
|
|
31
34
|
[K in keyof TEvents & string]?: CacheBridgeHandler<EventPayload<TEvents[K]>>;
|
|
32
35
|
};
|
|
36
|
+
export interface WatchCacheBinding {
|
|
37
|
+
readonly handle: WatchHandle<unknown>;
|
|
38
|
+
readonly queryKey: QueryKey;
|
|
39
|
+
readonly state?: (state: WatchStateFrame) => void;
|
|
40
|
+
}
|
|
33
41
|
export interface CacheBridgeConfig<TEvents> {
|
|
42
|
+
readonly watched?: readonly WatchCacheBinding[];
|
|
43
|
+
readonly session?: SessionOperation<unknown>;
|
|
34
44
|
socket: CacheBridgeSocket<TEvents>;
|
|
35
45
|
/**
|
|
36
46
|
* The TanStack Query client, or a thunk returning it. A thunk is resolved
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-bridge.d.ts","sourceRoot":"","sources":["../../src/react/cache-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEnE,wEAAwE;AACxE,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElE,MAAM,WAAW,iBAAiB,CAAC,OAAO;IACxC,EAAE,CAAC,CAAC,SAAS,MAAM,OAAO,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC;CACjF;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,WAAW,CAAC;IACzB,gFAAgF;IAChF,OAAO,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC;CACjC;AAED,oEAAoE;AACpE,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC;AAE3E,MAAM,MAAM,kBAAkB,CAAC,QAAQ,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,kBAAkB,KAAK,IAAI,CAAC;AAE7F,MAAM,MAAM,mBAAmB,CAAC,OAAO,IAAI;KACxC,CAAC,IAAI,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,EAAE,kBAAkB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;CAC7E,CAAC;AAEF,MAAM,WAAW,iBAAiB,CAAC,OAAO;IACxC,MAAM,EAAE,iBAAiB,CAAC,OAAO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,CAAC,OAAO,CAAC,CAAC;IACnC;;;;;OAKG;IACH,WAAW,EAAE,WAAW,GAAG,CAAC,MAAM,WAAW,CAAC,CAAC;IAC/C,QAAQ,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACvC,0FAA0F;IAC1F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0FAA0F;IAC1F,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,IAAI,IAAI,CAAC;IAChB,UAAU,IAAI,IAAI,CAAC;IACnB;qEACiE;IACjE,SAAS,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC/B,2EAA2E;IAC3E,UAAU,IAAI,IAAI,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,yBAAyB,CAAC,QAAQ,SAAS,qBAAqB,CAC/E,SAAQ,IAAI,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC;IAC1E,MAAM,EAAE,uBAAuB,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;CAClE;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAAG,WAAW,CAiI1F;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,SAAS,qBAAqB,EAC9E,MAAM,EAAE,yBAAyB,CAAC,QAAQ,CAAC,GAC1C,WAAW,CAKb"}
|
package/llms/agent-runtime.2.txt
CHANGED
|
@@ -772,3 +772,97 @@ first mutation**, so an adapter whose runtime rows reference an application-owne
|
|
|
772
772
|
can provision those parents; the optional `cleanup(context)` removes them again, and runs once
|
|
773
773
|
whether the scenario passed or failed. A factory that owns no fixture state ignores the argument and
|
|
774
774
|
keeps working unchanged.
|
|
775
|
+
|
|
776
|
+
## Plain completions and shared invocation receipts
|
|
777
|
+
|
|
778
|
+
Use `createModelInvocationLedger` from `stitchkit/agent-runtime` when a direct text
|
|
779
|
+
completion and an agent must share causal provider evidence. It uses the existing
|
|
780
|
+
runtime store, not a second database. The completion path sends exactly one user
|
|
781
|
+
prompt, no framework instructions and no tools. It never starts an agent loop.
|
|
782
|
+
|
|
783
|
+
```ts
|
|
784
|
+
import { createModelInvocationLedger } from 'stitchkit/agent-runtime';
|
|
785
|
+
|
|
786
|
+
const invocations = createModelInvocationLedger({
|
|
787
|
+
store, // the same AgentRuntimeStore object passed to createAgentRuntime
|
|
788
|
+
models, // an existing defineModelRegistry result
|
|
789
|
+
payloadKey, // 32 bytes from the host's secret store; retain separately from archives
|
|
790
|
+
authorize: async ({ context, conversationId, action, trace }) => {
|
|
791
|
+
const session = await authenticate(context);
|
|
792
|
+
await authorizeConversation(session, conversationId, action, trace);
|
|
793
|
+
return { subject: session.subject }; // verified identity, never a body field
|
|
794
|
+
},
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
const completion = await invocations.complete({
|
|
798
|
+
conversationId: 'evaluation-42',
|
|
799
|
+
idempotencyKey: 'summary-case-3',
|
|
800
|
+
trace: {
|
|
801
|
+
operationId: 'summary-42', purpose: 'summarize', project: 'example',
|
|
802
|
+
parent: { traceId: 'trace-42' }, experiment: 'evaluation', case: 'case-3',
|
|
803
|
+
},
|
|
804
|
+
prompt: 'Summarize these supplied facts.',
|
|
805
|
+
models: ['primary', 'fallback'], // registry keys; repeat a key for an explicit retry
|
|
806
|
+
settings: { maxOutputTokens: 500 },
|
|
807
|
+
timeoutMs: 30_000,
|
|
808
|
+
}, authenticatedContext);
|
|
809
|
+
|
|
810
|
+
// Add to the existing createAgentRuntime configuration:
|
|
811
|
+
const receiptConfig = {
|
|
812
|
+
ledger: invocations,
|
|
813
|
+
trace: ({ run }) => ({
|
|
814
|
+
operationId: run.id, purpose: 'assistant-turn', project: 'example',
|
|
815
|
+
}),
|
|
816
|
+
};
|
|
817
|
+
// createAgentRuntime({ ...existingConfig, invocations: receiptConfig });
|
|
818
|
+
|
|
819
|
+
const page = await invocations.read({
|
|
820
|
+
conversationId: 'evaluation-42', limit: 100,
|
|
821
|
+
}, authenticatedContext);
|
|
822
|
+
// Continue with fromSeq: page.nextSeq while it is defined.
|
|
823
|
+
```
|
|
824
|
+
|
|
825
|
+
`complete` returns `invocationId`, `outcome` and, on success, `text`. `duplicate`
|
|
826
|
+
returns the existing ID without provider execution or replaying plaintext. Changed
|
|
827
|
+
input, trace or caller under the same key is a conflict. Model attempts are explicit
|
|
828
|
+
and bounded to eight; SDK retries are disabled. Only provider failures trigger the
|
|
829
|
+
next attempt. Abort, audit refusal and configuration errors do not. An admitted call
|
|
830
|
+
whose process died stays claimed: inspect the receipt before choosing a new key.
|
|
831
|
+
|
|
832
|
+
The agent retains its existing prompt, tools and loop. Both modes produce
|
|
833
|
+
`invocation/started`, `provider/request`, `provider/response` and
|
|
834
|
+
`invocation/finished` records through `read`. Each attempt has its own ID; response
|
|
835
|
+
usage is counted once and keeps `unavailable` distinct from measured zero. Requested
|
|
836
|
+
registry selection, sent adapter identity and effective provider identity are
|
|
837
|
+
separate. Effective identity is null when not reported. A gateway's hidden retries
|
|
838
|
+
are not visible as additional attempts.
|
|
839
|
+
|
|
840
|
+
`currentModelInvocationAttempt()` returns the causal context inside a provider's
|
|
841
|
+
`fetch` callback or streamed read. Use it to join a host transport audit to
|
|
842
|
+
`operationId`, `invocationId`, `attemptId`, optional `runId` and `step`.
|
|
843
|
+
`onAttempt` is an awaited admission hook; a rejected hook prevents the provider call.
|
|
844
|
+
SDK payload hashes are not represented as hashes of HTTP wire bytes.
|
|
845
|
+
|
|
846
|
+
Prompts and output are AES-256-GCM payload artifacts. `read` returns references and
|
|
847
|
+
hashes; `readPayload({ conversationId, artifactId }, context)` separately authorizes
|
|
848
|
+
`read-payload` and checks authentication tags and hashes. `payloadKey` must be 32
|
|
849
|
+
bytes and is copied at construction. Keep it outside the event store/backups; retain
|
|
850
|
+
the appropriate key when restoring an archive. `maxPayloadBytes` defaults to 4 MiB
|
|
851
|
+
(range 1 KiB–64 MiB); streaming output evidence is capped at 1 MiB. Request headers
|
|
852
|
+
are excluded. Protect existing agent history independently: enabling receipts does
|
|
853
|
+
not encrypt its ordinary conversation records.
|
|
854
|
+
|
|
855
|
+
The built-in memory and SQLite stores implement `appendEventOnce`. Custom stores
|
|
856
|
+
must implement its once-only check and append atomically, returning the original
|
|
857
|
+
event on a duplicate key scoped by conversation and kind. A factory without this
|
|
858
|
+
capability refuses receipt setup. The driver-backed implementation reads bounded
|
|
859
|
+
pages under one transaction, without another table or database.
|
|
860
|
+
|
|
861
|
+
### Migration from direct SDK completions
|
|
862
|
+
|
|
863
|
+
**Who must act:** applications opting into shared completion/agent receipts.
|
|
864
|
+
Replace the direct `generateText` call with `invocations.complete`, configure host
|
|
865
|
+
authorization and a retained payload key, and pass the same ledger in the agent's
|
|
866
|
+
`invocations` option. Use the returned invocation ID and the paginated `read` method
|
|
867
|
+
for receipt queries; do not import runtime internals. This API is unreleased; it is
|
|
868
|
+
not present in 0.99.0. Existing runtime configurations need no migration.
|
package/llms/agent-runtime.3.txt
CHANGED
|
@@ -266,6 +266,30 @@ Managed effects and operator telemetry additionally export `AgentToolFenceConfig
|
|
|
266
266
|
may accompany checkpoint/terminal writes and tool context; internal causes are redacted unless an
|
|
267
267
|
operator-only observability sink explicitly opts in.
|
|
268
268
|
|
|
269
|
+
### Completion and agent invocation receipts
|
|
270
|
+
|
|
271
|
+
`createModelInvocationLedger` constructs a `ModelInvocationLedger` from
|
|
272
|
+
`ModelInvocationConfig`: the existing store and model registry, a 32-byte payload
|
|
273
|
+
key, required host authorization, optional bounded payload size and `onAttempt`.
|
|
274
|
+
`complete(input, context, signal?)` executes only the supplied prompt, with no tools
|
|
275
|
+
or framework instructions; repeated keys return the existing invocation ID.
|
|
276
|
+
`read(input, context)` returns a bounded event page shared by agent and completion;
|
|
277
|
+
`readPayload(input, context)` requires a separate authorization action to decrypt
|
|
278
|
+
one protected artifact. See the [guide and migration example](../guide/agent-runtime.md#plain-completions-and-shared-invocation-receipts).
|
|
279
|
+
|
|
280
|
+
| Export | Kind | Purpose |
|
|
281
|
+
| --- | --- | --- |
|
|
282
|
+
| `CompletionInvocationInputSchema` / `CompletionInvocationInput` | schema/type | strict prompt, model-attempt list, deadline, idempotency key and trace input |
|
|
283
|
+
| `ModelInvocationTraceSchema` / `ModelInvocationTrace` | schema/type | operation, purpose, project, parent trace and optional experiment/case/profile |
|
|
284
|
+
| `ModelInvocationRecordSchema` / `ModelInvocationRecord` | schema/type | discriminated invocation start/finish and per-attempt requested/sent/effective evidence |
|
|
285
|
+
| `ModelInvocationAttemptContext` | type | conversation, operation, invocation, attempt, step and optional agent run identity |
|
|
286
|
+
| `currentModelInvocationAttempt` | function | returns causal IDs inside the provider transport; undefined outside an invocation |
|
|
287
|
+
|
|
288
|
+
The runtime `invocations` option takes this ledger and a trace callback; it requires
|
|
289
|
+
the same store and preserves the existing tool loop. `AgentRuntimeStore.appendEventOnce`
|
|
290
|
+
is an optional atomic capability required by receipt admission. Built-in stores
|
|
291
|
+
supply it; custom adapters must honor its once-only transaction contract.
|
|
292
|
+
|
|
269
293
|
==============================================================================
|
|
270
294
|
# API reference: `stitchkit-tui` (docs/api/reference.md)
|
|
271
295
|
==============================================================================
|