stitchkit 0.99.0 → 0.100.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/CHANGELOG.md +124 -1
- 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 +28 -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 +20 -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 +52 -0
- package/dist/agent-runtime/invocations.d.ts.map +1 -0
- package/dist/agent-runtime/projections.d.ts.map +1 -1
- 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/schedule-dispatch.d.ts +9 -2
- package/dist/agent-runtime/schedule-dispatch.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-records.d.ts +8 -2
- package/dist/agent-runtime/schedule-records.d.ts.map +1 -1
- package/dist/agent-runtime/schedules.d.ts +5 -0
- package/dist/agent-runtime/schedules.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-events.d.ts.map +1 -1
- package/dist/agent-runtime/store-create.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver-contract.d.ts +9 -0
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
- package/dist/agent-runtime/store-event-once.d.ts +37 -0
- package/dist/agent-runtime/store-event-once.d.ts.map +1 -0
- package/dist/agent-runtime/store-memory.d.ts.map +1 -1
- package/dist/agent-runtime/store.d.ts +11 -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 +55 -0
- package/dist/application/notification-delivery.d.ts.map +1 -0
- package/dist/application/notification-outbox-state.d.ts +41 -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 +14 -84
- package/dist/application/watch-hub-core.d.ts.map +1 -1
- package/dist/application/watch-hub-source.d.ts +98 -0
- package/dist/application/watch-hub-source.d.ts.map +1 -0
- 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 +26 -0
- package/dist/browser/session-credentials.d.ts.map +1 -0
- package/dist/browser/session.d.ts +33 -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 +65 -20
- 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 +820 -294
- package/dist/entrypoints/files.js +9 -2
- package/dist/entrypoints/index.d.ts +2 -0
- package/dist/entrypoints/index.d.ts.map +1 -1
- package/dist/entrypoints/index.js +199 -0
- package/dist/entrypoints/live.js +78 -19
- package/dist/entrypoints/node.js +1 -1
- 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/entrypoints/server.js +4 -4
- package/dist/{index-sp1tzwnb.js → index-10x2hbx0.js} +5 -2
- package/dist/{index-8p52kd5p.js → index-c6bxbsnc.js} +100 -14
- package/dist/{index-gxrt5h6v.js → index-cyktc4bp.js} +3 -0
- package/dist/{index-1m2thnq0.js → index-eaysmdtq.js} +11 -2
- package/dist/{index-jhx828hc.js → index-f4fx2tza.js} +948 -279
- package/dist/{index-px2gm2jp.js → index-fhwqwxe0.js} +17 -55
- package/dist/{index-e4hkgm5t.js → index-gw8bmyaj.js} +4 -2
- package/dist/{index-p3vsv1fb.js → index-hadmp193.js} +14 -5
- package/dist/{index-wt743f7f.js → index-k6gpggb9.js} +2 -1
- package/dist/index-q3pyb9n0.js +22 -0
- package/dist/{index-wsm5w4ee.js → index-vqr7f7v8.js} +51 -3
- package/dist/index-zjjyynm3.js +42 -0
- package/dist/internal/coalesced-task.d.ts +17 -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/internal/with-exclusive-lock.d.ts.map +1 -1
- 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/dist/server/realtime.d.ts.map +1 -1
- package/llms/agent-runtime.2.txt +102 -0
- package/llms/agent-runtime.3.txt +30 -1
- package/llms/agent-runtime.txt +8 -3
- package/llms/application.2.txt +84 -2
- package/llms/application.txt +32 -2
- package/llms/files.txt +1 -1
- package/llms/live.txt +8 -0
- package/llms/react.txt +8 -0
- package/llms/server.3.txt +57 -0
- package/llms/stitchkit.2.txt +41 -0
- package/llms/stitchkit.3.txt +26 -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} +80 -123
- package/llms/upgrading.txt +4 -3
- package/llms-full.txt +471 -11
- 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
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadDarwinBinding
|
|
3
|
+
} from "./index-zjjyynm3.js";
|
|
1
4
|
import {
|
|
2
5
|
isRecord
|
|
3
6
|
} from "./index-hffjpmq9.js";
|
|
@@ -6,6 +9,7 @@ import {
|
|
|
6
9
|
import { constants } from "node:fs";
|
|
7
10
|
import { lstat, open, unlink } from "node:fs/promises";
|
|
8
11
|
import { hostname } from "node:os";
|
|
12
|
+
import { z as z2 } from "zod";
|
|
9
13
|
|
|
10
14
|
// src/internal/process-identity.ts
|
|
11
15
|
import { execFile } from "node:child_process";
|
|
@@ -47,9 +51,9 @@ async function machineIdentity(declared) {
|
|
|
47
51
|
detectedIdentity = platform() === "darwin" ? await readDarwinPlatformUuid() : await firstReadableLine(["/etc/machine-id", "/var/lib/dbus/machine-id"]);
|
|
48
52
|
return detectedIdentity;
|
|
49
53
|
}
|
|
50
|
-
async function probeLiveness(pid) {
|
|
54
|
+
async function probeLiveness(pid, reach = (target) => process.kill(target, 0)) {
|
|
51
55
|
try {
|
|
52
|
-
|
|
56
|
+
reach(pid);
|
|
53
57
|
} catch (error) {
|
|
54
58
|
return isRecord(error) && error.code === "ESRCH" ? "gone" : "alive";
|
|
55
59
|
}
|
|
@@ -73,7 +77,96 @@ async function isZombieProcess(pid, seam = {}) {
|
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
|
|
80
|
+
// src/internal/process-instance.ts
|
|
81
|
+
import { readFile as readFile2, readlink } from "node:fs/promises";
|
|
82
|
+
import { platform as platform2 } from "node:os";
|
|
83
|
+
import { z } from "zod";
|
|
84
|
+
var ProcessInstanceSchema = z.object({
|
|
85
|
+
platform: z.enum(["linux", "darwin"]),
|
|
86
|
+
bootId: z.string().min(1),
|
|
87
|
+
namespace: z.string().min(1),
|
|
88
|
+
startId: z.string().regex(/^\d+$/)
|
|
89
|
+
}).strict();
|
|
90
|
+
function linuxProcessStart(stat, pid) {
|
|
91
|
+
if (!stat.startsWith(`${pid} (`))
|
|
92
|
+
return null;
|
|
93
|
+
const end = stat.lastIndexOf(")");
|
|
94
|
+
if (end < 0)
|
|
95
|
+
return null;
|
|
96
|
+
const start = stat.slice(end + 1).trim().split(/\s+/)[19];
|
|
97
|
+
return start !== undefined && /^\d+$/.test(start) ? start : null;
|
|
98
|
+
}
|
|
99
|
+
async function readProcessInstance(pid, procRoot = "/proc") {
|
|
100
|
+
try {
|
|
101
|
+
if (platform2() === "darwin") {
|
|
102
|
+
const result = ProcessInstanceSchema.safeParse(loadDarwinBinding().processIdentity(pid));
|
|
103
|
+
return result.success ? result.data : null;
|
|
104
|
+
}
|
|
105
|
+
if (platform2() !== "linux")
|
|
106
|
+
return null;
|
|
107
|
+
const [bootId, namespace, ownStatus, timeNamespace, ownStat, stat] = await Promise.all([
|
|
108
|
+
readFile2(`${procRoot}/sys/kernel/random/boot_id`, "utf8"),
|
|
109
|
+
readlink(`${procRoot}/self/ns/pid`),
|
|
110
|
+
readFile2(`${procRoot}/self/status`, "utf8"),
|
|
111
|
+
readlink(`${procRoot}/self/ns/time`).catch((error) => {
|
|
112
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
113
|
+
return "";
|
|
114
|
+
throw error;
|
|
115
|
+
}),
|
|
116
|
+
readFile2(`${procRoot}/self/stat`, "utf8"),
|
|
117
|
+
readFile2(`${procRoot}/${pid}/stat`, "utf8")
|
|
118
|
+
]);
|
|
119
|
+
const namespacePids = ownStatus.match(/^NStgid:[ \t]*(.*)$/m)?.[1]?.trim().split(/\s+/);
|
|
120
|
+
if (namespacePids?.length !== 1 || namespacePids[0] !== String(process.pid) || linuxProcessStart(ownStat, process.pid) === null)
|
|
121
|
+
return null;
|
|
122
|
+
const startId = linuxProcessStart(stat, pid);
|
|
123
|
+
if (startId === null || !bootId.trim())
|
|
124
|
+
return null;
|
|
125
|
+
return {
|
|
126
|
+
platform: "linux",
|
|
127
|
+
bootId: bootId.trim(),
|
|
128
|
+
namespace: `${namespace};${timeNamespace}`,
|
|
129
|
+
startId
|
|
130
|
+
};
|
|
131
|
+
} catch {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async function probeProcessOwner(pid, recorded, probes = { read: readProcessInstance, liveness: probeLiveness }) {
|
|
136
|
+
if (recorded === undefined)
|
|
137
|
+
return { liveness: await probes.liveness(pid), identity: "legacy" };
|
|
138
|
+
const unavailable = {
|
|
139
|
+
liveness: "not-probed",
|
|
140
|
+
identity: "unavailable"
|
|
141
|
+
};
|
|
142
|
+
if (recorded === null)
|
|
143
|
+
return unavailable;
|
|
144
|
+
const current = await probes.read(process.pid);
|
|
145
|
+
if (!current || recorded.platform !== current.platform)
|
|
146
|
+
return unavailable;
|
|
147
|
+
if (recorded.bootId !== current.bootId)
|
|
148
|
+
return { liveness: "gone", identity: "different-boot" };
|
|
149
|
+
if (recorded.namespace !== current.namespace)
|
|
150
|
+
return unavailable;
|
|
151
|
+
const liveness = await probes.liveness(pid);
|
|
152
|
+
if (liveness === "gone")
|
|
153
|
+
return { liveness, identity: "pid-gone" };
|
|
154
|
+
const observed = await probes.read(pid);
|
|
155
|
+
if (!observed || observed.bootId !== current.bootId || observed.namespace !== current.namespace)
|
|
156
|
+
return unavailable;
|
|
157
|
+
if (recorded.startId !== observed.startId)
|
|
158
|
+
return { liveness: "gone", identity: "reused-pid" };
|
|
159
|
+
return { liveness: "alive", identity: "matched" };
|
|
160
|
+
}
|
|
161
|
+
|
|
76
162
|
// src/internal/exclusive-lock.ts
|
|
163
|
+
var ExclusiveLockOwnerSchema = z2.object({
|
|
164
|
+
pid: z2.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
165
|
+
host: z2.string().min(1),
|
|
166
|
+
acquiredAt: z2.string(),
|
|
167
|
+
machine: z2.string().min(1).optional().catch(undefined),
|
|
168
|
+
process: ProcessInstanceSchema.nullable().optional().catch(null)
|
|
169
|
+
});
|
|
77
170
|
function isCode(error, code) {
|
|
78
171
|
return isRecord(error) && error.code === code;
|
|
79
172
|
}
|
|
@@ -84,17 +177,8 @@ function readOwner(text) {
|
|
|
84
177
|
} catch {
|
|
85
178
|
return;
|
|
86
179
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const { pid, host, acquiredAt, machine } = parsed;
|
|
90
|
-
if (typeof pid !== "number" || !Number.isSafeInteger(pid) || pid <= 0)
|
|
91
|
-
return;
|
|
92
|
-
if (typeof host !== "string" || host.length === 0)
|
|
93
|
-
return;
|
|
94
|
-
if (typeof acquiredAt !== "string")
|
|
95
|
-
return;
|
|
96
|
-
const identified = typeof machine === "string" && machine.length > 0 ? { machine } : {};
|
|
97
|
-
return { pid, host, acquiredAt, ...identified };
|
|
180
|
+
const owner = ExclusiveLockOwnerSchema.safeParse(parsed);
|
|
181
|
+
return owner.success ? owner.data : undefined;
|
|
98
182
|
}
|
|
99
183
|
function attribute(owner, identity) {
|
|
100
184
|
if (identity !== null && owner.machine !== undefined) {
|
|
@@ -108,7 +192,7 @@ async function diagnose(owner, declaredIdentity) {
|
|
|
108
192
|
const attribution = attribute(owner, await machineIdentity(declaredIdentity));
|
|
109
193
|
if (attribution !== "this-machine")
|
|
110
194
|
return { attribution, liveness: "not-probed", owner };
|
|
111
|
-
return { attribution,
|
|
195
|
+
return { attribution, ...await probeProcessOwner(owner.pid, owner.process), owner };
|
|
112
196
|
}
|
|
113
197
|
async function readLockFile(path) {
|
|
114
198
|
let handle;
|
|
@@ -140,9 +224,11 @@ async function unlinkIfSame(path, ino) {
|
|
|
140
224
|
}
|
|
141
225
|
async function createOwned(path, options, reclaimed) {
|
|
142
226
|
const identity = await machineIdentity(options.machineIdentity);
|
|
227
|
+
const instance = await readProcessInstance(process.pid);
|
|
143
228
|
const handle = await open(path, "wx", options.mode);
|
|
144
229
|
const owner = {
|
|
145
230
|
pid: process.pid,
|
|
231
|
+
process: instance,
|
|
146
232
|
host: hostname(),
|
|
147
233
|
acquiredAt: new Date().toISOString(),
|
|
148
234
|
...identity !== null && { machine: identity }
|
|
@@ -17,6 +17,9 @@ import { z } from "zod";
|
|
|
17
17
|
var AgentStoreEventKindSchema = z.enum([
|
|
18
18
|
"runtime/baseline",
|
|
19
19
|
"runtime/transition",
|
|
20
|
+
"invocation/started",
|
|
21
|
+
"invocation/finished",
|
|
22
|
+
"provider/payload",
|
|
20
23
|
"provider/request",
|
|
21
24
|
"provider/response",
|
|
22
25
|
"provider/message",
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
AgentStoredRunSchema,
|
|
11
11
|
appendEventIn,
|
|
12
12
|
createAgentRuntimeStore
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-vqr7f7v8.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
|
|
@@ -528,6 +528,15 @@ var sqliteEvents = {
|
|
|
528
528
|
items,
|
|
529
529
|
...hasMore && lastEvent ? { nextSeq: lastEvent.seq + 1 } : {}
|
|
530
530
|
});
|
|
531
|
+
},
|
|
532
|
+
async find(transaction, input) {
|
|
533
|
+
const row = transaction.prepare(`
|
|
534
|
+
SELECT event_id, conversation_id, seq, schema_version, kind, occurred_at,
|
|
535
|
+
ignorable, payload
|
|
536
|
+
FROM stitchkit_agent_runtime_events
|
|
537
|
+
WHERE event_id = ? AND conversation_id = ?
|
|
538
|
+
`).get(input.eventId, input.conversationId);
|
|
539
|
+
return row === null || row === undefined ? undefined : parseEventRow(row);
|
|
531
540
|
}
|
|
532
541
|
};
|
|
533
542
|
var sqliteArchive = {
|