@agent-relay/factory 0.1.31 → 0.1.33
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 +36 -0
- package/dist/cli/fleet.d.ts +4 -1
- package/dist/cli/fleet.d.ts.map +1 -1
- package/dist/cli/fleet.js +113 -6
- package/dist/cli/fleet.js.map +1 -1
- package/dist/config/schema.d.ts +88 -8
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +10 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/dispatch/templates.d.ts.map +1 -1
- package/dist/dispatch/templates.js +6 -2
- package/dist/dispatch/templates.js.map +1 -1
- package/dist/fleet/internal-fleet-client.d.ts +9 -2
- package/dist/fleet/internal-fleet-client.d.ts.map +1 -1
- package/dist/fleet/internal-fleet-client.js +39 -1
- package/dist/fleet/internal-fleet-client.js.map +1 -1
- package/dist/fleet/relay-fleet-client.d.ts +1 -0
- package/dist/fleet/relay-fleet-client.d.ts.map +1 -1
- package/dist/fleet/relay-fleet-client.js +1 -0
- package/dist/fleet/relay-fleet-client.js.map +1 -1
- package/dist/git/agent-worktree.d.ts.map +1 -1
- package/dist/git/agent-worktree.js +52 -2
- package/dist/git/agent-worktree.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/observability/cloud-reporter.d.ts +46 -0
- package/dist/observability/cloud-reporter.d.ts.map +1 -0
- package/dist/observability/cloud-reporter.js +371 -0
- package/dist/observability/cloud-reporter.js.map +1 -0
- package/dist/observability/events.d.ts +1275 -0
- package/dist/observability/events.d.ts.map +1 -0
- package/dist/observability/events.js +229 -0
- package/dist/observability/events.js.map +1 -0
- package/dist/observability/index.d.ts +5 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +5 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/instance-identity.d.ts +7 -0
- package/dist/observability/instance-identity.d.ts.map +1 -0
- package/dist/observability/instance-identity.js +59 -0
- package/dist/observability/instance-identity.js.map +1 -0
- package/dist/observability/outbox.d.ts +42 -0
- package/dist/observability/outbox.d.ts.map +1 -0
- package/dist/observability/outbox.js +305 -0
- package/dist/observability/outbox.js.map +1 -0
- package/dist/orchestrator/factory.d.ts.map +1 -1
- package/dist/orchestrator/factory.js +465 -59
- package/dist/orchestrator/factory.js.map +1 -1
- package/dist/ports/fleet.d.ts +5 -4
- package/dist/ports/fleet.d.ts.map +1 -1
- package/dist/ports/index.d.ts +1 -0
- package/dist/ports/index.d.ts.map +1 -1
- package/dist/ports/observability.d.ts +19 -0
- package/dist/ports/observability.d.ts.map +1 -0
- package/dist/ports/observability.js +2 -0
- package/dist/ports/observability.js.map +1 -0
- package/dist/ports/worktree.d.ts +2 -0
- package/dist/ports/worktree.d.ts.map +1 -1
- package/dist/triage/schema.d.ts +14 -14
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/observability/events.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,+BAA+B,EAAG,sBAA+B,CAAA;AAC9E,eAAO,MAAM,kCAAkC,MAAM,CAAA;AACrD,+DAA+D;AAC/D,eAAO,MAAM,qCAAqC,QAAa,CAAA;AAE/D,eAAO,MAAM,gCAAgC,qMAanC,CAAA;AAEV,MAAM,MAAM,2BAA2B,GAAG,CAAC,OAAO,gCAAgC,CAAC,CAAC,MAAM,CAAC,CAAA;AAE3F,eAAO,MAAM,yBAAyB,gpBAiC5B,CAAA;AAEV,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAU9F,eAAO,MAAM,2BAA2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AO,CAAC,IAAI,CAAC,wBAAwB,EAAE,IAAI,GAAG,YAAY,CAAC,CAAC,EACzH,OAAO,GAAE,gCAAqC,GAC7C,wBAAwB,CAQ1B;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,2BAA2B,GAAG,SAAS,CAmC9G;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,IAAI,CAAC,wBAAwB,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC,GAAG,OAAO,CAQvH"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const FACTORY_CLOUD_EVENT_CONTRACT_V1 = 'factory.telemetry.v1';
|
|
4
|
+
export const FACTORY_CLOUD_EVENT_MAX_BATCH_SIZE = 100;
|
|
5
|
+
/** Leave headroom below Cloud's 256 KiB request-body limit. */
|
|
6
|
+
export const FACTORY_CLOUD_EVENT_MAX_PAYLOAD_BYTES = 240 * 1024;
|
|
7
|
+
export const FACTORY_CLOUD_RELEASE_REASONS_V1 = [
|
|
8
|
+
'completed',
|
|
9
|
+
'human_review',
|
|
10
|
+
'factory_stopped',
|
|
11
|
+
'waiting_for_human',
|
|
12
|
+
'exited',
|
|
13
|
+
'offline',
|
|
14
|
+
'node_offline',
|
|
15
|
+
'crashed',
|
|
16
|
+
'reconciled_missing',
|
|
17
|
+
'delivery_failed',
|
|
18
|
+
'dispatch_failed',
|
|
19
|
+
'other',
|
|
20
|
+
];
|
|
21
|
+
export const FACTORY_CLOUD_EVENT_TYPES = [
|
|
22
|
+
'instance.started',
|
|
23
|
+
'instance.heartbeat',
|
|
24
|
+
'instance.stopping',
|
|
25
|
+
'instance.stopped',
|
|
26
|
+
'run.queued',
|
|
27
|
+
'run.started',
|
|
28
|
+
'run.phase_changed',
|
|
29
|
+
'run.waiting',
|
|
30
|
+
'run.blocked',
|
|
31
|
+
'run.succeeded',
|
|
32
|
+
'run.failed',
|
|
33
|
+
'run.cancelled',
|
|
34
|
+
'agent.planned',
|
|
35
|
+
'agent.spawned',
|
|
36
|
+
'agent.adopted',
|
|
37
|
+
'agent.resumed',
|
|
38
|
+
'agent.exited',
|
|
39
|
+
'agent.released',
|
|
40
|
+
'clarification.requested',
|
|
41
|
+
'clarification.delivered',
|
|
42
|
+
'clarification.waiting',
|
|
43
|
+
'clarification.answered',
|
|
44
|
+
'clarification.woken',
|
|
45
|
+
'clarification.escalated',
|
|
46
|
+
'pull_request.discovered',
|
|
47
|
+
'pull_request.published',
|
|
48
|
+
'pull_request.ready',
|
|
49
|
+
'pull_request.merged',
|
|
50
|
+
'writeback.applied',
|
|
51
|
+
'factory.failure',
|
|
52
|
+
'factory.anomaly',
|
|
53
|
+
'factory.snapshot',
|
|
54
|
+
];
|
|
55
|
+
const opaqueString = z.string().trim().min(1).max(256);
|
|
56
|
+
const categoryString = z.string().trim().min(1).max(120).regex(/^[a-zA-Z0-9][a-zA-Z0-9._:/-]*$/u);
|
|
57
|
+
const nonNegativeInteger = z.number().int().nonnegative();
|
|
58
|
+
const boundedCount = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
59
|
+
const W3C_INVALID_TRACE_ID = '00000000000000000000000000000000';
|
|
60
|
+
const W3C_INVALID_SPAN_ID = '0000000000000000';
|
|
61
|
+
const FACTORY_RUN_TRACE_DOMAIN_V1 = 'agent-relay.factory.run-trace.v1\0';
|
|
62
|
+
export const FactoryCloudTraceIdV1Schema = z.string()
|
|
63
|
+
.regex(/^[a-f0-9]{32}$/u)
|
|
64
|
+
.refine((value) => value !== W3C_INVALID_TRACE_ID, 'traceId must not be all zeroes');
|
|
65
|
+
export const FactoryCloudSpanIdV1Schema = z.string()
|
|
66
|
+
.regex(/^[a-f0-9]{16}$/u)
|
|
67
|
+
.refine((value) => value !== W3C_INVALID_SPAN_ID, 'spanId must not be all zeroes');
|
|
68
|
+
/**
|
|
69
|
+
* Deliberately narrow operational attributes. This is not a general log bag:
|
|
70
|
+
* task text, prompts, issue descriptions, messages, paths, URLs, command lines,
|
|
71
|
+
* stack traces, and raw error messages have no representable field.
|
|
72
|
+
*/
|
|
73
|
+
export const FactoryCloudEventAttributesV1Schema = z.object({
|
|
74
|
+
backend: categoryString.optional(),
|
|
75
|
+
mode: categoryString.optional(),
|
|
76
|
+
component: categoryString.optional(),
|
|
77
|
+
operation: categoryString.optional(),
|
|
78
|
+
errorClass: categoryString.optional(),
|
|
79
|
+
errorCode: categoryString.optional(),
|
|
80
|
+
errorFingerprint: categoryString.optional(),
|
|
81
|
+
retryable: z.boolean().optional(),
|
|
82
|
+
attempt: nonNegativeInteger.optional(),
|
|
83
|
+
durationMs: nonNegativeInteger.optional(),
|
|
84
|
+
agentRole: categoryString.optional(),
|
|
85
|
+
invocationId: opaqueString.optional(),
|
|
86
|
+
nodeId: opaqueString.optional(),
|
|
87
|
+
previousPhase: categoryString.optional(),
|
|
88
|
+
releaseReason: z.enum(FACTORY_CLOUD_RELEASE_REASONS_V1).optional(),
|
|
89
|
+
dryRun: z.boolean().optional(),
|
|
90
|
+
count: boundedCount.optional(),
|
|
91
|
+
activeRuns: boundedCount.optional(),
|
|
92
|
+
queuedRuns: boundedCount.optional(),
|
|
93
|
+
trackedAgents: boundedCount.optional(),
|
|
94
|
+
unownedAgents: boundedCount.optional(),
|
|
95
|
+
outboxDepth: boundedCount.optional(),
|
|
96
|
+
outboxOldestAgeMs: nonNegativeInteger.optional(),
|
|
97
|
+
droppedEvents: boundedCount.optional(),
|
|
98
|
+
transport: categoryString.optional(),
|
|
99
|
+
locality: categoryString.optional(),
|
|
100
|
+
}).strict();
|
|
101
|
+
export const FactoryCloudInstanceV1Schema = z.object({
|
|
102
|
+
id: opaqueString,
|
|
103
|
+
bootId: opaqueString,
|
|
104
|
+
version: z.string().trim().min(1).max(64),
|
|
105
|
+
metadata: z.object({
|
|
106
|
+
backend: categoryString.optional(),
|
|
107
|
+
mode: categoryString.optional(),
|
|
108
|
+
platform: categoryString.optional(),
|
|
109
|
+
arch: categoryString.optional(),
|
|
110
|
+
runtime: categoryString.optional(),
|
|
111
|
+
}).strict().optional(),
|
|
112
|
+
}).strict();
|
|
113
|
+
const factoryCloudEventShape = {
|
|
114
|
+
id: opaqueString,
|
|
115
|
+
occurredAt: z.string().datetime({ offset: true }),
|
|
116
|
+
type: categoryString,
|
|
117
|
+
level: z.enum(['debug', 'info', 'warn', 'error']).optional(),
|
|
118
|
+
runId: opaqueString.optional(),
|
|
119
|
+
phase: categoryString.optional(),
|
|
120
|
+
status: z.enum(['queued', 'running', 'waiting', 'blocked', 'succeeded', 'failed', 'cancelled']).optional(),
|
|
121
|
+
run: z.object({
|
|
122
|
+
source: categoryString.optional(),
|
|
123
|
+
repository: opaqueString.optional(),
|
|
124
|
+
issueKey: opaqueString.optional(),
|
|
125
|
+
recipe: categoryString.optional(),
|
|
126
|
+
}).strict().optional(),
|
|
127
|
+
attributes: FactoryCloudEventAttributesV1Schema.optional(),
|
|
128
|
+
trace: z.object({
|
|
129
|
+
traceId: FactoryCloudTraceIdV1Schema,
|
|
130
|
+
spanId: FactoryCloudSpanIdV1Schema.optional(),
|
|
131
|
+
parentSpanId: FactoryCloudSpanIdV1Schema.optional(),
|
|
132
|
+
}).strict().optional(),
|
|
133
|
+
};
|
|
134
|
+
const requireRunId = (event, context) => {
|
|
135
|
+
if (event.type.startsWith('run.') && !event.runId) {
|
|
136
|
+
context.addIssue({
|
|
137
|
+
code: z.ZodIssueCode.custom,
|
|
138
|
+
path: ['runId'],
|
|
139
|
+
message: 'runId is required for run.* events',
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
export const FactoryCloudEventInputV1Schema = z.object(factoryCloudEventShape).strict().superRefine(requireRunId);
|
|
144
|
+
export const FactoryCloudEventV1Schema = z.object({
|
|
145
|
+
...factoryCloudEventShape,
|
|
146
|
+
sequence: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
147
|
+
}).strict().superRefine(requireRunId);
|
|
148
|
+
export const FactoryCloudEventBatchV1Schema = z.object({
|
|
149
|
+
contract: z.literal(FACTORY_CLOUD_EVENT_CONTRACT_V1),
|
|
150
|
+
instance: FactoryCloudInstanceV1Schema,
|
|
151
|
+
events: z.array(FactoryCloudEventV1Schema).min(1).max(FACTORY_CLOUD_EVENT_MAX_BATCH_SIZE),
|
|
152
|
+
}).strict();
|
|
153
|
+
/**
|
|
154
|
+
* Stable correlation ID for the durable run. It has W3C trace-id shape but is
|
|
155
|
+
* not evidence that an OpenTelemetry span was created or exported.
|
|
156
|
+
*/
|
|
157
|
+
export function factoryRunTraceIdV1(runId) {
|
|
158
|
+
const normalizedRunId = opaqueString.parse(runId);
|
|
159
|
+
const traceId = createHash('sha256')
|
|
160
|
+
.update(FACTORY_RUN_TRACE_DOMAIN_V1)
|
|
161
|
+
.update(normalizedRunId)
|
|
162
|
+
.digest('hex')
|
|
163
|
+
.slice(0, 32);
|
|
164
|
+
// SHA-256 producing this value is fantastically unlikely, but W3C forbids it
|
|
165
|
+
// and this helper promises validity rather than probability.
|
|
166
|
+
return traceId === W3C_INVALID_TRACE_ID
|
|
167
|
+
? '00000000000000000000000000000001'
|
|
168
|
+
: traceId;
|
|
169
|
+
}
|
|
170
|
+
export function createFactoryCloudEventV1(input, options = {}) {
|
|
171
|
+
const trace = input.trace ?? (input.runId ? { traceId: factoryRunTraceIdV1(input.runId) } : undefined);
|
|
172
|
+
return FactoryCloudEventInputV1Schema.parse({
|
|
173
|
+
...input,
|
|
174
|
+
id: input.id ?? (options.id ?? randomUUID)(),
|
|
175
|
+
occurredAt: input.occurredAt ?? (options.now ?? (() => new Date()))().toISOString(),
|
|
176
|
+
...(trace ? { trace } : {}),
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Converts provider-owned exit/release text into a closed operational category.
|
|
181
|
+
* Unknown text is never forwarded because it can contain task or error details.
|
|
182
|
+
*/
|
|
183
|
+
export function factoryCloudReleaseReasonV1(value) {
|
|
184
|
+
if (value === undefined || !value.trim())
|
|
185
|
+
return undefined;
|
|
186
|
+
switch (value.trim().toLowerCase()) {
|
|
187
|
+
case 'issue-done':
|
|
188
|
+
case 'done':
|
|
189
|
+
case 'completed':
|
|
190
|
+
return 'completed';
|
|
191
|
+
case 'issue-human-review':
|
|
192
|
+
return 'human_review';
|
|
193
|
+
case 'factory-stopped':
|
|
194
|
+
return 'factory_stopped';
|
|
195
|
+
case 'waiting-for-human':
|
|
196
|
+
return 'waiting_for_human';
|
|
197
|
+
case 'task_exit':
|
|
198
|
+
case 'exited':
|
|
199
|
+
return 'exited';
|
|
200
|
+
case 'offline':
|
|
201
|
+
return 'offline';
|
|
202
|
+
case 'node-offline':
|
|
203
|
+
return 'node_offline';
|
|
204
|
+
case 'crash':
|
|
205
|
+
case 'crashed':
|
|
206
|
+
return 'crashed';
|
|
207
|
+
case 'reconciled-missing':
|
|
208
|
+
return 'reconciled_missing';
|
|
209
|
+
case 'dead-lettered':
|
|
210
|
+
case 'dropped':
|
|
211
|
+
case 'max delivery retries exceeded':
|
|
212
|
+
case 'recipient unavailable':
|
|
213
|
+
return 'delivery_failed';
|
|
214
|
+
case 'dispatch failed':
|
|
215
|
+
return 'dispatch_failed';
|
|
216
|
+
default:
|
|
217
|
+
return 'other';
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
export function isCriticalFactoryCloudEvent(event) {
|
|
221
|
+
return event.level === 'error' ||
|
|
222
|
+
event.type === 'factory.failure' ||
|
|
223
|
+
event.type === 'factory.anomaly' ||
|
|
224
|
+
event.type === 'instance.stopped' ||
|
|
225
|
+
event.status === 'failed' ||
|
|
226
|
+
event.status === 'succeeded' ||
|
|
227
|
+
event.status === 'cancelled';
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../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Ac,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/observability/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,wBAAwB,CAAA;AACtC,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return one opaque identity for this Factory installation. The create-only
|
|
3
|
+
* file makes concurrent starts converge without deriving identity from a
|
|
4
|
+
* hostname, username, local path, or other machine fingerprint.
|
|
5
|
+
*/
|
|
6
|
+
export declare function loadOrCreateFactoryInstanceId(path: string): Promise<string>;
|
|
7
|
+
//# sourceMappingURL=instance-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance-identity.d.ts","sourceRoot":"","sources":["../../src/observability/instance-identity.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,wBAAsB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAqCjF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { link, mkdir, open, readFile, unlink } from 'node:fs/promises';
|
|
3
|
+
import { dirname } from 'node:path';
|
|
4
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
|
|
5
|
+
/**
|
|
6
|
+
* Return one opaque identity for this Factory installation. The create-only
|
|
7
|
+
* file makes concurrent starts converge without deriving identity from a
|
|
8
|
+
* hostname, username, local path, or other machine fingerprint.
|
|
9
|
+
*/
|
|
10
|
+
export async function loadOrCreateFactoryInstanceId(path) {
|
|
11
|
+
try {
|
|
12
|
+
const existing = (await readFile(path, 'utf8')).trim();
|
|
13
|
+
if (!UUID.test(existing))
|
|
14
|
+
throw new Error('Factory instance identity file is invalid');
|
|
15
|
+
return existing;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
if (!isMissingFileError(error))
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
await mkdir(dirname(path), { recursive: true, mode: 0o700 });
|
|
22
|
+
const candidatePath = `${path}.${randomUUID()}.tmp`;
|
|
23
|
+
let candidateExists = false;
|
|
24
|
+
try {
|
|
25
|
+
const handle = await open(candidatePath, 'wx', 0o600);
|
|
26
|
+
candidateExists = true;
|
|
27
|
+
const id = randomUUID();
|
|
28
|
+
try {
|
|
29
|
+
await handle.writeFile(`${id}\n`, 'utf8');
|
|
30
|
+
await handle.sync();
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
await handle.close();
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
await link(candidatePath, path);
|
|
37
|
+
return id;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (!isAlreadyExistsError(error))
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (!isAlreadyExistsError(error))
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
if (candidateExists)
|
|
50
|
+
await unlink(candidatePath).catch(() => undefined);
|
|
51
|
+
}
|
|
52
|
+
const id = (await readFile(path, 'utf8')).trim();
|
|
53
|
+
if (!UUID.test(id))
|
|
54
|
+
throw new Error('Factory instance identity file is invalid');
|
|
55
|
+
return id;
|
|
56
|
+
}
|
|
57
|
+
const isAlreadyExistsError = (error) => Boolean(error && typeof error === 'object' && 'code' in error && error.code === 'EEXIST');
|
|
58
|
+
const isMissingFileError = (error) => Boolean(error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT');
|
|
59
|
+
//# sourceMappingURL=instance-identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance-identity.js","sourceRoot":"","sources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oryCloudEventInputV1, type FactoryCloudEventV1, type FactoryCloudInstanceV1 } from './events.js';
|
|
2
|
+
export interface FileFactoryCloudEventOutboxOptions {
|
|
3
|
+
path: string;
|
|
4
|
+
maxEvents?: number;
|
|
5
|
+
maxBytes?: number;
|
|
6
|
+
/** Finite advisory-lock retries; defaults to a short fail-open window. */
|
|
7
|
+
lockRetries?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface FactoryCloudEventEnqueueResult {
|
|
10
|
+
event: FactoryCloudEventV1;
|
|
11
|
+
duplicate: boolean;
|
|
12
|
+
droppedEvents: number;
|
|
13
|
+
pending: number;
|
|
14
|
+
}
|
|
15
|
+
export interface FactoryCloudEventOutboxStats {
|
|
16
|
+
pending: number;
|
|
17
|
+
droppedEvents: number;
|
|
18
|
+
oldestOccurredAt?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface FactoryCloudEventOutbox {
|
|
21
|
+
enqueue(instance: FactoryCloudInstanceV1, event: FactoryCloudEventInputV1): Promise<FactoryCloudEventEnqueueResult>;
|
|
22
|
+
peekBatch(limit?: number, maxPayloadBytes?: number): Promise<FactoryCloudEventBatchV1 | undefined>;
|
|
23
|
+
acknowledge(eventIds: readonly string[]): Promise<number>;
|
|
24
|
+
/** Remove undeliverable events and increment the durable dropped counter. */
|
|
25
|
+
discard(eventIds: readonly string[]): Promise<number>;
|
|
26
|
+
stats(): Promise<FactoryCloudEventOutboxStats>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A process-safe, append-by-rewrite outbox. Documents are written atomically
|
|
30
|
+
* with mode 0600 and guarded by the same advisory-lock pattern as Factory's
|
|
31
|
+
* durable lifecycle store. Event IDs are first-write-wins idempotency keys.
|
|
32
|
+
*/
|
|
33
|
+
export declare class FileFactoryCloudEventOutbox implements FactoryCloudEventOutbox {
|
|
34
|
+
#private;
|
|
35
|
+
constructor(options: FileFactoryCloudEventOutboxOptions);
|
|
36
|
+
enqueue(rawInstance: FactoryCloudInstanceV1, rawEvent: FactoryCloudEventInputV1): Promise<FactoryCloudEventEnqueueResult>;
|
|
37
|
+
peekBatch(limit?: number, maxPayloadBytes?: number): Promise<FactoryCloudEventBatchV1 | undefined>;
|
|
38
|
+
acknowledge(eventIds: readonly string[]): Promise<number>;
|
|
39
|
+
discard(eventIds: readonly string[]): Promise<number>;
|
|
40
|
+
stats(): Promise<FactoryCloudEventOutboxStats>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=outbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox.d.ts","sourceRoot":"","sources":["../../src/observability/outbox.ts"],"names":[],"mappings":"AAOA,OAAO,EASL,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC5B,MAAM,UAAU,CAAA;AAwBjB,MAAM,WAAW,kCAAkC;IACjD,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,8BAA8B;IAC7C,KAAK,EAAE,mBAAmB,CAAA;IAC1B,SAAS,EAAE,OAAO,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,QAAQ,EAAE,sBAAsB,EAAE,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAA;IACnH,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,G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