@ekairos/story 1.6.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.
Files changed (73) hide show
  1. package/dist/agent.d.ts +73 -0
  2. package/dist/agent.d.ts.map +1 -0
  3. package/dist/agent.js +479 -0
  4. package/dist/agent.js.map +1 -0
  5. package/dist/document-parser.d.ts +16 -0
  6. package/dist/document-parser.d.ts.map +1 -0
  7. package/dist/document-parser.js +157 -0
  8. package/dist/document-parser.js.map +1 -0
  9. package/dist/engine.d.ts +22 -0
  10. package/dist/engine.d.ts.map +1 -0
  11. package/dist/engine.js +36 -0
  12. package/dist/engine.js.map +1 -0
  13. package/dist/events.d.ts +28 -0
  14. package/dist/events.d.ts.map +1 -0
  15. package/dist/events.js +204 -0
  16. package/dist/events.js.map +1 -0
  17. package/dist/index.d.ts +14 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +53 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/schema.d.ts +108 -0
  22. package/dist/schema.d.ts.map +1 -0
  23. package/dist/schema.js +64 -0
  24. package/dist/schema.js.map +1 -0
  25. package/dist/service.d.ts +45 -0
  26. package/dist/service.d.ts.map +1 -0
  27. package/dist/service.js +203 -0
  28. package/dist/service.js.map +1 -0
  29. package/dist/steps/ai.d.ts +43 -0
  30. package/dist/steps/ai.d.ts.map +1 -0
  31. package/dist/steps/ai.js +136 -0
  32. package/dist/steps/ai.js.map +1 -0
  33. package/dist/steps/base.d.ts +14 -0
  34. package/dist/steps/base.d.ts.map +1 -0
  35. package/dist/steps/base.js +37 -0
  36. package/dist/steps/base.js.map +1 -0
  37. package/dist/steps/index.d.ts +5 -0
  38. package/dist/steps/index.d.ts.map +1 -0
  39. package/dist/steps/index.js +21 -0
  40. package/dist/steps/index.js.map +1 -0
  41. package/dist/steps/registry.d.ts +5 -0
  42. package/dist/steps/registry.d.ts.map +1 -0
  43. package/dist/steps/registry.js +29 -0
  44. package/dist/steps/registry.js.map +1 -0
  45. package/dist/steps/sampleStep.d.ts +2 -0
  46. package/dist/steps/sampleStep.d.ts.map +1 -0
  47. package/dist/steps/sampleStep.js +16 -0
  48. package/dist/steps/sampleStep.js.map +1 -0
  49. package/dist/steps-context.d.ts +12 -0
  50. package/dist/steps-context.d.ts.map +1 -0
  51. package/dist/steps-context.js +20 -0
  52. package/dist/steps-context.js.map +1 -0
  53. package/dist/story.d.ts +50 -0
  54. package/dist/story.d.ts.map +1 -0
  55. package/dist/story.js +55 -0
  56. package/dist/story.js.map +1 -0
  57. package/dist/storyEngine.d.ts +55 -0
  58. package/dist/storyEngine.d.ts.map +1 -0
  59. package/dist/storyEngine.js +51 -0
  60. package/dist/storyEngine.js.map +1 -0
  61. package/dist/storyRunner.d.ts +8 -0
  62. package/dist/storyRunner.d.ts.map +1 -0
  63. package/dist/storyRunner.js +56 -0
  64. package/dist/storyRunner.js.map +1 -0
  65. package/dist/workflows/index.d.ts +2 -0
  66. package/dist/workflows/index.d.ts.map +1 -0
  67. package/dist/workflows/index.js +18 -0
  68. package/dist/workflows/index.js.map +1 -0
  69. package/dist/workflows/sampleWorkflow.d.ts +8 -0
  70. package/dist/workflows/sampleWorkflow.d.ts.map +1 -0
  71. package/dist/workflows/sampleWorkflow.js +19 -0
  72. package/dist/workflows/sampleWorkflow.js.map +1 -0
  73. package/package.json +52 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/steps/base.ts"],"names":[],"mappings":"AAEA,wBAAsB,qBAAqB,CAAC,MAAM,EAAE;IAAE,iBAAiB,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE;;;;;;;;GA6B9G"}
