@stackbone/sdk 0.1.0-alpha.5 → 0.1.0-alpha.7
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/CHANGELOG.md +77 -0
- package/call-connector-CYDw_yG5.d.cts +118 -0
- package/call-connector-CYDw_yG5.d.ts +118 -0
- package/connect.cjs +270 -0
- package/connect.cjs.map +1 -0
- package/connect.d.cts +94 -0
- package/connect.d.ts +94 -0
- package/connect.js +257 -0
- package/connect.js.map +1 -0
- package/index.cjs +486 -96
- package/index.cjs.map +1 -1
- package/index.d.cts +401 -19
- package/index.d.ts +401 -19
- package/index.js +481 -98
- package/index.js.map +1 -1
- package/observability/index.cjs +1 -268
- package/observability/index.cjs.map +1 -1
- package/observability/index.d.cts +1 -96
- package/observability/index.d.ts +1 -96
- package/observability/index.js +2 -264
- package/observability/index.js.map +1 -1
- package/package.json +33 -1
- package/stackbone-sdk-0.1.0-alpha.7.tgz +0 -0
- package/workflow-scheduler-DXCNKDOS.d.cts +119 -0
- package/workflow-scheduler-DXCNKDOS.d.ts +119 -0
- package/workflow.cjs +17417 -0
- package/workflow.cjs.map +1 -0
- package/workflow.d.cts +207 -0
- package/workflow.d.ts +207 -0
- package/workflow.js +17392 -0
- package/workflow.js.map +1 -0
- package/stackbone-sdk-0.1.0-alpha.5.tgz +0 -0
package/workflow.d.cts
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
export { defineHook, sleep } from 'workflow';
|
|
2
|
+
import { Client } from 'eve/client';
|
|
3
|
+
import { A as AgentName, W as WorkflowTriggerOptions, a as WorkflowStartHandle, S as ScheduledWorkflow } from './workflow-scheduler-DXCNKDOS.cjs';
|
|
4
|
+
export { b as AgentRegistry } from './workflow-scheduler-DXCNKDOS.cjs';
|
|
5
|
+
import { RagIngestOutput } from '@stackbone/rag-core';
|
|
6
|
+
export { RagIngestInput, RagIngestOutput } from '@stackbone/rag-core';
|
|
7
|
+
export { C as CallConnectorOptions, a as ConnectionAccessor, b as ConnectorCallError, c as ConnectorHandle, P as Principal, S as StackboneConnections, d as callConnector, e as connection } from './call-connector-CYDw_yG5.cjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Discriminator stored in `approvals.metadata.resumeKind` so the inbox /
|
|
11
|
+
* run-inspection knows a parked Workflow hook (resumed by token) backs this
|
|
12
|
+
* approval — as opposed to the legacy fire-and-forget HMAC-callback approval.
|
|
13
|
+
*/
|
|
14
|
+
declare const WORKFLOW_HOOK_RESUME_KIND: "workflow_hook";
|
|
15
|
+
/** Fallback applied when the timeout elapses before a human decides. */
|
|
16
|
+
type ApprovalFallback = 'approve' | 'reject';
|
|
17
|
+
interface RequestApprovalOptions<TPayload = unknown> {
|
|
18
|
+
/**
|
|
19
|
+
* The hook resume key — unique per approval within a run. The host resumes the
|
|
20
|
+
* parked run by this token (`resumeHook(token, ...)`), so it must be stable
|
|
21
|
+
* and unguessable for the lifetime of the pause.
|
|
22
|
+
*/
|
|
23
|
+
token: string;
|
|
24
|
+
/** Approval category, mirrored to `approvals.topic`. */
|
|
25
|
+
topic: string;
|
|
26
|
+
/** The data the human reviews, mirrored to `approvals.payload`. */
|
|
27
|
+
payload: TPayload;
|
|
28
|
+
/** Human-readable title surfaced in the inbox / run inspection. */
|
|
29
|
+
title?: string;
|
|
30
|
+
/** ISO 8601 duration (`'24h'`) or milliseconds. Passed to `sleep`. */
|
|
31
|
+
timeout?: string | number;
|
|
32
|
+
/** Decision applied when the timeout wins the race. Default `'reject'`. */
|
|
33
|
+
fallback?: ApprovalFallback;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The decision the gated step branches on. `status === 'approved'` is the only
|
|
37
|
+
* green light for the side-effect; `timedOut` is `true` only when the fallback
|
|
38
|
+
* was applied because no human decided before the timeout.
|
|
39
|
+
*/
|
|
40
|
+
interface ApprovalDecision<TPayload = unknown> {
|
|
41
|
+
status: 'approved' | 'rejected';
|
|
42
|
+
/** The payload the human attached when approving/rejecting, if any. */
|
|
43
|
+
payload?: TPayload;
|
|
44
|
+
/** `true` when this decision is the timeout fallback, not a human decision. */
|
|
45
|
+
timedOut: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Workflow-level HITL helper. PAUSES the workflow durably on a hook and returns
|
|
49
|
+
* a decision the caller gates the side-effect on. MUST be called from the
|
|
50
|
+
* workflow body, never inside a `"use step"` block.
|
|
51
|
+
*/
|
|
52
|
+
declare function requestApproval<TPayload = unknown>(options: RequestApprovalOptions<TPayload>): Promise<ApprovalDecision<TPayload>>;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Resolve a sibling eve agent by name and return its `Client`, AS-IS. The name is
|
|
56
|
+
* the agent's folder name under `agents/`; the URL comes from the emulator-injected
|
|
57
|
+
* `AGENT_URLS` map. The `headers` resolver runs fresh per request, so every
|
|
58
|
+
* session-create and stream GET carries a current timestamp (always inside the
|
|
59
|
+
* 5-minute drift window).
|
|
60
|
+
*
|
|
61
|
+
* `name` is typed `AgentName` — a loose `string` by default, but narrowed to the
|
|
62
|
+
* workspace's declared agent names once `stackbone dev` has generated
|
|
63
|
+
* `.stackbone/agents.d.ts` from `stackbone.config.ts` (see `agent-registry.ts`),
|
|
64
|
+
* so a typo becomes a compile error and the editor autocompletes the real names.
|
|
65
|
+
*
|
|
66
|
+
* @deprecated Prefer the namespaced `stackbone.agent(id)` from the main
|
|
67
|
+
* `@stackbone/sdk` barrel — same signed call, same eve `Client`, one unified
|
|
68
|
+
* namespace, and the `eve` peer is pulled lazily only on first use. This top-level
|
|
69
|
+
* export still works and resolves the peer eagerly (it lives on the
|
|
70
|
+
* `@stackbone/sdk/workflow` subpath, which already imports the peer).
|
|
71
|
+
*/
|
|
72
|
+
declare function eveAgent(name: AgentName): Client;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Augmentable registry of the workspace's WORKFLOW names. By default it is empty,
|
|
76
|
+
* so `startWorkflow(name, ...)` / `startWorkflowAndWait(name, ...)` accept any
|
|
77
|
+
* `string` (today's behavior, validated only at runtime against the injected
|
|
78
|
+
* name→ref registry). `stackbone dev` generates an ambient
|
|
79
|
+
* `.stackbone/workflows.d.ts` from the project's `stackbone.config.ts` workflow
|
|
80
|
+
* list and augments this interface so the names become a closed set:
|
|
81
|
+
*
|
|
82
|
+
* declare module '@stackbone/sdk/workflow' {
|
|
83
|
+
* interface WorkflowRegistry {
|
|
84
|
+
* onboarding: true;
|
|
85
|
+
* qualifyLead: true;
|
|
86
|
+
* }
|
|
87
|
+
* }
|
|
88
|
+
*
|
|
89
|
+
* Once augmented, `startWorkflow('qualifyLead', ...)` is fine and
|
|
90
|
+
* `startWorkflow('typo', ...)` is a compile error — the editor also autocompletes
|
|
91
|
+
* the declared names. Mirrors the `AgentRegistry` augmentable-interface pattern
|
|
92
|
+
* used for `eveAgent`.
|
|
93
|
+
*/
|
|
94
|
+
interface WorkflowRegistry {
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The set of workflow names the trigger helpers accept, derived from the
|
|
98
|
+
* augmentable `WorkflowRegistry`. The tuple wrap (`[X] extends [never]`) defeats
|
|
99
|
+
* the conditional-type distributivity a bare `keyof WorkflowRegistry extends
|
|
100
|
+
* never` would trigger:
|
|
101
|
+
*
|
|
102
|
+
* - empty registry -> `string` (today's loose behavior: any name, checked at
|
|
103
|
+
* runtime when the workflow resolves it against the manifest);
|
|
104
|
+
* - augmented registry -> the union of declared workflow names (typo = compile error).
|
|
105
|
+
*/
|
|
106
|
+
type WorkflowName = [keyof WorkflowRegistry] extends [never] ? string : keyof WorkflowRegistry;
|
|
107
|
+
|
|
108
|
+
/** Options for {@link startWorkflow}. See {@link WorkflowTriggerOptions}. */
|
|
109
|
+
type StartWorkflowOptions = WorkflowTriggerOptions;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Start the workflow named `name` with its own independent run and return its
|
|
113
|
+
* `{ runId }` immediately — fire-and-forget. The input is validated against the
|
|
114
|
+
* target's declared input schema BEFORE the run is enqueued; a name that does
|
|
115
|
+
* not resolve, or input that violates the schema, rejects without starting
|
|
116
|
+
* anything.
|
|
117
|
+
*
|
|
118
|
+
* `name` is typed `WorkflowName` — a loose `string` by default, narrowed to the
|
|
119
|
+
* workspace's declared workflow names once `stackbone dev` has generated
|
|
120
|
+
* `.stackbone/workflows.d.ts` (see `workflow-registry.ts`), so a typo becomes a
|
|
121
|
+
* compile error.
|
|
122
|
+
*
|
|
123
|
+
* MUST be called from inside a running workflow (the runtime binds the starter on
|
|
124
|
+
* first dispatch); calling it elsewhere throws.
|
|
125
|
+
*
|
|
126
|
+
* DURABILITY: the enqueue runs in a `"use step"`, so once it completes a parent
|
|
127
|
+
* restart resumes with the memoized `{ runId }` and does NOT re-enqueue. A crash
|
|
128
|
+
* WHILE the step is mid-flight re-runs it (at-least-once) — the same shape the
|
|
129
|
+
* eve-agent-from-step path has; for fire-and-forget fan-out this is acceptable.
|
|
130
|
+
* Use {@link startWorkflowAndWait} when you need the child's result.
|
|
131
|
+
*/
|
|
132
|
+
declare function startWorkflow(name: WorkflowName, input: unknown, opts?: StartWorkflowOptions): Promise<WorkflowStartHandle>;
|
|
133
|
+
|
|
134
|
+
/** Options for {@link startWorkflowAndWait}. See {@link WorkflowTriggerOptions}. */
|
|
135
|
+
type StartWorkflowAndWaitOptions = WorkflowTriggerOptions;
|
|
136
|
+
/**
|
|
137
|
+
* Start the workflow named `name` with its own independent run and durably wait
|
|
138
|
+
* for it to finish, returning its terminal output (validated against the
|
|
139
|
+
* target's declared output schema). Use this when one workflow needs another's
|
|
140
|
+
* result to continue.
|
|
141
|
+
*
|
|
142
|
+
* The input is validated against the target's declared input schema BEFORE the
|
|
143
|
+
* run is enqueued; a name that does not resolve, or input that violates the
|
|
144
|
+
* schema, rejects without starting anything. `TOutput` lets the caller name the
|
|
145
|
+
* expected output shape (defaults to `unknown`).
|
|
146
|
+
*
|
|
147
|
+
* `name` is typed `WorkflowName` — narrowed to the workspace's declared workflow
|
|
148
|
+
* names once `stackbone dev` has generated `.stackbone/workflows.d.ts`. MUST be
|
|
149
|
+
* called from inside a running workflow.
|
|
150
|
+
*/
|
|
151
|
+
declare function startWorkflowAndWait<TOutput = unknown>(name: WorkflowName, input: unknown, opts?: StartWorkflowAndWaitOptions): Promise<TOutput>;
|
|
152
|
+
|
|
153
|
+
/** Content the helper stages on the caller's behalf (text or raw bytes). */
|
|
154
|
+
type IngestContent = string | Uint8Array;
|
|
155
|
+
/** The two input shapes {@link ingestDocuments} accepts. */
|
|
156
|
+
type IngestDocumentsArgs = {
|
|
157
|
+
collection: string;
|
|
158
|
+
contentType: string;
|
|
159
|
+
/** Inline content to stage + ingest. Mutually exclusive with `storageKey`. */
|
|
160
|
+
content: IngestContent;
|
|
161
|
+
storageKey?: never;
|
|
162
|
+
} | {
|
|
163
|
+
collection: string;
|
|
164
|
+
contentType: string;
|
|
165
|
+
/** A pre-staged original under the `rag/` prefix. Mutually exclusive with `content`. */
|
|
166
|
+
storageKey: string;
|
|
167
|
+
content?: never;
|
|
168
|
+
};
|
|
169
|
+
/** Options for {@link ingestDocuments}. */
|
|
170
|
+
interface IngestDocumentsOptions {
|
|
171
|
+
/**
|
|
172
|
+
* @internal Test seam — override how inline content is staged to storage,
|
|
173
|
+
* returning the resulting storage key. Production callers omit it (the default
|
|
174
|
+
* stages through the ambient `stackbone.storage`).
|
|
175
|
+
*/
|
|
176
|
+
stage?: (collection: string, content: IngestContent, contentType: string) => Promise<string>;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Ingest a document into RAG by running the reserved `rag-ingest` workflow as a
|
|
180
|
+
* durable sub-workflow, returning its `{ documentId, chunks }` output. Pass
|
|
181
|
+
* `content` to have the helper stage it for you, or `storageKey` when it is
|
|
182
|
+
* already staged. The workflow input is validated against the well-known contract
|
|
183
|
+
* before triggering; an invalid call rejects without starting anything.
|
|
184
|
+
*/
|
|
185
|
+
declare function ingestDocuments(args: IngestDocumentsArgs, opts?: IngestDocumentsOptions): Promise<RagIngestOutput>;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Register (or upsert) a dynamic recurring trigger that starts the workflow named
|
|
189
|
+
* `name` with `input` on the `cron` cadence. Idempotent by `name` — calling it
|
|
190
|
+
* again replaces the cadence/input. `name` is narrowed to the workspace's
|
|
191
|
+
* declared workflows once `stackbone dev` has generated `.stackbone/workflows.d.ts`.
|
|
192
|
+
*/
|
|
193
|
+
declare function scheduleWorkflow(name: WorkflowName, input: unknown, cron: string): Promise<void>;
|
|
194
|
+
/**
|
|
195
|
+
* Cancel a dynamic scheduled trigger by `name`. Resolves whether or not a trigger
|
|
196
|
+
* existed. Does not touch declarative schedules (those are owned by the workflow's
|
|
197
|
+
* `export const schedules` and reconciled on deploy/boot).
|
|
198
|
+
*/
|
|
199
|
+
declare function unschedule(name: WorkflowName): Promise<void>;
|
|
200
|
+
/**
|
|
201
|
+
* List the active scheduled triggers — both declarative (harvested from workflows)
|
|
202
|
+
* and dynamic (registered via {@link scheduleWorkflow}) — so an operator can see
|
|
203
|
+
* what recurring work is registered.
|
|
204
|
+
*/
|
|
205
|
+
declare function listSchedules(): Promise<ScheduledWorkflow[]>;
|
|
206
|
+
|
|
207
|
+
export { type ApprovalDecision, type ApprovalFallback, type IngestContent, type IngestDocumentsArgs, type IngestDocumentsOptions, type RequestApprovalOptions, ScheduledWorkflow, type StartWorkflowAndWaitOptions, type StartWorkflowOptions, WORKFLOW_HOOK_RESUME_KIND, type WorkflowName, type WorkflowRegistry, WorkflowStartHandle, eveAgent, ingestDocuments, listSchedules, requestApproval, scheduleWorkflow, startWorkflow, startWorkflowAndWait, unschedule };
|
package/workflow.d.ts
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
export { defineHook, sleep } from 'workflow';
|
|
2
|
+
import { Client } from 'eve/client';
|
|
3
|
+
import { A as AgentName, W as WorkflowTriggerOptions, a as WorkflowStartHandle, S as ScheduledWorkflow } from './workflow-scheduler-DXCNKDOS.js';
|
|
4
|
+
export { b as AgentRegistry } from './workflow-scheduler-DXCNKDOS.js';
|
|
5
|
+
import { RagIngestOutput } from '@stackbone/rag-core';
|
|
6
|
+
export { RagIngestInput, RagIngestOutput } from '@stackbone/rag-core';
|
|
7
|
+
export { C as CallConnectorOptions, a as ConnectionAccessor, b as ConnectorCallError, c as ConnectorHandle, P as Principal, S as StackboneConnections, d as callConnector, e as connection } from './call-connector-CYDw_yG5.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Discriminator stored in `approvals.metadata.resumeKind` so the inbox /
|
|
11
|
+
* run-inspection knows a parked Workflow hook (resumed by token) backs this
|
|
12
|
+
* approval — as opposed to the legacy fire-and-forget HMAC-callback approval.
|
|
13
|
+
*/
|
|
14
|
+
declare const WORKFLOW_HOOK_RESUME_KIND: "workflow_hook";
|
|
15
|
+
/** Fallback applied when the timeout elapses before a human decides. */
|
|
16
|
+
type ApprovalFallback = 'approve' | 'reject';
|
|
17
|
+
interface RequestApprovalOptions<TPayload = unknown> {
|
|
18
|
+
/**
|
|
19
|
+
* The hook resume key — unique per approval within a run. The host resumes the
|
|
20
|
+
* parked run by this token (`resumeHook(token, ...)`), so it must be stable
|
|
21
|
+
* and unguessable for the lifetime of the pause.
|
|
22
|
+
*/
|
|
23
|
+
token: string;
|
|
24
|
+
/** Approval category, mirrored to `approvals.topic`. */
|
|
25
|
+
topic: string;
|
|
26
|
+
/** The data the human reviews, mirrored to `approvals.payload`. */
|
|
27
|
+
payload: TPayload;
|
|
28
|
+
/** Human-readable title surfaced in the inbox / run inspection. */
|
|
29
|
+
title?: string;
|
|
30
|
+
/** ISO 8601 duration (`'24h'`) or milliseconds. Passed to `sleep`. */
|
|
31
|
+
timeout?: string | number;
|
|
32
|
+
/** Decision applied when the timeout wins the race. Default `'reject'`. */
|
|
33
|
+
fallback?: ApprovalFallback;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The decision the gated step branches on. `status === 'approved'` is the only
|
|
37
|
+
* green light for the side-effect; `timedOut` is `true` only when the fallback
|
|
38
|
+
* was applied because no human decided before the timeout.
|
|
39
|
+
*/
|
|
40
|
+
interface ApprovalDecision<TPayload = unknown> {
|
|
41
|
+
status: 'approved' | 'rejected';
|
|
42
|
+
/** The payload the human attached when approving/rejecting, if any. */
|
|
43
|
+
payload?: TPayload;
|
|
44
|
+
/** `true` when this decision is the timeout fallback, not a human decision. */
|
|
45
|
+
timedOut: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Workflow-level HITL helper. PAUSES the workflow durably on a hook and returns
|
|
49
|
+
* a decision the caller gates the side-effect on. MUST be called from the
|
|
50
|
+
* workflow body, never inside a `"use step"` block.
|
|
51
|
+
*/
|
|
52
|
+
declare function requestApproval<TPayload = unknown>(options: RequestApprovalOptions<TPayload>): Promise<ApprovalDecision<TPayload>>;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Resolve a sibling eve agent by name and return its `Client`, AS-IS. The name is
|
|
56
|
+
* the agent's folder name under `agents/`; the URL comes from the emulator-injected
|
|
57
|
+
* `AGENT_URLS` map. The `headers` resolver runs fresh per request, so every
|
|
58
|
+
* session-create and stream GET carries a current timestamp (always inside the
|
|
59
|
+
* 5-minute drift window).
|
|
60
|
+
*
|
|
61
|
+
* `name` is typed `AgentName` — a loose `string` by default, but narrowed to the
|
|
62
|
+
* workspace's declared agent names once `stackbone dev` has generated
|
|
63
|
+
* `.stackbone/agents.d.ts` from `stackbone.config.ts` (see `agent-registry.ts`),
|
|
64
|
+
* so a typo becomes a compile error and the editor autocompletes the real names.
|
|
65
|
+
*
|
|
66
|
+
* @deprecated Prefer the namespaced `stackbone.agent(id)` from the main
|
|
67
|
+
* `@stackbone/sdk` barrel — same signed call, same eve `Client`, one unified
|
|
68
|
+
* namespace, and the `eve` peer is pulled lazily only on first use. This top-level
|
|
69
|
+
* export still works and resolves the peer eagerly (it lives on the
|
|
70
|
+
* `@stackbone/sdk/workflow` subpath, which already imports the peer).
|
|
71
|
+
*/
|
|
72
|
+
declare function eveAgent(name: AgentName): Client;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Augmentable registry of the workspace's WORKFLOW names. By default it is empty,
|
|
76
|
+
* so `startWorkflow(name, ...)` / `startWorkflowAndWait(name, ...)` accept any
|
|
77
|
+
* `string` (today's behavior, validated only at runtime against the injected
|
|
78
|
+
* name→ref registry). `stackbone dev` generates an ambient
|
|
79
|
+
* `.stackbone/workflows.d.ts` from the project's `stackbone.config.ts` workflow
|
|
80
|
+
* list and augments this interface so the names become a closed set:
|
|
81
|
+
*
|
|
82
|
+
* declare module '@stackbone/sdk/workflow' {
|
|
83
|
+
* interface WorkflowRegistry {
|
|
84
|
+
* onboarding: true;
|
|
85
|
+
* qualifyLead: true;
|
|
86
|
+
* }
|
|
87
|
+
* }
|
|
88
|
+
*
|
|
89
|
+
* Once augmented, `startWorkflow('qualifyLead', ...)` is fine and
|
|
90
|
+
* `startWorkflow('typo', ...)` is a compile error — the editor also autocompletes
|
|
91
|
+
* the declared names. Mirrors the `AgentRegistry` augmentable-interface pattern
|
|
92
|
+
* used for `eveAgent`.
|
|
93
|
+
*/
|
|
94
|
+
interface WorkflowRegistry {
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The set of workflow names the trigger helpers accept, derived from the
|
|
98
|
+
* augmentable `WorkflowRegistry`. The tuple wrap (`[X] extends [never]`) defeats
|
|
99
|
+
* the conditional-type distributivity a bare `keyof WorkflowRegistry extends
|
|
100
|
+
* never` would trigger:
|
|
101
|
+
*
|
|
102
|
+
* - empty registry -> `string` (today's loose behavior: any name, checked at
|
|
103
|
+
* runtime when the workflow resolves it against the manifest);
|
|
104
|
+
* - augmented registry -> the union of declared workflow names (typo = compile error).
|
|
105
|
+
*/
|
|
106
|
+
type WorkflowName = [keyof WorkflowRegistry] extends [never] ? string : keyof WorkflowRegistry;
|
|
107
|
+
|
|
108
|
+
/** Options for {@link startWorkflow}. See {@link WorkflowTriggerOptions}. */
|
|
109
|
+
type StartWorkflowOptions = WorkflowTriggerOptions;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Start the workflow named `name` with its own independent run and return its
|
|
113
|
+
* `{ runId }` immediately — fire-and-forget. The input is validated against the
|
|
114
|
+
* target's declared input schema BEFORE the run is enqueued; a name that does
|
|
115
|
+
* not resolve, or input that violates the schema, rejects without starting
|
|
116
|
+
* anything.
|
|
117
|
+
*
|
|
118
|
+
* `name` is typed `WorkflowName` — a loose `string` by default, narrowed to the
|
|
119
|
+
* workspace's declared workflow names once `stackbone dev` has generated
|
|
120
|
+
* `.stackbone/workflows.d.ts` (see `workflow-registry.ts`), so a typo becomes a
|
|
121
|
+
* compile error.
|
|
122
|
+
*
|
|
123
|
+
* MUST be called from inside a running workflow (the runtime binds the starter on
|
|
124
|
+
* first dispatch); calling it elsewhere throws.
|
|
125
|
+
*
|
|
126
|
+
* DURABILITY: the enqueue runs in a `"use step"`, so once it completes a parent
|
|
127
|
+
* restart resumes with the memoized `{ runId }` and does NOT re-enqueue. A crash
|
|
128
|
+
* WHILE the step is mid-flight re-runs it (at-least-once) — the same shape the
|
|
129
|
+
* eve-agent-from-step path has; for fire-and-forget fan-out this is acceptable.
|
|
130
|
+
* Use {@link startWorkflowAndWait} when you need the child's result.
|
|
131
|
+
*/
|
|
132
|
+
declare function startWorkflow(name: WorkflowName, input: unknown, opts?: StartWorkflowOptions): Promise<WorkflowStartHandle>;
|
|
133
|
+
|
|
134
|
+
/** Options for {@link startWorkflowAndWait}. See {@link WorkflowTriggerOptions}. */
|
|
135
|
+
type StartWorkflowAndWaitOptions = WorkflowTriggerOptions;
|
|
136
|
+
/**
|
|
137
|
+
* Start the workflow named `name` with its own independent run and durably wait
|
|
138
|
+
* for it to finish, returning its terminal output (validated against the
|
|
139
|
+
* target's declared output schema). Use this when one workflow needs another's
|
|
140
|
+
* result to continue.
|
|
141
|
+
*
|
|
142
|
+
* The input is validated against the target's declared input schema BEFORE the
|
|
143
|
+
* run is enqueued; a name that does not resolve, or input that violates the
|
|
144
|
+
* schema, rejects without starting anything. `TOutput` lets the caller name the
|
|
145
|
+
* expected output shape (defaults to `unknown`).
|
|
146
|
+
*
|
|
147
|
+
* `name` is typed `WorkflowName` — narrowed to the workspace's declared workflow
|
|
148
|
+
* names once `stackbone dev` has generated `.stackbone/workflows.d.ts`. MUST be
|
|
149
|
+
* called from inside a running workflow.
|
|
150
|
+
*/
|
|
151
|
+
declare function startWorkflowAndWait<TOutput = unknown>(name: WorkflowName, input: unknown, opts?: StartWorkflowAndWaitOptions): Promise<TOutput>;
|
|
152
|
+
|
|
153
|
+
/** Content the helper stages on the caller's behalf (text or raw bytes). */
|
|
154
|
+
type IngestContent = string | Uint8Array;
|
|
155
|
+
/** The two input shapes {@link ingestDocuments} accepts. */
|
|
156
|
+
type IngestDocumentsArgs = {
|
|
157
|
+
collection: string;
|
|
158
|
+
contentType: string;
|
|
159
|
+
/** Inline content to stage + ingest. Mutually exclusive with `storageKey`. */
|
|
160
|
+
content: IngestContent;
|
|
161
|
+
storageKey?: never;
|
|
162
|
+
} | {
|
|
163
|
+
collection: string;
|
|
164
|
+
contentType: string;
|
|
165
|
+
/** A pre-staged original under the `rag/` prefix. Mutually exclusive with `content`. */
|
|
166
|
+
storageKey: string;
|
|
167
|
+
content?: never;
|
|
168
|
+
};
|
|
169
|
+
/** Options for {@link ingestDocuments}. */
|
|
170
|
+
interface IngestDocumentsOptions {
|
|
171
|
+
/**
|
|
172
|
+
* @internal Test seam — override how inline content is staged to storage,
|
|
173
|
+
* returning the resulting storage key. Production callers omit it (the default
|
|
174
|
+
* stages through the ambient `stackbone.storage`).
|
|
175
|
+
*/
|
|
176
|
+
stage?: (collection: string, content: IngestContent, contentType: string) => Promise<string>;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Ingest a document into RAG by running the reserved `rag-ingest` workflow as a
|
|
180
|
+
* durable sub-workflow, returning its `{ documentId, chunks }` output. Pass
|
|
181
|
+
* `content` to have the helper stage it for you, or `storageKey` when it is
|
|
182
|
+
* already staged. The workflow input is validated against the well-known contract
|
|
183
|
+
* before triggering; an invalid call rejects without starting anything.
|
|
184
|
+
*/
|
|
185
|
+
declare function ingestDocuments(args: IngestDocumentsArgs, opts?: IngestDocumentsOptions): Promise<RagIngestOutput>;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Register (or upsert) a dynamic recurring trigger that starts the workflow named
|
|
189
|
+
* `name` with `input` on the `cron` cadence. Idempotent by `name` — calling it
|
|
190
|
+
* again replaces the cadence/input. `name` is narrowed to the workspace's
|
|
191
|
+
* declared workflows once `stackbone dev` has generated `.stackbone/workflows.d.ts`.
|
|
192
|
+
*/
|
|
193
|
+
declare function scheduleWorkflow(name: WorkflowName, input: unknown, cron: string): Promise<void>;
|
|
194
|
+
/**
|
|
195
|
+
* Cancel a dynamic scheduled trigger by `name`. Resolves whether or not a trigger
|
|
196
|
+
* existed. Does not touch declarative schedules (those are owned by the workflow's
|
|
197
|
+
* `export const schedules` and reconciled on deploy/boot).
|
|
198
|
+
*/
|
|
199
|
+
declare function unschedule(name: WorkflowName): Promise<void>;
|
|
200
|
+
/**
|
|
201
|
+
* List the active scheduled triggers — both declarative (harvested from workflows)
|
|
202
|
+
* and dynamic (registered via {@link scheduleWorkflow}) — so an operator can see
|
|
203
|
+
* what recurring work is registered.
|
|
204
|
+
*/
|
|
205
|
+
declare function listSchedules(): Promise<ScheduledWorkflow[]>;
|
|
206
|
+
|
|
207
|
+
export { type ApprovalDecision, type ApprovalFallback, type IngestContent, type IngestDocumentsArgs, type IngestDocumentsOptions, type RequestApprovalOptions, ScheduledWorkflow, type StartWorkflowAndWaitOptions, type StartWorkflowOptions, WORKFLOW_HOOK_RESUME_KIND, type WorkflowName, type WorkflowRegistry, WorkflowStartHandle, eveAgent, ingestDocuments, listSchedules, requestApproval, scheduleWorkflow, startWorkflow, startWorkflowAndWait, unschedule };
|