@lightspeed-ai/agent-client 0.1.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/README.md +63 -0
- package/dist/client.d.ts +65 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +194 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +20 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +47 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/methods.d.ts +2497 -0
- package/dist/generated/methods.d.ts.map +1 -0
- package/dist/generated/methods.js +1751 -0
- package/dist/generated/methods.js.map +1 -0
- package/dist/generated/types.d.ts +6950 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +6 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/generated/workflow-manifest.d.ts +219 -0
- package/dist/generated/workflow-manifest.d.ts.map +1 -0
- package/dist/generated/workflow-manifest.js +251 -0
- package/dist/generated/workflow-manifest.js.map +1 -0
- package/dist/generated/workflow-types.d.ts +451 -0
- package/dist/generated/workflow-types.d.ts.map +1 -0
- package/dist/generated/workflow-types.js +6 -0
- package/dist/generated/workflow-types.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/workflow.d.ts +217 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +338 -0
- package/dist/workflow.js.map +1 -0
- package/examples/temporal-activity.ts +33 -0
- package/package.json +55 -0
- package/release.json +4 -0
- package/schema/api.schema.json +16643 -0
- package/schema/workflow.json +246 -0
- package/schema/workflow.schema.json +880 -0
- package/src/client.ts +318 -0
- package/src/errors.ts +64 -0
- package/src/generated/methods.ts +2888 -0
- package/src/generated/types.ts +7189 -0
- package/src/generated/workflow-manifest.ts +251 -0
- package/src/generated/workflow-types.ts +468 -0
- package/src/index.ts +31 -0
- package/src/workflow.ts +468 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import type { EmissionEnvelope, PromiseResolution, WorkflowToolInvocation } from "./generated/workflow-types.js";
|
|
2
|
+
export type * from "./generated/workflow-types.js";
|
|
3
|
+
export declare const DELIVER_EMISSION_SIGNAL: "deliver_emission";
|
|
4
|
+
export declare const WORKFLOW_TOOL_RECOVERY_QUERY: "workflow_tool_recovery";
|
|
5
|
+
export declare const WORKFLOW_TOOL_EXECUTION_KIND: "workflow_tool.execution";
|
|
6
|
+
export declare const WORKFLOW_TOOL_RECIPE_FORMAT_V1: 1;
|
|
7
|
+
export declare const WORKFLOW_TOOL_RECIPE_FINGERPRINT_PREFIX: "wtr:sha256:";
|
|
8
|
+
export declare const REPLY_COMPLETION_KEY: "reply";
|
|
9
|
+
/** Activity names a connector host registers on its account task queues. */
|
|
10
|
+
export declare const CHANNEL_CONNECTOR_ACTIVITIES: {
|
|
11
|
+
readonly deliverChannelMessage: "deliverChannelMessage";
|
|
12
|
+
readonly maintainChannelTyping: "maintainChannelTyping";
|
|
13
|
+
readonly prepareChannelMedia: "prepareChannelMedia";
|
|
14
|
+
};
|
|
15
|
+
export declare const CHANNEL_CONVERSATION_WORKFLOW_KIND: "ChannelConversationWorkflow";
|
|
16
|
+
export declare const CHANNEL_INBOUND_SIGNAL: "chat_inbound";
|
|
17
|
+
export declare const CHANNEL_STATE_QUERY: "chat_state";
|
|
18
|
+
export declare const CHANNEL_DELIVERY_RECEIPT_SIGNAL: "bot_delivery";
|
|
19
|
+
/** Known-answer vectors emitted by Rust and shared by every generated consumer. */
|
|
20
|
+
export declare const WORKFLOW_CONTRACT_VECTORS: {
|
|
21
|
+
readonly channels: {
|
|
22
|
+
readonly connectorTaskQueue: "lightspeed-connector-telegram-9b32a282ab8d90f892b5916c";
|
|
23
|
+
readonly conversationKey: "tg-main/12345/7";
|
|
24
|
+
readonly conversationWorkflowId: "6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f/chat-telegram-4f32eceadb5d05f640c88ff4517eccbd4ab9c99c72c84db5";
|
|
25
|
+
readonly inputs: {
|
|
26
|
+
readonly accountId: "tg-main";
|
|
27
|
+
readonly chatId: "12345";
|
|
28
|
+
readonly provider: "telegram";
|
|
29
|
+
readonly threadId: "7";
|
|
30
|
+
readonly universeId: "6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f";
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
readonly emissionIds: {
|
|
34
|
+
readonly invocationCancellation: "emission:sha256:6b88bd2ef714193fc9274b5f212cc415da4dd25733e1717fa89c7fdddc3eca4e";
|
|
35
|
+
readonly runTerminal: "emission:sha256:a477a56dbeb4f3937959dc5ece1cf363c7030bec130415e4019b507e48098240";
|
|
36
|
+
readonly sourceResolution: "emission:sha256:8980ea03cd17fbacf2682cdf4e5a13593d6c596ca8965ebcdb601ad56e40ec85";
|
|
37
|
+
readonly toolInvocation: "wti:sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
|
38
|
+
};
|
|
39
|
+
readonly envelopes: readonly [{
|
|
40
|
+
readonly body: {
|
|
41
|
+
readonly failure_message_ref: null;
|
|
42
|
+
readonly kind: "run_terminal";
|
|
43
|
+
readonly output_ref: "sha256:e0ee8bb50685e05fa0f47ed04203ae953fdfd055f5bd2892ea186504254f8c3a";
|
|
44
|
+
readonly run_id: 7;
|
|
45
|
+
readonly status: "completed";
|
|
46
|
+
readonly token: "terminal-token-1";
|
|
47
|
+
};
|
|
48
|
+
readonly emission_id: "emission:sha256:a477a56dbeb4f3937959dc5ece1cf363c7030bec130415e4019b507e48098240";
|
|
49
|
+
readonly producer: {
|
|
50
|
+
readonly kind: "session";
|
|
51
|
+
readonly log_seq: 42;
|
|
52
|
+
readonly session_id: "bot:v1:triage";
|
|
53
|
+
readonly universe_id: "6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f";
|
|
54
|
+
};
|
|
55
|
+
}, {
|
|
56
|
+
readonly body: {
|
|
57
|
+
readonly kind: "source_resolution";
|
|
58
|
+
readonly promise_id: "promise_1";
|
|
59
|
+
readonly resolution: {
|
|
60
|
+
readonly kind: "resolved";
|
|
61
|
+
readonly payload_ref: null;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
readonly emission_id: "emission:sha256:8980ea03cd17fbacf2682cdf4e5a13593d6c596ca8965ebcdb601ad56e40ec85";
|
|
65
|
+
readonly producer: {
|
|
66
|
+
readonly kind: "workflow";
|
|
67
|
+
readonly universe_id: "6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f";
|
|
68
|
+
readonly workflow_id: "lightspeed.bots.v1/6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f/triage";
|
|
69
|
+
};
|
|
70
|
+
}, {
|
|
71
|
+
readonly body: {
|
|
72
|
+
readonly holder_workflow_id: "6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f/bot:v1:triage";
|
|
73
|
+
readonly invocation: {
|
|
74
|
+
readonly arguments_ref: "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a";
|
|
75
|
+
readonly binding_fingerprint: "binding:v1:vector";
|
|
76
|
+
readonly completion_promises: {
|
|
77
|
+
readonly reply: "promise_1";
|
|
78
|
+
};
|
|
79
|
+
readonly execution_context_ref: null;
|
|
80
|
+
readonly invocation_id: "wti:sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
|
81
|
+
readonly run_id: 7;
|
|
82
|
+
readonly schema_revision: 1;
|
|
83
|
+
readonly semantic_type: "lightspeed.bots.event.resolve.v1";
|
|
84
|
+
readonly session_id: "bot:v1:triage";
|
|
85
|
+
readonly session_universe_id: "6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f";
|
|
86
|
+
readonly tool_batch_id: 9;
|
|
87
|
+
readonly tool_call_id: "call_1";
|
|
88
|
+
readonly tool_id: "lightspeed.bots.event.resolve.v1";
|
|
89
|
+
readonly turn_id: 8;
|
|
90
|
+
};
|
|
91
|
+
readonly kind: "tool_invocation";
|
|
92
|
+
};
|
|
93
|
+
readonly emission_id: "wti:sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
|
94
|
+
readonly producer: {
|
|
95
|
+
readonly kind: "session";
|
|
96
|
+
readonly log_seq: 43;
|
|
97
|
+
readonly session_id: "bot:v1:triage";
|
|
98
|
+
readonly universe_id: "6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f";
|
|
99
|
+
};
|
|
100
|
+
}, {
|
|
101
|
+
readonly body: {
|
|
102
|
+
readonly completion_key: "reply";
|
|
103
|
+
readonly invocation_id: "wti:sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
|
104
|
+
readonly kind: "invocation_cancellation";
|
|
105
|
+
readonly promise_id: "promise_1";
|
|
106
|
+
};
|
|
107
|
+
readonly emission_id: "emission:sha256:6b88bd2ef714193fc9274b5f212cc415da4dd25733e1717fa89c7fdddc3eca4e";
|
|
108
|
+
readonly producer: {
|
|
109
|
+
readonly kind: "session";
|
|
110
|
+
readonly log_seq: 44;
|
|
111
|
+
readonly session_id: "bot:v1:triage";
|
|
112
|
+
readonly universe_id: "6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f";
|
|
113
|
+
};
|
|
114
|
+
}];
|
|
115
|
+
readonly inputs: {
|
|
116
|
+
readonly completionKey: "reply";
|
|
117
|
+
readonly environmentId: "env_1";
|
|
118
|
+
readonly holderWorkflowId: "6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f/bot:v1:triage";
|
|
119
|
+
readonly invocationId: "wti:sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
|
120
|
+
readonly jobGroupId: "job_1";
|
|
121
|
+
readonly producerWorkflowId: "lightspeed.bots.v1/6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f/triage";
|
|
122
|
+
readonly promiseId: "promise_1";
|
|
123
|
+
readonly recipeJson: "{\"workflowType\":\"BotControllerWorkflow\",\"taskQueue\":\"lightspeed-bots\"}";
|
|
124
|
+
readonly runId: 7;
|
|
125
|
+
readonly sessionId: "bot:v1:triage";
|
|
126
|
+
readonly token: "terminal-token-1";
|
|
127
|
+
readonly universeId: "6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f";
|
|
128
|
+
};
|
|
129
|
+
readonly recipe: {
|
|
130
|
+
readonly taskQueue: "lightspeed-bots";
|
|
131
|
+
readonly workflowType: "BotControllerWorkflow";
|
|
132
|
+
};
|
|
133
|
+
readonly recipeFingerprint: "wtr:sha256:7c3d35ba94ba53a7d51d12749aa2fb43e8026d6a3b69dfca7ef4b9422b846010";
|
|
134
|
+
readonly recoveryResult: {
|
|
135
|
+
readonly resolutions: {
|
|
136
|
+
readonly reply: {
|
|
137
|
+
readonly kind: "resolved";
|
|
138
|
+
readonly payload_ref: null;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
readonly startArgs: {
|
|
143
|
+
readonly execution_id: "wte:vector";
|
|
144
|
+
readonly holder_workflow_id: "6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f/bot:v1:triage";
|
|
145
|
+
readonly invocation: {
|
|
146
|
+
readonly arguments_ref: "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a";
|
|
147
|
+
readonly binding_fingerprint: "binding:v1:vector";
|
|
148
|
+
readonly completion_promises: {
|
|
149
|
+
readonly reply: "promise_1";
|
|
150
|
+
};
|
|
151
|
+
readonly execution_context_ref: null;
|
|
152
|
+
readonly invocation_id: "wti:sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
|
153
|
+
readonly run_id: 7;
|
|
154
|
+
readonly schema_revision: 1;
|
|
155
|
+
readonly semantic_type: "lightspeed.bots.event.resolve.v1";
|
|
156
|
+
readonly session_id: "bot:v1:triage";
|
|
157
|
+
readonly session_universe_id: "6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f";
|
|
158
|
+
readonly tool_batch_id: 9;
|
|
159
|
+
readonly tool_call_id: "call_1";
|
|
160
|
+
readonly tool_id: "lightspeed.bots.event.resolve.v1";
|
|
161
|
+
readonly turn_id: 8;
|
|
162
|
+
};
|
|
163
|
+
readonly universe_id: "6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f";
|
|
164
|
+
};
|
|
165
|
+
readonly workflowIds: {
|
|
166
|
+
readonly environmentJob: "6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f/envjob-env_1-job_1";
|
|
167
|
+
readonly session: "6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f/bot:v1:triage";
|
|
168
|
+
readonly split: {
|
|
169
|
+
readonly sessionId: "bot:v1:triage";
|
|
170
|
+
readonly universeId: "6f3a1a52-58c1-4f0e-9c2d-1a2b3c4d5e6f";
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
export declare const emissionId: {
|
|
175
|
+
readonly runTerminal: (universeId: string, sessionId: string, runId: number, token: string) => string;
|
|
176
|
+
/**
|
|
177
|
+
* Promise ids are session-scoped counters (`promise_7`), so the holder
|
|
178
|
+
* workflow id is part of the emission identity: one producer resolving
|
|
179
|
+
* `promise_7` for two holders sends two distinct emissions.
|
|
180
|
+
*/
|
|
181
|
+
readonly sourceResolution: (universeId: string, producerWorkflowId: string, holderWorkflowId: string, promiseId: string) => string;
|
|
182
|
+
readonly toolInvocation: (invocationId: string) => string;
|
|
183
|
+
readonly invocationCancellation: (invocationId: string, completionKey: string) => string;
|
|
184
|
+
};
|
|
185
|
+
export interface SourceResolutionEnvelopeInput {
|
|
186
|
+
universeId: string;
|
|
187
|
+
producerWorkflowId: string;
|
|
188
|
+
/** The Lightspeed session workflow that holds the promise. */
|
|
189
|
+
holderWorkflowId: string;
|
|
190
|
+
promiseId: string;
|
|
191
|
+
resolution: PromiseResolution;
|
|
192
|
+
}
|
|
193
|
+
/** Build the exact envelope a workflow sends back to a Lightspeed holder. */
|
|
194
|
+
export declare function sourceResolutionEnvelope(input: SourceResolutionEnvelopeInput): EmissionEnvelope;
|
|
195
|
+
/** Decode and validate the fixed signal payload at a workflow boundary. */
|
|
196
|
+
export declare function parseEmissionEnvelope(value: unknown): EmissionEnvelope;
|
|
197
|
+
/** Return the single receiver-visible Promise under the reserved `reply` key. */
|
|
198
|
+
export declare function replyPromiseId(invocation: WorkflowToolInvocation): string;
|
|
199
|
+
/** Compose the stable Temporal workflow id of a Lightspeed session. */
|
|
200
|
+
export declare function sessionWorkflowId(universeId: string, sessionId: string): string;
|
|
201
|
+
/** Compose the stable Temporal workflow id of an environment job group. */
|
|
202
|
+
export declare function environmentJobWorkflowId(universeId: string, environmentId: string, jobGroupId: string): string;
|
|
203
|
+
/**
|
|
204
|
+
* Task queue of the connector host serving one channel account:
|
|
205
|
+
* `lightspeed-connector-{provider}-{24 hex}`, the hex being sha256 over the
|
|
206
|
+
* length-prefixed domain, hyphenated lowercase universe id, provider, and
|
|
207
|
+
* account id. The core routes connector activities here; the host polls it.
|
|
208
|
+
*/
|
|
209
|
+
export declare function connectorTaskQueue(universeId: string, provider: string, accountId: string): string;
|
|
210
|
+
/** Split a canonical session workflow id, returning undefined for other ids. */
|
|
211
|
+
export declare function splitWorkflowId(workflowId: string): {
|
|
212
|
+
universeId: string;
|
|
213
|
+
sessionId: string;
|
|
214
|
+
} | undefined;
|
|
215
|
+
/** Fingerprint the exact raw recipe bytes with the canonical prefix. */
|
|
216
|
+
export declare function recipeFingerprint(recipe: string | Uint8Array): string;
|
|
217
|
+
//# sourceMappingURL=workflow.d.ts.map
|
|
@@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C3B,8DAA8D;IAC9D,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,iBAAiB,CAAC;CAC/B;AAED,6EAA6E;AAC7E,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,6BAA6B,GACnC,gBAAgB,CAwBlB;AAED,2EAA2E;AAC3E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAMtE;AAED,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,UAAU,EAAE,sBAAsB,GAAG,MAAM,CAgBzE;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,MAAM,CAGR;AAED,2EAA2E;AAC3E,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,GACjB,MAAM,CAIR;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,MAAM,CAcR;AAED,gFAAgF;AAChF,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,GACjB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAavD;AAED,wEAAwE;AACxE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAGrE"}
|
package/dist/workflow.js
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
2
|
+
import { WORKFLOW_CONTRACT_MANIFEST } from "./generated/workflow-manifest.js";
|
|
3
|
+
export const DELIVER_EMISSION_SIGNAL = WORKFLOW_CONTRACT_MANIFEST.signals.deliverEmission;
|
|
4
|
+
export const WORKFLOW_TOOL_RECOVERY_QUERY = WORKFLOW_CONTRACT_MANIFEST.queries.workflowToolRecovery;
|
|
5
|
+
export const WORKFLOW_TOOL_EXECUTION_KIND = WORKFLOW_CONTRACT_MANIFEST.workflowTools.executionKind;
|
|
6
|
+
export const WORKFLOW_TOOL_RECIPE_FORMAT_V1 = WORKFLOW_CONTRACT_MANIFEST.workflowTools.recipeFormatV1;
|
|
7
|
+
export const WORKFLOW_TOOL_RECIPE_FINGERPRINT_PREFIX = WORKFLOW_CONTRACT_MANIFEST.workflowTools.recipeFingerprintPrefix;
|
|
8
|
+
export const REPLY_COMPLETION_KEY = WORKFLOW_CONTRACT_MANIFEST.workflowTools.replyCompletionKey;
|
|
9
|
+
/** Activity names a connector host registers on its account task queues. */
|
|
10
|
+
export const CHANNEL_CONNECTOR_ACTIVITIES = WORKFLOW_CONTRACT_MANIFEST.channels.connectorActivities;
|
|
11
|
+
export const CHANNEL_CONVERSATION_WORKFLOW_KIND = WORKFLOW_CONTRACT_MANIFEST.channels.workflowKind;
|
|
12
|
+
export const CHANNEL_INBOUND_SIGNAL = WORKFLOW_CONTRACT_MANIFEST.channels.inboundSignal;
|
|
13
|
+
export const CHANNEL_STATE_QUERY = WORKFLOW_CONTRACT_MANIFEST.channels.stateQuery;
|
|
14
|
+
export const CHANNEL_DELIVERY_RECEIPT_SIGNAL = WORKFLOW_CONTRACT_MANIFEST.channels.deliveryReceiptSignal;
|
|
15
|
+
/** Known-answer vectors emitted by Rust and shared by every generated consumer. */
|
|
16
|
+
export const WORKFLOW_CONTRACT_VECTORS = WORKFLOW_CONTRACT_MANIFEST.vectors;
|
|
17
|
+
const EMISSION_ID = /^(?:emission|wti):sha256:[0-9a-f]{64}$/;
|
|
18
|
+
const INVOCATION_ID = /^wti:sha256:[0-9a-f]{64}$/;
|
|
19
|
+
const BLOB_REF = /^sha256:[0-9a-f]{64}$/;
|
|
20
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
21
|
+
const SESSION_ID = /^[A-Za-z0-9][A-Za-z0-9_.:-]*$/;
|
|
22
|
+
const textEncoder = new TextEncoder();
|
|
23
|
+
export const emissionId = {
|
|
24
|
+
runTerminal(universeId, sessionId, runId, token) {
|
|
25
|
+
requireSessionId(sessionId);
|
|
26
|
+
requireSafeIntegerValue(runId, "runId");
|
|
27
|
+
requireNonEmpty(token, "token");
|
|
28
|
+
return derivedEmissionId("run_terminal", [
|
|
29
|
+
utf8(normalizeUniverseId(universeId)),
|
|
30
|
+
utf8(sessionId),
|
|
31
|
+
u64be(runId),
|
|
32
|
+
utf8(token),
|
|
33
|
+
]);
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* Promise ids are session-scoped counters (`promise_7`), so the holder
|
|
37
|
+
* workflow id is part of the emission identity: one producer resolving
|
|
38
|
+
* `promise_7` for two holders sends two distinct emissions.
|
|
39
|
+
*/
|
|
40
|
+
sourceResolution(universeId, producerWorkflowId, holderWorkflowId, promiseId) {
|
|
41
|
+
requireNonEmpty(producerWorkflowId, "producerWorkflowId");
|
|
42
|
+
requireNonEmpty(holderWorkflowId, "holderWorkflowId");
|
|
43
|
+
requireNonEmpty(promiseId, "promiseId");
|
|
44
|
+
return derivedEmissionId("source_resolution", [
|
|
45
|
+
utf8(normalizeUniverseId(universeId)),
|
|
46
|
+
utf8(producerWorkflowId),
|
|
47
|
+
utf8(holderWorkflowId),
|
|
48
|
+
utf8(promiseId),
|
|
49
|
+
]);
|
|
50
|
+
},
|
|
51
|
+
toolInvocation(invocationId) {
|
|
52
|
+
requireCanonicalInvocationId(invocationId);
|
|
53
|
+
return invocationId;
|
|
54
|
+
},
|
|
55
|
+
invocationCancellation(invocationId, completionKey) {
|
|
56
|
+
requireCanonicalInvocationId(invocationId);
|
|
57
|
+
requireNonEmpty(completionKey, "completionKey");
|
|
58
|
+
return derivedEmissionId("invocation_cancellation", [
|
|
59
|
+
utf8(invocationId),
|
|
60
|
+
utf8(completionKey),
|
|
61
|
+
]);
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
/** Build the exact envelope a workflow sends back to a Lightspeed holder. */
|
|
65
|
+
export function sourceResolutionEnvelope(input) {
|
|
66
|
+
const universeId = normalizeUniverseId(input.universeId);
|
|
67
|
+
requireNonEmpty(input.producerWorkflowId, "producerWorkflowId");
|
|
68
|
+
requireNonEmpty(input.holderWorkflowId, "holderWorkflowId");
|
|
69
|
+
requireNonEmpty(input.promiseId, "promiseId");
|
|
70
|
+
parseResolution(input.resolution);
|
|
71
|
+
return {
|
|
72
|
+
emission_id: emissionId.sourceResolution(universeId, input.producerWorkflowId, input.holderWorkflowId, input.promiseId),
|
|
73
|
+
producer: {
|
|
74
|
+
kind: "workflow",
|
|
75
|
+
universe_id: universeId,
|
|
76
|
+
workflow_id: input.producerWorkflowId,
|
|
77
|
+
},
|
|
78
|
+
body: {
|
|
79
|
+
kind: "source_resolution",
|
|
80
|
+
promise_id: input.promiseId,
|
|
81
|
+
resolution: input.resolution,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** Decode and validate the fixed signal payload at a workflow boundary. */
|
|
86
|
+
export function parseEmissionEnvelope(value) {
|
|
87
|
+
const envelope = record(value, "emission envelope");
|
|
88
|
+
requirePattern(envelope, "emission_id", EMISSION_ID);
|
|
89
|
+
parseProducer(envelope.producer);
|
|
90
|
+
parseBody(envelope.body);
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
/** Return the single receiver-visible Promise under the reserved `reply` key. */
|
|
94
|
+
export function replyPromiseId(invocation) {
|
|
95
|
+
const promises = invocation.completion_promises;
|
|
96
|
+
if (promises === undefined || promises === null) {
|
|
97
|
+
throw new TypeError("pushed invocation must carry exactly the reserved `reply` completion promise");
|
|
98
|
+
}
|
|
99
|
+
const keys = Object.keys(promises);
|
|
100
|
+
if (keys.length !== 1 || keys[0] !== REPLY_COMPLETION_KEY) {
|
|
101
|
+
throw new TypeError("pushed invocation must carry exactly the reserved `reply` completion promise");
|
|
102
|
+
}
|
|
103
|
+
const promiseId = promises[REPLY_COMPLETION_KEY];
|
|
104
|
+
requireNonEmptyValue(promiseId, "reply promise");
|
|
105
|
+
return promiseId;
|
|
106
|
+
}
|
|
107
|
+
/** Compose the stable Temporal workflow id of a Lightspeed session. */
|
|
108
|
+
export function sessionWorkflowId(universeId, sessionId) {
|
|
109
|
+
requireSessionId(sessionId);
|
|
110
|
+
return `${normalizeUniverseId(universeId)}/${sessionId}`;
|
|
111
|
+
}
|
|
112
|
+
/** Compose the stable Temporal workflow id of an environment job group. */
|
|
113
|
+
export function environmentJobWorkflowId(universeId, environmentId, jobGroupId) {
|
|
114
|
+
requireNonEmpty(environmentId, "environmentId");
|
|
115
|
+
requireNonEmpty(jobGroupId, "jobGroupId");
|
|
116
|
+
return `${normalizeUniverseId(universeId)}/envjob-${environmentId}-${jobGroupId}`;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Task queue of the connector host serving one channel account:
|
|
120
|
+
* `lightspeed-connector-{provider}-{24 hex}`, the hex being sha256 over the
|
|
121
|
+
* length-prefixed domain, hyphenated lowercase universe id, provider, and
|
|
122
|
+
* account id. The core routes connector activities here; the host polls it.
|
|
123
|
+
*/
|
|
124
|
+
export function connectorTaskQueue(universeId, provider, accountId) {
|
|
125
|
+
requireNonEmpty(provider, "provider");
|
|
126
|
+
requireNonEmpty(accountId, "accountId");
|
|
127
|
+
const digest = sha256.create();
|
|
128
|
+
for (const part of [
|
|
129
|
+
utf8(WORKFLOW_CONTRACT_MANIFEST.channels.domains.connectorTaskQueue),
|
|
130
|
+
utf8(normalizeUniverseId(universeId)),
|
|
131
|
+
utf8(provider),
|
|
132
|
+
utf8(accountId),
|
|
133
|
+
]) {
|
|
134
|
+
digest.update(u64be(part.length));
|
|
135
|
+
digest.update(part);
|
|
136
|
+
}
|
|
137
|
+
return `lightspeed-connector-${provider}-${hex(digest.digest()).slice(0, 24)}`;
|
|
138
|
+
}
|
|
139
|
+
/** Split a canonical session workflow id, returning undefined for other ids. */
|
|
140
|
+
export function splitWorkflowId(workflowId) {
|
|
141
|
+
const separator = workflowId.indexOf("/");
|
|
142
|
+
if (separator < 0 || workflowId.indexOf("/", separator + 1) >= 0)
|
|
143
|
+
return undefined;
|
|
144
|
+
const universeId = workflowId.slice(0, separator);
|
|
145
|
+
const sessionId = workflowId.slice(separator + 1);
|
|
146
|
+
try {
|
|
147
|
+
const normalizedUniverseId = normalizeUniverseId(universeId);
|
|
148
|
+
requireSessionId(sessionId);
|
|
149
|
+
return { universeId: normalizedUniverseId, sessionId };
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/** Fingerprint the exact raw recipe bytes with the canonical prefix. */
|
|
156
|
+
export function recipeFingerprint(recipe) {
|
|
157
|
+
const bytes = typeof recipe === "string" ? utf8(recipe) : recipe;
|
|
158
|
+
return `${WORKFLOW_TOOL_RECIPE_FINGERPRINT_PREFIX}${hex(sha256(bytes))}`;
|
|
159
|
+
}
|
|
160
|
+
function derivedEmissionId(kind, parts) {
|
|
161
|
+
const digest = sha256.create();
|
|
162
|
+
for (const part of [
|
|
163
|
+
utf8(WORKFLOW_CONTRACT_MANIFEST.emissionIds.hashDomain),
|
|
164
|
+
utf8(kind),
|
|
165
|
+
...parts,
|
|
166
|
+
]) {
|
|
167
|
+
digest.update(u64be(part.length));
|
|
168
|
+
digest.update(part);
|
|
169
|
+
}
|
|
170
|
+
return `${WORKFLOW_CONTRACT_MANIFEST.emissionIds.prefix}${hex(digest.digest())}`;
|
|
171
|
+
}
|
|
172
|
+
function parseProducer(value) {
|
|
173
|
+
const producer = record(value, "emission producer");
|
|
174
|
+
const kind = requireString(producer, "kind");
|
|
175
|
+
normalizeUniverseId(requireString(producer, "universe_id"));
|
|
176
|
+
if (kind === "session") {
|
|
177
|
+
requireSessionId(requireString(producer, "session_id"));
|
|
178
|
+
requireSafeInteger(producer, "log_seq");
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (kind === "workflow") {
|
|
182
|
+
requireNonEmpty(requireString(producer, "workflow_id"), "producer.workflow_id");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
throw new TypeError(`unknown emission producer kind: ${kind}`);
|
|
186
|
+
}
|
|
187
|
+
function parseBody(value) {
|
|
188
|
+
const body = record(value, "emission body");
|
|
189
|
+
const kind = requireString(body, "kind");
|
|
190
|
+
switch (kind) {
|
|
191
|
+
case "run_terminal":
|
|
192
|
+
requireNonEmpty(requireString(body, "token"), "run_terminal.token");
|
|
193
|
+
requireSafeInteger(body, "run_id");
|
|
194
|
+
requireRunStatus(body.status);
|
|
195
|
+
requireOptionalBlobRef(body, "output_ref");
|
|
196
|
+
requireOptionalBlobRef(body, "failure_message_ref");
|
|
197
|
+
return;
|
|
198
|
+
case "source_resolution":
|
|
199
|
+
requireNonEmpty(requireString(body, "promise_id"), "source_resolution.promise_id");
|
|
200
|
+
parseResolution(body.resolution);
|
|
201
|
+
return;
|
|
202
|
+
case "tool_invocation":
|
|
203
|
+
parseInvocation(body.invocation);
|
|
204
|
+
requireNonEmpty(requireString(body, "holder_workflow_id"), "tool_invocation.holder_workflow_id");
|
|
205
|
+
return;
|
|
206
|
+
case "invocation_cancellation":
|
|
207
|
+
requirePattern(body, "invocation_id", INVOCATION_ID);
|
|
208
|
+
requireNonEmpty(requireString(body, "completion_key"), "cancellation.completion_key");
|
|
209
|
+
requireNonEmpty(requireString(body, "promise_id"), "cancellation.promise_id");
|
|
210
|
+
return;
|
|
211
|
+
default:
|
|
212
|
+
throw new TypeError(`unknown emission body kind: ${kind}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function parseInvocation(value) {
|
|
216
|
+
const invocation = record(value, "workflow tool invocation");
|
|
217
|
+
requirePattern(invocation, "invocation_id", INVOCATION_ID);
|
|
218
|
+
for (const key of [
|
|
219
|
+
"tool_id",
|
|
220
|
+
"semantic_type",
|
|
221
|
+
"binding_fingerprint",
|
|
222
|
+
"session_id",
|
|
223
|
+
"tool_call_id",
|
|
224
|
+
]) {
|
|
225
|
+
requireNonEmpty(requireString(invocation, key), `invocation.${key}`);
|
|
226
|
+
}
|
|
227
|
+
normalizeUniverseId(requireString(invocation, "session_universe_id"));
|
|
228
|
+
requirePattern(invocation, "arguments_ref", BLOB_REF);
|
|
229
|
+
const contextRef = invocation.execution_context_ref;
|
|
230
|
+
if (contextRef !== undefined && contextRef !== null) {
|
|
231
|
+
requirePattern(invocation, "execution_context_ref", BLOB_REF);
|
|
232
|
+
}
|
|
233
|
+
for (const key of ["schema_revision", "run_id", "turn_id", "tool_batch_id"]) {
|
|
234
|
+
requireSafeInteger(invocation, key);
|
|
235
|
+
}
|
|
236
|
+
if (invocation.completion_promises !== undefined &&
|
|
237
|
+
invocation.completion_promises !== null) {
|
|
238
|
+
const promises = record(invocation.completion_promises, "completion promises");
|
|
239
|
+
for (const [key, promiseId] of Object.entries(promises)) {
|
|
240
|
+
requireNonEmpty(key, "completion promise key");
|
|
241
|
+
requireNonEmptyValue(promiseId, `completion promise ${key}`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function parseResolution(value) {
|
|
246
|
+
const resolution = record(value, "promise resolution");
|
|
247
|
+
const kind = requireString(resolution, "kind");
|
|
248
|
+
if (kind === "resolved") {
|
|
249
|
+
requireOptionalBlobRef(resolution, "payload_ref");
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (kind === "failed") {
|
|
253
|
+
requireOptionalBlobRef(resolution, "error_ref");
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (kind !== "cancelled") {
|
|
257
|
+
throw new TypeError(`unknown promise resolution kind: ${kind}`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function requireRunStatus(value) {
|
|
261
|
+
if (value !== "active" &&
|
|
262
|
+
value !== "parked" &&
|
|
263
|
+
value !== "cancelling" &&
|
|
264
|
+
value !== "cancelling_grace" &&
|
|
265
|
+
value !== "completed" &&
|
|
266
|
+
value !== "failed" &&
|
|
267
|
+
value !== "cancelled") {
|
|
268
|
+
throw new TypeError(`invalid run status: ${String(value)}`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function requireOptionalBlobRef(value, key) {
|
|
272
|
+
const field = value[key];
|
|
273
|
+
if (field !== undefined && field !== null) {
|
|
274
|
+
requireNonEmptyValue(field, key);
|
|
275
|
+
if (!BLOB_REF.test(field))
|
|
276
|
+
throw new TypeError(`${key} is not a canonical blob ref`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
function record(value, name) {
|
|
280
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
281
|
+
throw new TypeError(`${name} must be an object`);
|
|
282
|
+
}
|
|
283
|
+
return value;
|
|
284
|
+
}
|
|
285
|
+
function requireString(value, key) {
|
|
286
|
+
const field = value[key];
|
|
287
|
+
if (typeof field !== "string")
|
|
288
|
+
throw new TypeError(`${key} must be a string`);
|
|
289
|
+
return field;
|
|
290
|
+
}
|
|
291
|
+
function requirePattern(value, key, pattern) {
|
|
292
|
+
const field = requireString(value, key);
|
|
293
|
+
if (!pattern.test(field))
|
|
294
|
+
throw new TypeError(`${key} has an invalid format`);
|
|
295
|
+
}
|
|
296
|
+
function requireSafeInteger(value, key) {
|
|
297
|
+
requireSafeIntegerValue(value[key], key);
|
|
298
|
+
}
|
|
299
|
+
function requireSafeIntegerValue(value, name) {
|
|
300
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
301
|
+
throw new TypeError(`${name} must be a non-negative safe integer`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
function requireSessionId(value) {
|
|
305
|
+
if (!SESSION_ID.test(value) || utf8(value).length > 128) {
|
|
306
|
+
throw new TypeError("invalid session id");
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function normalizeUniverseId(value) {
|
|
310
|
+
if (!UUID.test(value))
|
|
311
|
+
throw new TypeError("universeId must be a UUID");
|
|
312
|
+
return value.toLowerCase();
|
|
313
|
+
}
|
|
314
|
+
function requireCanonicalInvocationId(value) {
|
|
315
|
+
if (!INVOCATION_ID.test(value))
|
|
316
|
+
throw new TypeError("invalid workflow tool invocation id");
|
|
317
|
+
}
|
|
318
|
+
function requireNonEmpty(value, name) {
|
|
319
|
+
if (value.length === 0)
|
|
320
|
+
throw new TypeError(`${name} must not be empty`);
|
|
321
|
+
}
|
|
322
|
+
function requireNonEmptyValue(value, name) {
|
|
323
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
324
|
+
throw new TypeError(`${name} must be a non-empty string`);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
function utf8(value) {
|
|
328
|
+
return textEncoder.encode(value);
|
|
329
|
+
}
|
|
330
|
+
function u64be(value) {
|
|
331
|
+
const bytes = new Uint8Array(8);
|
|
332
|
+
new DataView(bytes.buffer).setBigUint64(0, BigInt(value), false);
|
|
333
|
+
return bytes;
|
|
334
|
+
}
|
|
335
|
+
function hex(value) {
|
|
336
|
+
return Array.from(value, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
337
|
+
}
|
|
338
|
+
//# sourceMappingURL=workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAU9E,MAAM,CAAC,MAAM,uBAAuB,GAClC,0BAA0B,CAAC,OAAO,CAAC,eAAe,CAAC;AACrD,MAAM,CAAC,MAAM,4BAA4B,GACvC,0BAA0B,CAAC,OAAO,CAAC,oBAAoB,CAAC;AAC1D,MAAM,CAAC,MAAM,4BAA4B,GACvC,0BAA0B,CAAC,aAAa,CAAC,aAAa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}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Context } from "@temporalio/activity";
|
|
2
|
+
import { LightspeedClient, type EventCursor } from "@lightspeed-ai/agent-client";
|
|
3
|
+
|
|
4
|
+
export interface RunLightspeedStepInput {
|
|
5
|
+
endpoint: string;
|
|
6
|
+
sessionId: string;
|
|
7
|
+
prompt: string;
|
|
8
|
+
submissionId: string;
|
|
9
|
+
after?: EventCursor | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export async function runLightspeedStep(input: RunLightspeedStepInput) {
|
|
13
|
+
const activity = Context.current();
|
|
14
|
+
const lightspeed = new LightspeedClient(input.endpoint);
|
|
15
|
+
|
|
16
|
+
const session = await lightspeed.call("session/start", {
|
|
17
|
+
sessionId: input.sessionId,
|
|
18
|
+
cwd: null,
|
|
19
|
+
config: null,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const run = await lightspeed.startRun(
|
|
23
|
+
session.result.session.id,
|
|
24
|
+
[{ type: "text", text: input.prompt }],
|
|
25
|
+
{ submissionId: input.submissionId },
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return lightspeed.awaitRun(session.result.session.id, run.result.run.id, {
|
|
29
|
+
after: input.after ?? null,
|
|
30
|
+
waitMs: 30_000,
|
|
31
|
+
heartbeat: (cursor) => activity.heartbeat({ cursor }),
|
|
32
|
+
});
|
|
33
|
+
}
|