@stackbone/sdk 0.1.0-alpha.6 → 0.1.0-alpha.8

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/workflow.d.cts ADDED
@@ -0,0 +1,128 @@
1
+ export { defineHook, sleep } from 'workflow';
2
+ import { Client } from 'eve/client';
3
+ import { A as AgentName, S as ScheduledWorkflow, W as WorkflowName } from './agent-registry-BNXuj88Q.cjs';
4
+ export { a as AgentRegistry, b as StartWorkflowAndWaitOptions, c as StartWorkflowOptions, d as WorkflowRegistry, e as WorkflowStartHandle, s as startWorkflow, f as startWorkflowAndWait } from './agent-registry-BNXuj88Q.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
+ /** Content the helper stages on the caller's behalf (text or raw bytes). */
75
+ type IngestContent = string | Uint8Array;
76
+ /** The two input shapes {@link ingestDocuments} accepts. */
77
+ type IngestDocumentsArgs = {
78
+ collection: string;
79
+ contentType: string;
80
+ /** Inline content to stage + ingest. Mutually exclusive with `storageKey`. */
81
+ content: IngestContent;
82
+ storageKey?: never;
83
+ } | {
84
+ collection: string;
85
+ contentType: string;
86
+ /** A pre-staged original under the `rag/` prefix. Mutually exclusive with `content`. */
87
+ storageKey: string;
88
+ content?: never;
89
+ };
90
+ /** Options for {@link ingestDocuments}. */
91
+ interface IngestDocumentsOptions {
92
+ /**
93
+ * @internal Test seam — override how inline content is staged to storage,
94
+ * returning the resulting storage key. Production callers omit it (the default
95
+ * stages through the ambient `stackbone.storage`).
96
+ */
97
+ stage?: (collection: string, content: IngestContent, contentType: string) => Promise<string>;
98
+ }
99
+ /**
100
+ * Ingest a document into RAG by running the reserved `rag-ingest` workflow as a
101
+ * durable sub-workflow, returning its `{ documentId, chunks }` output. Pass
102
+ * `content` to have the helper stage it for you, or `storageKey` when it is
103
+ * already staged. The workflow input is validated against the well-known contract
104
+ * before triggering; an invalid call rejects without starting anything.
105
+ */
106
+ declare function ingestDocuments(args: IngestDocumentsArgs, opts?: IngestDocumentsOptions): Promise<RagIngestOutput>;
107
+
108
+ /**
109
+ * Register (or upsert) a dynamic recurring trigger that starts the workflow named
110
+ * `name` with `input` on the `cron` cadence. Idempotent by `name` — calling it
111
+ * again replaces the cadence/input. `name` is narrowed to the workspace's
112
+ * declared workflows once `stackbone dev` has generated `.stackbone/workflows.d.ts`.
113
+ */
114
+ declare function scheduleWorkflow(name: WorkflowName, input: unknown, cron: string): Promise<void>;
115
+ /**
116
+ * Cancel a dynamic scheduled trigger by `name`. Resolves whether or not a trigger
117
+ * existed. Does not touch declarative schedules (those are owned by the workflow's
118
+ * `export const schedules` and reconciled on deploy/boot).
119
+ */
120
+ declare function unschedule(name: WorkflowName): Promise<void>;
121
+ /**
122
+ * List the active scheduled triggers — both declarative (harvested from workflows)
123
+ * and dynamic (registered via {@link scheduleWorkflow}) — so an operator can see
124
+ * what recurring work is registered.
125
+ */
126
+ declare function listSchedules(): Promise<ScheduledWorkflow[]>;
127
+
128
+ export { type ApprovalDecision, type ApprovalFallback, type IngestContent, type IngestDocumentsArgs, type IngestDocumentsOptions, type RequestApprovalOptions, ScheduledWorkflow, WORKFLOW_HOOK_RESUME_KIND, WorkflowName, eveAgent, ingestDocuments, listSchedules, requestApproval, scheduleWorkflow, unschedule };
package/workflow.d.ts ADDED
@@ -0,0 +1,128 @@
1
+ export { defineHook, sleep } from 'workflow';
2
+ import { Client } from 'eve/client';
3
+ import { A as AgentName, S as ScheduledWorkflow, W as WorkflowName } from './agent-registry-BNXuj88Q.js';
4
+ export { a as AgentRegistry, b as StartWorkflowAndWaitOptions, c as StartWorkflowOptions, d as WorkflowRegistry, e as WorkflowStartHandle, s as startWorkflow, f as startWorkflowAndWait } from './agent-registry-BNXuj88Q.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
+ /** Content the helper stages on the caller's behalf (text or raw bytes). */
75
+ type IngestContent = string | Uint8Array;
76
+ /** The two input shapes {@link ingestDocuments} accepts. */
77
+ type IngestDocumentsArgs = {
78
+ collection: string;
79
+ contentType: string;
80
+ /** Inline content to stage + ingest. Mutually exclusive with `storageKey`. */
81
+ content: IngestContent;
82
+ storageKey?: never;
83
+ } | {
84
+ collection: string;
85
+ contentType: string;
86
+ /** A pre-staged original under the `rag/` prefix. Mutually exclusive with `content`. */
87
+ storageKey: string;
88
+ content?: never;
89
+ };
90
+ /** Options for {@link ingestDocuments}. */
91
+ interface IngestDocumentsOptions {
92
+ /**
93
+ * @internal Test seam — override how inline content is staged to storage,
94
+ * returning the resulting storage key. Production callers omit it (the default
95
+ * stages through the ambient `stackbone.storage`).
96
+ */
97
+ stage?: (collection: string, content: IngestContent, contentType: string) => Promise<string>;
98
+ }
99
+ /**
100
+ * Ingest a document into RAG by running the reserved `rag-ingest` workflow as a
101
+ * durable sub-workflow, returning its `{ documentId, chunks }` output. Pass
102
+ * `content` to have the helper stage it for you, or `storageKey` when it is
103
+ * already staged. The workflow input is validated against the well-known contract
104
+ * before triggering; an invalid call rejects without starting anything.
105
+ */
106
+ declare function ingestDocuments(args: IngestDocumentsArgs, opts?: IngestDocumentsOptions): Promise<RagIngestOutput>;
107
+
108
+ /**
109
+ * Register (or upsert) a dynamic recurring trigger that starts the workflow named
110
+ * `name` with `input` on the `cron` cadence. Idempotent by `name` — calling it
111
+ * again replaces the cadence/input. `name` is narrowed to the workspace's
112
+ * declared workflows once `stackbone dev` has generated `.stackbone/workflows.d.ts`.
113
+ */
114
+ declare function scheduleWorkflow(name: WorkflowName, input: unknown, cron: string): Promise<void>;
115
+ /**
116
+ * Cancel a dynamic scheduled trigger by `name`. Resolves whether or not a trigger
117
+ * existed. Does not touch declarative schedules (those are owned by the workflow's
118
+ * `export const schedules` and reconciled on deploy/boot).
119
+ */
120
+ declare function unschedule(name: WorkflowName): Promise<void>;
121
+ /**
122
+ * List the active scheduled triggers — both declarative (harvested from workflows)
123
+ * and dynamic (registered via {@link scheduleWorkflow}) — so an operator can see
124
+ * what recurring work is registered.
125
+ */
126
+ declare function listSchedules(): Promise<ScheduledWorkflow[]>;
127
+
128
+ export { type ApprovalDecision, type ApprovalFallback, type IngestContent, type IngestDocumentsArgs, type IngestDocumentsOptions, type RequestApprovalOptions, ScheduledWorkflow, WORKFLOW_HOOK_RESUME_KIND, WorkflowName, eveAgent, ingestDocuments, listSchedules, requestApproval, scheduleWorkflow, unschedule };