@relaycast/engine 8.2.1 → 8.2.2
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/adapters/node/realtime.d.ts +5 -1
- package/dist/adapters/node/realtime.d.ts.map +1 -1
- package/dist/adapters/node/realtime.js +48 -3
- package/dist/adapters/node/realtime.js.map +1 -1
- package/dist/db/migrations/0042_action_invocation_handler_snapshot.sql +6 -0
- package/dist/db/schema.d.ts +38 -0
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +5 -0
- package/dist/db/schema.js.map +1 -1
- package/dist/engine/action.d.ts +38 -15
- package/dist/engine/action.d.ts.map +1 -1
- package/dist/engine/action.js +343 -18
- package/dist/engine/action.js.map +1 -1
- package/dist/lib/httpQuery.d.ts +3 -3
- package/dist/lib/httpQuery.d.ts.map +1 -1
- package/dist/node-invocations.d.ts +1 -1
- package/dist/node-invocations.d.ts.map +1 -1
- package/dist/node-invocations.js +1 -1
- package/dist/node-invocations.js.map +1 -1
- package/dist/ports/realtime.d.ts +26 -0
- package/dist/ports/realtime.d.ts.map +1 -1
- package/dist/ports/realtime.js.map +1 -1
- package/dist/routes/action.d.ts.map +1 -1
- package/dist/routes/action.js +26 -16
- package/dist/routes/action.js.map +1 -1
- package/package.json +3 -3
package/dist/engine/action.d.ts
CHANGED
|
@@ -15,10 +15,39 @@ export declare const ACTION_DISPATCH_TIMEOUT_MS = 30000;
|
|
|
15
15
|
* a signal instead of an unbounded hang.
|
|
16
16
|
*/
|
|
17
17
|
export declare const ACTION_HANDLER_UNREACHABLE_TTL_MS = 120000;
|
|
18
|
+
/**
|
|
19
|
+
* Absolute age bound for a `pending` invocation that was NEVER dispatched to a
|
|
20
|
+
* node (`dispatch_attempts = 0`). The handler-unreachable TTL only fires once a
|
|
21
|
+
* dispatched handler connection has been observed offline; an invocation that
|
|
22
|
+
* never left the queue has no handler to observe, so the clock never starts
|
|
23
|
+
* and the row can sit `pending` forever. When the queue eventually drains
|
|
24
|
+
* (e.g. a node returns after a long outage), week-old spawn briefs come back
|
|
25
|
+
* to life as fresh agents that can evict the live resident under the same
|
|
26
|
+
* name — a delayed-action identity hazard, not inert backlog. Sized deliberately:
|
|
27
|
+
* long enough to ride out a weekend-scale node outage plus a day of buffer,
|
|
28
|
+
* far shorter than the observed multi-month backlog that motivated it.
|
|
29
|
+
*/
|
|
30
|
+
export declare const PENDING_INVOCATION_MAX_AGE_MS: number;
|
|
31
|
+
/**
|
|
32
|
+
* Sleep between the never-dispatched sweep's candidate SELECT and its atomic
|
|
33
|
+
* UPDATE. `dispatchNodeInvocation` sends the frame before recording
|
|
34
|
+
* `dispatchAttempts += 1`, so a sweep landing between those two dispatcher
|
|
35
|
+
* calls could otherwise mark an in-flight dispatch `never_dispatched_expired`
|
|
36
|
+
* while the handler already has the frame. The atomic UPDATE re-checks
|
|
37
|
+
* `dispatch_attempts = 0`, so once the dispatcher's UPDATE lands, the sweep's
|
|
38
|
+
* WHERE excludes the row. This grace window (default 5s) covers the send→record
|
|
39
|
+
* gap by a wide margin — the dispatcher's UPDATE is one D1 round-trip — while
|
|
40
|
+
* still bounding sweep latency. Set to 0 in tests to keep them fast.
|
|
41
|
+
*/
|
|
42
|
+
export declare const NEVER_DISPATCHED_SWEEP_GRACE_MS = 5000;
|
|
18
43
|
export interface SweepTimedOutInvocationsOptions {
|
|
19
44
|
timeoutMs?: number;
|
|
20
45
|
/** Override for {@link ACTION_HANDLER_UNREACHABLE_TTL_MS}. */
|
|
21
46
|
handlerUnreachableTtlMs?: number;
|
|
47
|
+
/** Override for {@link PENDING_INVOCATION_MAX_AGE_MS}. */
|
|
48
|
+
pendingInvocationMaxAgeMs?: number;
|
|
49
|
+
/** Override for {@link NEVER_DISPATCHED_SWEEP_GRACE_MS}. */
|
|
50
|
+
neverDispatchedSweepGraceMs?: number;
|
|
22
51
|
/** When provided, TTL failures emit `action.failed` back to the caller. */
|
|
23
52
|
completionDeps?: InvocationCompletionDeps;
|
|
24
53
|
}
|
|
@@ -77,6 +106,7 @@ export declare function getAction(db: Db, workspaceId: string, name: string, cal
|
|
|
77
106
|
export declare function deleteAction(db: Db, workspaceId: string, name: string, options?: {
|
|
78
107
|
completionDeps?: InvocationCompletionDeps;
|
|
79
108
|
}): Promise<boolean>;
|
|
109
|
+
export declare function wasInvocationReplayed(result: object): boolean;
|
|
80
110
|
/**
|
|
81
111
|
* Capacity-direct spawn used by handler-context `ctx.spawnAgent`: it targets a
|
|
82
112
|
* node's capacity executor and never re-enters action dispatch, so a
|
|
@@ -92,8 +122,8 @@ export declare function dispatchCapacitySpawn(db: Db, workspaceId: string, data:
|
|
|
92
122
|
}): Promise<{
|
|
93
123
|
invocation_id: string;
|
|
94
124
|
action_name: string;
|
|
95
|
-
handler_agent_id: null;
|
|
96
|
-
handler_node_id: string;
|
|
125
|
+
handler_agent_id: string | null;
|
|
126
|
+
handler_node_id: string | null;
|
|
97
127
|
dispatched_node_id: string | null;
|
|
98
128
|
input: Record<string, unknown>;
|
|
99
129
|
status: string;
|
|
@@ -113,8 +143,8 @@ export declare function invokeNodeAction(db: Db, workspaceId: string, nodeId: st
|
|
|
113
143
|
}): Promise<{
|
|
114
144
|
invocation_id: string;
|
|
115
145
|
action_name: string;
|
|
116
|
-
handler_agent_id: null;
|
|
117
|
-
handler_node_id: string;
|
|
146
|
+
handler_agent_id: string | null;
|
|
147
|
+
handler_node_id: string | null;
|
|
118
148
|
dispatched_node_id: string | null;
|
|
119
149
|
input: Record<string, unknown>;
|
|
120
150
|
status: string;
|
|
@@ -127,23 +157,16 @@ export declare function invokeAction(db: Db, workspaceId: string, actionName: st
|
|
|
127
157
|
}, options?: {
|
|
128
158
|
nodeConnections?: NodeConnectionRegistry;
|
|
129
159
|
completionDeps?: InvocationCompletionDeps;
|
|
160
|
+
/** A validated caller-supplied key for an atomic durable invocation claim. */
|
|
161
|
+
idempotencyKey?: string;
|
|
130
162
|
/** Resolve plain node-scoped actions too (message triggers bind by name
|
|
131
163
|
* without a node); the resolved row is dispatched node-addressed. */
|
|
132
164
|
includeNodeScoped?: boolean;
|
|
133
165
|
}): Promise<{
|
|
134
166
|
invocation_id: string;
|
|
135
167
|
action_name: string;
|
|
136
|
-
handler_agent_id: null;
|
|
137
|
-
handler_node_id: string;
|
|
138
|
-
dispatched_node_id: string | null;
|
|
139
|
-
input: Record<string, unknown>;
|
|
140
|
-
status: string;
|
|
141
|
-
created_at: string;
|
|
142
|
-
} | {
|
|
143
|
-
invocation_id: string;
|
|
144
|
-
action_name: string;
|
|
145
|
-
handler_agent_id: string;
|
|
146
|
-
handler_node_id: string;
|
|
168
|
+
handler_agent_id: string | null;
|
|
169
|
+
handler_node_id: string | null;
|
|
147
170
|
dispatched_node_id: string | null;
|
|
148
171
|
input: Record<string, unknown>;
|
|
149
172
|
status: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/engine/action.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAW,iBAAiB,EAAoE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/engine/action.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAW,iBAAiB,EAAoE,MAAM,iBAAiB,CAAC;AAO/H,OAAO,EAIL,KAAK,wBAAwB,EAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAKrF,KAAK,EAAE,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AAEnC,KAAK,aAAa,GAAG,OAAO,iBAAiB,CAAC,YAAY,CAAC;AAC3D,KAAK,sBAAsB,GAAG,IAAI,CAChC,aAAa,EACb,IAAI,GAAG,aAAa,GA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