@relayflows/sdk 2.0.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/dist/authored-flow-error.d.ts +9 -0
- package/dist/authored-flow-error.d.ts.map +1 -0
- package/dist/authored-flow-error.js +13 -0
- package/dist/authored-flow-error.js.map +1 -0
- package/dist/authored-flow-executor.d.ts +28 -0
- package/dist/authored-flow-executor.d.ts.map +1 -0
- package/dist/authored-flow-executor.js +203 -0
- package/dist/authored-flow-executor.js.map +1 -0
- package/dist/authored-flow-lifecycle.d.ts +61 -0
- package/dist/authored-flow-lifecycle.d.ts.map +1 -0
- package/dist/authored-flow-lifecycle.js +284 -0
- package/dist/authored-flow-lifecycle.js.map +1 -0
- package/dist/authored-flow-loader.d.ts +7 -0
- package/dist/authored-flow-loader.d.ts.map +1 -0
- package/dist/authored-flow-loader.js +39 -0
- package/dist/authored-flow-loader.js.map +1 -0
- package/dist/authored-flow-operation.d.ts +43 -0
- package/dist/authored-flow-operation.d.ts.map +1 -0
- package/dist/authored-flow-operation.js +176 -0
- package/dist/authored-flow-operation.js.map +1 -0
- package/dist/authored-flow.d.ts +12 -0
- package/dist/authored-flow.d.ts.map +1 -0
- package/dist/authored-flow.js +13 -0
- package/dist/authored-flow.js.map +1 -0
- package/dist/authored-promise-graph.d.ts +67 -0
- package/dist/authored-promise-graph.d.ts.map +1 -0
- package/dist/authored-promise-graph.js +206 -0
- package/dist/authored-promise-graph.js.map +1 -0
- package/dist/backlog-picker.d.ts +55 -0
- package/dist/backlog-picker.d.ts.map +1 -0
- package/dist/backlog-picker.js +117 -0
- package/dist/backlog-picker.js.map +1 -0
- package/dist/canonical.d.ts +18 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +55 -0
- package/dist/canonical.js.map +1 -0
- package/dist/cli/check.d.ts +30 -0
- package/dist/cli/check.d.ts.map +1 -0
- package/dist/cli/check.js +324 -0
- package/dist/cli/check.js.map +1 -0
- package/dist/cli/direct-run.d.ts +3 -0
- package/dist/cli/direct-run.d.ts.map +1 -0
- package/dist/cli/direct-run.js +69 -0
- package/dist/cli/direct-run.js.map +1 -0
- package/dist/cli/hn-monitor.d.ts +107 -0
- package/dist/cli/hn-monitor.d.ts.map +1 -0
- package/dist/cli/hn-monitor.js +220 -0
- package/dist/cli/hn-monitor.js.map +1 -0
- package/dist/cli/interruptible-sleep.d.ts +13 -0
- package/dist/cli/interruptible-sleep.d.ts.map +1 -0
- package/dist/cli/interruptible-sleep.js +31 -0
- package/dist/cli/interruptible-sleep.js.map +1 -0
- package/dist/cli/run.d.ts +54 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +316 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/cli/tick-runner.d.ts +151 -0
- package/dist/cli/tick-runner.d.ts.map +1 -0
- package/dist/cli/tick-runner.js +258 -0
- package/dist/cli/tick-runner.js.map +1 -0
- package/dist/cli-adapter.d.ts +29 -0
- package/dist/cli-adapter.d.ts.map +1 -0
- package/dist/cli-adapter.js +92 -0
- package/dist/cli-adapter.js.map +1 -0
- package/dist/cli-executable.d.ts +3 -0
- package/dist/cli-executable.d.ts.map +1 -0
- package/dist/cli-executable.js +10 -0
- package/dist/cli-executable.js.map +1 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +348 -0
- package/dist/cli.js.map +1 -0
- package/dist/compile.d.ts +42 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +515 -0
- package/dist/compile.js.map +1 -0
- package/dist/demo-hn-monitor.d.ts +2 -0
- package/dist/demo-hn-monitor.d.ts.map +1 -0
- package/dist/demo-hn-monitor.js +118 -0
- package/dist/demo-hn-monitor.js.map +1 -0
- package/dist/dir-watcher-poller.d.ts +73 -0
- package/dist/dir-watcher-poller.d.ts.map +1 -0
- package/dist/dir-watcher-poller.js +80 -0
- package/dist/dir-watcher-poller.js.map +1 -0
- package/dist/direct-input.d.ts +10 -0
- package/dist/direct-input.d.ts.map +1 -0
- package/dist/direct-input.js +61 -0
- package/dist/direct-input.js.map +1 -0
- package/dist/failure-kinds.d.ts +25 -0
- package/dist/failure-kinds.d.ts.map +1 -0
- package/dist/failure-kinds.js +64 -0
- package/dist/failure-kinds.js.map +1 -0
- package/dist/gate-contract.d.ts +24 -0
- package/dist/gate-contract.d.ts.map +1 -0
- package/dist/gate-contract.js +50 -0
- package/dist/gate-contract.js.map +1 -0
- package/dist/hn-poller.d.ts +50 -0
- package/dist/hn-poller.d.ts.map +1 -0
- package/dist/hn-poller.js +79 -0
- package/dist/hn-poller.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/journal-client.d.ts +122 -0
- package/dist/journal-client.d.ts.map +1 -0
- package/dist/journal-client.js +277 -0
- package/dist/journal-client.js.map +1 -0
- package/dist/json-schema-bound.d.ts +7 -0
- package/dist/json-schema-bound.d.ts.map +1 -0
- package/dist/json-schema-bound.js +353 -0
- package/dist/json-schema-bound.js.map +1 -0
- package/dist/json-schema.d.ts +5 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/json-schema.js +72 -0
- package/dist/json-schema.js.map +1 -0
- package/dist/json-value.d.ts +6 -0
- package/dist/json-value.d.ts.map +1 -0
- package/dist/json-value.js +94 -0
- package/dist/json-value.js.map +1 -0
- package/dist/model-name.d.ts +7 -0
- package/dist/model-name.d.ts.map +1 -0
- package/dist/model-name.js +21 -0
- package/dist/model-name.js.map +1 -0
- package/dist/output-schema.d.ts +8 -0
- package/dist/output-schema.d.ts.map +1 -0
- package/dist/output-schema.js +28 -0
- package/dist/output-schema.js.map +1 -0
- package/dist/preflight.d.ts +80 -0
- package/dist/preflight.d.ts.map +1 -0
- package/dist/preflight.js +361 -0
- package/dist/preflight.js.map +1 -0
- package/dist/protocol.d.ts +359 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +15 -0
- package/dist/protocol.js.map +1 -0
- package/dist/spec.d.ts +294 -0
- package/dist/spec.d.ts.map +1 -0
- package/dist/spec.js +13 -0
- package/dist/spec.js.map +1 -0
- package/dist/step-dependencies.d.ts +2 -0
- package/dist/step-dependencies.d.ts.map +1 -0
- package/dist/step-dependencies.js +88 -0
- package/dist/step-dependencies.js.map +1 -0
- package/dist/step-fields.d.ts +17 -0
- package/dist/step-fields.d.ts.map +1 -0
- package/dist/step-fields.js +32 -0
- package/dist/step-fields.js.map +1 -0
- package/dist/tick-source.d.ts +205 -0
- package/dist/tick-source.d.ts.map +1 -0
- package/dist/tick-source.js +234 -0
- package/dist/tick-source.js.map +1 -0
- package/dist/unknown-keys.d.ts +7 -0
- package/dist/unknown-keys.d.ts.map +1 -0
- package/dist/unknown-keys.js +47 -0
- package/dist/unknown-keys.js.map +1 -0
- package/dist/validate.d.ts +7 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +458 -0
- package/dist/validate.js.map +1 -0
- package/dist/work-package-consumer.d.ts +33 -0
- package/dist/work-package-consumer.d.ts.map +1 -0
- package/dist/work-package-consumer.js +44 -0
- package/dist/work-package-consumer.js.map +1 -0
- package/dist/work-package-validator.d.ts +15 -0
- package/dist/work-package-validator.d.ts.map +1 -0
- package/dist/work-package-validator.js +72 -0
- package/dist/work-package-validator.js.map +1 -0
- package/dist/worker-cli.d.ts +16 -0
- package/dist/worker-cli.d.ts.map +1 -0
- package/dist/worker-cli.js +77 -0
- package/dist/worker-cli.js.map +1 -0
- package/dist/worker.d.ts +57 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +129 -0
- package/dist/worker.js.map +1 -0
- package/dist/wrapper-runtime.d.ts +10 -0
- package/dist/wrapper-runtime.d.ts.map +1 -0
- package/dist/wrapper-runtime.js +83 -0
- package/dist/wrapper-runtime.js.map +1 -0
- package/dist/wrapper-session.d.ts +16 -0
- package/dist/wrapper-session.d.ts.map +1 -0
- package/dist/wrapper-session.js +244 -0
- package/dist/wrapper-session.js.map +1 -0
- package/package.json +50 -0
- package/src/authored-flow-error.ts +31 -0
- package/src/authored-flow-executor.ts +365 -0
- package/src/authored-flow-lifecycle.ts +344 -0
- package/src/authored-flow-loader.ts +44 -0
- package/src/authored-flow-operation.ts +252 -0
- package/src/authored-flow.ts +21 -0
- package/src/authored-promise-graph.ts +196 -0
- package/src/backlog-picker.ts +153 -0
- package/src/canonical.ts +57 -0
- package/src/cli/check.ts +391 -0
- package/src/cli/direct-run.ts +86 -0
- package/src/cli/hn-monitor.ts +286 -0
- package/src/cli/interruptible-sleep.ts +27 -0
- package/src/cli/run.ts +439 -0
- package/src/cli/tick-runner.ts +378 -0
- package/src/cli-adapter.ts +115 -0
- package/src/cli-executable.ts +12 -0
- package/src/cli.ts +364 -0
- package/src/compile.ts +573 -0
- package/src/demo-hn-monitor.ts +132 -0
- package/src/dir-watcher-poller.ts +122 -0
- package/src/direct-input.ts +69 -0
- package/src/failure-kinds.ts +77 -0
- package/src/gate-contract.ts +72 -0
- package/src/hn-poller.ts +104 -0
- package/src/index.ts +195 -0
- package/src/journal-client.ts +379 -0
- package/src/json-schema-bound.ts +357 -0
- package/src/json-schema.ts +65 -0
- package/src/json-value.ts +110 -0
- package/src/model-name.ts +20 -0
- package/src/output-schema.ts +33 -0
- package/src/preflight.ts +482 -0
- package/src/protocol.ts +364 -0
- package/src/spec.ts +343 -0
- package/src/step-dependencies.ts +100 -0
- package/src/step-fields.ts +36 -0
- package/src/tick-source.ts +334 -0
- package/src/unknown-keys.ts +52 -0
- package/src/validate.ts +503 -0
- package/src/work-package-consumer.ts +73 -0
- package/src/work-package-validator.ts +90 -0
- package/src/worker-cli.ts +110 -0
- package/src/worker.ts +150 -0
- package/src/wrapper-runtime.ts +93 -0
- package/src/wrapper-session.ts +287 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hacker News -> relayflow events.
|
|
3
|
+
*
|
|
4
|
+
* This lives OUTSIDE `kernel/` deliberately. An earlier version called Hacker
|
|
5
|
+
* News from `kernel/relayflowd` and review rejected it (PR #16, P1): a
|
|
6
|
+
* durable-execution kernel must not own provider-specific product logic or
|
|
7
|
+
* network I/O, or engine availability and dependencies become coupled to an
|
|
8
|
+
* external service. The kernel gained a `ureq` dependency purely to fetch a
|
|
9
|
+
* JSON feed — a clear sign the code was in the wrong place.
|
|
10
|
+
*
|
|
11
|
+
* So the adapter sits on the authoring surface and submits its events through
|
|
12
|
+
* the journal protocol (`event.submit`), which is the same path any other
|
|
13
|
+
* external producer would use. The kernel learns about Hacker News the way it
|
|
14
|
+
* learns about everything else: as an event.
|
|
15
|
+
*/
|
|
16
|
+
const TOP_STORIES_URL = 'https://hacker-news.firebaseio.com/v0/topstories.json';
|
|
17
|
+
const DEFAULT_STORY_LIMIT = 5;
|
|
18
|
+
/**
|
|
19
|
+
* Typed fetch-transport error. Callers (like sdk/src/cli/hn-monitor.ts)
|
|
20
|
+
* `instanceof` this to distinguish transient HN fetch failures from
|
|
21
|
+
* journal failures — avoids message-string matching (fragile cross-module
|
|
22
|
+
* coupling) and covers the shapes fetch() itself throws (network errors,
|
|
23
|
+
* ECONNREFUSED, TypeError('fetch failed')).
|
|
24
|
+
*/
|
|
25
|
+
export class HnTransientFetchError extends Error {
|
|
26
|
+
constructor(message, cause) {
|
|
27
|
+
// Use the native ErrorOptions.cause path so stack formatting and
|
|
28
|
+
// downstream inspectors (util.inspect, structured loggers) see it.
|
|
29
|
+
super(message, cause !== undefined ? { cause } : undefined);
|
|
30
|
+
this.name = 'HnTransientFetchError';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const defaultFetcher = async (url) => {
|
|
34
|
+
let response;
|
|
35
|
+
try {
|
|
36
|
+
response = await fetch(url);
|
|
37
|
+
}
|
|
38
|
+
catch (cause) {
|
|
39
|
+
// Network-layer failures from fetch() itself — TypeError('fetch failed'),
|
|
40
|
+
// ECONNREFUSED, DNS lookup failures — are all transient.
|
|
41
|
+
throw new HnTransientFetchError(`HN fetch failed: ${String(cause)}`, cause);
|
|
42
|
+
}
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
throw new HnTransientFetchError(`HN fetch failed: HTTP ${response.status}`);
|
|
45
|
+
}
|
|
46
|
+
return response.text();
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Fetch the top-stories feed once and submit each story as an event.
|
|
50
|
+
*
|
|
51
|
+
* Dedupe is the kernel's job, not ours: the flow's `dedupeKeyTemplate` plus the
|
|
52
|
+
* (flow, subscription, key) claim means submitting the same story twice wakes
|
|
53
|
+
* it once. This function deliberately does not track what it has already seen.
|
|
54
|
+
*/
|
|
55
|
+
export async function pollHackerNewsOnce(spec, sink, options = {}) {
|
|
56
|
+
const storyLimit = options.storyLimit ?? DEFAULT_STORY_LIMIT;
|
|
57
|
+
const fetcher = options.fetcher ?? defaultFetcher;
|
|
58
|
+
const body = await fetcher(TOP_STORIES_URL);
|
|
59
|
+
let storyIds;
|
|
60
|
+
try {
|
|
61
|
+
storyIds = JSON.parse(body);
|
|
62
|
+
}
|
|
63
|
+
catch (cause) {
|
|
64
|
+
throw new HnTransientFetchError(`HN top stories response was not JSON: ${String(cause)}`);
|
|
65
|
+
}
|
|
66
|
+
if (!Array.isArray(storyIds)) {
|
|
67
|
+
throw new HnTransientFetchError('HN top stories response was not an array');
|
|
68
|
+
}
|
|
69
|
+
const outcomes = [];
|
|
70
|
+
for (const id of storyIds.slice(0, storyLimit)) {
|
|
71
|
+
outcomes.push(await sink.eventSubmit(spec, {
|
|
72
|
+
type: 'hn.story_posted',
|
|
73
|
+
payload: { id, type: 'story' },
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
return outcomes;
|
|
77
|
+
}
|
|
78
|
+
export const HN_TOP_STORIES_URL = TOP_STORIES_URL;
|
|
79
|
+
//# sourceMappingURL=hn-poller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hn-poller.js","sourceRoot":"","s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C,eAAe,CAAC,CAAC;IAE5C,IAAI,QAAiB,CAAC;IACtB,IAAI,CAAC;QACH,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,qBAAqB,CAAC,yCAAyC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC5F,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,qBAAqB,CAAC,0CAA0C,CAAC,CAAC;IAC9E,CAAC;IAED,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,KAAK,MAAM,EAAE,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,CAAC;QAC/C,QAAQ,CAAC,IAAI,CACX,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE;YAC3B,IAAI,EAAE,iBAAiB;YACvB,OAAO,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;SAC/B,CAAC,CACH,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type { AgentStepSpec, AgentSurfaces, BaseStepSpec, BudgetSpec, DeterministicStepSpec, ExitCodeGate, FlowSpec, JsonSchemaGate, JsonOutputSchema, KernelAgentStep, KernelAgentSurfaces, KernelBudgetSpec, KernelDeterministicStep, KernelLlmStep, KernelPermissionsSpec, KernelRetryPolicy, KernelRunSpec, KernelStepCommon, KernelStepSpec, KernelTriggerSpec, KernelVerificationSpec, LlmStepSpec, NamedAgentSpec, OutputContainsGate, OutputVerificationSpec, PermissionsSpec, RecoveryMode, StreamSurface, StepSpec, StepType, TriggerSpec, VerificationGateType, VerificationSpec, WorkspaceSurface, } from './spec.js';
|
|
2
|
+
export { SPEC_SCHEMA_VERSION } from './spec.js';
|
|
3
|
+
export { canonicalize, specHash } from './canonical.js';
|
|
4
|
+
export { compileAndHash, compileSpec, compileYaml, compileYamlToCanonicalJson, kernelToAuthoring, toKernelSpec, CompileError, } from './compile.js';
|
|
5
|
+
export { validateSpec, type ValidationResult } from './validate.js';
|
|
6
|
+
export { getAuthoredFlowDefinition, type AuthoredFlowDefinition, type FlowHandle, } from './authored-flow.js';
|
|
7
|
+
export { preflight, type CliResolution, type CliResolutionSource, type CliProbeResult, type PreflightDiagnostic, type PreflightOptions, type PreflightProbes, type PreflightRefusal, type PreflightResult, type PreflightWarning, } from './preflight.js';
|
|
8
|
+
export { type DataGateClassification, type JournalGateCheck, type StepGateInspection, } from './gate-contract.js';
|
|
9
|
+
export { CHECK_FAILURE_KINDS, CHECK_INPUT_FAILURE_KINDS, PREFLIGHT_FAILURE_KINDS, PREFLIGHT_WARNING_KINDS, isCheckFailureKind, type CheckFailureKind, type PreflightFailureKind, type PreflightWarningKind, } from './failure-kinds.js';
|
|
10
|
+
export { runCli, type CheckInputDiagnostic, type CheckReport, type CliIo } from './cli.js';
|
|
11
|
+
export type { CompletionReason, EffectRecordParams, EffectRecordResult, EffectRef, EventEmitParams, EventEmitResult, HelloParams, HelloResult, JournalReadParams, JournalReadResult, ProtocolError, Pins, Request, Response, RunGetParams, RunGetResult, RunOutcome, RunCompletionReason, RunCancelParams, RunCancelResult, RunResumeParams, RunResumeResult, RunStatus, RunWatchParams, RunWatchResult, ServerEvent, StepCompleteParams, StepCompleteResult, StepDispatchEvent, StepHeartbeatParams, StepHeartbeatResult, StreamAppendParams, StreamAppendResult, StreamReadParams, StreamReadResult, Verb, VerbContract, WorkerAttachParams, WorkerAttachResult, } from './protocol.js';
|
|
12
|
+
export { JOURNAL_WRITE_FAILED, PROTOCOL_VERSION } from './protocol.js';
|
|
13
|
+
export { JournalClient, type JournalClientOptions } from './journal-client.js';
|
|
14
|
+
export { AgentWorker, type AgentWorkerOptions } from './worker.js';
|
|
15
|
+
export { validateWorkPackage, packageFromEntry, type ValidatedWorkPackage, type WorkPackageValidation, type WorkPackageValidationReason, } from './backlog-picker.js';
|
|
16
|
+
export { consumeWorkPackage, type EmittedWorkPackage, type WorkPackageConsumption, type WorkPackageRefusalReason, } from './work-package-consumer.js';
|
|
17
|
+
export { validateNextWorkPackage, type NextWorkPackageRefusalReason, type NextWorkPackageValidation, type WorkPackagePathExists, } from './work-package-validator.js';
|
|
18
|
+
export { pollHackerNewsOnce, HnTransientFetchError, HN_TOP_STORIES_URL, type EventSink, type Fetcher, type PollOptions, } from './hn-poller.js';
|
|
19
|
+
export { pollDirectoryOnce, type DirLister, type PollOptions as DirWatcherPollOptions, } from './dir-watcher-poller.js';
|
|
20
|
+
export { emitDueTicks, scheduledForMs, TickEmitError, slotFor, tickDedupeKey, DEFAULT_MAX_CATCH_UP, TICK_DEDUPE_KEY_TEMPLATE, TICK_EVENT_TYPE, type EventSink as TickEventSink, type TickCursor, type TickEmitResult, type TickPayload, type TickSchedule, } from './tick-source.js';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,YAAY,EACV,aAAa,EACb,aAAa,EACb,YAAY,EACZ,UAAU,EACV,qBAAqB,EACrB,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,oBA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b,oBAAoB,EACpB,wBAAwB,EACxB,eAAe,EACf,KAAK,SAAS,IAAI,aAAa,EAC/B,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// @relayflows/sdk — TypeScript-first authoring SDK for Relayflows.
|
|
2
|
+
// Compiles specs (RFC-0001 §1 ladder) and speaks the journal protocol v0
|
|
3
|
+
// (kernel DESIGN.md §5).
|
|
4
|
+
export { SPEC_SCHEMA_VERSION } from './spec.js';
|
|
5
|
+
export { canonicalize, specHash } from './canonical.js';
|
|
6
|
+
export { compileAndHash, compileSpec, compileYaml, compileYamlToCanonicalJson, kernelToAuthoring, toKernelSpec, CompileError, } from './compile.js';
|
|
7
|
+
export { validateSpec } from './validate.js';
|
|
8
|
+
export { getAuthoredFlowDefinition, } from './authored-flow.js';
|
|
9
|
+
export { preflight, } from './preflight.js';
|
|
10
|
+
export { CHECK_FAILURE_KINDS, CHECK_INPUT_FAILURE_KINDS, PREFLIGHT_FAILURE_KINDS, PREFLIGHT_WARNING_KINDS, isCheckFailureKind, } from './failure-kinds.js';
|
|
11
|
+
export { runCli } from './cli.js';
|
|
12
|
+
export { JOURNAL_WRITE_FAILED, PROTOCOL_VERSION } from './protocol.js';
|
|
13
|
+
export { JournalClient } from './journal-client.js';
|
|
14
|
+
export { AgentWorker } from './worker.js';
|
|
15
|
+
export { validateWorkPackage, packageFromEntry, } from './backlog-picker.js';
|
|
16
|
+
export { consumeWorkPackage, } from './work-package-consumer.js';
|
|
17
|
+
export { validateNextWorkPackage, } from './work-package-validator.js';
|
|
18
|
+
// Hacker News adapter — deliberately outside kernel/ (see sdk/src/hn-poller.ts).
|
|
19
|
+
export { pollHackerNewsOnce, HnTransientFetchError, HN_TOP_STORIES_URL, } from './hn-poller.js';
|
|
20
|
+
// Directory watcher — second proactive workload for gate 2 primitives.
|
|
21
|
+
// Non-provider: no HTTP, no API tokens, no gate-6 dependency. Proves the
|
|
22
|
+
// pattern generalizes without regressing RFC-0001 §6 (providers = relayfile
|
|
23
|
+
// adapters, not SDK code).
|
|
24
|
+
export { pollDirectoryOnce, } from './dir-watcher-poller.js';
|
|
25
|
+
// Tick event source — a relayflow can be scheduled. A schedule is an event
|
|
26
|
+
// source subject to the same liveness sweep as any other subscription, not a
|
|
27
|
+
// scheduler inside the kernel (RFC-0001 gate 2: "triggers are entry
|
|
28
|
+
// conditions, not schedulers").
|
|
29
|
+
export { emitDueTicks, scheduledForMs, TickEmitError, slotFor, tickDedupeKey, DEFAULT_MAX_CATCH_UP, TICK_DEDUPE_KEY_TEMPLATE, TICK_EVENT_TYPE, } from './tick-source.js';
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,yEAAyE;AACzE,yBAAyB;AAsCzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EACL,cAAc,EACd,WAAW,EACX,WAAW,EACX,0BAA0B,EAC1B,iBAAiB,EACjB,YAAY,EACZ,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAyB,MAAM,eAAe,CAAC;AAEpE,OAAO,EACL,yBAAyB,GAG1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,SAAS,GAUV,MAAM,gBAAgB,CAAC;AAMxB,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,GAInB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAA2D,MAAM,UAAU,CAAC;AA2C3F,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,aAAa,EAA6B,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAA2B,MAAM,aAAa,CAAC;AAEnE,OAAO,EACL,mBAAmB,EACnB,gBAAgB,GAIjB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,GAInB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,uBAAuB,GAIxB,MAAM,6BAA6B,CAAC;AAErC,iFAAiF;AACjF,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,GAInB,MAAM,gBAAgB,CAAC;AAExB,uEAAuE;AACvE,yEAAyE;AACzE,4EAA4E;AAC5E,2BAA2B;AAC3B,OAAO,EACL,iBAAiB,GAGlB,MAAM,yBAAyB,CAAC;AAEjC,2EAA2E;AAC3E,6EAA6E;AAC7E,oEAAoE;AACpE,gCAAgC;AAChC,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,EACb,OAAO,EACP,aAAa,EACb,oBAAoB,EACpB,wBAAwB,EACxB,eAAe,GAMhB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import type { VerbContract, EventSubmitParams } from './protocol.js';
|
|
3
|
+
import { type CompletionReason, type EffectRef, type Pins } from './protocol.js';
|
|
4
|
+
import type { KernelRunSpec, StepType } from './spec.js';
|
|
5
|
+
export interface JournalClientOptions {
|
|
6
|
+
/** Override the timeout for bounded protocol requests (ms). Default 30000. */
|
|
7
|
+
requestTimeoutMs?: number;
|
|
8
|
+
}
|
|
9
|
+
/** A structured rejection returned by relayflowd over the journal protocol. */
|
|
10
|
+
export declare class JournalProtocolError extends Error {
|
|
11
|
+
readonly code: string;
|
|
12
|
+
constructor(code: string, message: string);
|
|
13
|
+
}
|
|
14
|
+
export declare class JournalClient extends EventEmitter {
|
|
15
|
+
private readonly socketPath;
|
|
16
|
+
private socket;
|
|
17
|
+
private buffer;
|
|
18
|
+
private readonly pending;
|
|
19
|
+
private readonly requestTimeoutMs;
|
|
20
|
+
constructor(socketPath: string, options?: JournalClientOptions);
|
|
21
|
+
/** Open the unix socket connection. Rejects on connect failure (fail-closed). */
|
|
22
|
+
connect(): Promise<void>;
|
|
23
|
+
/** Close the connection and reject any pending requests. */
|
|
24
|
+
close(): void;
|
|
25
|
+
private onData;
|
|
26
|
+
private onLine;
|
|
27
|
+
private failAll;
|
|
28
|
+
private request;
|
|
29
|
+
/** Handshake; version mismatch is a hard error. */
|
|
30
|
+
hello(client: string): Promise<VerbContract['hello']['result']>;
|
|
31
|
+
/**
|
|
32
|
+
* Validate a compiled kernel-dialect spec (zero-agent flows legal), create
|
|
33
|
+
* the run file, and append `run.spawned`. Authoring specs must be compiled
|
|
34
|
+
* with `toKernelSpec` before crossing this journal-protocol boundary.
|
|
35
|
+
*/
|
|
36
|
+
runStart(spec: KernelRunSpec): Promise<VerbContract['run.start']['result']>;
|
|
37
|
+
/** §3 memoized resume. */
|
|
38
|
+
runResume(runId: string): Promise<VerbContract['run.resume']['result']>;
|
|
39
|
+
/** Durably request cancellation and return the terminal run fact. */
|
|
40
|
+
runCancel(runId: string): Promise<VerbContract['run.cancel']['result']>;
|
|
41
|
+
/** Snapshot for legibility. */
|
|
42
|
+
runGet(runId: string): Promise<VerbContract['run.get']['result']>;
|
|
43
|
+
/**
|
|
44
|
+
* Open a push stream of every appended entry. Resolves once subscribed;
|
|
45
|
+
* entries arrive as `'entry'` events: `client.on('entry', (entry) => …)`.
|
|
46
|
+
*/
|
|
47
|
+
runWatch(runId: string): Promise<VerbContract['run.watch']['result']>;
|
|
48
|
+
/** Connection becomes a worker; receives `step.dispatch` events. */
|
|
49
|
+
workerAttach(workerId: string, stepTypes: StepType[], pins?: Pins, capacity?: number): Promise<VerbContract['worker.attach']['result']>;
|
|
50
|
+
/**
|
|
51
|
+
* Phase one of the writeback protocol (Appendix A rule 5): ask the journal to
|
|
52
|
+
* elect this attempt to perform the effect. **Do not call this directly to
|
|
53
|
+
* perform an effect** — use {@link performEffect}, which cannot leave the
|
|
54
|
+
* election and the provider call separated. A `false` here means this attempt
|
|
55
|
+
* owes the provider call *and* the {@link effectConfirm} that closes it;
|
|
56
|
+
* returning from `effectRecord` without doing both leaves the election open.
|
|
57
|
+
*/
|
|
58
|
+
effectRecord(runId: string, stepId: string, attempt: number, idempotencyKey: string, surfacePath: string, revisionBefore: string, revisionAfter: string): Promise<VerbContract['effect.record']['result']>;
|
|
59
|
+
/**
|
|
60
|
+
* Phase two: the provider call this attempt was elected for has happened.
|
|
61
|
+
* Confirming closes the election so no later attempt reclaims it. Only the
|
|
62
|
+
* attempt holding the election may confirm it; the kernel refuses anything
|
|
63
|
+
* else.
|
|
64
|
+
*/
|
|
65
|
+
effectConfirm(runId: string, stepId: string, attempt: number, idempotencyKey: string, surfacePath: string): Promise<VerbContract['effect.confirm']['result']>;
|
|
66
|
+
/**
|
|
67
|
+
* Perform one declared external effect exactly once: elect, perform, confirm.
|
|
68
|
+
*
|
|
69
|
+
* Election alone is not a promise that the writeback happened — a worker that
|
|
70
|
+
* dies between `effect.record` and its provider call would otherwise leave a
|
|
71
|
+
* winner nothing ever performed, and every retry would skip the call while
|
|
72
|
+
* the run completed as if the effect had occurred. Holding the three phases
|
|
73
|
+
* inside one call is what makes them inseparable at this boundary: `perform`
|
|
74
|
+
* runs only for the attempt that won the election, and the election is closed
|
|
75
|
+
* only after `perform` returns. A `perform` that throws leaves the election
|
|
76
|
+
* unconfirmed and therefore reclaimable, so the next attempt performs it.
|
|
77
|
+
*
|
|
78
|
+
* Returns whether this attempt made the provider call; `false` means a
|
|
79
|
+
* confirmed election already covered it.
|
|
80
|
+
*/
|
|
81
|
+
performEffect(effect: {
|
|
82
|
+
runId: string;
|
|
83
|
+
stepId: string;
|
|
84
|
+
attempt: number;
|
|
85
|
+
idempotencyKey: string;
|
|
86
|
+
surfacePath: string;
|
|
87
|
+
revisionBefore: string;
|
|
88
|
+
revisionAfter: string;
|
|
89
|
+
}, perform: () => Promise<void>): Promise<boolean>;
|
|
90
|
+
/** Renew the lease — the one lease primitive. */
|
|
91
|
+
stepHeartbeat(runId: string, stepId: string, attempt: number, leaseId: string): Promise<VerbContract['step.heartbeat']['result']>;
|
|
92
|
+
/** Complete a dispatched step — also the out-of-band path. */
|
|
93
|
+
stepComplete(runId: string, stepId: string, attempt: number, idempotencyKey: string, completionReason: CompletionReason, extra?: {
|
|
94
|
+
output?: unknown;
|
|
95
|
+
usage?: {
|
|
96
|
+
tokens_in: number;
|
|
97
|
+
tokens_out: number;
|
|
98
|
+
dollars: string;
|
|
99
|
+
};
|
|
100
|
+
started_pins?: Pins;
|
|
101
|
+
end_pins?: Pins;
|
|
102
|
+
effects?: EffectRef[];
|
|
103
|
+
trajectory_tail?: unknown;
|
|
104
|
+
}): Promise<VerbContract['step.complete']['result']>;
|
|
105
|
+
/** Satisfy `wait.event`; a human response arrives here too. */
|
|
106
|
+
eventEmit(runId: string, eventKey: string, payload: unknown): Promise<VerbContract['event.emit']['result']>;
|
|
107
|
+
/**
|
|
108
|
+
* Submit an external event to a flow that declares an event trigger.
|
|
109
|
+
*
|
|
110
|
+
* Without this wrapper the verb existed on the server but was unreachable
|
|
111
|
+
* through the typed client, so authors had to bypass the protocol surface
|
|
112
|
+
* entirely to use the feature.
|
|
113
|
+
*/
|
|
114
|
+
eventSubmit(spec: unknown, event: EventSubmitParams['event']): Promise<VerbContract['event.submit']['result']>;
|
|
115
|
+
/** Durable channel write; journals `stream.appended`. */
|
|
116
|
+
streamAppend(runId: string, stream: string, message: unknown): Promise<VerbContract['stream.append']['result']>;
|
|
117
|
+
/** At-least-once replayable read. Committing the consumer offset happens via pins. */
|
|
118
|
+
streamRead(runId: string, stream: string, fromOffset: number, limit?: number): Promise<VerbContract['stream.read']['result']>;
|
|
119
|
+
/** Raw journal access — replay, audit, the report step. */
|
|
120
|
+
journalRead(runId: string, fromSeq: number, limit?: number): Promise<VerbContract['journal.read']['result']>;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=journal-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"journal-client.d.ts","sourceRoot":"","sources":["../src/journal-client.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,IAAI,EAIV,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEzD,MAAM,WAAW,oBAAoB;IACnC,8EAA8E;IAC9E,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAQD,+EAA+E;AAC/E,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK1C;AAED,qBAAa,aAAc,SAAQ,YAAY;IAO3C,OAAO,CAAC,QAAQ,CAAC,UAAU;IAN7B,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IACtD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;gBAGvB,UAAU,EAAE,MAAM,EACnC,OAAO,GAAE,oBAAyB;IAMpC,iFAAiF;IACjF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAqBxB,4DAA4D;IAC5D,KAAK,IAAI,IAAI;IAOb,OAAO,CAAC,MAAM;IAUd,OAAO,CAAC,MAAM;IAyBd,OAAO,CAAC,OAAO;IAQf,OAAO,CAAC,OAAO;IAgCf,mDAAmD;IACnD,KAAK,CAAC,MAAM,EAAE,MAA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AC/D,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,CAAC;IAI3G;;;;;;OAMG;IACH,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,CAAC;IAI9G,yDAAyD;IACzD,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,CAAC;IAI/G,sFAAsF;IACtF,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAC;IAI7H,2DAA2D;IAC3D,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,CAAC;CAG7G"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
// Journal-protocol v0 client (kernel DESIGN.md §5).
|
|
2
|
+
//
|
|
3
|
+
// A real client implementation of the wire protocol — newline-delimited JSON
|
|
4
|
+
// over a unix socket. It correlates requests by `id`, demultiplexes
|
|
5
|
+
// server-pushed events, and is fail-closed: a connection drop or write error
|
|
6
|
+
// rejects every pending request (a journal write that fails fails the step;
|
|
7
|
+
// AGENTS.md rule 4). The kernel binary (`kernel/relayflowd serve`) speaks
|
|
8
|
+
// this transport, including out-of-band leases, watches, events, and durable
|
|
9
|
+
// stream plumbing. The client's framing and failure behavior is covered by a
|
|
10
|
+
// loopback double in tests.
|
|
11
|
+
import { EventEmitter } from 'node:events';
|
|
12
|
+
import { randomUUID } from 'node:crypto';
|
|
13
|
+
import { createConnection } from 'node:net';
|
|
14
|
+
import { PROTOCOL_VERSION, } from './protocol.js';
|
|
15
|
+
/** A structured rejection returned by relayflowd over the journal protocol. */
|
|
16
|
+
export class JournalProtocolError extends Error {
|
|
17
|
+
code;
|
|
18
|
+
constructor(code, message) {
|
|
19
|
+
super(`${code}: ${message}`);
|
|
20
|
+
this.name = 'JournalProtocolError';
|
|
21
|
+
this.code = code;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export class JournalClient extends EventEmitter {
|
|
25
|
+
socketPath;
|
|
26
|
+
socket = null;
|
|
27
|
+
buffer = '';
|
|
28
|
+
pending = new Map();
|
|
29
|
+
requestTimeoutMs;
|
|
30
|
+
constructor(socketPath, options = {}) {
|
|
31
|
+
super();
|
|
32
|
+
this.socketPath = socketPath;
|
|
33
|
+
this.requestTimeoutMs = options.requestTimeoutMs ?? 30_000;
|
|
34
|
+
}
|
|
35
|
+
/** Open the unix socket connection. Rejects on connect failure (fail-closed). */
|
|
36
|
+
connect() {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
if (this.socket)
|
|
39
|
+
return resolve();
|
|
40
|
+
const socket = createConnection({ path: this.socketPath });
|
|
41
|
+
const onError = (err) => {
|
|
42
|
+
socket.removeAllListeners();
|
|
43
|
+
this.failAll(err);
|
|
44
|
+
reject(new Error(`journal client: connect failed: ${err.message}`));
|
|
45
|
+
};
|
|
46
|
+
socket.once('error', onError);
|
|
47
|
+
socket.once('connect', () => {
|
|
48
|
+
socket.removeListener('error', onError);
|
|
49
|
+
socket.on('error', (err) => this.failAll(err));
|
|
50
|
+
socket.on('data', (chunk) => this.onData(chunk));
|
|
51
|
+
socket.on('close', () => this.failAll(new Error('journal client: connection closed')));
|
|
52
|
+
this.socket = socket;
|
|
53
|
+
resolve();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** Close the connection and reject any pending requests. */
|
|
58
|
+
close() {
|
|
59
|
+
this.failAll(new Error('journal client: closed by caller'));
|
|
60
|
+
this.socket?.destroy();
|
|
61
|
+
this.socket = null;
|
|
62
|
+
this.buffer = '';
|
|
63
|
+
}
|
|
64
|
+
onData(chunk) {
|
|
65
|
+
this.buffer += chunk.toString('utf8');
|
|
66
|
+
let nl;
|
|
67
|
+
while ((nl = this.buffer.indexOf('\n')) !== -1) {
|
|
68
|
+
const line = this.buffer.slice(0, nl);
|
|
69
|
+
this.buffer = this.buffer.slice(nl + 1);
|
|
70
|
+
if (line.length > 0)
|
|
71
|
+
this.onLine(line);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
onLine(line) {
|
|
75
|
+
let msg;
|
|
76
|
+
try {
|
|
77
|
+
msg = JSON.parse(line);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// A malformed frame is a protocol violation; fail closed.
|
|
81
|
+
this.failAll(new Error('journal client: malformed frame from server'));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (typeof msg.id === 'string' && 'ok' in msg) {
|
|
85
|
+
const res = msg;
|
|
86
|
+
const pending = this.pending.get(res.id);
|
|
87
|
+
if (!pending)
|
|
88
|
+
return; // reply for an already-timed-out request
|
|
89
|
+
this.pending.delete(res.id);
|
|
90
|
+
if (pending.timer !== undefined)
|
|
91
|
+
clearTimeout(pending.timer);
|
|
92
|
+
if (res.ok)
|
|
93
|
+
pending.resolve(res.result);
|
|
94
|
+
else
|
|
95
|
+
pending.reject(new JournalProtocolError(res.error.code, res.error.message));
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
const ev = msg;
|
|
99
|
+
this.emit(ev.event, ev.data);
|
|
100
|
+
this.emit('event', ev);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
failAll(err) {
|
|
104
|
+
for (const [, p] of this.pending) {
|
|
105
|
+
if (p.timer !== undefined)
|
|
106
|
+
clearTimeout(p.timer);
|
|
107
|
+
p.reject(err);
|
|
108
|
+
}
|
|
109
|
+
this.pending.clear();
|
|
110
|
+
}
|
|
111
|
+
request(verb, params, timeoutMs = this.requestTimeoutMs) {
|
|
112
|
+
return new Promise((resolve, reject) => {
|
|
113
|
+
if (!this.socket || this.socket.destroyed) {
|
|
114
|
+
reject(new Error(`journal client: not connected (${verb})`));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const id = randomUUID();
|
|
118
|
+
const frame = { id, verb: verb, params };
|
|
119
|
+
const timer = timeoutMs === null ? undefined : setTimeout(() => {
|
|
120
|
+
this.pending.delete(id);
|
|
121
|
+
reject(new Error(`journal client: ${verb} timed out after ${timeoutMs}ms`));
|
|
122
|
+
}, timeoutMs);
|
|
123
|
+
this.pending.set(id, { resolve: resolve, reject, timer });
|
|
124
|
+
this.socket.write(JSON.stringify(frame) + '\n', (err) => {
|
|
125
|
+
if (err) {
|
|
126
|
+
const p = this.pending.get(id);
|
|
127
|
+
if (p) {
|
|
128
|
+
if (p.timer !== undefined)
|
|
129
|
+
clearTimeout(p.timer);
|
|
130
|
+
this.pending.delete(id);
|
|
131
|
+
p.reject(new Error(`journal client: ${verb} write failed: ${err.message}`));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
// --- Typed verb methods (gate 1 minimal set, kernel DESIGN.md §5) --------
|
|
138
|
+
/** Handshake; version mismatch is a hard error. */
|
|
139
|
+
hello(client) {
|
|
140
|
+
return this.request('hello', { protocol: PROTOCOL_VERSION, client });
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Validate a compiled kernel-dialect spec (zero-agent flows legal), create
|
|
144
|
+
* the run file, and append `run.spawned`. Authoring specs must be compiled
|
|
145
|
+
* with `toKernelSpec` before crossing this journal-protocol boundary.
|
|
146
|
+
*/
|
|
147
|
+
runStart(spec) {
|
|
148
|
+
return this.request('run.start', { spec }, null);
|
|
149
|
+
}
|
|
150
|
+
/** §3 memoized resume. */
|
|
151
|
+
runResume(runId) {
|
|
152
|
+
return this.request('run.resume', { run_id: runId }, null);
|
|
153
|
+
}
|
|
154
|
+
/** Durably request cancellation and return the terminal run fact. */
|
|
155
|
+
runCancel(runId) {
|
|
156
|
+
return this.request('run.cancel', { run_id: runId }, null);
|
|
157
|
+
}
|
|
158
|
+
/** Snapshot for legibility. */
|
|
159
|
+
runGet(runId) {
|
|
160
|
+
return this.request('run.get', { run_id: runId });
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Open a push stream of every appended entry. Resolves once subscribed;
|
|
164
|
+
* entries arrive as `'entry'` events: `client.on('entry', (entry) => …)`.
|
|
165
|
+
*/
|
|
166
|
+
runWatch(runId) {
|
|
167
|
+
return this.request('run.watch', { run_id: runId });
|
|
168
|
+
}
|
|
169
|
+
/** Connection becomes a worker; receives `step.dispatch` events. */
|
|
170
|
+
workerAttach(workerId, stepTypes, pins, capacity) {
|
|
171
|
+
return this.request('worker.attach', { worker_id: workerId, step_types: stepTypes, pins, capacity });
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Phase one of the writeback protocol (Appendix A rule 5): ask the journal to
|
|
175
|
+
* elect this attempt to perform the effect. **Do not call this directly to
|
|
176
|
+
* perform an effect** — use {@link performEffect}, which cannot leave the
|
|
177
|
+
* election and the provider call separated. A `false` here means this attempt
|
|
178
|
+
* owes the provider call *and* the {@link effectConfirm} that closes it;
|
|
179
|
+
* returning from `effectRecord` without doing both leaves the election open.
|
|
180
|
+
*/
|
|
181
|
+
effectRecord(runId, stepId, attempt, idempotencyKey, surfacePath, revisionBefore, revisionAfter) {
|
|
182
|
+
return this.request('effect.record', {
|
|
183
|
+
run_id: runId,
|
|
184
|
+
step_id: stepId,
|
|
185
|
+
attempt,
|
|
186
|
+
idempotency_key: idempotencyKey,
|
|
187
|
+
surface_path: surfacePath,
|
|
188
|
+
revision_before: revisionBefore,
|
|
189
|
+
revision_after: revisionAfter,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Phase two: the provider call this attempt was elected for has happened.
|
|
194
|
+
* Confirming closes the election so no later attempt reclaims it. Only the
|
|
195
|
+
* attempt holding the election may confirm it; the kernel refuses anything
|
|
196
|
+
* else.
|
|
197
|
+
*/
|
|
198
|
+
effectConfirm(runId, stepId, attempt, idempotencyKey, surfacePath) {
|
|
199
|
+
return this.request('effect.confirm', {
|
|
200
|
+
run_id: runId,
|
|
201
|
+
step_id: stepId,
|
|
202
|
+
attempt,
|
|
203
|
+
idempotency_key: idempotencyKey,
|
|
204
|
+
surface_path: surfacePath,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Perform one declared external effect exactly once: elect, perform, confirm.
|
|
209
|
+
*
|
|
210
|
+
* Election alone is not a promise that the writeback happened — a worker that
|
|
211
|
+
* dies between `effect.record` and its provider call would otherwise leave a
|
|
212
|
+
* winner nothing ever performed, and every retry would skip the call while
|
|
213
|
+
* the run completed as if the effect had occurred. Holding the three phases
|
|
214
|
+
* inside one call is what makes them inseparable at this boundary: `perform`
|
|
215
|
+
* runs only for the attempt that won the election, and the election is closed
|
|
216
|
+
* only after `perform` returns. A `perform` that throws leaves the election
|
|
217
|
+
* unconfirmed and therefore reclaimable, so the next attempt performs it.
|
|
218
|
+
*
|
|
219
|
+
* Returns whether this attempt made the provider call; `false` means a
|
|
220
|
+
* confirmed election already covered it.
|
|
221
|
+
*/
|
|
222
|
+
async performEffect(effect, perform) {
|
|
223
|
+
const { deduped } = await this.effectRecord(effect.runId, effect.stepId, effect.attempt, effect.idempotencyKey, effect.surfacePath, effect.revisionBefore, effect.revisionAfter);
|
|
224
|
+
if (deduped)
|
|
225
|
+
return false;
|
|
226
|
+
await perform();
|
|
227
|
+
await this.effectConfirm(effect.runId, effect.stepId, effect.attempt, effect.idempotencyKey, effect.surfacePath);
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
/** Renew the lease — the one lease primitive. */
|
|
231
|
+
stepHeartbeat(runId, stepId, attempt, leaseId) {
|
|
232
|
+
return this.request('step.heartbeat', {
|
|
233
|
+
run_id: runId,
|
|
234
|
+
step_id: stepId,
|
|
235
|
+
attempt,
|
|
236
|
+
lease_id: leaseId,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
/** Complete a dispatched step — also the out-of-band path. */
|
|
240
|
+
stepComplete(runId, stepId, attempt, idempotencyKey, completionReason, extra = {}) {
|
|
241
|
+
return this.request('step.complete', {
|
|
242
|
+
run_id: runId,
|
|
243
|
+
step_id: stepId,
|
|
244
|
+
attempt,
|
|
245
|
+
idempotency_key: idempotencyKey,
|
|
246
|
+
completionReason,
|
|
247
|
+
...extra,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/** Satisfy `wait.event`; a human response arrives here too. */
|
|
251
|
+
eventEmit(runId, eventKey, payload) {
|
|
252
|
+
return this.request('event.emit', { run_id: runId, event_key: eventKey, payload });
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Submit an external event to a flow that declares an event trigger.
|
|
256
|
+
*
|
|
257
|
+
* Without this wrapper the verb existed on the server but was unreachable
|
|
258
|
+
* through the typed client, so authors had to bypass the protocol surface
|
|
259
|
+
* entirely to use the feature.
|
|
260
|
+
*/
|
|
261
|
+
eventSubmit(spec, event) {
|
|
262
|
+
return this.request('event.submit', { spec, event });
|
|
263
|
+
}
|
|
264
|
+
/** Durable channel write; journals `stream.appended`. */
|
|
265
|
+
streamAppend(runId, stream, message) {
|
|
266
|
+
return this.request('stream.append', { run_id: runId, stream, message });
|
|
267
|
+
}
|
|
268
|
+
/** At-least-once replayable read. Committing the consumer offset happens via pins. */
|
|
269
|
+
streamRead(runId, stream, fromOffset, limit) {
|
|
270
|
+
return this.request('stream.read', { run_id: runId, stream, from_offset: fromOffset, limit });
|
|
271
|
+
}
|
|
272
|
+
/** Raw journal access — replay, audit, the report step. */
|
|
273
|
+
journalRead(runId, fromSeq, limit) {
|
|
274
|
+
return this.request('journal.read', { run_id: runId, from_seq: fromSeq, limit });
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=journal-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"journal-client.js","sourceRoot":"","sources":["../src/journal-client.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,EAAE;AACF,6EAA6E;AAC7E,oEAAoE;AACpE,6EAA6E;AAC7E,4EAA4E;AAC5E,0EAA0E;AAC1E,6EAA6E;AAC7E,6EAA6E;AAC7E,4BAA4B;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAe,MAAM,UAAU,CAAC;AAEzD,OAAO,EACL,gBAAgB,GAOjB,MAAM,eAAe,CAAC;AAcvB,+EAA+E;AAC/E,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,IAAI,CAAS;IAEtB,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,MAAM,OAAO,aAAc,SAAQ,YAAY;IAO1B;IANX,MAAM,GAAkB,IAAI,CAAC;IAC7B,MAAM,GAAG,EAAE,CAAC;IACH,OAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;IACrC,gBAAgB,CAAS;IAE1C,YACmB,UAAkB,EACnC,UAAgC,EAAE;QAElC,KAAK,EAAE,CAAC;QAHS,eAAU,GAAV,UAAU,CAAQ;QAInC,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC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AAE,OAAe,EAAE,KAAc;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IACnF,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const UNBOUNDED_REF_CYCLE = "unbounded $ref cycle";
|
|
2
|
+
/**
|
|
3
|
+
* Refuse a declaration whose validation is not guaranteed to terminate.
|
|
4
|
+
* Returns the named refusal, or `undefined` when the schema is bounded.
|
|
5
|
+
*/
|
|
6
|
+
export declare function jsonSchemaBoundError(schema: unknown): string | undefined;
|
|
7
|
+
//# sourceMappingURL=json-schema-bound.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema-bound.d.ts","sourceRoot":"","sources":["../src/json-schema-bound.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,mBAAmB,yBAAyB,CAAC;AAoR1D;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAyDxE"}
|