@cosmonapse/sdk 0.1.3 → 0.1.4
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/index.cjs +554 -200
- package/dist/index.d.cts +118 -1
- package/dist/index.d.ts +118 -1
- package/dist/index.js +551 -200
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -45,6 +45,8 @@ declare const SignalType: {
|
|
|
45
45
|
readonly IMPRINT: "IMPRINT";
|
|
46
46
|
readonly IMPRINTED: "IMPRINTED";
|
|
47
47
|
readonly DISCOVER: "DISCOVER";
|
|
48
|
+
readonly STOP: "STOP";
|
|
49
|
+
readonly STOPPED: "STOPPED";
|
|
48
50
|
};
|
|
49
51
|
type SignalType = (typeof SignalType)[keyof typeof SignalType];
|
|
50
52
|
/** Types the Axon (skill) is allowed to produce. */
|
|
@@ -456,6 +458,68 @@ declare function imprintedSignal(args: {
|
|
|
456
458
|
directed?: DirectedInput;
|
|
457
459
|
meta?: Json;
|
|
458
460
|
}): Signal;
|
|
461
|
+
/** [C] Broadcast a cooperative-cancellation request for a whole trace.
|
|
462
|
+
* `rollback` only reverses Engram state via the saga journal; external side
|
|
463
|
+
* effects a Neuron caused through an Axon are not reversible. */
|
|
464
|
+
declare function stopSignal(args: {
|
|
465
|
+
traceId: string;
|
|
466
|
+
parentId?: string | null;
|
|
467
|
+
rollback?: boolean;
|
|
468
|
+
reason?: string;
|
|
469
|
+
directed?: DirectedInput;
|
|
470
|
+
meta?: Json;
|
|
471
|
+
}): Signal;
|
|
472
|
+
/** [C] Ack from one Dendrite that it has quiesced its share of a trace.
|
|
473
|
+
* `parentId` MUST be the STOP's id so the originator can correlate acks. */
|
|
474
|
+
declare function stoppedSignal(args: {
|
|
475
|
+
traceId: string;
|
|
476
|
+
parentId?: string | null;
|
|
477
|
+
node?: string;
|
|
478
|
+
rolledBack?: boolean;
|
|
479
|
+
cancelled?: number;
|
|
480
|
+
compensated?: number;
|
|
481
|
+
directed?: DirectedInput;
|
|
482
|
+
meta?: Json;
|
|
483
|
+
}): Signal;
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* @cosmonapse/sdk - retry policy for the dispatch + wait shape.
|
|
487
|
+
*
|
|
488
|
+
* Consumed by `Dendrite.dispatchAndWait({ retry })` and
|
|
489
|
+
* `Dendrite.runWithRetry(...)`. Retry only fits the request/reply shape, where
|
|
490
|
+
* the Dendrite owns the whole arc (dispatch -> wait -> close) and can
|
|
491
|
+
* transparently re-dispatch. The streaming shapes hand the live Pathway to the
|
|
492
|
+
* caller, so retry there would orphan the caller's subscriptions.
|
|
493
|
+
*
|
|
494
|
+
* "Stuck" = no terminal within `timeoutMs` (a TimeoutError from Pathway.wait),
|
|
495
|
+
* the Pathway closing before a terminal (PathwayClosedError), or a returned
|
|
496
|
+
* ERROR flagged `recoverable`. New-trace retries STOP the abandoned attempt
|
|
497
|
+
* before the next try so a stalled worker can't outlive the retry.
|
|
498
|
+
*/
|
|
499
|
+
|
|
500
|
+
type RetryOutcome = Signal | Error;
|
|
501
|
+
/** Default predicate: retry on timeout, a Pathway closed before a terminal, or
|
|
502
|
+
* a returned ERROR flagged `recoverable`. FINAL / AGENT_OUTPUT /
|
|
503
|
+
* CLARIFICATION / PERMISSION are never retried. */
|
|
504
|
+
declare function defaultRetryOn(outcome: RetryOutcome): boolean;
|
|
505
|
+
interface RetryStrategy {
|
|
506
|
+
/** Total tries including the first (>= 1). Default 3. */
|
|
507
|
+
maxAttempts?: number;
|
|
508
|
+
/** Per-attempt terminal timeout in ms. Default 30000. */
|
|
509
|
+
timeoutMs?: number;
|
|
510
|
+
/** attempt -> ms to sleep before the next try (0-based). Default 0. */
|
|
511
|
+
backoffMs?: (attempt: number) => number;
|
|
512
|
+
/** outcome -> whether to retry. Default {@link defaultRetryOn}. */
|
|
513
|
+
retryOn?: (outcome: RetryOutcome) => boolean;
|
|
514
|
+
/** Fresh trace per attempt (and STOP the abandoned one). Default true. */
|
|
515
|
+
newTrace?: boolean;
|
|
516
|
+
/** Also roll back the abandoned attempt's Engram writes. Default false. */
|
|
517
|
+
rollbackOnRetry?: boolean;
|
|
518
|
+
/** Hook fired just before a re-dispatch. */
|
|
519
|
+
onRetry?: (attempt: number, outcome: RetryOutcome) => void;
|
|
520
|
+
/** Reason carried on the preemptive STOP. Default "retry". */
|
|
521
|
+
reason?: string;
|
|
522
|
+
}
|
|
459
523
|
|
|
460
524
|
/**
|
|
461
525
|
* @cosmonapse/sdk - synapse
|
|
@@ -1232,6 +1296,14 @@ interface ImprintOptions {
|
|
|
1232
1296
|
mergeKey?: string;
|
|
1233
1297
|
/** Originating IMPRINT signal id; backends use it for idempotency. */
|
|
1234
1298
|
imprintId?: string;
|
|
1299
|
+
/**
|
|
1300
|
+
* Containing TASK's trace. When set, a backend that supports rollback
|
|
1301
|
+
* records the inverse of this write in a per-trace saga journal (via
|
|
1302
|
+
* `sagaRecord`) so the whole trace can be reversed by `compensate`. A
|
|
1303
|
+
* missing traceId means "do not journal" - exactly how `compensate`
|
|
1304
|
+
* replays inverse ops without re-journaling them.
|
|
1305
|
+
*/
|
|
1306
|
+
traceId?: string;
|
|
1235
1307
|
}
|
|
1236
1308
|
/**
|
|
1237
1309
|
* Storage wrapper. One backend per Engram instance. Every backend implements
|
|
@@ -1250,6 +1322,19 @@ declare abstract class Engram {
|
|
|
1250
1322
|
abstract recall(query: Json, opts?: RecallOptions): Promise<Hit[]>;
|
|
1251
1323
|
/** Write to the backend. `op` is one of add | append | merge | upsert | delete. */
|
|
1252
1324
|
abstract imprint(op: ImprintOp, entry: Json, opts?: ImprintOptions): Promise<ImprintReceipt>;
|
|
1325
|
+
protected sagaJournal: Map<string, Array<{
|
|
1326
|
+
op: ImprintOp;
|
|
1327
|
+
entry: Json;
|
|
1328
|
+
mergeKey: string | undefined;
|
|
1329
|
+
}>>;
|
|
1330
|
+
protected sagaRecord(traceId: string | undefined, op: ImprintOp, entry: Json, mergeKey?: string): void;
|
|
1331
|
+
/** Reverse every journaled write for `traceId` (LIFO) and discard the
|
|
1332
|
+
* journal. Returns the number of inverse ops applied. Best-effort. Only
|
|
1333
|
+
* Engram state is reversed - external side effects are out of scope. */
|
|
1334
|
+
compensate(traceId: string): Promise<number>;
|
|
1335
|
+
/** Discard the trace's saga journal without reversing anything. Called at
|
|
1336
|
+
* the workflow commit point (FINAL/ERROR on the trace). */
|
|
1337
|
+
commit(traceId: string): Promise<void>;
|
|
1253
1338
|
/** Return false if this Engram cannot satisfy the query. Default: serve all. */
|
|
1254
1339
|
canServe(_query: Json): Promise<boolean>;
|
|
1255
1340
|
}
|
|
@@ -1777,6 +1862,7 @@ declare class Dendrite {
|
|
|
1777
1862
|
/** Hosted Engrams keyed by engramId, plus a kind index so RECALL/IMPRINT
|
|
1778
1863
|
* addressed by engramKind reach every matching host. */
|
|
1779
1864
|
private readonly _engrams;
|
|
1865
|
+
private readonly traceAborts;
|
|
1780
1866
|
private readonly engramKindIndex;
|
|
1781
1867
|
/** Engrams learned from peer REGISTER signals (possibly out-of-process). */
|
|
1782
1868
|
private readonly _engramRegistrations;
|
|
@@ -1990,6 +2076,7 @@ declare class Dendrite {
|
|
|
1990
2076
|
scope?: PathwayScope;
|
|
1991
2077
|
finalize?: boolean;
|
|
1992
2078
|
timeoutMs?: number;
|
|
2079
|
+
retry?: RetryStrategy;
|
|
1993
2080
|
}): Promise<Signal>;
|
|
1994
2081
|
/** Async-shape sugar: dispatch, return the live Pathway immediately. The
|
|
1995
2082
|
* caller attaches `pw.on(...)` callbacks or iterates. */
|
|
@@ -2213,6 +2300,36 @@ declare class Dendrite {
|
|
|
2213
2300
|
* PERMISSION pause the workflow and ERROR is already terminal.
|
|
2214
2301
|
*/
|
|
2215
2302
|
private onTask;
|
|
2303
|
+
private registerTraceAbort;
|
|
2304
|
+
private unregisterTraceAbort;
|
|
2305
|
+
/** Resolve to the promise's value, or to null if the signal aborts first. */
|
|
2306
|
+
private raceAbort;
|
|
2307
|
+
private onStop;
|
|
2308
|
+
/** Broadcast a STOP for `traceId` (orchestrator-gated). Best-effort and
|
|
2309
|
+
* idempotent. */
|
|
2310
|
+
emitStop(args: {
|
|
2311
|
+
traceId: string;
|
|
2312
|
+
rollback?: boolean;
|
|
2313
|
+
reason?: string;
|
|
2314
|
+
}): Promise<Signal>;
|
|
2315
|
+
/** Stop a whole workflow. With `collectAcks` returns the STOPPED acks seen
|
|
2316
|
+
* within `timeoutMs` (best effort). */
|
|
2317
|
+
stopTrace(traceId: string, opts?: {
|
|
2318
|
+
rollback?: boolean;
|
|
2319
|
+
reason?: string;
|
|
2320
|
+
collectAcks?: boolean;
|
|
2321
|
+
timeoutMs?: number;
|
|
2322
|
+
}): Promise<Signal[]>;
|
|
2323
|
+
private safeStop;
|
|
2324
|
+
/** Dispatch and wait, retrying per `retry` until a non-retryable outcome or
|
|
2325
|
+
* attempts are exhausted. Returns the resolved Signal; re-throws the last
|
|
2326
|
+
* error when every attempt failed with an exception. */
|
|
2327
|
+
runWithRetry(args: DispatchArgs & {
|
|
2328
|
+
scope?: PathwayScope;
|
|
2329
|
+
finalize?: boolean;
|
|
2330
|
+
timeoutMs?: number;
|
|
2331
|
+
retry: RetryStrategy;
|
|
2332
|
+
}): Promise<Signal>;
|
|
2216
2333
|
private emitRegister;
|
|
2217
2334
|
private emitDeregister;
|
|
2218
2335
|
private heartbeatTick;
|
|
@@ -2544,4 +2661,4 @@ declare class PostgresEngram extends Engram {
|
|
|
2544
2661
|
*/
|
|
2545
2662
|
declare const VERSION: string;
|
|
2546
2663
|
|
|
2547
|
-
export { AXON_TYPES, type AnthropicNeuronOptions, Axon, type AxonExtra, type AxonOptions, COSMO_INTENT_SYSTEM_PROMPT, type ClarificationOutput, type CloseableNeuronFn, type ConnectHook, type ContextFetcher, Cortex, DendriteProtocolError as CortexProtocolError, Dendrite, type DendriteOptions, DendriteProtocolError, type DendriteRole, DevSynapse, type DevSynapseOptions, DevSynapseServer, type DevSynapseServerOptions, type Directed, type DirectedInput, Engram, EngramBinding, type EngramBindingInit, EngramCancelled, EngramClient, EngramError, EngramNotBound, EngramOverloaded, type EngramPublisher, EngramTimeout, type ErrorOutput, type HandlerFilter, type Hit, type HuggingFaceNeuronOptions, type ImprintCallArgs, type ImprintOp, type ImprintOptions, type ImprintReceipt, InMemoryEngram, type InMemoryEngramInit, type Json, KafkaSynapse, type KafkaSynapseOptions, LifecycleHooks, type ListOptions, type McpNeuronOptions, MemoryRegistryStore, MemorySynapse, type MessageHandler, NatsSynapse, type NatsSynapseOptions, type NeuronFn, type NeuronHelpers, type NeuronRecord, type NeuronRecordInit, type NeuronSource, type NeuronStatus, type NewSignalInput, type OllamaNeuronOptions, type OpenAICompatNeuronOptions, type OpenAINeuronOptions, type OutputParser, PATHWAY_TYPES, Pathway, type PathwayCloseHook, PathwayClosedError, type PathwayOptions, type PathwayRole, type PathwayScope, type PathwaySignalHandler, type PermissionRequestOutput, PostgresEngram, type PostgresEngramInit, PostgresRegistryStore, type PostgresRegistryStoreOptions, type RecallCallArgs, type RecallMode, type RecallOptions, type RecallResult, type Recogniser, type RefreshEvent, type RefreshHook, type RegistryStore, type RequestOptions, SYNAPSE_TYPES, type ScheduleHook, type Signal, type SignalHandler, SignalType, SqliteEngram, type SqliteEngramInit, SqliteRegistryStore, type SubscribeOptions, type Subscription, type Synapse, TERMINAL_TYPES, VERSION, agentOutputSignal, ambientTrace, anthropicNeuron, bidSignal, clarificationAnswerSignal, clarificationSignal, clarify, connectSynapse, consensusSignal, contextSyncSignal, createSignal, critiqueSignal, decode, deepMerge, deregisterSignal, directedTo, discoverSignal, encode, errorResult, errorSignal, escalationSignal, finalSignal, followupPrompt, heartbeatSignal, huggingFaceNeuron, imprintSignal, imprintedSignal, isClarification, isErrorOutput, isPermissionRequest, mcpNeuron, memoryAppendSignal, neuron, neuronRecord, newEngramId, newEventId, newTraceId, normalizeDirected, ollamaNeuron, openaiNeuron, parseLlmIntents, parseMcpIntents, permissionDecisionSignal, permissionRequest, permissionSignal, planSignal, recallSignal, recalledSignal, registerSignal, reply, runWithTraceContext, standardMcpServers, synapseFromUrl, taskAwardedSignal, taskDeclinedSignal, taskOfferSignal, taskSignal, thoughtDeltaSignal, toolCallSignal, toolResultSignal, validateSignal };
|
|
2664
|
+
export { AXON_TYPES, type AnthropicNeuronOptions, Axon, type AxonExtra, type AxonOptions, COSMO_INTENT_SYSTEM_PROMPT, type ClarificationOutput, type CloseableNeuronFn, type ConnectHook, type ContextFetcher, Cortex, DendriteProtocolError as CortexProtocolError, Dendrite, type DendriteOptions, DendriteProtocolError, type DendriteRole, DevSynapse, type DevSynapseOptions, DevSynapseServer, type DevSynapseServerOptions, type Directed, type DirectedInput, Engram, EngramBinding, type EngramBindingInit, EngramCancelled, EngramClient, EngramError, EngramNotBound, EngramOverloaded, type EngramPublisher, EngramTimeout, type ErrorOutput, type HandlerFilter, type Hit, type HuggingFaceNeuronOptions, type ImprintCallArgs, type ImprintOp, type ImprintOptions, type ImprintReceipt, InMemoryEngram, type InMemoryEngramInit, type Json, KafkaSynapse, type KafkaSynapseOptions, LifecycleHooks, type ListOptions, type McpNeuronOptions, MemoryRegistryStore, MemorySynapse, type MessageHandler, NatsSynapse, type NatsSynapseOptions, type NeuronFn, type NeuronHelpers, type NeuronRecord, type NeuronRecordInit, type NeuronSource, type NeuronStatus, type NewSignalInput, type OllamaNeuronOptions, type OpenAICompatNeuronOptions, type OpenAINeuronOptions, type OutputParser, PATHWAY_TYPES, Pathway, type PathwayCloseHook, PathwayClosedError, type PathwayOptions, type PathwayRole, type PathwayScope, type PathwaySignalHandler, type PermissionRequestOutput, PostgresEngram, type PostgresEngramInit, PostgresRegistryStore, type PostgresRegistryStoreOptions, type RecallCallArgs, type RecallMode, type RecallOptions, type RecallResult, type Recogniser, type RefreshEvent, type RefreshHook, type RegistryStore, type RequestOptions, type RetryOutcome, type RetryStrategy, SYNAPSE_TYPES, type ScheduleHook, type Signal, type SignalHandler, SignalType, SqliteEngram, type SqliteEngramInit, SqliteRegistryStore, type SubscribeOptions, type Subscription, type Synapse, TERMINAL_TYPES, VERSION, agentOutputSignal, ambientTrace, anthropicNeuron, bidSignal, clarificationAnswerSignal, clarificationSignal, clarify, connectSynapse, consensusSignal, contextSyncSignal, createSignal, critiqueSignal, decode, deepMerge, defaultRetryOn, deregisterSignal, directedTo, discoverSignal, encode, errorResult, errorSignal, escalationSignal, finalSignal, followupPrompt, heartbeatSignal, huggingFaceNeuron, imprintSignal, imprintedSignal, isClarification, isErrorOutput, isPermissionRequest, mcpNeuron, memoryAppendSignal, neuron, neuronRecord, newEngramId, newEventId, newTraceId, normalizeDirected, ollamaNeuron, openaiNeuron, parseLlmIntents, parseMcpIntents, permissionDecisionSignal, permissionRequest, permissionSignal, planSignal, recallSignal, recalledSignal, registerSignal, reply, runWithTraceContext, standardMcpServers, stopSignal, stoppedSignal, synapseFromUrl, taskAwardedSignal, taskDeclinedSignal, taskOfferSignal, taskSignal, thoughtDeltaSignal, toolCallSignal, toolResultSignal, validateSignal };
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,8 @@ declare const SignalType: {
|
|
|
45
45
|
readonly IMPRINT: "IMPRINT";
|
|
46
46
|
readonly IMPRINTED: "IMPRINTED";
|
|
47
47
|
readonly DISCOVER: "DISCOVER";
|
|
48
|
+
readonly STOP: "STOP";
|
|
49
|
+
readonly STOPPED: "STOPPED";
|
|
48
50
|
};
|
|
49
51
|
type SignalType = (typeof SignalType)[keyof typeof SignalType];
|
|
50
52
|
/** Types the Axon (skill) is allowed to produce. */
|
|
@@ -456,6 +458,68 @@ declare function imprintedSignal(args: {
|
|
|
456
458
|
directed?: DirectedInput;
|
|
457
459
|
meta?: Json;
|
|
458
460
|
}): Signal;
|
|
461
|
+
/** [C] Broadcast a cooperative-cancellation request for a whole trace.
|
|
462
|
+
* `rollback` only reverses Engram state via the saga journal; external side
|
|
463
|
+
* effects a Neuron caused through an Axon are not reversible. */
|
|
464
|
+
declare function stopSignal(args: {
|
|
465
|
+
traceId: string;
|
|
466
|
+
parentId?: string | null;
|
|
467
|
+
rollback?: boolean;
|
|
468
|
+
reason?: string;
|
|
469
|
+
directed?: DirectedInput;
|
|
470
|
+
meta?: Json;
|
|
471
|
+
}): Signal;
|
|
472
|
+
/** [C] Ack from one Dendrite that it has quiesced its share of a trace.
|
|
473
|
+
* `parentId` MUST be the STOP's id so the originator can correlate acks. */
|
|
474
|
+
declare function stoppedSignal(args: {
|
|
475
|
+
traceId: string;
|
|
476
|
+
parentId?: string | null;
|
|
477
|
+
node?: string;
|
|
478
|
+
rolledBack?: boolean;
|
|
479
|
+
cancelled?: number;
|
|
480
|
+
compensated?: number;
|
|
481
|
+
directed?: DirectedInput;
|
|
482
|
+
meta?: Json;
|
|
483
|
+
}): Signal;
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* @cosmonapse/sdk - retry policy for the dispatch + wait shape.
|
|
487
|
+
*
|
|
488
|
+
* Consumed by `Dendrite.dispatchAndWait({ retry })` and
|
|
489
|
+
* `Dendrite.runWithRetry(...)`. Retry only fits the request/reply shape, where
|
|
490
|
+
* the Dendrite owns the whole arc (dispatch -> wait -> close) and can
|
|
491
|
+
* transparently re-dispatch. The streaming shapes hand the live Pathway to the
|
|
492
|
+
* caller, so retry there would orphan the caller's subscriptions.
|
|
493
|
+
*
|
|
494
|
+
* "Stuck" = no terminal within `timeoutMs` (a TimeoutError from Pathway.wait),
|
|
495
|
+
* the Pathway closing before a terminal (PathwayClosedError), or a returned
|
|
496
|
+
* ERROR flagged `recoverable`. New-trace retries STOP the abandoned attempt
|
|
497
|
+
* before the next try so a stalled worker can't outlive the retry.
|
|
498
|
+
*/
|
|
499
|
+
|
|
500
|
+
type RetryOutcome = Signal | Error;
|
|
501
|
+
/** Default predicate: retry on timeout, a Pathway closed before a terminal, or
|
|
502
|
+
* a returned ERROR flagged `recoverable`. FINAL / AGENT_OUTPUT /
|
|
503
|
+
* CLARIFICATION / PERMISSION are never retried. */
|
|
504
|
+
declare function defaultRetryOn(outcome: RetryOutcome): boolean;
|
|
505
|
+
interface RetryStrategy {
|
|
506
|
+
/** Total tries including the first (>= 1). Default 3. */
|
|
507
|
+
maxAttempts?: number;
|
|
508
|
+
/** Per-attempt terminal timeout in ms. Default 30000. */
|
|
509
|
+
timeoutMs?: number;
|
|
510
|
+
/** attempt -> ms to sleep before the next try (0-based). Default 0. */
|
|
511
|
+
backoffMs?: (attempt: number) => number;
|
|
512
|
+
/** outcome -> whether to retry. Default {@link defaultRetryOn}. */
|
|
513
|
+
retryOn?: (outcome: RetryOutcome) => boolean;
|
|
514
|
+
/** Fresh trace per attempt (and STOP the abandoned one). Default true. */
|
|
515
|
+
newTrace?: boolean;
|
|
516
|
+
/** Also roll back the abandoned attempt's Engram writes. Default false. */
|
|
517
|
+
rollbackOnRetry?: boolean;
|
|
518
|
+
/** Hook fired just before a re-dispatch. */
|
|
519
|
+
onRetry?: (attempt: number, outcome: RetryOutcome) => void;
|
|
520
|
+
/** Reason carried on the preemptive STOP. Default "retry". */
|
|
521
|
+
reason?: string;
|
|
522
|
+
}
|
|
459
523
|
|
|
460
524
|
/**
|
|
461
525
|
* @cosmonapse/sdk - synapse
|
|
@@ -1232,6 +1296,14 @@ interface ImprintOptions {
|
|
|
1232
1296
|
mergeKey?: string;
|
|
1233
1297
|
/** Originating IMPRINT signal id; backends use it for idempotency. */
|
|
1234
1298
|
imprintId?: string;
|
|
1299
|
+
/**
|
|
1300
|
+
* Containing TASK's trace. When set, a backend that supports rollback
|
|
1301
|
+
* records the inverse of this write in a per-trace saga journal (via
|
|
1302
|
+
* `sagaRecord`) so the whole trace can be reversed by `compensate`. A
|
|
1303
|
+
* missing traceId means "do not journal" - exactly how `compensate`
|
|
1304
|
+
* replays inverse ops without re-journaling them.
|
|
1305
|
+
*/
|
|
1306
|
+
traceId?: string;
|
|
1235
1307
|
}
|
|
1236
1308
|
/**
|
|
1237
1309
|
* Storage wrapper. One backend per Engram instance. Every backend implements
|
|
@@ -1250,6 +1322,19 @@ declare abstract class Engram {
|
|
|
1250
1322
|
abstract recall(query: Json, opts?: RecallOptions): Promise<Hit[]>;
|
|
1251
1323
|
/** Write to the backend. `op` is one of add | append | merge | upsert | delete. */
|
|
1252
1324
|
abstract imprint(op: ImprintOp, entry: Json, opts?: ImprintOptions): Promise<ImprintReceipt>;
|
|
1325
|
+
protected sagaJournal: Map<string, Array<{
|
|
1326
|
+
op: ImprintOp;
|
|
1327
|
+
entry: Json;
|
|
1328
|
+
mergeKey: string | undefined;
|
|
1329
|
+
}>>;
|
|
1330
|
+
protected sagaRecord(traceId: string | undefined, op: ImprintOp, entry: Json, mergeKey?: string): void;
|
|
1331
|
+
/** Reverse every journaled write for `traceId` (LIFO) and discard the
|
|
1332
|
+
* journal. Returns the number of inverse ops applied. Best-effort. Only
|
|
1333
|
+
* Engram state is reversed - external side effects are out of scope. */
|
|
1334
|
+
compensate(traceId: string): Promise<number>;
|
|
1335
|
+
/** Discard the trace's saga journal without reversing anything. Called at
|
|
1336
|
+
* the workflow commit point (FINAL/ERROR on the trace). */
|
|
1337
|
+
commit(traceId: string): Promise<void>;
|
|
1253
1338
|
/** Return false if this Engram cannot satisfy the query. Default: serve all. */
|
|
1254
1339
|
canServe(_query: Json): Promise<boolean>;
|
|
1255
1340
|
}
|
|
@@ -1777,6 +1862,7 @@ declare class Dendrite {
|
|
|
1777
1862
|
/** Hosted Engrams keyed by engramId, plus a kind index so RECALL/IMPRINT
|
|
1778
1863
|
* addressed by engramKind reach every matching host. */
|
|
1779
1864
|
private readonly _engrams;
|
|
1865
|
+
private readonly traceAborts;
|
|
1780
1866
|
private readonly engramKindIndex;
|
|
1781
1867
|
/** Engrams learned from peer REGISTER signals (possibly out-of-process). */
|
|
1782
1868
|
private readonly _engramRegistrations;
|
|
@@ -1990,6 +2076,7 @@ declare class Dendrite {
|
|
|
1990
2076
|
scope?: PathwayScope;
|
|
1991
2077
|
finalize?: boolean;
|
|
1992
2078
|
timeoutMs?: number;
|
|
2079
|
+
retry?: RetryStrategy;
|
|
1993
2080
|
}): Promise<Signal>;
|
|
1994
2081
|
/** Async-shape sugar: dispatch, return the live Pathway immediately. The
|
|
1995
2082
|
* caller attaches `pw.on(...)` callbacks or iterates. */
|
|
@@ -2213,6 +2300,36 @@ declare class Dendrite {
|
|
|
2213
2300
|
* PERMISSION pause the workflow and ERROR is already terminal.
|
|
2214
2301
|
*/
|
|
2215
2302
|
private onTask;
|
|
2303
|
+
private registerTraceAbort;
|
|
2304
|
+
private unregisterTraceAbort;
|
|
2305
|
+
/** Resolve to the promise's value, or to null if the signal aborts first. */
|
|
2306
|
+
private raceAbort;
|
|
2307
|
+
private onStop;
|
|
2308
|
+
/** Broadcast a STOP for `traceId` (orchestrator-gated). Best-effort and
|
|
2309
|
+
* idempotent. */
|
|
2310
|
+
emitStop(args: {
|
|
2311
|
+
traceId: string;
|
|
2312
|
+
rollback?: boolean;
|
|
2313
|
+
reason?: string;
|
|
2314
|
+
}): Promise<Signal>;
|
|
2315
|
+
/** Stop a whole workflow. With `collectAcks` returns the STOPPED acks seen
|
|
2316
|
+
* within `timeoutMs` (best effort). */
|
|
2317
|
+
stopTrace(traceId: string, opts?: {
|
|
2318
|
+
rollback?: boolean;
|
|
2319
|
+
reason?: string;
|
|
2320
|
+
collectAcks?: boolean;
|
|
2321
|
+
timeoutMs?: number;
|
|
2322
|
+
}): Promise<Signal[]>;
|
|
2323
|
+
private safeStop;
|
|
2324
|
+
/** Dispatch and wait, retrying per `retry` until a non-retryable outcome or
|
|
2325
|
+
* attempts are exhausted. Returns the resolved Signal; re-throws the last
|
|
2326
|
+
* error when every attempt failed with an exception. */
|
|
2327
|
+
runWithRetry(args: DispatchArgs & {
|
|
2328
|
+
scope?: PathwayScope;
|
|
2329
|
+
finalize?: boolean;
|
|
2330
|
+
timeoutMs?: number;
|
|
2331
|
+
retry: RetryStrategy;
|
|
2332
|
+
}): Promise<Signal>;
|
|
2216
2333
|
private emitRegister;
|
|
2217
2334
|
private emitDeregister;
|
|
2218
2335
|
private heartbeatTick;
|
|
@@ -2544,4 +2661,4 @@ declare class PostgresEngram extends Engram {
|
|
|
2544
2661
|
*/
|
|
2545
2662
|
declare const VERSION: string;
|
|
2546
2663
|
|
|
2547
|
-
export { AXON_TYPES, type AnthropicNeuronOptions, Axon, type AxonExtra, type AxonOptions, COSMO_INTENT_SYSTEM_PROMPT, type ClarificationOutput, type CloseableNeuronFn, type ConnectHook, type ContextFetcher, Cortex, DendriteProtocolError as CortexProtocolError, Dendrite, type DendriteOptions, DendriteProtocolError, type DendriteRole, DevSynapse, type DevSynapseOptions, DevSynapseServer, type DevSynapseServerOptions, type Directed, type DirectedInput, Engram, EngramBinding, type EngramBindingInit, EngramCancelled, EngramClient, EngramError, EngramNotBound, EngramOverloaded, type EngramPublisher, EngramTimeout, type ErrorOutput, type HandlerFilter, type Hit, type HuggingFaceNeuronOptions, type ImprintCallArgs, type ImprintOp, type ImprintOptions, type ImprintReceipt, InMemoryEngram, type InMemoryEngramInit, type Json, KafkaSynapse, type KafkaSynapseOptions, LifecycleHooks, type ListOptions, type McpNeuronOptions, MemoryRegistryStore, MemorySynapse, type MessageHandler, NatsSynapse, type NatsSynapseOptions, type NeuronFn, type NeuronHelpers, type NeuronRecord, type NeuronRecordInit, type NeuronSource, type NeuronStatus, type NewSignalInput, type OllamaNeuronOptions, type OpenAICompatNeuronOptions, type OpenAINeuronOptions, type OutputParser, PATHWAY_TYPES, Pathway, type PathwayCloseHook, PathwayClosedError, type PathwayOptions, type PathwayRole, type PathwayScope, type PathwaySignalHandler, type PermissionRequestOutput, PostgresEngram, type PostgresEngramInit, PostgresRegistryStore, type PostgresRegistryStoreOptions, type RecallCallArgs, type RecallMode, type RecallOptions, type RecallResult, type Recogniser, type RefreshEvent, type RefreshHook, type RegistryStore, type RequestOptions, SYNAPSE_TYPES, type ScheduleHook, type Signal, type SignalHandler, SignalType, SqliteEngram, type SqliteEngramInit, SqliteRegistryStore, type SubscribeOptions, type Subscription, type Synapse, TERMINAL_TYPES, VERSION, agentOutputSignal, ambientTrace, anthropicNeuron, bidSignal, clarificationAnswerSignal, clarificationSignal, clarify, connectSynapse, consensusSignal, contextSyncSignal, createSignal, critiqueSignal, decode, deepMerge, deregisterSignal, directedTo, discoverSignal, encode, errorResult, errorSignal, escalationSignal, finalSignal, followupPrompt, heartbeatSignal, huggingFaceNeuron, imprintSignal, imprintedSignal, isClarification, isErrorOutput, isPermissionRequest, mcpNeuron, memoryAppendSignal, neuron, neuronRecord, newEngramId, newEventId, newTraceId, normalizeDirected, ollamaNeuron, openaiNeuron, parseLlmIntents, parseMcpIntents, permissionDecisionSignal, permissionRequest, permissionSignal, planSignal, recallSignal, recalledSignal, registerSignal, reply, runWithTraceContext, standardMcpServers, synapseFromUrl, taskAwardedSignal, taskDeclinedSignal, taskOfferSignal, taskSignal, thoughtDeltaSignal, toolCallSignal, toolResultSignal, validateSignal };
|
|
2664
|
+
export { AXON_TYPES, type AnthropicNeuronOptions, Axon, type AxonExtra, type AxonOptions, COSMO_INTENT_SYSTEM_PROMPT, type ClarificationOutput, type CloseableNeuronFn, type ConnectHook, type ContextFetcher, Cortex, DendriteProtocolError as CortexProtocolError, Dendrite, type DendriteOptions, DendriteProtocolError, type DendriteRole, DevSynapse, type DevSynapseOptions, DevSynapseServer, type DevSynapseServerOptions, type Directed, type DirectedInput, Engram, EngramBinding, type EngramBindingInit, EngramCancelled, EngramClient, EngramError, EngramNotBound, EngramOverloaded, type EngramPublisher, EngramTimeout, type ErrorOutput, type HandlerFilter, type Hit, type HuggingFaceNeuronOptions, type ImprintCallArgs, type ImprintOp, type ImprintOptions, type ImprintReceipt, InMemoryEngram, type InMemoryEngramInit, type Json, KafkaSynapse, type KafkaSynapseOptions, LifecycleHooks, type ListOptions, type McpNeuronOptions, MemoryRegistryStore, MemorySynapse, type MessageHandler, NatsSynapse, type NatsSynapseOptions, type NeuronFn, type NeuronHelpers, type NeuronRecord, type NeuronRecordInit, type NeuronSource, type NeuronStatus, type NewSignalInput, type OllamaNeuronOptions, type OpenAICompatNeuronOptions, type OpenAINeuronOptions, type OutputParser, PATHWAY_TYPES, Pathway, type PathwayCloseHook, PathwayClosedError, type PathwayOptions, type PathwayRole, type PathwayScope, type PathwaySignalHandler, type PermissionRequestOutput, PostgresEngram, type PostgresEngramInit, PostgresRegistryStore, type PostgresRegistryStoreOptions, type RecallCallArgs, type RecallMode, type RecallOptions, type RecallResult, type Recogniser, type RefreshEvent, type RefreshHook, type RegistryStore, type RequestOptions, type RetryOutcome, type RetryStrategy, SYNAPSE_TYPES, type ScheduleHook, type Signal, type SignalHandler, SignalType, SqliteEngram, type SqliteEngramInit, SqliteRegistryStore, type SubscribeOptions, type Subscription, type Synapse, TERMINAL_TYPES, VERSION, agentOutputSignal, ambientTrace, anthropicNeuron, bidSignal, clarificationAnswerSignal, clarificationSignal, clarify, connectSynapse, consensusSignal, contextSyncSignal, createSignal, critiqueSignal, decode, deepMerge, defaultRetryOn, deregisterSignal, directedTo, discoverSignal, encode, errorResult, errorSignal, escalationSignal, finalSignal, followupPrompt, heartbeatSignal, huggingFaceNeuron, imprintSignal, imprintedSignal, isClarification, isErrorOutput, isPermissionRequest, mcpNeuron, memoryAppendSignal, neuron, neuronRecord, newEngramId, newEventId, newTraceId, normalizeDirected, ollamaNeuron, openaiNeuron, parseLlmIntents, parseMcpIntents, permissionDecisionSignal, permissionRequest, permissionSignal, planSignal, recallSignal, recalledSignal, registerSignal, reply, runWithTraceContext, standardMcpServers, stopSignal, stoppedSignal, synapseFromUrl, taskAwardedSignal, taskDeclinedSignal, taskOfferSignal, taskSignal, thoughtDeltaSignal, toolCallSignal, toolResultSignal, validateSignal };
|