@swirls/looms 0.0.1
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/LICENSE +190 -0
- package/README.md +9 -0
- package/dist/actor/cell.d.ts +27 -0
- package/dist/actor/cell.js +41 -0
- package/dist/actor/host.d.ts +27 -0
- package/dist/actor/host.js +82 -0
- package/dist/actor/index.d.ts +3 -0
- package/dist/actor/index.js +3 -0
- package/dist/actor/routing.d.ts +15 -0
- package/dist/actor/routing.js +80 -0
- package/dist/agent/definitions-store.d.ts +11 -0
- package/dist/agent/definitions-store.js +10 -0
- package/dist/agent/definitions.d.ts +152 -0
- package/dist/agent/definitions.js +74 -0
- package/dist/agent/effects.d.ts +425 -0
- package/dist/agent/effects.js +318 -0
- package/dist/agent/events.d.ts +170 -0
- package/dist/agent/events.js +61 -0
- package/dist/agent/index.d.ts +13 -0
- package/dist/agent/index.js +13 -0
- package/dist/agent/llm.d.ts +35 -0
- package/dist/agent/llm.js +48 -0
- package/dist/agent/module.d.ts +1037 -0
- package/dist/agent/module.js +27 -0
- package/dist/agent/projections.d.ts +17 -0
- package/dist/agent/projections.js +81 -0
- package/dist/agent/scope.d.ts +171 -0
- package/dist/agent/scope.js +7 -0
- package/dist/agent/signals.d.ts +17 -0
- package/dist/agent/signals.js +19 -0
- package/dist/agent/stop-when.d.ts +12 -0
- package/dist/agent/stop-when.js +6 -0
- package/dist/agent/threads.d.ts +34 -0
- package/dist/agent/threads.js +407 -0
- package/dist/agent/tool-schema.d.ts +21 -0
- package/dist/agent/tool-schema.js +67 -0
- package/dist/agent/types.d.ts +87 -0
- package/dist/agent/types.js +32 -0
- package/dist/ai-vercel/index.d.ts +2 -0
- package/dist/ai-vercel/index.js +2 -0
- package/dist/ai-vercel/messages.d.ts +9 -0
- package/dist/ai-vercel/messages.js +68 -0
- package/dist/ai-vercel/vercel-llm.d.ts +8 -0
- package/dist/ai-vercel/vercel-llm.js +98 -0
- package/dist/approval/effects.d.ts +133 -0
- package/dist/approval/effects.js +13 -0
- package/dist/approval/events.d.ts +52 -0
- package/dist/approval/events.js +28 -0
- package/dist/approval/index.d.ts +6 -0
- package/dist/approval/index.js +6 -0
- package/dist/approval/module.d.ts +342 -0
- package/dist/approval/module.js +10 -0
- package/dist/approval/projections.d.ts +42 -0
- package/dist/approval/projections.js +57 -0
- package/dist/approval/scope.d.ts +45 -0
- package/dist/approval/scope.js +7 -0
- package/dist/approval/signals.d.ts +19 -0
- package/dist/approval/signals.js +34 -0
- package/dist/cli/cli.d.ts +2 -0
- package/dist/cli/cli.js +6 -0
- package/dist/cli/commands.d.ts +13 -0
- package/dist/cli/commands.js +133 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/client/client.d.ts +69 -0
- package/dist/client/client.js +179 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +2 -0
- package/dist/client/sse.d.ts +10 -0
- package/dist/client/sse.js +103 -0
- package/dist/cloudflare/alarm-scheduler.d.ts +9 -0
- package/dist/cloudflare/alarm-scheduler.js +13 -0
- package/dist/cloudflare/durable-object.d.ts +24 -0
- package/dist/cloudflare/durable-object.js +43 -0
- package/dist/cloudflare/event-store.d.ts +10 -0
- package/dist/cloudflare/event-store.js +18 -0
- package/dist/cloudflare/index.d.ts +4 -0
- package/dist/cloudflare/index.js +4 -0
- package/dist/cloudflare/router.d.ts +12 -0
- package/dist/cloudflare/router.js +26 -0
- package/dist/core/bun-sqlite.d.ts +13 -0
- package/dist/core/bun-sqlite.js +19 -0
- package/dist/core/catalog.d.ts +49 -0
- package/dist/core/catalog.js +39 -0
- package/dist/core/coalesce.d.ts +21 -0
- package/dist/core/coalesce.js +178 -0
- package/dist/core/compose.d.ts +59 -0
- package/dist/core/compose.js +97 -0
- package/dist/core/cursor.d.ts +16 -0
- package/dist/core/cursor.js +46 -0
- package/dist/core/effects.d.ts +110 -0
- package/dist/core/effects.js +99 -0
- package/dist/core/envelope.d.ts +79 -0
- package/dist/core/envelope.js +68 -0
- package/dist/core/event-codec.d.ts +8 -0
- package/dist/core/event-codec.js +82 -0
- package/dist/core/event-index.d.ts +28 -0
- package/dist/core/event-index.js +86 -0
- package/dist/core/fold.d.ts +19 -0
- package/dist/core/fold.js +362 -0
- package/dist/core/ids.d.ts +11 -0
- package/dist/core/ids.js +47 -0
- package/dist/core/index.d.ts +26 -0
- package/dist/core/index.js +25 -0
- package/dist/core/match.d.ts +8 -0
- package/dist/core/match.js +58 -0
- package/dist/core/module-scope.d.ts +99 -0
- package/dist/core/module-scope.js +72 -0
- package/dist/core/module.d.ts +74 -0
- package/dist/core/module.js +3 -0
- package/dist/core/projection.d.ts +83 -0
- package/dist/core/projection.js +241 -0
- package/dist/core/protocol.d.ts +99 -0
- package/dist/core/protocol.js +101 -0
- package/dist/core/replay.d.ts +13 -0
- package/dist/core/replay.js +34 -0
- package/dist/core/schema.d.ts +35 -0
- package/dist/core/schema.js +130 -0
- package/dist/core/serialize.d.ts +14 -0
- package/dist/core/serialize.js +42 -0
- package/dist/core/snapshot-store.d.ts +39 -0
- package/dist/core/snapshot-store.js +53 -0
- package/dist/core/snapshots.d.ts +26 -0
- package/dist/core/snapshots.js +100 -0
- package/dist/core/sqlite-store.d.ts +31 -0
- package/dist/core/sqlite-store.js +328 -0
- package/dist/core/state.d.ts +43 -0
- package/dist/core/state.js +31 -0
- package/dist/core/store.d.ts +146 -0
- package/dist/core/store.js +229 -0
- package/dist/core/thread.d.ts +41 -0
- package/dist/core/thread.js +13 -0
- package/dist/core/types.d.ts +27 -0
- package/dist/core/types.js +42 -0
- package/dist/core/validate-event.d.ts +19 -0
- package/dist/core/validate-event.js +42 -0
- package/dist/debugger/components/debugger-split.d.ts +23 -0
- package/dist/debugger/components/debugger-split.js +25 -0
- package/dist/debugger/components/event-inspector.d.ts +5 -0
- package/dist/debugger/components/event-inspector.js +38 -0
- package/dist/debugger/components/event-stream.d.ts +13 -0
- package/dist/debugger/components/event-stream.js +119 -0
- package/dist/debugger/components/json-view.d.ts +5 -0
- package/dist/debugger/components/json-view.js +5 -0
- package/dist/debugger/components/run-tree.d.ts +14 -0
- package/dist/debugger/components/run-tree.js +38 -0
- package/dist/debugger/components/status-dot.d.ts +3 -0
- package/dist/debugger/components/status-dot.js +5 -0
- package/dist/debugger/contracts.d.ts +22 -0
- package/dist/debugger/contracts.js +1 -0
- package/dist/debugger/events/catalog.d.ts +6 -0
- package/dist/debugger/events/catalog.js +27 -0
- package/dist/debugger/events/domain-summarize.d.ts +3 -0
- package/dist/debugger/events/domain-summarize.js +107 -0
- package/dist/debugger/events/family.d.ts +8 -0
- package/dist/debugger/events/family.js +44 -0
- package/dist/debugger/events/protocol-summarize.d.ts +3 -0
- package/dist/debugger/events/protocol-summarize.js +70 -0
- package/dist/debugger/index.d.ts +17 -0
- package/dist/debugger/index.js +16 -0
- package/dist/debugger/lib/cn.d.ts +5 -0
- package/dist/debugger/lib/cn.js +17 -0
- package/dist/debugger/lib/event-counts.d.ts +5 -0
- package/dist/debugger/lib/event-counts.js +23 -0
- package/dist/debugger/lib/event-meta.d.ts +8 -0
- package/dist/debugger/lib/event-meta.js +20 -0
- package/dist/debugger/lib/project-run.d.ts +9 -0
- package/dist/debugger/lib/project-run.js +14 -0
- package/dist/debugger/lib/status.d.ts +3 -0
- package/dist/debugger/lib/status.js +31 -0
- package/dist/debugger/lib/visible-events.d.ts +8 -0
- package/dist/debugger/lib/visible-events.js +21 -0
- package/dist/debugger/styles.css +71 -0
- package/dist/debugger/ui/checkbox.d.ts +4 -0
- package/dist/debugger/ui/checkbox.js +9 -0
- package/dist/debugger/ui/input.d.ts +3 -0
- package/dist/debugger/ui/input.js +7 -0
- package/dist/debugger/ui/scroll-area.d.ts +9 -0
- package/dist/debugger/ui/scroll-area.js +10 -0
- package/dist/debugger/ui/tabs.d.ts +7 -0
- package/dist/debugger/ui/tabs.js +17 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/projectors/index-model.d.ts +56 -0
- package/dist/projectors/index-model.js +117 -0
- package/dist/projectors/index.d.ts +4 -0
- package/dist/projectors/index.js +3 -0
- package/dist/projectors/memory.d.ts +5 -0
- package/dist/projectors/memory.js +77 -0
- package/dist/projectors/postgres.d.ts +9 -0
- package/dist/projectors/postgres.js +108 -0
- package/dist/projectors/projector.d.ts +11 -0
- package/dist/projectors/projector.js +1 -0
- package/dist/projectors/schema.d.ts +5 -0
- package/dist/projectors/schema.js +43 -0
- package/dist/projectors/sqlite.d.ts +9 -0
- package/dist/projectors/sqlite.js +103 -0
- package/dist/projectors/with-projectors.d.ts +17 -0
- package/dist/projectors/with-projectors.js +55 -0
- package/dist/react/derived.d.ts +19 -0
- package/dist/react/derived.js +50 -0
- package/dist/react/index.d.ts +6 -0
- package/dist/react/index.js +5 -0
- package/dist/react/materialize.d.ts +3 -0
- package/dist/react/materialize.js +86 -0
- package/dist/react/notify.d.ts +18 -0
- package/dist/react/notify.js +80 -0
- package/dist/react/react.d.ts +61 -0
- package/dist/react/react.js +187 -0
- package/dist/react/register.d.ts +31 -0
- package/dist/react/register.js +1 -0
- package/dist/react/sse.d.ts +1 -0
- package/dist/react/sse.js +1 -0
- package/dist/react/store.d.ts +56 -0
- package/dist/react/store.js +340 -0
- package/dist/react/tables.d.ts +21 -0
- package/dist/react/tables.js +6 -0
- package/dist/runtime/dispatch-effect.d.ts +3 -0
- package/dist/runtime/dispatch-effect.js +113 -0
- package/dist/runtime/events-api.d.ts +4 -0
- package/dist/runtime/events-api.js +84 -0
- package/dist/runtime/index.d.ts +5 -0
- package/dist/runtime/index.js +5 -0
- package/dist/runtime/looms.d.ts +74 -0
- package/dist/runtime/looms.js +109 -0
- package/dist/runtime/runtime-helpers.d.ts +51 -0
- package/dist/runtime/runtime-helpers.js +230 -0
- package/dist/runtime/runtime.d.ts +91 -0
- package/dist/runtime/runtime.js +531 -0
- package/dist/runtime/server.d.ts +17 -0
- package/dist/runtime/server.js +226 -0
- package/dist/runtime/sse.d.ts +15 -0
- package/dist/runtime/sse.js +96 -0
- package/dist/runtime/wake-scheduler.d.ts +8 -0
- package/dist/runtime/wake-scheduler.js +38 -0
- package/dist/s2/config.d.ts +27 -0
- package/dist/s2/config.js +54 -0
- package/dist/s2/index.d.ts +6 -0
- package/dist/s2/index.js +6 -0
- package/dist/s2/lite.d.ts +26 -0
- package/dist/s2/lite.js +150 -0
- package/dist/s2/projector.d.ts +8 -0
- package/dist/s2/projector.js +28 -0
- package/dist/s2/serialize.d.ts +1 -0
- package/dist/s2/serialize.js +1 -0
- package/dist/s2/snapshot-store.d.ts +17 -0
- package/dist/s2/snapshot-store.js +320 -0
- package/dist/s2/store.d.ts +35 -0
- package/dist/s2/store.js +337 -0
- package/dist/testing/index.d.ts +11 -0
- package/dist/testing/index.js +63 -0
- package/dist/workflow/definitions-store.d.ts +11 -0
- package/dist/workflow/definitions-store.js +8 -0
- package/dist/workflow/definitions.d.ts +82 -0
- package/dist/workflow/definitions.js +32 -0
- package/dist/workflow/effects.d.ts +305 -0
- package/dist/workflow/effects.js +208 -0
- package/dist/workflow/events.d.ts +60 -0
- package/dist/workflow/events.js +39 -0
- package/dist/workflow/index.d.ts +8 -0
- package/dist/workflow/index.js +8 -0
- package/dist/workflow/module.d.ts +926 -0
- package/dist/workflow/module.js +19 -0
- package/dist/workflow/projections.d.ts +30 -0
- package/dist/workflow/projections.js +43 -0
- package/dist/workflow/scope.d.ts +61 -0
- package/dist/workflow/scope.js +7 -0
- package/dist/workflow/threads.d.ts +171 -0
- package/dist/workflow/threads.js +287 -0
- package/package.json +183 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {} from 'ai';
|
|
2
|
+
export function toModelMessages(messages) {
|
|
3
|
+
const converted = [];
|
|
4
|
+
for (const message of messages) {
|
|
5
|
+
switch (message.role) {
|
|
6
|
+
case 'system':
|
|
7
|
+
break;
|
|
8
|
+
case 'user':
|
|
9
|
+
converted.push({ role: 'user', content: message.content });
|
|
10
|
+
break;
|
|
11
|
+
case 'assistant': {
|
|
12
|
+
const toolCalls = message.toolCalls ?? [];
|
|
13
|
+
if (toolCalls.length === 0) {
|
|
14
|
+
converted.push({ role: 'assistant', content: message.content });
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
const content = [];
|
|
18
|
+
if (message.content) {
|
|
19
|
+
content.push({ type: 'text', text: message.content });
|
|
20
|
+
}
|
|
21
|
+
for (const toolCall of toolCalls) {
|
|
22
|
+
content.push({
|
|
23
|
+
type: 'tool-call',
|
|
24
|
+
toolCallId: toolCall.id,
|
|
25
|
+
toolName: toolCall.name,
|
|
26
|
+
input: toolCall.arguments,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
converted.push({ role: 'assistant', content });
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
case 'tool':
|
|
33
|
+
converted.push({
|
|
34
|
+
role: 'tool',
|
|
35
|
+
content: [
|
|
36
|
+
{
|
|
37
|
+
type: 'tool-result',
|
|
38
|
+
toolCallId: message.toolCallId ?? message.name ?? 'unknown',
|
|
39
|
+
toolName: message.name ?? 'unknown',
|
|
40
|
+
output: parseToolOutput(message.content),
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
break;
|
|
45
|
+
default: {
|
|
46
|
+
const exhaustiveCheck = message.role;
|
|
47
|
+
return exhaustiveCheck;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return converted;
|
|
52
|
+
}
|
|
53
|
+
function parseToolOutput(content) {
|
|
54
|
+
try {
|
|
55
|
+
// SAFETY: tool message content is parsed JSON from JSON.parse.
|
|
56
|
+
return { type: 'json', value: JSON.parse(content) };
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return { type: 'text', value: content };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export function toLoomsToolCalls(calls) {
|
|
63
|
+
return calls.map((call) => ({
|
|
64
|
+
id: call.toolCallId,
|
|
65
|
+
name: call.toolName,
|
|
66
|
+
arguments: call.input,
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type LanguageModel } from 'ai';
|
|
2
|
+
import type { LlmAdapter } from '@swirls/looms/agent';
|
|
3
|
+
export interface VercelLlmOptions {
|
|
4
|
+
readonly model: LanguageModel;
|
|
5
|
+
/** Prefer streamText when the turn supplies `onTextDelta`. Default true. */
|
|
6
|
+
readonly stream?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function vercelLlm(options: VercelLlmOptions): LlmAdapter;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { generateText, jsonSchema, streamText, tool } from 'ai';
|
|
2
|
+
import { toLoomsToolCalls, toModelMessages } from './messages.js';
|
|
3
|
+
function toAiTools(specs) {
|
|
4
|
+
return Object.fromEntries(specs.map((spec) => [
|
|
5
|
+
spec.name,
|
|
6
|
+
tool({
|
|
7
|
+
description: spec.description,
|
|
8
|
+
// SAFETY: LlmToolSpec.inputJsonSchema is JSON Schema produced by toolJsonSchema.
|
|
9
|
+
inputSchema: jsonSchema(spec.inputJsonSchema),
|
|
10
|
+
}),
|
|
11
|
+
]));
|
|
12
|
+
}
|
|
13
|
+
function toolCallInput(call) {
|
|
14
|
+
const input = 'input' in call ? call.input : {};
|
|
15
|
+
// SAFETY: AI SDK tool-call input is JSON produced by the model against our schema.
|
|
16
|
+
return (input ?? {});
|
|
17
|
+
}
|
|
18
|
+
export function vercelLlm(options) {
|
|
19
|
+
const streamEnabled = options.stream !== false;
|
|
20
|
+
return {
|
|
21
|
+
async complete(args) {
|
|
22
|
+
const messages = toModelMessages(args.messages);
|
|
23
|
+
const tools = args.toolSpecs && args.toolSpecs.length > 0 ? toAiTools(args.toolSpecs) : undefined;
|
|
24
|
+
const shouldStream = streamEnabled && args.onTextDelta !== undefined;
|
|
25
|
+
if (shouldStream) {
|
|
26
|
+
const result = tools
|
|
27
|
+
? streamText({
|
|
28
|
+
model: options.model,
|
|
29
|
+
instructions: args.instructions,
|
|
30
|
+
messages,
|
|
31
|
+
abortSignal: args.signal,
|
|
32
|
+
// SAFETY: VercelAiTool values are `tool()` instances from the AI SDK.
|
|
33
|
+
tools: tools,
|
|
34
|
+
})
|
|
35
|
+
: streamText({
|
|
36
|
+
model: options.model,
|
|
37
|
+
instructions: args.instructions,
|
|
38
|
+
messages,
|
|
39
|
+
abortSignal: args.signal,
|
|
40
|
+
});
|
|
41
|
+
for await (const part of result.fullStream) {
|
|
42
|
+
if (part.type === 'text-delta') {
|
|
43
|
+
const delta = 'text' in part ? part.text : '';
|
|
44
|
+
if (delta) {
|
|
45
|
+
await args.onTextDelta?.(delta);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const [text, rawToolCalls] = await Promise.all([result.text, result.toolCalls]);
|
|
51
|
+
const toolCalls = toLoomsToolCalls(rawToolCalls.map((call) => ({
|
|
52
|
+
toolCallId: call.toolCallId,
|
|
53
|
+
toolName: call.toolName,
|
|
54
|
+
input: toolCallInput(call),
|
|
55
|
+
})));
|
|
56
|
+
return {
|
|
57
|
+
message: { role: 'assistant', content: text, toolCalls },
|
|
58
|
+
toolCalls,
|
|
59
|
+
usage: { input: 0, output: text.length },
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
if (!(err instanceof Error) || !err.message.includes('No output generated')) {
|
|
64
|
+
throw err;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const result = tools
|
|
69
|
+
? await generateText({
|
|
70
|
+
model: options.model,
|
|
71
|
+
instructions: args.instructions,
|
|
72
|
+
messages,
|
|
73
|
+
abortSignal: args.signal,
|
|
74
|
+
// SAFETY: VercelAiTool values are `tool()` instances from the AI SDK.
|
|
75
|
+
tools: tools,
|
|
76
|
+
})
|
|
77
|
+
: await generateText({
|
|
78
|
+
model: options.model,
|
|
79
|
+
instructions: args.instructions,
|
|
80
|
+
messages,
|
|
81
|
+
abortSignal: args.signal,
|
|
82
|
+
});
|
|
83
|
+
const toolCalls = toLoomsToolCalls(result.toolCalls.map((call) => ({
|
|
84
|
+
toolCallId: call.toolCallId,
|
|
85
|
+
toolName: call.toolName,
|
|
86
|
+
input: toolCallInput(call),
|
|
87
|
+
})));
|
|
88
|
+
return {
|
|
89
|
+
message: { role: 'assistant', content: result.text, toolCalls },
|
|
90
|
+
toolCalls,
|
|
91
|
+
usage: {
|
|
92
|
+
input: result.usage?.inputTokens ?? 0,
|
|
93
|
+
output: result.usage?.outputTokens ?? result.text.length,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
export declare const requestApprovalEffect: NoInfer<import("@swirls/looms/core").EffectDefinition<{
|
|
2
|
+
readonly approvalId: string;
|
|
3
|
+
readonly title: string;
|
|
4
|
+
readonly description?: string | undefined;
|
|
5
|
+
readonly actions: readonly {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly label: string;
|
|
8
|
+
readonly outcome: "approve" | "reject";
|
|
9
|
+
}[];
|
|
10
|
+
readonly schema?: import("effect/Schema").Json | undefined;
|
|
11
|
+
}, never, (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
12
|
+
readonly type: "approval.decided";
|
|
13
|
+
readonly payload: {
|
|
14
|
+
readonly approvalId: string;
|
|
15
|
+
readonly actionId: string;
|
|
16
|
+
readonly outcome: "approve" | "reject";
|
|
17
|
+
readonly payload?: import("effect/Schema").Json | undefined;
|
|
18
|
+
};
|
|
19
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
20
|
+
readonly type: "approval.requested";
|
|
21
|
+
readonly payload: {
|
|
22
|
+
readonly approvalId: string;
|
|
23
|
+
readonly title: string;
|
|
24
|
+
readonly description?: string | undefined;
|
|
25
|
+
readonly actions: readonly {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly label: string;
|
|
28
|
+
readonly outcome: "approve" | "reject";
|
|
29
|
+
}[];
|
|
30
|
+
readonly schema?: import("effect/Schema").Json | undefined;
|
|
31
|
+
};
|
|
32
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
33
|
+
readonly type: "approval.timed_out";
|
|
34
|
+
readonly payload: {
|
|
35
|
+
readonly approvalId: string;
|
|
36
|
+
};
|
|
37
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
38
|
+
readonly type: "runtime.effect.failed";
|
|
39
|
+
readonly payload: {
|
|
40
|
+
readonly effectId: string;
|
|
41
|
+
readonly error: string;
|
|
42
|
+
};
|
|
43
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
44
|
+
readonly type: "runtime.run.completed";
|
|
45
|
+
readonly payload: {
|
|
46
|
+
readonly output: import("effect/Schema").Json;
|
|
47
|
+
readonly error: string | null;
|
|
48
|
+
};
|
|
49
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
50
|
+
readonly type: "runtime.run.started";
|
|
51
|
+
readonly payload: {
|
|
52
|
+
readonly rootThreadId?: string | undefined;
|
|
53
|
+
readonly kind: string;
|
|
54
|
+
readonly definitionName: string;
|
|
55
|
+
readonly input: import("effect/Schema").Json;
|
|
56
|
+
};
|
|
57
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
58
|
+
readonly type: "runtime.signal.received";
|
|
59
|
+
readonly payload: {
|
|
60
|
+
readonly signalType: string;
|
|
61
|
+
};
|
|
62
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
63
|
+
readonly type: "runtime.snapshot.taken";
|
|
64
|
+
readonly payload: {
|
|
65
|
+
readonly seq: number;
|
|
66
|
+
readonly stateHash: string;
|
|
67
|
+
readonly state?: import("effect/Schema").Json | undefined;
|
|
68
|
+
};
|
|
69
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
70
|
+
readonly type: "runtime.thread.cancelled";
|
|
71
|
+
readonly payload: {
|
|
72
|
+
readonly threadId: string;
|
|
73
|
+
readonly reason?: string | undefined;
|
|
74
|
+
};
|
|
75
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
76
|
+
readonly type: "runtime.thread.completed";
|
|
77
|
+
readonly payload: {
|
|
78
|
+
readonly threadId: string;
|
|
79
|
+
readonly output: import("effect/Schema").Json;
|
|
80
|
+
};
|
|
81
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
82
|
+
readonly type: "runtime.thread.failed";
|
|
83
|
+
readonly payload: {
|
|
84
|
+
readonly threadId: string;
|
|
85
|
+
readonly error: string;
|
|
86
|
+
};
|
|
87
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
88
|
+
readonly type: "runtime.thread.started";
|
|
89
|
+
readonly payload: {
|
|
90
|
+
readonly threadId: string;
|
|
91
|
+
readonly kind: string;
|
|
92
|
+
readonly definitionName: string;
|
|
93
|
+
readonly input: import("effect/Schema").Json;
|
|
94
|
+
readonly parentThreadId: string | null;
|
|
95
|
+
};
|
|
96
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
97
|
+
readonly type: "runtime.timer.fired";
|
|
98
|
+
readonly payload: {
|
|
99
|
+
readonly timerId: string;
|
|
100
|
+
readonly waitId: string;
|
|
101
|
+
};
|
|
102
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
103
|
+
readonly type: "runtime.timer.set";
|
|
104
|
+
readonly payload: {
|
|
105
|
+
readonly timerId: string;
|
|
106
|
+
readonly waitId: string;
|
|
107
|
+
readonly wakeAt: number;
|
|
108
|
+
};
|
|
109
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
110
|
+
readonly type: "runtime.wait.registered";
|
|
111
|
+
readonly payload: {
|
|
112
|
+
readonly waitId: string;
|
|
113
|
+
readonly threadId?: string | undefined;
|
|
114
|
+
readonly on: {
|
|
115
|
+
readonly type: string | readonly string[];
|
|
116
|
+
readonly match?: import("effect/Schema").Json | undefined;
|
|
117
|
+
} | {
|
|
118
|
+
readonly timerAt: number;
|
|
119
|
+
};
|
|
120
|
+
readonly tag?: import("effect/Schema").Json | undefined;
|
|
121
|
+
};
|
|
122
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
123
|
+
readonly type: "runtime.wait.satisfied";
|
|
124
|
+
readonly payload: {
|
|
125
|
+
readonly waitId: string;
|
|
126
|
+
readonly tag?: import("effect/Schema").Json | undefined;
|
|
127
|
+
readonly event: {
|
|
128
|
+
readonly id: string;
|
|
129
|
+
readonly type: string;
|
|
130
|
+
readonly payload: import("effect/Schema").Json;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
})>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ApprovalRequestedPayloadSchema } from './events.js';
|
|
2
|
+
import { approvalModule } from './scope.js';
|
|
3
|
+
export const requestApprovalEffect = approvalModule.effect({
|
|
4
|
+
type: 'approval.request',
|
|
5
|
+
input: ApprovalRequestedPayloadSchema,
|
|
6
|
+
execute: (input, ctx) => [
|
|
7
|
+
{
|
|
8
|
+
type: 'approval.requested',
|
|
9
|
+
payload: input,
|
|
10
|
+
threadId: ctx.threadId,
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
export declare const ApprovalActionSchema: Schema.Struct<{
|
|
3
|
+
readonly id: Schema.String;
|
|
4
|
+
readonly label: Schema.String;
|
|
5
|
+
readonly outcome: Schema.Union<readonly [Schema.Literal<"approve">, Schema.Literal<"reject">]>;
|
|
6
|
+
}>;
|
|
7
|
+
export type ApprovalAction = Schema.Schema.Type<typeof ApprovalActionSchema>;
|
|
8
|
+
export declare const ApprovalRequestedPayloadSchema: Schema.Struct<{
|
|
9
|
+
readonly approvalId: Schema.String;
|
|
10
|
+
readonly title: Schema.String;
|
|
11
|
+
readonly description: Schema.optional<Schema.String>;
|
|
12
|
+
readonly actions: Schema.$Array<Schema.Struct<{
|
|
13
|
+
readonly id: Schema.String;
|
|
14
|
+
readonly label: Schema.String;
|
|
15
|
+
readonly outcome: Schema.Union<readonly [Schema.Literal<"approve">, Schema.Literal<"reject">]>;
|
|
16
|
+
}>>;
|
|
17
|
+
readonly schema: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
18
|
+
}>;
|
|
19
|
+
export type ApprovalRequested = Schema.Schema.Type<typeof ApprovalRequestedPayloadSchema>;
|
|
20
|
+
export declare const ApprovalDecidedPayloadSchema: Schema.Struct<{
|
|
21
|
+
readonly approvalId: Schema.String;
|
|
22
|
+
readonly actionId: Schema.String;
|
|
23
|
+
readonly outcome: Schema.Union<readonly [Schema.Literal<"approve">, Schema.Literal<"reject">]>;
|
|
24
|
+
readonly payload: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
25
|
+
}>;
|
|
26
|
+
export type ApprovalDecided = Schema.Schema.Type<typeof ApprovalDecidedPayloadSchema>;
|
|
27
|
+
export declare const ApprovalTimedOutPayloadSchema: Schema.Struct<{
|
|
28
|
+
readonly approvalId: Schema.String;
|
|
29
|
+
}>;
|
|
30
|
+
export type ApprovalTimedOut = Schema.Schema.Type<typeof ApprovalTimedOutPayloadSchema>;
|
|
31
|
+
export declare const approvalCatalog: import("@swirls/looms/core").EventCatalog<"approval", {
|
|
32
|
+
requested: Schema.Struct<{
|
|
33
|
+
readonly approvalId: Schema.String;
|
|
34
|
+
readonly title: Schema.String;
|
|
35
|
+
readonly description: Schema.optional<Schema.String>;
|
|
36
|
+
readonly actions: Schema.$Array<Schema.Struct<{
|
|
37
|
+
readonly id: Schema.String;
|
|
38
|
+
readonly label: Schema.String;
|
|
39
|
+
readonly outcome: Schema.Union<readonly [Schema.Literal<"approve">, Schema.Literal<"reject">]>;
|
|
40
|
+
}>>;
|
|
41
|
+
readonly schema: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
42
|
+
}>;
|
|
43
|
+
decided: Schema.Struct<{
|
|
44
|
+
readonly approvalId: Schema.String;
|
|
45
|
+
readonly actionId: Schema.String;
|
|
46
|
+
readonly outcome: Schema.Union<readonly [Schema.Literal<"approve">, Schema.Literal<"reject">]>;
|
|
47
|
+
readonly payload: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
48
|
+
}>;
|
|
49
|
+
timed_out: Schema.Struct<{
|
|
50
|
+
readonly approvalId: Schema.String;
|
|
51
|
+
}>;
|
|
52
|
+
}>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
import { defineEventCatalog } from '@swirls/looms/core';
|
|
3
|
+
export const ApprovalActionSchema = Schema.Struct({
|
|
4
|
+
id: Schema.String,
|
|
5
|
+
label: Schema.String,
|
|
6
|
+
outcome: Schema.Union([Schema.Literal('approve'), Schema.Literal('reject')]),
|
|
7
|
+
});
|
|
8
|
+
export const ApprovalRequestedPayloadSchema = Schema.Struct({
|
|
9
|
+
approvalId: Schema.String,
|
|
10
|
+
title: Schema.String,
|
|
11
|
+
description: Schema.optional(Schema.String),
|
|
12
|
+
actions: Schema.Array(ApprovalActionSchema),
|
|
13
|
+
schema: Schema.optional(Schema.Json),
|
|
14
|
+
});
|
|
15
|
+
export const ApprovalDecidedPayloadSchema = Schema.Struct({
|
|
16
|
+
approvalId: Schema.String,
|
|
17
|
+
actionId: Schema.String,
|
|
18
|
+
outcome: Schema.Union([Schema.Literal('approve'), Schema.Literal('reject')]),
|
|
19
|
+
payload: Schema.optional(Schema.Json),
|
|
20
|
+
});
|
|
21
|
+
export const ApprovalTimedOutPayloadSchema = Schema.Struct({
|
|
22
|
+
approvalId: Schema.String,
|
|
23
|
+
});
|
|
24
|
+
export const approvalCatalog = defineEventCatalog('approval', {
|
|
25
|
+
requested: ApprovalRequestedPayloadSchema,
|
|
26
|
+
decided: ApprovalDecidedPayloadSchema,
|
|
27
|
+
timed_out: ApprovalTimedOutPayloadSchema,
|
|
28
|
+
});
|