@ekairos/story 1.6.3 → 1.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts +72 -72
- package/dist/agent.js +478 -478
- package/dist/document-parser.d.ts +15 -15
- package/dist/document-parser.js +156 -156
- package/dist/engine.d.ts +21 -21
- package/dist/engine.js +35 -35
- package/dist/events.d.ts +27 -27
- package/dist/events.js +203 -203
- package/dist/index.d.ts +11 -11
- package/dist/index.js +50 -50
- package/dist/schema.d.ts +107 -107
- package/dist/schema.js +63 -63
- package/dist/service.d.ts +44 -44
- package/dist/service.js +202 -202
- package/dist/steps/ai.d.ts +42 -42
- package/dist/steps/ai.js +135 -135
- package/dist/steps/base.d.ts +13 -13
- package/dist/steps/base.js +36 -36
- package/dist/steps/index.d.ts +3 -3
- package/dist/steps/index.js +19 -19
- package/dist/steps/registry.d.ts +4 -4
- package/dist/steps/registry.js +28 -28
- package/dist/steps/sampleStep.d.ts.map +1 -1
- package/dist/steps/sampleStep.js.map +1 -1
- package/dist/steps-context.d.ts +11 -11
- package/dist/steps-context.js +19 -19
- package/dist/story.d.ts +49 -49
- package/dist/story.js +54 -54
- package/dist/storyEngine.d.ts +54 -54
- package/dist/storyEngine.js +50 -50
- package/dist/storyRunner.d.ts +7 -7
- package/dist/storyRunner.js +55 -55
- package/dist/workflows/sampleWorkflow.d.ts.map +1 -1
- package/dist/workflows/sampleWorkflow.js.map +1 -1
- package/package.json +1 -1
package/dist/steps/ai.js
CHANGED
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runReasoningOnceStep = runReasoningOnceStep;
|
|
4
|
-
const ai_1 = require("ai");
|
|
5
|
-
const openai_1 = require("@ai-sdk/openai");
|
|
6
|
-
const zod_1 = require("zod");
|
|
7
|
-
const admin_1 = require("@instantdb/admin");
|
|
8
|
-
const events_1 = require("../events");
|
|
9
|
-
function zodFromField(field) {
|
|
10
|
-
switch (field.type) {
|
|
11
|
-
case "string":
|
|
12
|
-
return zod_1.z.string().describe(field.description ?? "");
|
|
13
|
-
case "number":
|
|
14
|
-
return zod_1.z.number().describe(field.description ?? "");
|
|
15
|
-
case "boolean":
|
|
16
|
-
return zod_1.z.boolean().describe(field.description ?? "");
|
|
17
|
-
case "array":
|
|
18
|
-
if (!field.items)
|
|
19
|
-
return zod_1.z.array(zod_1.z.any()).describe(field.description ?? "");
|
|
20
|
-
return zod_1.z.array(zodFromField(field.items)).describe(field.description ?? "");
|
|
21
|
-
case "object":
|
|
22
|
-
return zod_1.z.object(Object.fromEntries(Object.entries(field.properties ?? {}).map(([k, v]) => [k, zodFromField(v)])))
|
|
23
|
-
.describe(field.description ?? "");
|
|
24
|
-
default:
|
|
25
|
-
return zod_1.z.any();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function zodFromSchema(schema) {
|
|
29
|
-
if (!schema || schema.type !== "object")
|
|
30
|
-
return zod_1.z.object({}).strict();
|
|
31
|
-
const shape = {};
|
|
32
|
-
for (const [name, field] of Object.entries(schema.properties ?? {})) {
|
|
33
|
-
const base = zodFromField(field);
|
|
34
|
-
shape[name] = field.required ? base : base.optional();
|
|
35
|
-
}
|
|
36
|
-
const obj = zod_1.z.object(shape);
|
|
37
|
-
return obj;
|
|
38
|
-
}
|
|
39
|
-
async function runReasoningOnceStep(params) {
|
|
40
|
-
"use step";
|
|
41
|
-
// Construir tools para el modelo sin ejecutar (sin execute)
|
|
42
|
-
const tools = {};
|
|
43
|
-
const includeBase = params.options?.includeBaseTools || { createMessage: true, requestDirection: true, end: true };
|
|
44
|
-
for (const action of params.actions) {
|
|
45
|
-
const inputSchema = zodFromSchema(action.inputSchema);
|
|
46
|
-
tools[action.name] = (0, ai_1.tool)({
|
|
47
|
-
description: action.description,
|
|
48
|
-
inputSchema: inputSchema,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (includeBase.createMessage) {
|
|
52
|
-
tools.createMessage = (0, ai_1.tool)({
|
|
53
|
-
description: "Send a message to the user. Use for final confirmations or information.",
|
|
54
|
-
inputSchema: zod_1.z.object({ message: zod_1.z.string().describe("Markdown content") }),
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
if (includeBase.requestDirection) {
|
|
58
|
-
tools.requestDirection = (0, ai_1.tool)({
|
|
59
|
-
description: "Ask a human for guidance when blocked or unsure.",
|
|
60
|
-
inputSchema: zod_1.z.object({ issue: zod_1.z.string(), context: zod_1.z.string(), suggestedActions: zod_1.z.array(zod_1.z.string()).optional(), urgency: zod_1.z.enum(["low", "medium", "high"]).default("medium") }),
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
if (includeBase.end) {
|
|
64
|
-
tools.end = (0, ai_1.tool)({
|
|
65
|
-
description: "End the current interaction loop.",
|
|
66
|
-
inputSchema: zod_1.z.object({}).strict(),
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
const providerOptions = {};
|
|
70
|
-
if (params.options?.reasoningEffort) {
|
|
71
|
-
providerOptions.openai = {
|
|
72
|
-
reasoningEffort: params.options.reasoningEffort,
|
|
73
|
-
reasoningSummary: "detailed",
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
const result = (0, ai_1.streamText)({
|
|
77
|
-
model: (0, openai_1.openai)("gpt-4o-mini"),
|
|
78
|
-
system: params.systemPrompt,
|
|
79
|
-
messages: [],
|
|
80
|
-
tools,
|
|
81
|
-
toolChoice: "required",
|
|
82
|
-
stopWhen: (0, ai_1.stepCountIs)(1),
|
|
83
|
-
...(Object.keys(providerOptions).length > 0 && { providerOptions }),
|
|
84
|
-
});
|
|
85
|
-
result.consumeStream();
|
|
86
|
-
let resolveFinish;
|
|
87
|
-
let rejectFinish;
|
|
88
|
-
const finishPromise = new Promise((resolve, reject) => {
|
|
89
|
-
resolveFinish = resolve;
|
|
90
|
-
rejectFinish = reject;
|
|
91
|
-
});
|
|
92
|
-
const eventId = (0, admin_1.id)();
|
|
93
|
-
result
|
|
94
|
-
.toUIMessageStream({
|
|
95
|
-
sendStart: false,
|
|
96
|
-
generateMessageId: () => eventId,
|
|
97
|
-
messageMetadata() {
|
|
98
|
-
return { eventId };
|
|
99
|
-
},
|
|
100
|
-
onFinish: ({ messages }) => {
|
|
101
|
-
const lastEvent = (0, events_1.createAssistantEventFromUIMessages)(eventId, messages);
|
|
102
|
-
resolveFinish(lastEvent);
|
|
103
|
-
},
|
|
104
|
-
onError: (e) => {
|
|
105
|
-
rejectFinish(e);
|
|
106
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
107
|
-
return message;
|
|
108
|
-
},
|
|
109
|
-
})
|
|
110
|
-
.pipeThrough(new TransformStream({
|
|
111
|
-
transform(chunk, controller) {
|
|
112
|
-
if (chunk.type === "start")
|
|
113
|
-
return;
|
|
114
|
-
if (chunk.type === "finish-step")
|
|
115
|
-
return;
|
|
116
|
-
if (chunk.type === "start-step")
|
|
117
|
-
return;
|
|
118
|
-
if (chunk.type === "finish")
|
|
119
|
-
return;
|
|
120
|
-
controller.enqueue(chunk);
|
|
121
|
-
},
|
|
122
|
-
}));
|
|
123
|
-
const lastEvent = await finishPromise;
|
|
124
|
-
const toolCalls = [];
|
|
125
|
-
try {
|
|
126
|
-
for (const p of lastEvent.content.parts || []) {
|
|
127
|
-
if (typeof p.type === "string" && p.type.startsWith("tool-")) {
|
|
128
|
-
const toolName = p.type.split("-")[1];
|
|
129
|
-
toolCalls.push({ toolCallId: p.toolCallId, toolName, args: p.input });
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
catch { }
|
|
134
|
-
return { toolCalls };
|
|
135
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runReasoningOnceStep = runReasoningOnceStep;
|
|
4
|
+
const ai_1 = require("ai");
|
|
5
|
+
const openai_1 = require("@ai-sdk/openai");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const admin_1 = require("@instantdb/admin");
|
|
8
|
+
const events_1 = require("../events");
|
|
9
|
+
function zodFromField(field) {
|
|
10
|
+
switch (field.type) {
|
|
11
|
+
case "string":
|
|
12
|
+
return zod_1.z.string().describe(field.description ?? "");
|
|
13
|
+
case "number":
|
|
14
|
+
return zod_1.z.number().describe(field.description ?? "");
|
|
15
|
+
case "boolean":
|
|
16
|
+
return zod_1.z.boolean().describe(field.description ?? "");
|
|
17
|
+
case "array":
|
|
18
|
+
if (!field.items)
|
|
19
|
+
return zod_1.z.array(zod_1.z.any()).describe(field.description ?? "");
|
|
20
|
+
return zod_1.z.array(zodFromField(field.items)).describe(field.description ?? "");
|
|
21
|
+
case "object":
|
|
22
|
+
return zod_1.z.object(Object.fromEntries(Object.entries(field.properties ?? {}).map(([k, v]) => [k, zodFromField(v)])))
|
|
23
|
+
.describe(field.description ?? "");
|
|
24
|
+
default:
|
|
25
|
+
return zod_1.z.any();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function zodFromSchema(schema) {
|
|
29
|
+
if (!schema || schema.type !== "object")
|
|
30
|
+
return zod_1.z.object({}).strict();
|
|
31
|
+
const shape = {};
|
|
32
|
+
for (const [name, field] of Object.entries(schema.properties ?? {})) {
|
|
33
|
+
const base = zodFromField(field);
|
|
34
|
+
shape[name] = field.required ? base : base.optional();
|
|
35
|
+
}
|
|
36
|
+
const obj = zod_1.z.object(shape);
|
|
37
|
+
return obj;
|
|
38
|
+
}
|
|
39
|
+
async function runReasoningOnceStep(params) {
|
|
40
|
+
"use step";
|
|
41
|
+
// Construir tools para el modelo sin ejecutar (sin execute)
|
|
42
|
+
const tools = {};
|
|
43
|
+
const includeBase = params.options?.includeBaseTools || { createMessage: true, requestDirection: true, end: true };
|
|
44
|
+
for (const action of params.actions) {
|
|
45
|
+
const inputSchema = zodFromSchema(action.inputSchema);
|
|
46
|
+
tools[action.name] = (0, ai_1.tool)({
|
|
47
|
+
description: action.description,
|
|
48
|
+
inputSchema: inputSchema,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (includeBase.createMessage) {
|
|
52
|
+
tools.createMessage = (0, ai_1.tool)({
|
|
53
|
+
description: "Send a message to the user. Use for final confirmations or information.",
|
|
54
|
+
inputSchema: zod_1.z.object({ message: zod_1.z.string().describe("Markdown content") }),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (includeBase.requestDirection) {
|
|
58
|
+
tools.requestDirection = (0, ai_1.tool)({
|
|
59
|
+
description: "Ask a human for guidance when blocked or unsure.",
|
|
60
|
+
inputSchema: zod_1.z.object({ issue: zod_1.z.string(), context: zod_1.z.string(), suggestedActions: zod_1.z.array(zod_1.z.string()).optional(), urgency: zod_1.z.enum(["low", "medium", "high"]).default("medium") }),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (includeBase.end) {
|
|
64
|
+
tools.end = (0, ai_1.tool)({
|
|
65
|
+
description: "End the current interaction loop.",
|
|
66
|
+
inputSchema: zod_1.z.object({}).strict(),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const providerOptions = {};
|
|
70
|
+
if (params.options?.reasoningEffort) {
|
|
71
|
+
providerOptions.openai = {
|
|
72
|
+
reasoningEffort: params.options.reasoningEffort,
|
|
73
|
+
reasoningSummary: "detailed",
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const result = (0, ai_1.streamText)({
|
|
77
|
+
model: (0, openai_1.openai)("gpt-4o-mini"),
|
|
78
|
+
system: params.systemPrompt,
|
|
79
|
+
messages: [],
|
|
80
|
+
tools,
|
|
81
|
+
toolChoice: "required",
|
|
82
|
+
stopWhen: (0, ai_1.stepCountIs)(1),
|
|
83
|
+
...(Object.keys(providerOptions).length > 0 && { providerOptions }),
|
|
84
|
+
});
|
|
85
|
+
result.consumeStream();
|
|
86
|
+
let resolveFinish;
|
|
87
|
+
let rejectFinish;
|
|
88
|
+
const finishPromise = new Promise((resolve, reject) => {
|
|
89
|
+
resolveFinish = resolve;
|
|
90
|
+
rejectFinish = reject;
|
|
91
|
+
});
|
|
92
|
+
const eventId = (0, admin_1.id)();
|
|
93
|
+
result
|
|
94
|
+
.toUIMessageStream({
|
|
95
|
+
sendStart: false,
|
|
96
|
+
generateMessageId: () => eventId,
|
|
97
|
+
messageMetadata() {
|
|
98
|
+
return { eventId };
|
|
99
|
+
},
|
|
100
|
+
onFinish: ({ messages }) => {
|
|
101
|
+
const lastEvent = (0, events_1.createAssistantEventFromUIMessages)(eventId, messages);
|
|
102
|
+
resolveFinish(lastEvent);
|
|
103
|
+
},
|
|
104
|
+
onError: (e) => {
|
|
105
|
+
rejectFinish(e);
|
|
106
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
107
|
+
return message;
|
|
108
|
+
},
|
|
109
|
+
})
|
|
110
|
+
.pipeThrough(new TransformStream({
|
|
111
|
+
transform(chunk, controller) {
|
|
112
|
+
if (chunk.type === "start")
|
|
113
|
+
return;
|
|
114
|
+
if (chunk.type === "finish-step")
|
|
115
|
+
return;
|
|
116
|
+
if (chunk.type === "start-step")
|
|
117
|
+
return;
|
|
118
|
+
if (chunk.type === "finish")
|
|
119
|
+
return;
|
|
120
|
+
controller.enqueue(chunk);
|
|
121
|
+
},
|
|
122
|
+
}));
|
|
123
|
+
const lastEvent = await finishPromise;
|
|
124
|
+
const toolCalls = [];
|
|
125
|
+
try {
|
|
126
|
+
for (const p of lastEvent.content.parts || []) {
|
|
127
|
+
if (typeof p.type === "string" && p.type.startsWith("tool-")) {
|
|
128
|
+
const toolName = p.type.split("-")[1];
|
|
129
|
+
toolCalls.push({ toolCallId: p.toolCallId, toolName, args: p.input });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch { }
|
|
134
|
+
return { toolCalls };
|
|
135
|
+
}
|
|
136
136
|
//# sourceMappingURL=ai.js.map
|
package/dist/steps/base.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export declare function executeRegisteredStep(params: {
|
|
2
|
-
implementationKey: string;
|
|
3
|
-
contextId: string;
|
|
4
|
-
args: any;
|
|
5
|
-
}): Promise<{
|
|
6
|
-
success: boolean;
|
|
7
|
-
result: any;
|
|
8
|
-
message?: undefined;
|
|
9
|
-
} | {
|
|
10
|
-
success: boolean;
|
|
11
|
-
message: any;
|
|
12
|
-
result?: undefined;
|
|
13
|
-
}>;
|
|
1
|
+
export declare function executeRegisteredStep(params: {
|
|
2
|
+
implementationKey: string;
|
|
3
|
+
contextId: string;
|
|
4
|
+
args: any;
|
|
5
|
+
}): Promise<{
|
|
6
|
+
success: boolean;
|
|
7
|
+
result: any;
|
|
8
|
+
message?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
success: boolean;
|
|
11
|
+
message: any;
|
|
12
|
+
result?: undefined;
|
|
13
|
+
}>;
|
|
14
14
|
//# sourceMappingURL=base.d.ts.map
|
package/dist/steps/base.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.executeRegisteredStep = executeRegisteredStep;
|
|
4
|
-
const registry_1 = require("./registry");
|
|
5
|
-
async function executeRegisteredStep(params) {
|
|
6
|
-
"use step";
|
|
7
|
-
// 1) Intentar step registrado explícito
|
|
8
|
-
const step = (0, registry_1.getRegisteredStep)(params.implementationKey);
|
|
9
|
-
if (step) {
|
|
10
|
-
try {
|
|
11
|
-
const result = await step({ contextId: params.contextId, ...(params.args ?? {}) });
|
|
12
|
-
return { success: true, result };
|
|
13
|
-
}
|
|
14
|
-
catch (error) {
|
|
15
|
-
return { success: false, message: error?.message ?? String(error) };
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
// 2) Intentar acción runtime desde storyEngine (no serializable)
|
|
19
|
-
// Buscamos una story que tenga esta implementación (acceso directo al símbolo global)
|
|
20
|
-
try {
|
|
21
|
-
const stories = globalThis[Symbol.for("PULZAR_STORY_ENGINE")]?.stories;
|
|
22
|
-
if (stories) {
|
|
23
|
-
for (const [, rt] of stories) {
|
|
24
|
-
const action = rt.actions?.[params.implementationKey];
|
|
25
|
-
if (action && typeof action.execute === "function") {
|
|
26
|
-
const result = await action.execute({ contextId: params.contextId, ...(params.args ?? {}) });
|
|
27
|
-
return { success: true, result };
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
return { success: false, message: error?.message ?? String(error) };
|
|
34
|
-
}
|
|
35
|
-
return { success: false, message: `Step not found: ${params.implementationKey}` };
|
|
36
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeRegisteredStep = executeRegisteredStep;
|
|
4
|
+
const registry_1 = require("./registry");
|
|
5
|
+
async function executeRegisteredStep(params) {
|
|
6
|
+
"use step";
|
|
7
|
+
// 1) Intentar step registrado explícito
|
|
8
|
+
const step = (0, registry_1.getRegisteredStep)(params.implementationKey);
|
|
9
|
+
if (step) {
|
|
10
|
+
try {
|
|
11
|
+
const result = await step({ contextId: params.contextId, ...(params.args ?? {}) });
|
|
12
|
+
return { success: true, result };
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
return { success: false, message: error?.message ?? String(error) };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// 2) Intentar acción runtime desde storyEngine (no serializable)
|
|
19
|
+
// Buscamos una story que tenga esta implementación (acceso directo al símbolo global)
|
|
20
|
+
try {
|
|
21
|
+
const stories = globalThis[Symbol.for("PULZAR_STORY_ENGINE")]?.stories;
|
|
22
|
+
if (stories) {
|
|
23
|
+
for (const [, rt] of stories) {
|
|
24
|
+
const action = rt.actions?.[params.implementationKey];
|
|
25
|
+
if (action && typeof action.execute === "function") {
|
|
26
|
+
const result = await action.execute({ contextId: params.contextId, ...(params.args ?? {}) });
|
|
27
|
+
return { success: true, result };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return { success: false, message: error?.message ?? String(error) };
|
|
34
|
+
}
|
|
35
|
+
return { success: false, message: `Step not found: ${params.implementationKey}` };
|
|
36
|
+
}
|
|
37
37
|
//# sourceMappingURL=base.js.map
|
package/dist/steps/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./registry";
|
|
2
|
-
export * from "./ai";
|
|
3
|
-
export * from "./base";
|
|
1
|
+
export * from "./registry";
|
|
2
|
+
export * from "./ai";
|
|
3
|
+
export * from "./base";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/steps/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./registry"), exports);
|
|
18
|
-
__exportStar(require("./ai"), exports);
|
|
19
|
-
__exportStar(require("./base"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./registry"), exports);
|
|
18
|
+
__exportStar(require("./ai"), exports);
|
|
19
|
+
__exportStar(require("./base"), exports);
|
|
20
20
|
//# sourceMappingURL=index.js.map
|
package/dist/steps/registry.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type RegisteredStep = (args: any) => Promise<any>;
|
|
2
|
-
export declare function registerStep(key: string, fn: RegisteredStep): void;
|
|
3
|
-
export declare function getRegisteredStep(key: string): RegisteredStep | undefined;
|
|
4
|
-
export declare function listRegisteredSteps(): string[];
|
|
1
|
+
export type RegisteredStep = (args: any) => Promise<any>;
|
|
2
|
+
export declare function registerStep(key: string, fn: RegisteredStep): void;
|
|
3
|
+
export declare function getRegisteredStep(key: string): RegisteredStep | undefined;
|
|
4
|
+
export declare function listRegisteredSteps(): string[];
|
|
5
5
|
//# sourceMappingURL=registry.d.ts.map
|
package/dist/steps/registry.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Registro simple de steps por clave de implementación
|
|
3
|
-
// Cada step debe ser una función que internamente use "use step"
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.registerStep = registerStep;
|
|
6
|
-
exports.getRegisteredStep = getRegisteredStep;
|
|
7
|
-
exports.listRegisteredSteps = listRegisteredSteps;
|
|
8
|
-
const GLOBAL_STEP_REGISTRY_SYMBOL = Symbol.for("PULZAR_STEP_REGISTRY");
|
|
9
|
-
function getRegistry() {
|
|
10
|
-
const g = globalThis;
|
|
11
|
-
if (!g[GLOBAL_STEP_REGISTRY_SYMBOL]) {
|
|
12
|
-
g[GLOBAL_STEP_REGISTRY_SYMBOL] = new Map();
|
|
13
|
-
}
|
|
14
|
-
return g[GLOBAL_STEP_REGISTRY_SYMBOL];
|
|
15
|
-
}
|
|
16
|
-
function registerStep(key, fn) {
|
|
17
|
-
if (!key || typeof key !== "string")
|
|
18
|
-
throw new Error("registerStep: key inválida");
|
|
19
|
-
if (typeof fn !== "function")
|
|
20
|
-
throw new Error("registerStep: fn inválida");
|
|
21
|
-
getRegistry().set(key, fn);
|
|
22
|
-
}
|
|
23
|
-
function getRegisteredStep(key) {
|
|
24
|
-
return getRegistry().get(key);
|
|
25
|
-
}
|
|
26
|
-
function listRegisteredSteps() {
|
|
27
|
-
return Array.from(getRegistry().keys());
|
|
28
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
// Registro simple de steps por clave de implementación
|
|
3
|
+
// Cada step debe ser una función que internamente use "use step"
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.registerStep = registerStep;
|
|
6
|
+
exports.getRegisteredStep = getRegisteredStep;
|
|
7
|
+
exports.listRegisteredSteps = listRegisteredSteps;
|
|
8
|
+
const GLOBAL_STEP_REGISTRY_SYMBOL = Symbol.for("PULZAR_STEP_REGISTRY");
|
|
9
|
+
function getRegistry() {
|
|
10
|
+
const g = globalThis;
|
|
11
|
+
if (!g[GLOBAL_STEP_REGISTRY_SYMBOL]) {
|
|
12
|
+
g[GLOBAL_STEP_REGISTRY_SYMBOL] = new Map();
|
|
13
|
+
}
|
|
14
|
+
return g[GLOBAL_STEP_REGISTRY_SYMBOL];
|
|
15
|
+
}
|
|
16
|
+
function registerStep(key, fn) {
|
|
17
|
+
if (!key || typeof key !== "string")
|
|
18
|
+
throw new Error("registerStep: key inválida");
|
|
19
|
+
if (typeof fn !== "function")
|
|
20
|
+
throw new Error("registerStep: fn inválida");
|
|
21
|
+
getRegistry().set(key, fn);
|
|
22
|
+
}
|
|
23
|
+
function getRegisteredStep(key) {
|
|
24
|
+
return getRegistry().get(key);
|
|
25
|
+
}
|
|
26
|
+
function listRegisteredSteps() {
|
|
27
|
+
return Array.from(getRegistry().keys());
|
|
28
|
+
}
|
|
29
29
|
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sampleStep.d.ts","sourceRoot":"","sources":["../../src/steps/sampleStep.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sampleStep.d.ts","sourceRoot":"","sources":["../../src/steps/sampleStep.ts"],"names":[],"mappings":"AACA,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAe/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sampleStep.js","sourceRoot":"","sources":["../../src/steps/sampleStep.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"sampleStep.js","sourceRoot":"","sources":["../../src/steps/sampleStep.ts"],"names":[],"mappings":";;AACA,gCAeC;AAfM,KAAK,UAAU,UAAU,CAAC,KAAa;IAC5C,UAAU,CAAC;IACX,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAE7B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAErC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/steps-context.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ContextIdentifier } from "./service";
|
|
2
|
-
export declare function ensureContextStep(params: {
|
|
3
|
-
key: string;
|
|
4
|
-
context: ContextIdentifier | null;
|
|
5
|
-
}): Promise<{
|
|
6
|
-
contextId: string;
|
|
7
|
-
}>;
|
|
8
|
-
export declare function buildSystemPromptStep(params: {
|
|
9
|
-
contextId: string;
|
|
10
|
-
narrative: string;
|
|
11
|
-
}): Promise<string>;
|
|
1
|
+
import { ContextIdentifier } from "./service";
|
|
2
|
+
export declare function ensureContextStep(params: {
|
|
3
|
+
key: string;
|
|
4
|
+
context: ContextIdentifier | null;
|
|
5
|
+
}): Promise<{
|
|
6
|
+
contextId: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function buildSystemPromptStep(params: {
|
|
9
|
+
contextId: string;
|
|
10
|
+
narrative: string;
|
|
11
|
+
}): Promise<string>;
|
|
12
12
|
//# sourceMappingURL=steps-context.d.ts.map
|
package/dist/steps-context.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ensureContextStep = ensureContextStep;
|
|
4
|
-
exports.buildSystemPromptStep = buildSystemPromptStep;
|
|
5
|
-
const service_1 = require("./service");
|
|
6
|
-
async function ensureContextStep(params) {
|
|
7
|
-
"use step";
|
|
8
|
-
const service = new service_1.AgentService();
|
|
9
|
-
const selector = params.context;
|
|
10
|
-
const ctx = await service.getOrCreateContext(selector ?? { key: params.key });
|
|
11
|
-
return { contextId: ctx.id };
|
|
12
|
-
}
|
|
13
|
-
async function buildSystemPromptStep(params) {
|
|
14
|
-
"use step";
|
|
15
|
-
// Por ahora el prompt es plano, concatenando narrativa y metadatos básicos de contexto
|
|
16
|
-
// No modificar prompts de negocio existentes; este es un prompt genérico de Story
|
|
17
|
-
const systemPrompt = `${params.narrative}\n\n[context]\ncontextId: ${params.contextId}`;
|
|
18
|
-
return systemPrompt;
|
|
19
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureContextStep = ensureContextStep;
|
|
4
|
+
exports.buildSystemPromptStep = buildSystemPromptStep;
|
|
5
|
+
const service_1 = require("./service");
|
|
6
|
+
async function ensureContextStep(params) {
|
|
7
|
+
"use step";
|
|
8
|
+
const service = new service_1.AgentService();
|
|
9
|
+
const selector = params.context;
|
|
10
|
+
const ctx = await service.getOrCreateContext(selector ?? { key: params.key });
|
|
11
|
+
return { contextId: ctx.id };
|
|
12
|
+
}
|
|
13
|
+
async function buildSystemPromptStep(params) {
|
|
14
|
+
"use step";
|
|
15
|
+
// Por ahora el prompt es plano, concatenando narrativa y metadatos básicos de contexto
|
|
16
|
+
// No modificar prompts de negocio existentes; este es un prompt genérico de Story
|
|
17
|
+
const systemPrompt = `${params.narrative}\n\n[context]\ncontextId: ${params.contextId}`;
|
|
18
|
+
return systemPrompt;
|
|
19
|
+
}
|
|
20
20
|
//# sourceMappingURL=steps-context.js.map
|