@meistrari/agent-core 0.1.11 → 0.1.12
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meistrari/agent-core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.12",
|
|
5
5
|
"packageManager": "bun@1.3.12",
|
|
6
6
|
"description": "Shared contracts and runtime modules for Tela coding-agent sandboxes: agent protocol, supervisor wire protocol, resident supervisor, worker runtime client, and Claude/Codex harness adapters.",
|
|
7
7
|
"license": "UNLICENSED",
|
package/src/provenance.gen.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Generated by scripts/write-provenance.ts. Do not edit by hand.
|
|
2
2
|
export const generatedProvenance = {
|
|
3
|
-
version: "0.1.
|
|
4
|
-
sha: "
|
|
5
|
-
buildTime: "2026-09-
|
|
3
|
+
version: "0.1.12",
|
|
4
|
+
sha: "5ae702eaa6828a3f52fd17ae64587ec3908a205d",
|
|
5
|
+
buildTime: "2026-09-14T18:55:01.358Z",
|
|
6
6
|
} as const
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer'
|
|
2
|
+
|
|
3
|
+
/** Connection-local best effort only; never persisted or acknowledged as durable. */
|
|
4
|
+
export class EphemeralFrameBuffer {
|
|
5
|
+
private readonly frames: { value: string, bytes: number, barrier: number, expires: number }[] = []
|
|
6
|
+
private bytes = 0
|
|
7
|
+
|
|
8
|
+
constructor(private readonly options = { maxFrames: 2048, maxBytes: 1024 * 1024, ttlMs: 10_000, now: Date.now }) {}
|
|
9
|
+
|
|
10
|
+
enqueue(value: string, barrier: number): void {
|
|
11
|
+
this.expire()
|
|
12
|
+
const bytes = Buffer.byteLength(value)
|
|
13
|
+
if (this.frames.length >= this.options.maxFrames || this.bytes + bytes > this.options.maxBytes)
|
|
14
|
+
return
|
|
15
|
+
this.frames.push({ value, bytes, barrier, expires: this.options.now() + this.options.ttlMs })
|
|
16
|
+
this.bytes += bytes
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
flush(ackFloor: number, send: (value: string) => number): void {
|
|
20
|
+
this.expire()
|
|
21
|
+
while (this.frames.length > 0) {
|
|
22
|
+
const frame = this.frames[0]!
|
|
23
|
+
if (frame.barrier > ackFloor || send(frame.value) < 0)
|
|
24
|
+
return
|
|
25
|
+
this.bytes -= frame.bytes
|
|
26
|
+
this.frames.shift()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
clear(): void {
|
|
31
|
+
this.frames.length = 0
|
|
32
|
+
this.bytes = 0
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private expire(): void {
|
|
36
|
+
while (this.frames[0] && this.frames[0].expires <= this.options.now())
|
|
37
|
+
this.bytes -= this.frames.shift()!.bytes
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -11,6 +11,7 @@ import { durabilityOf } from '../supervisor-protocol/durability'
|
|
|
11
11
|
import { wireEventBodySchema } from '../supervisor-protocol/event-body'
|
|
12
12
|
import { maxDurableEventBytes, maxEphemeralDeltaBytes } from '../supervisor-protocol/payload-overflow'
|
|
13
13
|
import { decodeControlPlaneFrame, encodeWireFrame } from '../supervisor-protocol/wire-codec'
|
|
14
|
+
import { EphemeralFrameBuffer } from './ephemeral-frame-buffer'
|
|
14
15
|
import { SupervisorRpcClient } from './rpc-client'
|
|
15
16
|
|
|
16
17
|
export interface ResidentSupervisorSocket {
|
|
@@ -36,6 +37,7 @@ export class SupervisorRuntimeHandler implements RuntimeConnectionHandler {
|
|
|
36
37
|
private eventAckFloor = 0
|
|
37
38
|
private stopped = false
|
|
38
39
|
private readonly retainedFrames: string[] = []
|
|
40
|
+
private readonly ephemeralFrames = new EphemeralFrameBuffer()
|
|
39
41
|
private readonly heartbeatTimer: ReturnType<typeof setInterval>
|
|
40
42
|
|
|
41
43
|
constructor(private readonly dependencies: {
|
|
@@ -67,6 +69,7 @@ export class SupervisorRuntimeHandler implements RuntimeConnectionHandler {
|
|
|
67
69
|
this.socket = input.socket
|
|
68
70
|
this.eventAckFloor = input.eventAckFloor
|
|
69
71
|
this.retainedFrames.length = 0
|
|
72
|
+
this.ephemeralFrames.clear()
|
|
70
73
|
if (previous && previous !== input.socket)
|
|
71
74
|
previous.close(1008, 'Connection generation was superseded.')
|
|
72
75
|
this.rpc.attach(frame => this.sendRetained(frame))
|
|
@@ -107,6 +110,7 @@ export class SupervisorRuntimeHandler implements RuntimeConnectionHandler {
|
|
|
107
110
|
return
|
|
108
111
|
}
|
|
109
112
|
this.eventAckFloor = Math.max(this.eventAckFloor, frame.highWaterMark)
|
|
113
|
+
this.flushEphemeral()
|
|
110
114
|
return
|
|
111
115
|
}
|
|
112
116
|
if (frame.kind === 'rpc.response') {
|
|
@@ -121,6 +125,7 @@ export class SupervisorRuntimeHandler implements RuntimeConnectionHandler {
|
|
|
121
125
|
return
|
|
122
126
|
this.socket = undefined
|
|
123
127
|
this.retainedFrames.length = 0
|
|
128
|
+
this.ephemeralFrames.clear()
|
|
124
129
|
this.rpc.detach()
|
|
125
130
|
}
|
|
126
131
|
|
|
@@ -128,6 +133,7 @@ export class SupervisorRuntimeHandler implements RuntimeConnectionHandler {
|
|
|
128
133
|
if (this.socket !== socket)
|
|
129
134
|
return
|
|
130
135
|
this.flushRetained()
|
|
136
|
+
this.flushEphemeral()
|
|
131
137
|
}
|
|
132
138
|
|
|
133
139
|
async refreshSecrets(input: {
|
|
@@ -154,6 +160,7 @@ export class SupervisorRuntimeHandler implements RuntimeConnectionHandler {
|
|
|
154
160
|
this.rpc.stop()
|
|
155
161
|
this.socket?.close(1001, 'Supervisor runtime stopped.')
|
|
156
162
|
this.socket = undefined
|
|
163
|
+
this.ephemeralFrames.clear()
|
|
157
164
|
await this.processing.catch(() => undefined)
|
|
158
165
|
}
|
|
159
166
|
|
|
@@ -269,14 +276,20 @@ export class SupervisorRuntimeHandler implements RuntimeConnectionHandler {
|
|
|
269
276
|
private sendEvent(event: EventEnvelope): void {
|
|
270
277
|
const frame = encodeWireFrame(event)
|
|
271
278
|
if (event.delivery_semantics === 'ephemeral') {
|
|
272
|
-
if (this.
|
|
279
|
+
if (!this.socket)
|
|
273
280
|
return
|
|
274
|
-
this.
|
|
281
|
+
this.ephemeralFrames.enqueue(frame, this.dependencies.store.localEventMax())
|
|
282
|
+
this.flushEphemeral()
|
|
275
283
|
return
|
|
276
284
|
}
|
|
277
285
|
this.sendRetained(frame)
|
|
278
286
|
}
|
|
279
287
|
|
|
288
|
+
private flushEphemeral(): void {
|
|
289
|
+
if (this.socket && this.retainedFrames.length === 0)
|
|
290
|
+
this.ephemeralFrames.flush(this.eventAckFloor, frame => this.socket!.send(frame))
|
|
291
|
+
}
|
|
292
|
+
|
|
280
293
|
private sendRetained(frame: string): void {
|
|
281
294
|
const socket = this.socket
|
|
282
295
|
if (!socket)
|