@@ -0,0 +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
+ }
37
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/steps/base.ts"],"names":[],"mappings":";;AAEA,sDA6BC;AA/BD,yCAA8C;AAEvC,KAAK,UAAU,qBAAqB,CAAC,MAAmE;IAC7G,UAAU,CAAA;IACV,wCAAwC;IACxC,MAAM,IAAI,GAAG,IAAA,4BAAiB,EAAC,MAAM,CAAC,iBAAiB,CAAC,CAAA;IACxD,IAAI,IAAI,EAAE,CAAC;QACT,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC,CAAA;YAClF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;QAClC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAA;QACrE,CAAC;IACH,CAAC;IACD,iEAAiE;IACjE,sFAAsF;IACtF,IAAI,CAAC;QACH,MAAM,OAAO,GAAI,UAAkB,CAAC,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,EAAE,OAAuC,CAAA;QAC/G,IAAI,OAAO,EAAE,CAAC;YACZ,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC;gBAC7B,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAA;gBACrD,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;oBACnD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC,CAAA;oBAC5F,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;gBAClC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAA;IACrE,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,mBAAmB,MAAM,CAAC,iBAAiB,EAAE,EAAE,CAAA;AACnF,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from "./registry";
2
+ export * from "./ai";
3
+ export * from "./base";
4
+ export * from "./sampleStep";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/steps/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,MAAM,CAAA;AACpB,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA"}
@@ -0,0 +1,21 @@
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
+ __exportStar(require("./sampleStep"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/steps/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,uCAAoB;AACpB,yCAAsB;AACtB,+CAA4B"}
@@ -0,0 +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[];
5
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/steps/registry.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;AAYxD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,cAAc,QAI3D;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAEzE;AAED,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAE9C"}
@@ -0,0 +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
+ }
29
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/steps/registry.ts"],"names":[],"mappings":";AAAA,uDAAuD;AACvD,iEAAiE;;AAcjE,oCAIC;AAED,8CAEC;AAED,kDAEC;AAtBD,MAAM,2BAA2B,GAAG,MAAM,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA;AAEtE,SAAS,WAAW;IAClB,MAAM,CAAC,GAAG,UAAiB,CAAA;IAC3B,IAAI,CAAC,CAAC,CAAC,2BAA2B,CAAC,EAAE,CAAC;QACpC,CAAC,CAAC,2BAA2B,CAAC,GAAG,IAAI,GAAG,EAA0B,CAAA;IACpE,CAAC;IACD,OAAO,CAAC,CAAC,2BAA2B,CAAgC,CAAA;AACtE,CAAC;AAED,SAAgB,YAAY,CAAC,GAAW,EAAE,EAAkB;IAC1D,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;IAClF,IAAI,OAAO,EAAE,KAAK,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;IAC1E,WAAW,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AAC5B,CAAC;AAED,SAAgB,iBAAiB,CAAC,GAAW;IAC3C,OAAO,WAAW,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAC/B,CAAC;AAED,SAAgB,mBAAmB;IACjC,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,CAAA;AACzC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function sampleStep(input: string): Promise<string>;
2
+ //# sourceMappingURL=sampleStep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sampleStep.d.ts","sourceRoot":"","sources":["../../src/steps/sampleStep.ts"],"names":[],"mappings":"AAEA,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiB/D"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ "use step";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.sampleStep = sampleStep;
5
+ async function sampleStep(input) {
6
+ if (input == null) {
7
+ throw new Error("input is required");
8
+ }
9
+ const trimmed = input.trim();
10
+ if (trimmed.length === 0) {
11
+ throw new Error("input must contain characters");
12
+ }
13
+ const result = trimmed.toUpperCase();
14
+ return result;
15
+ }
16
+ //# sourceMappingURL=sampleStep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sampleStep.js","sourceRoot":"","sources":["../../src/steps/sampleStep.ts"],"names":[],"mappings":";AAAA,UAAU,CAAC;;AAEX,gCAiBC;AAjBM,KAAK,UAAU,UAAU,CAAC,KAAa;IAE5C,IAAI,KAAK,IAAI,IAAI,EACjB,CAAC;QACC,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,EACxB,CAAC;QACC,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"}
@@ -0,0 +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>;
12
+ //# sourceMappingURL=steps-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"steps-context.d.ts","sourceRoot":"","sources":["../src/steps-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAE3D,wBAAsB,iBAAiB,CAAC,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAA;CAAE;;GAOjG;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,mBAM3F"}
@@ -0,0 +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
+ }
20
+ //# sourceMappingURL=steps-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"steps-context.js","sourceRoot":"","sources":["../src/steps-context.ts"],"names":[],"mappings":";;AAEA,8CAOC;AAED,sDAMC;AAjBD,uCAA2D;AAEpD,KAAK,UAAU,iBAAiB,CAAC,MAA0D;IAChG,UAAU,CAAA;IACV,MAAM,OAAO,GAAG,IAAI,sBAAY,EAAE,CAAA;IAElC,MAAM,QAAQ,GAA6B,MAAM,CAAC,OAAO,CAAA;IACzD,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAM,QAAQ,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC,CAAA;IAClF,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,EAAE,EAAE,CAAA;AAC9B,CAAC;AAEM,KAAK,UAAU,qBAAqB,CAAC,MAAgD;IAC1F,UAAU,CAAA;IACV,uFAAuF;IACvF,kFAAkF;IAClF,MAAM,YAAY,GAAG,GAAG,MAAM,CAAC,SAAS,6BAA6B,MAAM,CAAC,SAAS,EAAE,CAAA;IACvF,OAAO,YAAY,CAAA;AACrB,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { ContextIdentifier } from "./service";
2
+ export type PrimitiveType = "string" | "number" | "boolean" | "object" | "array";
3
+ export type FieldSchema = {
4
+ type: PrimitiveType;
5
+ description?: string;
6
+ required?: boolean;
7
+ properties?: Record<string, FieldSchema>;
8
+ items?: FieldSchema;
9
+ };
10
+ export type StepInputSchema = {
11
+ type: "object";
12
+ description?: string;
13
+ properties?: Record<string, FieldSchema>;
14
+ };
15
+ export type StoryActionSpec = {
16
+ name: string;
17
+ description: string;
18
+ implementationKey: string;
19
+ inputSchema?: StepInputSchema;
20
+ finalize?: boolean;
21
+ execute?: (args: any & {
22
+ contextId?: string;
23
+ }) => Promise<any>;
24
+ };
25
+ export type StoryOptions = {
26
+ reasoningEffort?: "low" | "medium" | "high";
27
+ webSearch?: boolean;
28
+ maxLoops?: number;
29
+ finalActions?: string[];
30
+ includeBaseTools?: {
31
+ createMessage?: boolean;
32
+ requestDirection?: boolean;
33
+ end?: boolean;
34
+ };
35
+ };
36
+ export type StoryConfig = {
37
+ narrative: string;
38
+ actions: StoryActionSpec[];
39
+ options?: StoryOptions;
40
+ };
41
+ export type StoryStartArgs = {
42
+ context?: ContextIdentifier | null;
43
+ trigger?: any | null;
44
+ };
45
+ export declare function story(key: string, config: StoryConfig): (args?: StoryStartArgs) => Promise<{
46
+ contextId: string;
47
+ status: "completed";
48
+ }>;
49
+ export type { StoryActionSpec as StoryAction, StoryOptions as StoryConfigOptions };
50
+ //# sourceMappingURL=story.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"story.d.ts","sourceRoot":"","sources":["../src/story.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAOlD,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEhF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,aAAa,CAAA;I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AAM,cAAc,GAAG;IAC3B,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAClC,OAAO,CAAC,EAAE,GAAG,GAAG,IAAI,CAAA;CACrB,CAAA;AAYD,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,IAErB,OAAO,cAAc;;;GAqDrD;AAED,YAAY,EAAE,eAAe,IAAI,WAAW,EAAE,YAAY,IAAI,kBAAkB,EAAE,CAAA"}
package/dist/story.js ADDED
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.story = story;
4
+ // Steps (se resuelven en tiempo de ejecución del step, no en workflow)
5
+ // Se importan como referencias; su lógica corre con "use step" dentro de cada función.
6
+ const steps_context_1 = require("./steps-context");
7
+ const ai_1 = require("./steps/ai");
8
+ const base_1 = require("./steps/base");
9
+ // story(): genera una función workflow que orquesta los steps de manera durable
10
+ function story(key, config) {
11
+ // Retorna una función que orquesta la iteración del workflow (sin directiva)
12
+ return async function runStory(args) {
13
+ const maxLoops = config.options?.maxLoops ?? 10;
14
+ const { contextId } = await (0, steps_context_1.ensureContextStep)({ key, context: args?.context ?? null });
15
+ let loopCount = 0;
16
+ while (loopCount < maxLoops) {
17
+ loopCount++;
18
+ const systemPrompt = await (0, steps_context_1.buildSystemPromptStep)({
19
+ contextId,
20
+ narrative: config.narrative,
21
+ });
22
+ const { toolCalls } = await (0, ai_1.runReasoningOnceStep)({
23
+ contextId,
24
+ systemPrompt,
25
+ actions: config.actions,
26
+ options: config.options ?? {},
27
+ });
28
+ if (!toolCalls || toolCalls.length === 0) {
29
+ break;
30
+ }
31
+ const executions = await Promise.all(toolCalls.map(async (tc) => {
32
+ const action = config.actions.find((a) => a.name === tc.toolName);
33
+ const implementationKey = (action?.implementationKey || tc.toolName);
34
+ const result = await (0, base_1.executeRegisteredStep)({
35
+ implementationKey,
36
+ contextId,
37
+ args: tc.args,
38
+ });
39
+ return { tc, action, result };
40
+ }));
41
+ const shouldEnd = executions.some(({ action }) => {
42
+ const isFinalByAction = Boolean(action?.finalize);
43
+ const isFinalByOptions = action && Array.isArray(config.options?.finalActions)
44
+ ? (config.options.finalActions).includes(action.name)
45
+ : false;
46
+ return isFinalByAction || isFinalByOptions;
47
+ });
48
+ if (shouldEnd) {
49
+ break;
50
+ }
51
+ }
52
+ return { contextId, status: "completed" };
53
+ };
54
+ }
55
+ //# sourceMappingURL=story.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"story.js","sourceRoot":"","sources":["../src/story.ts"],"names":[],"mappings":";;AAiEA,sBAuDC;AA9DD,uEAAuE;AACvE,uFAAuF;AACvF,mDAA0E;AAC1E,mCAAiD;AACjD,uCAAoD;AAEpD,gFAAgF;AAChF,SAAgB,KAAK,CAAC,GAAW,EAAE,MAAmB;IACpD,6EAA6E;IAC7E,OAAO,KAAK,UAAU,QAAQ,CAAC,IAAqB;QAClD,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,IAAI,EAAE,CAAA;QAE/C,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,IAAA,iCAAiB,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,IAAI,IAAI,EAAE,CAAC,CAAA;QAEtF,IAAI,SAAS,GAAG,CAAC,CAAA;QACjB,OAAO,SAAS,GAAG,QAAQ,EAAE,CAAC;YAC5B,SAAS,EAAE,CAAA;YAEX,MAAM,YAAY,GAAG,MAAM,IAAA,qCAAqB,EAAC;gBAC/C,SAAS;gBACT,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAA;YAEF,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,IAAA,yBAAoB,EAAC;gBAC/C,SAAS;gBACT,YAAY;gBACZ,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,EAAE;aAC9B,CAAC,CAAA;YAEF,IAAI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AA;IACpD,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { StoryActionSpec } from "./story";
2
+ export type StoryRuntimeAction = {
3
+ name: string;
4
+ implementationKey: string;
5
+ execute: (args: any & {
6
+ contextId?: string;
7
+ }) => Promise<any>;
8
+ };
9
+ export type StoryRuntimeCallbacks = {
10
+ onToolCallExecuted?: (executionEvent: {
11
+ toolCall: {
12
+ toolCallId: string;
13
+ toolName: string;
14
+ args: any;
15
+ };
16
+ success: boolean;
17
+ message?: string;
18
+ result?: any;
19
+ contextId: string;
20
+ }) => void | Promise<void>;
21
+ evaluateToolCalls?: (toolCalls: any[]) => Promise<{
22
+ success: boolean;
23
+ message?: string;
24
+ }>;
25
+ onEnd?: (lastEvent: any) => void | {
26
+ end?: boolean;
27
+ } | Promise<void | {
28
+ end?: boolean;
29
+ }>;
30
+ };
31
+ export type StoryRuntime = {
32
+ key: string;
33
+ narrative: string;
34
+ actions: Record<string, StoryRuntimeAction>;
35
+ callbacks?: StoryRuntimeCallbacks;
36
+ };
37
+ export type StoryDescriptor = {
38
+ key: string;
39
+ narrative: string;
40
+ actions: Array<Pick<StoryActionSpec, "name" | "description" | "inputSchema" | "finalize" | "implementationKey">>;
41
+ options?: any;
42
+ };
43
+ export declare const engine: {
44
+ register(story: {
45
+ key: string;
46
+ narrative: string;
47
+ actions: StoryActionSpec[];
48
+ callbacks?: StoryRuntimeCallbacks;
49
+ options?: any;
50
+ }): {
51
+ story: (key: string) => StoryDescriptor;
52
+ };
53
+ get(key: string): StoryRuntime | undefined;
54
+ };
55
+ //# sourceMappingURL=storyEngine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storyEngine.d.ts","sourceRoot":"","sources":["../src/storyEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAEzC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,iBAAiB,EAAE,M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C,eAAe,EAAE,MAAM,GAAG,aAAa,GAAG,aAAa,GAAG,UAAU,GAAG,mBAAmB,CAAC,CAAC,CAAA;IAChH,OAAO,CAAC,EAAE,GAAG,CAAA;CACd,CAAA;AAgBD,eAAO,MAAM,MAAM;oBACD;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,eAAe,EAAE,CAAC;QAAC,SAAS,CAAC,EAAE,qBAAqB,CAAC;QAAC,OAAO,CAAC,EAAE,GAAG,CAAA;KAAE;qBAmB/G,MAAM,KAAG,eAAe;;aAchC,MAAM,GAAG,YAAY,GAAG,SAAS;CAG3C,CAAA"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.engine = void 0;
4
+ const GLOBAL_STORY_ENGINE_SYMBOL = Symbol.for("PULZAR_STORY_ENGINE");
5
+ function getGlobalEngine() {
6
+ const g = globalThis;
7
+ if (!g[GLOBAL_STORY_ENGINE_SYMBOL]) {
8
+ g[GLOBAL_STORY_ENGINE_SYMBOL] = { stories: new Map() };
9
+ }
10
+ return g[GLOBAL_STORY_ENGINE_SYMBOL];
11
+ }
12
+ exports.engine = {
13
+ register(story) {
14
+ const runtimeActions = {};
15
+ for (const a of story.actions) {
16
+ if (typeof a.execute === "function") {
17
+ runtimeActions[a.implementationKey || a.name] = {
18
+ name: a.name,
19
+ implementationKey: a.implementationKey || a.name,
20
+ execute: (a.execute),
21
+ };
22
+ }
23
+ }
24
+ const runtime = {
25
+ key: story.key,
26
+ narrative: story.narrative,
27
+ actions: runtimeActions,
28
+ callbacks: story.callbacks,
29
+ };
30
+ getGlobalEngine().stories.set(story.key, runtime);
31
+ return {
32
+ story: (key) => {
33
+ const rt = getGlobalEngine().stories.get(key);
34
+ if (!rt)
35
+ throw new Error(`Story not registered: ${key}`);
36
+ const actions = story.actions.map((a) => ({
37
+ name: a.name,
38
+ description: a.description,
39
+ inputSchema: a.inputSchema,
40
+ finalize: a.finalize,
41
+ implementationKey: a.implementationKey,
42
+ }));
43
+ return { key: story.key, narrative: story.narrative, actions, options: story.options };
44
+ }
45
+ };
46
+ },
47
+ get(key) {
48
+ return getGlobalEngine().stories.get(key);
49
+ }
50
+ };
51
+ //# sourceMappingURL=storyEngine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storyEngine.js","sourceRoot":"","sources":["../src/storyEngine.ts"],"names":[],"mappings":";;;AAkCA,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAA;AAMpE,SAAS,eAAe;IACtB,MAAM,CAAC,GAAG,UAAiB,CAAA;IAC3B,IAAI,CAAC,CAAC,CAAC,0BAA0B,CAAC,EAAE,CAAC;QACnC,CAAC,CAAC,0BAA0B,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,GAAG,EAAwB,EAAE,CAAA;IAC9E,CAAC;IACD,OAAO,CAAC,CAAC,0BAA0B,CAAgB,CAAA;AACrD,CAAC;AAEY,QAAA,MAAM,GAAG;IACpB,QAAQ,CAAC,KAAuH;QAC9H,MAAM,cAAc,GAAuC,EAAE,CAAA;QAC7D,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAC9B,IAAI,OAAQ,CAAS,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;gBAC7C,cAAc,CAAC,CAAC,CAAC,iBAAiB,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG;oBAC9C,IAAI,EAAE,CAAC,CAAC,IAAI;oBACZ,iBAAiB,EAAE,CAAC,CAAC,iBAAiB,IAAI,CAAC,CAAC,IAAI;oBAChD,OAAO,EAAE,CAAE,CAAS,CAAC,OAAO,CAAgC;iBAC7D,CAAA;YACH,CAAC;QACH,CAAC;QACD,MAAM,OAAO,GAAiB;YAC5B,GAAG,EAAE,KAAK,CAAC,GAAG;YACd,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,OAAO,EAAE,cAAc;YACvB,SAAS,EAAE,KAAK,CAAC,SAAS;SAC3B,CAAA;QACD,eAAe,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QACjD,OAAO;YACL,KAAK,EAAE,CAAC,GAAW,EAAmB,EAAE;gBACtC,MAAM,EAAE,GAAG,eAAe,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;gBAC7C,IAAI,CAAC,EAAE;oBAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,EAAE,CAAC,CAAA;gBACxD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;oBACxC,IAAI,EAAE,CAAC,CAAC,IAAI;oBACZ,WAAW,EAAE,CAAC,CAAC,WAAW;oBAC1B,WAAW,EAAE,CAAC,CAAC,WAAW;oBAC1B,QAAQ,EAAE,CAAC,CAAC,QAAQ;oBACpB,iBAAiB,EAAE,CAAC,CAAC,iBAAiB;iBACvC,CAAC,CAAC,CAAA;gBACH,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAA;YACxF,CAAC;SACF,CAAA;IACH,CAAC;IACD,GAAG,CAAC,GAAW;QACb,OAAO,eAAe,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC3C,CAAC;CACF,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { type StoryDescriptor } from "./storyEngine";
2
+ export declare function storyRunner(serialized: StoryDescriptor, args?: {
3
+ context?: any;
4
+ }): Promise<{
5
+ success: boolean;
6
+ contextId: string;
7
+ }>;
8
+ //# sourceMappingURL=storyRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storyRunner.d.ts","sourceRoot":"","sources":["../src/storyRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,eAAe,EAAE,MAAM,eAAe,CAAA;AAO5D,wBAAsB,WAAW,CAAC,UAAU,EAAE,eAAe,EAAE,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,GAAG,CAAA;CAAE;;;GAyDtF"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.storyRunner = storyRunner;
4
+ const storyEngine_1 = require("./storyEngine");
5
+ const steps_context_1 = require("./steps-context");
6
+ const ai_1 = require("./steps/ai");
7
+ const base_1 = require("./steps/base");
8
+ async function storyRunner(serialized, args) {
9
+ "use workflow";
10
+ const maxLoops = 10;
11
+ const { contextId } = await (0, steps_context_1.ensureContextStep)({ key: serialized.key, context: args?.context ?? null });
12
+ let loopCount = 0;
13
+ while (loopCount < maxLoops) {
14
+ loopCount++;
15
+ const systemPrompt = await (0, steps_context_1.buildSystemPromptStep)({
16
+ contextId,
17
+ narrative: serialized.narrative,
18
+ });
19
+ const { toolCalls } = await (0, ai_1.runReasoningOnceStep)({
20
+ contextId,
21
+ systemPrompt,
22
+ actions: serialized.actions.map((a) => ({
23
+ name: a.name,
24
+ description: a.description,
25
+ implementationKey: a.implementationKey || a.name,
26
+ inputSchema: a.inputSchema,
27
+ finalize: a.finalize,
28
+ })),
29
+ options: { reasoningEffort: "medium" },
30
+ });
31
+ if (!toolCalls || toolCalls.length === 0) {
32
+ break;
33
+ }
34
+ const rt = storyEngine_1.engine.get(serialized.key);
35
+ if (!rt)
36
+ throw new Error(`Story runtime not found for key=${serialized.key}`);
37
+ const executions = await Promise.all(toolCalls.map(async (tc) => {
38
+ const implKey = tc.toolName;
39
+ const action = rt.actions[implKey];
40
+ if (action && typeof action.execute === "function") {
41
+ // Ejecutar en el runtime local (no serializable) dentro de un step wrapper
42
+ return await (0, base_1.executeRegisteredStep)({ implementationKey: implKey, contextId, args: tc.args });
43
+ }
44
+ // fallback: ejecutar step registrado directo si existe
45
+ return await (0, base_1.executeRegisteredStep)({ implementationKey: implKey, contextId, args: tc.args });
46
+ }));
47
+ const shouldEnd = executions.some((_r, i) => {
48
+ const a = serialized.actions.find((x) => (x.implementationKey || x.name) === toolCalls[i].toolName);
49
+ return Boolean(a?.finalize);
50
+ });
51
+ if (shouldEnd)
52
+ break;
53
+ }
54
+ return { success: true, contextId };
55
+ }
56
+ //# sourceMappingURL=storyRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storyRunner.js","sourceRoot":"","sources":["../src/storyRunner.ts"],"names":[],"mappings":";;AAOA,kCAyDC;AAhED,+CAA4D;AAC5D,mDAA0E;AAC1E,mCAAiD;AACjD,uCAAoD;AAI7C,KAAK,UAAU,WAAW,CAAC,UAA2B,EAAE,IAAwB;IACrF,cAAc,CAAA;IAEd,MAAM,QAAQ,GAAG,EAAE,CAAA;IAEnB,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,IAAA,iCAAiB,EAAC,EAAE,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,IAAI,IAAI,EAAE,CAAC,CAAA;IAEtG,IAAI,SAAS,GAAG,CAAC,CAAA;IACjB,OAAO,SAAS,GAAG,QAAQ,EAAE,CAAC;QAC5B,SAAS,EAAE,CAAA;QAEX,MAAM,YAAY,GAAG,MAAM,IAAA,qCAAqB,EAAC;YAC/C,SAAS;YACT,SAAS,EAAE,UAAU,CAAC,SAAS;SAChC,CAAC,CAAA;QAEF,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,IAAA,yBAAoB,EAAC;YAC/C,SAAS;YACT,YAAY;YACZ,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACtC,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,WAAW,EAAE,CAAC,CAAC,WAAW;gBAC1B,iBAAiB,EAAE,CA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AAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,iBAAiB,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;YACnG,OAAO,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAA;QAC7B,CAAC,CAAC,CAAA;QACF,IAAI,SAAS;YAAE,MAAK;IACtB,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;AACrC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./sampleWorkflow";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workflows/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,18 @@
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("./sampleWorkflow"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflows/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
@@ -0,0 +1,8 @@
1
+ export interface SampleWorkflowInput {
2
+ text: string;
3
+ }
4
+ export interface SampleWorkflowOutput {
5
+ uppercase: string;
6
+ }
7
+ export declare function sampleWorkflow(input: SampleWorkflowInput): Promise<SampleWorkflowOutput>;
8
+ //# sourceMappingURL=sampleWorkflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sampleWorkflow.d.ts","sourceRoot":"","sources":["../../src/workflows/sampleWorkflow.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,mBAAmB;IAElC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IAEnC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAmB9F"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ "use workflow";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.sampleWorkflow = sampleWorkflow;
5
+ const sampleStep_1 = require("../steps/sampleStep");
6
+ async function sampleWorkflow(input) {
7
+ if (input == null) {
8
+ throw new Error("input is required");
9
+ }
10
+ const { text } = input;
11
+ if (text == null) {
12
+ throw new Error("text is required");
13
+ }
14
+ const uppercase = await (0, sampleStep_1.sampleStep)(text);
15
+ return {
16
+ uppercase,
17
+ };
18
+ }
19
+ //# sourceMappingURL=sampleWorkflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sampleWorkflow.js","sourceRoot":"","sources":["../../src/workflows/sampleWorkflow.ts"],"names":[],"mappings":";AAAA,cAAc,CAAC;;AAcf,wCAmBC;AA/BD,oDAAiD;AAY1C,KAAK,UAAU,cAAc,CAAC,KAA0B;IAE7D,IAAI,KAAK,IAAI,IAAI,EACjB,CAAC;QACC,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAEvB,IAAI,IAAI,IAAI,IAAI,EAChB,CAAC;QACC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,IAAA,uBAAU,EAAC,IAAI,CAAC,CAAC;IAEzC,OAAO;QACL,SAAS;KACV,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@ekairos/story",
3
+ "version": "1.6.0",
4
+ "description": "Pulzar Story - Workflow-based AI Stories",
5
+ "type": "commonjs",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "license": "MIT",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/pulz-ar/pulzar-lib-core.git",
18
+ "directory": "packages/story"
19
+ },
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "require": "./dist/index.js",
24
+ "default": "./dist/index.js"
25
+ }
26
+ },
27
+ "scripts": {
28
+ "build": "tsc -p tsconfig.json",
29
+ "dev": "tsc -p tsconfig.json --watch",
30
+ "clean": "node -e \"require('fs').rmSync('dist', {recursive:true, force:true})\"",
31
+ "typecheck": "tsc --noEmit"
32
+ },
33
+ "dependencies": {
34
+ "@ai-sdk/openai": "^2.0.52",
35
+ "@ekairos/domain": "^1.6.0",
36
+ "@instantdb/admin": "^0.22.13",
37
+ "@instantdb/core": "^0.22.13",
38
+ "@vercel/sandbox": "^0.0.23",
39
+ "ai": "^5.0.44",
40
+ "ajv": "^8.17.1",
41
+ "braintrust": "^0.3.7",
42
+ "llamaindex": "^0.12.0",
43
+ "xmlbuilder2": "^3.1.1",
44
+ "zod": "^4.1.8"
45
+ },
46
+ "devDependencies": {
47
+ "@ekairos/tsconfig": "workspace:*",
48
+ "@types/node": "^24.5.0",
49
+ "typescript": "^5.9.2"
50
+ }
51
+ }
52
+