@elizaos/plugin-agent-orchestrator 2.0.3-beta.2 → 2.0.3-beta.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.
Files changed (176) hide show
  1. package/dist/cjs/index.d.ts +2 -0
  2. package/dist/cjs/index.node.cjs +20962 -0
  3. package/dist/cjs/index.node.js.map +82 -0
  4. package/dist/index.d.ts +2 -0
  5. package/dist/node/index.d.ts +2 -0
  6. package/dist/node/index.d.ts.map +1 -0
  7. package/dist/node/index.node.d.ts +4 -0
  8. package/dist/node/index.node.d.ts.map +1 -0
  9. package/dist/node/index.node.js +20946 -0
  10. package/dist/node/index.node.js.map +82 -0
  11. package/dist/node/src/actions/common.d.ts +114 -0
  12. package/dist/node/src/actions/common.d.ts.map +1 -0
  13. package/dist/node/src/actions/elizaos-capability.d.ts +3 -0
  14. package/dist/node/src/actions/elizaos-capability.d.ts.map +1 -0
  15. package/dist/node/src/actions/sandbox-stub.d.ts +25 -0
  16. package/dist/node/src/actions/sandbox-stub.d.ts.map +1 -0
  17. package/dist/node/src/actions/tasks.d.ts +108 -0
  18. package/dist/node/src/actions/tasks.d.ts.map +1 -0
  19. package/dist/node/src/api/agent-routes.d.ts +18 -0
  20. package/dist/node/src/api/agent-routes.d.ts.map +1 -0
  21. package/dist/node/src/api/bridge-routes.d.ts +70 -0
  22. package/dist/node/src/api/bridge-routes.d.ts.map +1 -0
  23. package/dist/node/src/api/credential-prompt.d.ts +38 -0
  24. package/dist/node/src/api/credential-prompt.d.ts.map +1 -0
  25. package/dist/node/src/api/issue-routes.d.ts +17 -0
  26. package/dist/node/src/api/issue-routes.d.ts.map +1 -0
  27. package/dist/node/src/api/orchestrator-routes.d.ts +25 -0
  28. package/dist/node/src/api/orchestrator-routes.d.ts.map +1 -0
  29. package/dist/node/src/api/parent-context-routes.d.ts +17 -0
  30. package/dist/node/src/api/parent-context-routes.d.ts.map +1 -0
  31. package/dist/node/src/api/route-utils.d.ts +34 -0
  32. package/dist/node/src/api/route-utils.d.ts.map +1 -0
  33. package/dist/node/src/api/routes.d.ts +22 -0
  34. package/dist/node/src/api/routes.d.ts.map +1 -0
  35. package/dist/node/src/api/workspace-routes.d.ts +17 -0
  36. package/dist/node/src/api/workspace-routes.d.ts.map +1 -0
  37. package/dist/node/src/evaluators/sub-agent-completion.d.ts +3 -0
  38. package/dist/node/src/evaluators/sub-agent-completion.d.ts.map +1 -0
  39. package/dist/node/src/index.d.ts +57 -0
  40. package/dist/node/src/index.d.ts.map +1 -0
  41. package/dist/node/src/providers/action-examples.d.ts +14 -0
  42. package/dist/node/src/providers/action-examples.d.ts.map +1 -0
  43. package/dist/node/src/providers/active-sub-agents.d.ts +15 -0
  44. package/dist/node/src/providers/active-sub-agents.d.ts.map +1 -0
  45. package/dist/node/src/providers/active-workspace-context.d.ts +13 -0
  46. package/dist/node/src/providers/active-workspace-context.d.ts.map +1 -0
  47. package/dist/node/src/providers/available-agents.d.ts +4 -0
  48. package/dist/node/src/providers/available-agents.d.ts.map +1 -0
  49. package/dist/node/src/providers/coding-session-changes.d.ts +17 -0
  50. package/dist/node/src/providers/coding-session-changes.d.ts.map +1 -0
  51. package/dist/node/src/register-routes.d.ts +31 -0
  52. package/dist/node/src/register-routes.d.ts.map +1 -0
  53. package/dist/node/src/services/acceptance-criteria.d.ts +84 -0
  54. package/dist/node/src/services/acceptance-criteria.d.ts.map +1 -0
  55. package/dist/node/src/services/acp-native-transport.d.ts +111 -0
  56. package/dist/node/src/services/acp-native-transport.d.ts.map +1 -0
  57. package/dist/node/src/services/acp-service.d.ts +226 -0
  58. package/dist/node/src/services/acp-service.d.ts.map +1 -0
  59. package/dist/node/src/services/active-session-forward.d.ts +31 -0
  60. package/dist/node/src/services/active-session-forward.d.ts.map +1 -0
  61. package/dist/node/src/services/agent-name-assignment.d.ts +50 -0
  62. package/dist/node/src/services/agent-name-assignment.d.ts.map +1 -0
  63. package/dist/node/src/services/ansi-utils.d.ts +64 -0
  64. package/dist/node/src/services/ansi-utils.d.ts.map +1 -0
  65. package/dist/node/src/services/app-deploy-guidance.d.ts +52 -0
  66. package/dist/node/src/services/app-deploy-guidance.d.ts.map +1 -0
  67. package/dist/node/src/services/audit.d.ts +18 -0
  68. package/dist/node/src/services/audit.d.ts.map +1 -0
  69. package/dist/node/src/services/coding-account-selection.d.ts +79 -0
  70. package/dist/node/src/services/coding-account-selection.d.ts.map +1 -0
  71. package/dist/node/src/services/completion-envelope.d.ts +63 -0
  72. package/dist/node/src/services/completion-envelope.d.ts.map +1 -0
  73. package/dist/node/src/services/completion-evidence.d.ts +144 -0
  74. package/dist/node/src/services/completion-evidence.d.ts.map +1 -0
  75. package/dist/node/src/services/config-env.d.ts +27 -0
  76. package/dist/node/src/services/config-env.d.ts.map +1 -0
  77. package/dist/node/src/services/goal-contract.d.ts +25 -0
  78. package/dist/node/src/services/goal-contract.d.ts.map +1 -0
  79. package/dist/node/src/services/goal-llm-verifier.d.ts +157 -0
  80. package/dist/node/src/services/goal-llm-verifier.d.ts.map +1 -0
  81. package/dist/node/src/services/goal-prompt.d.ts +82 -0
  82. package/dist/node/src/services/goal-prompt.d.ts.map +1 -0
  83. package/dist/node/src/services/independent-verifier.d.ts +58 -0
  84. package/dist/node/src/services/independent-verifier.d.ts.map +1 -0
  85. package/dist/node/src/services/interruption-decider.d.ts +43 -0
  86. package/dist/node/src/services/interruption-decider.d.ts.map +1 -0
  87. package/dist/node/src/services/json-model-output.d.ts +2 -0
  88. package/dist/node/src/services/json-model-output.d.ts.map +1 -0
  89. package/dist/node/src/services/opencode-config.d.ts +21 -0
  90. package/dist/node/src/services/opencode-config.d.ts.map +1 -0
  91. package/dist/node/src/services/orchestrator-device-support-matrix.d.ts +46 -0
  92. package/dist/node/src/services/orchestrator-device-support-matrix.d.ts.map +1 -0
  93. package/dist/node/src/services/orchestrator-task-mapper.d.ts +192 -0
  94. package/dist/node/src/services/orchestrator-task-mapper.d.ts.map +1 -0
  95. package/dist/node/src/services/orchestrator-task-service.d.ts +370 -0
  96. package/dist/node/src/services/orchestrator-task-service.d.ts.map +1 -0
  97. package/dist/node/src/services/orchestrator-task-store.d.ts +156 -0
  98. package/dist/node/src/services/orchestrator-task-store.d.ts.map +1 -0
  99. package/dist/node/src/services/orchestrator-task-types.d.ts +334 -0
  100. package/dist/node/src/services/orchestrator-task-types.d.ts.map +1 -0
  101. package/dist/node/src/services/parent-agent-broker.d.ts +23 -0
  102. package/dist/node/src/services/parent-agent-broker.d.ts.map +1 -0
  103. package/dist/node/src/services/parent-agent-dispatch.d.ts +62 -0
  104. package/dist/node/src/services/parent-agent-dispatch.d.ts.map +1 -0
  105. package/dist/node/src/services/repo-input.d.ts +16 -0
  106. package/dist/node/src/services/repo-input.d.ts.map +1 -0
  107. package/dist/node/src/services/screenshot-delivery.d.ts +38 -0
  108. package/dist/node/src/services/screenshot-delivery.d.ts.map +1 -0
  109. package/dist/node/src/services/session-event-queue.d.ts +18 -0
  110. package/dist/node/src/services/session-event-queue.d.ts.map +1 -0
  111. package/dist/node/src/services/session-store.d.ts +108 -0
  112. package/dist/node/src/services/session-store.d.ts.map +1 -0
  113. package/dist/node/src/services/skill-lifeops-context-broker.d.ts +20 -0
  114. package/dist/node/src/services/skill-lifeops-context-broker.d.ts.map +1 -0
  115. package/dist/node/src/services/skill-manifest.d.ts +48 -0
  116. package/dist/node/src/services/skill-manifest.d.ts.map +1 -0
  117. package/dist/node/src/services/skill-recommender.d.ts +53 -0
  118. package/dist/node/src/services/skill-recommender.d.ts.map +1 -0
  119. package/dist/node/src/services/smithers-task-executor.d.ts +73 -0
  120. package/dist/node/src/services/smithers-task-executor.d.ts.map +1 -0
  121. package/dist/node/src/services/smithers-task-integration.d.ts +52 -0
  122. package/dist/node/src/services/smithers-task-integration.d.ts.map +1 -0
  123. package/dist/node/src/services/smithers-task-runner.d.ts +27 -0
  124. package/dist/node/src/services/smithers-task-runner.d.ts.map +1 -0
  125. package/dist/node/src/services/smithers-task-types.d.ts +96 -0
  126. package/dist/node/src/services/smithers-task-types.d.ts.map +1 -0
  127. package/dist/node/src/services/spawn-trajectory.d.ts +23 -0
  128. package/dist/node/src/services/spawn-trajectory.d.ts.map +1 -0
  129. package/dist/node/src/services/spend-allowance.d.ts +143 -0
  130. package/dist/node/src/services/spend-allowance.d.ts.map +1 -0
  131. package/dist/node/src/services/ssrf-guard.d.ts +66 -0
  132. package/dist/node/src/services/ssrf-guard.d.ts.map +1 -0
  133. package/dist/node/src/services/sub-agent-identity.d.ts +27 -0
  134. package/dist/node/src/services/sub-agent-identity.d.ts.map +1 -0
  135. package/dist/node/src/services/sub-agent-inbox.d.ts +26 -0
  136. package/dist/node/src/services/sub-agent-inbox.d.ts.map +1 -0
  137. package/dist/node/src/services/sub-agent-router.d.ts +178 -0
  138. package/dist/node/src/services/sub-agent-router.d.ts.map +1 -0
  139. package/dist/node/src/services/task-agent-frameworks.d.ts +103 -0
  140. package/dist/node/src/services/task-agent-frameworks.d.ts.map +1 -0
  141. package/dist/node/src/services/task-agent-routing.d.ts +33 -0
  142. package/dist/node/src/services/task-agent-routing.d.ts.map +1 -0
  143. package/dist/node/src/services/task-policy.d.ts +17 -0
  144. package/dist/node/src/services/task-policy.d.ts.map +1 -0
  145. package/dist/node/src/services/task-supervisor-service.d.ts +65 -0
  146. package/dist/node/src/services/task-supervisor-service.d.ts.map +1 -0
  147. package/dist/node/src/services/task-watchdog-service.d.ts +50 -0
  148. package/dist/node/src/services/task-watchdog-service.d.ts.map +1 -0
  149. package/dist/node/src/services/terminal-capabilities.d.ts +48 -0
  150. package/dist/node/src/services/terminal-capabilities.d.ts.map +1 -0
  151. package/dist/node/src/services/trajectory-context.d.ts +69 -0
  152. package/dist/node/src/services/trajectory-context.d.ts.map +1 -0
  153. package/dist/node/src/services/trajectory-feedback.d.ts +53 -0
  154. package/dist/node/src/services/trajectory-feedback.d.ts.map +1 -0
  155. package/dist/node/src/services/types.d.ts +188 -0
  156. package/dist/node/src/services/types.d.ts.map +1 -0
  157. package/dist/node/src/services/view-deploy-guidance.d.ts +14 -0
  158. package/dist/node/src/services/view-deploy-guidance.d.ts.map +1 -0
  159. package/dist/node/src/services/workdir-validation.d.ts +10 -0
  160. package/dist/node/src/services/workdir-validation.d.ts.map +1 -0
  161. package/dist/node/src/services/workspace-diff.d.ts +50 -0
  162. package/dist/node/src/services/workspace-diff.d.ts.map +1 -0
  163. package/dist/node/src/services/workspace-git-ops.d.ts +28 -0
  164. package/dist/node/src/services/workspace-git-ops.d.ts.map +1 -0
  165. package/dist/node/src/services/workspace-github.d.ts +60 -0
  166. package/dist/node/src/services/workspace-github.d.ts.map +1 -0
  167. package/dist/node/src/services/workspace-lifecycle.d.ts +5 -0
  168. package/dist/node/src/services/workspace-lifecycle.d.ts.map +1 -0
  169. package/dist/node/src/services/workspace-service.d.ts +126 -0
  170. package/dist/node/src/services/workspace-service.d.ts.map +1 -0
  171. package/dist/node/src/services/workspace-types.d.ts +81 -0
  172. package/dist/node/src/services/workspace-types.d.ts.map +1 -0
  173. package/dist/node/src/setup-routes.d.ts +9 -0
  174. package/dist/node/src/setup-routes.d.ts.map +1 -0
  175. package/docs/multi-account-orchestration.md +1 -1
  176. package/package.json +7 -4
@@ -0,0 +1,20 @@
1
+ import type { ActionResult, IAgentRuntime } from "@elizaos/core";
2
+ import type { RecommendedSkill } from "./skill-recommender.js";
3
+ import type { SessionInfo } from "./types.js";
4
+ export declare const LIFEOPS_CONTEXT_BROKER_SLUG = "lifeops-context";
5
+ export declare const LIFEOPS_CONTEXT_BROKER_MANIFEST_ENTRY: {
6
+ readonly slug: "lifeops-context";
7
+ readonly name: "LifeOps Context Broker";
8
+ readonly description: "Task-scoped parent broker for owner LifeOps context. Supports email, calendar, inbox/priority, contacts, documents, and generic cross-channel search/context.";
9
+ readonly guidance: "Use only when task-relevant personal context is needed. Example: `USE_SKILL lifeops-context {\"category\":\"email\",\"query\":\"contract from Alex\",\"limit\":5}`. Categories: email, calendar, inbox, priority, contacts, documents, search, context.";
10
+ };
11
+ export interface LifeOpsContextBrokerRequest {
12
+ runtime: IAgentRuntime;
13
+ sessionId: string;
14
+ session?: SessionInfo;
15
+ args: unknown;
16
+ }
17
+ export declare function runLifeOpsContextBroker(request: LifeOpsContextBrokerRequest): Promise<ActionResult>;
18
+ export declare function shouldRecommendLifeOpsContextBroker(taskText: string): boolean;
19
+ export declare function withLifeOpsContextBrokerRecommendation(taskText: string, recommendations: readonly RecommendedSkill[]): RecommendedSkill[];
20
+ //# sourceMappingURL=skill-lifeops-context-broker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-lifeops-context-broker.d.ts","sourceRoot":"","sources":["../../../../src/services/skill-lifeops-context-broker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,YAAY,EAGZ,aAAa,EAId,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA+C9C,eAAO,MAAM,2BAA2B,oBAAoB,CAAC;AAE7D,eAAO,MAAM,qCAAqC;;;;;CAOxC,CAAC;AAuBX,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,aAAa,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;CACf;AAsXD,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,YAAY,CAAC,CA8HvB;AAWD,wBAAgB,mCAAmC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAc7E;AAED,wBAAgB,sCAAsC,CACpD,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,SAAS,gBAAgB,EAAE,GAC3C,gBAAgB,EAAE,CAmBpB"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Skill manifest builder.
3
+ *
4
+ * Renders a Markdown SKILLS.md document for spawned task agents so they have
5
+ * full visibility into the skills installed in the parent runtime. The parent
6
+ * agent owns skill execution; spawned agents request skill invocation by
7
+ * calling back to the parent (see skill callback bridge in send-to-agent.ts
8
+ * via the child→parent USE_SKILL skill callback bridge).
9
+ *
10
+ * Source of truth is the AGENT_SKILLS_SERVICE (`@elizaos/plugin-agent-skills`).
11
+ *
12
+ * @module services/skill-manifest
13
+ */
14
+ import type { IAgentRuntime } from "@elizaos/core";
15
+ export interface ManifestSkillEntry {
16
+ slug: string;
17
+ name: string;
18
+ description: string;
19
+ /** Task-scoped invocation guidance for virtual broker skills. */
20
+ guidance?: string;
21
+ }
22
+ export interface BuildSkillsManifestOptions {
23
+ /** Restrict the "All available skills" section to eligible-and-enabled skills. */
24
+ onlyEligible?: boolean;
25
+ /**
26
+ * Slugs to highlight in a dedicated "Recommended for this task" section.
27
+ * Slugs not present in the eligible/enabled set are silently dropped — the
28
+ * recommender does not guarantee installed status.
29
+ */
30
+ recommendedSlugs?: string[];
31
+ /** Additional task-scoped skills handled by the orchestrator bridge. */
32
+ virtualSkills?: ManifestSkillEntry[];
33
+ }
34
+ export interface SkillsManifestResult {
35
+ /** Markdown document suitable for writing to SKILLS.md inside a workspace. */
36
+ markdown: string;
37
+ /** Slugs that the spawned agent can actually request via USE_SKILL. */
38
+ slugs: string[];
39
+ }
40
+ /**
41
+ * Build a SKILLS.md markdown document plus the canonical slug list.
42
+ *
43
+ * The slug list is the deduplicated union of recommended + available slugs,
44
+ * so callers can persist it for trajectory annotation or programmatic checks
45
+ * without re-resolving against the service.
46
+ */
47
+ export declare function buildSkillsManifest(runtime: IAgentRuntime, opts?: BuildSkillsManifestOptions): Promise<SkillsManifestResult>;
48
+ //# sourceMappingURL=skill-manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-manifest.d.ts","sourceRoot":"","sources":["../../../../src/services/skill-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,eAAe,CAAC;AAKpE,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAcD,MAAM,WAAW,0BAA0B;IACzC,kFAAkF;IAClF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,wEAAwE;IACxE,aAAa,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,oBAAoB;IACnC,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAuED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,aAAa,EACtB,IAAI,GAAE,0BAA+B,GACpC,OAAO,CAAC,oBAAoB,CAAC,CAsE/B"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Skill recommender — suggests relevant skills for a task description.
3
+ *
4
+ * Two-pass strategy:
5
+ * 1. Cheap keyword/category match against installed skill metadata. Returns
6
+ * up to 10 candidate slugs sorted by overlap score.
7
+ * 2. Optional LLM scoring pass over the surviving candidates that returns a
8
+ * small JSON scores array. Skipped when any keyword
9
+ * match already scores ≥ 0.9 (no need to spend a model call) or when the
10
+ * runtime model is unavailable.
11
+ *
12
+ * The output is task-aware ranking: the orchestrator can then write the top
13
+ * N into SKILLS.md and reference them in the spawned agent's initial prompt.
14
+ *
15
+ * @module services/skill-recommender
16
+ */
17
+ import { type IAgentRuntime } from "@elizaos/core";
18
+ export declare const APP_BUILD_TASK_RE: RegExp;
19
+ export declare const APP_DEPLOY_TASK_RE: RegExp;
20
+ export interface RecommendedSkill {
21
+ slug: string;
22
+ name: string;
23
+ /** Score in [0, 1]. 0 = irrelevant, 1 = perfect fit. */
24
+ score: number;
25
+ /** Short, human-readable justification (≤ 1 line). */
26
+ reason: string;
27
+ }
28
+ export interface RecommendSkillsOptions {
29
+ /** Optional task kind classification (coding | research | planning | ops | mixed). */
30
+ taskKind?: string;
31
+ /** Free-form task description provided by the user or planner. */
32
+ taskText: string;
33
+ /** Optional repo/language context — used to bias toward language-specific skills. */
34
+ repoContext?: {
35
+ language?: string;
36
+ framework?: string;
37
+ };
38
+ /** Maximum number of recommendations to return. Defaults to 5. */
39
+ max?: number;
40
+ /**
41
+ * Force-disable the LLM scoring pass. Defaults to false; when omitted the
42
+ * recommender runs the LLM pass unless a keyword match already scores ≥ 0.9.
43
+ */
44
+ disableLlmPass?: boolean;
45
+ }
46
+ /**
47
+ * Recommend skills relevant to a task.
48
+ *
49
+ * Always returns the top `max` (default 5) candidates ranked by score.
50
+ * Returns an empty array if no skills are eligible/enabled.
51
+ */
52
+ export declare function recommendSkillsForTask(runtime: IAgentRuntime, opts: RecommendSkillsOptions): Promise<RecommendedSkill[]>;
53
+ //# sourceMappingURL=skill-recommender.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-recommender.d.ts","sourceRoot":"","sources":["../../../../src/services/skill-recommender.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,eAAe,CAAC;AAUvB,eAAO,MAAM,iBAAiB,QAC0P,CAAC;AAQzR,eAAO,MAAM,kBAAkB,QACmQ,CAAC;AA6CnS,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,sFAAsF;IACtF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,QAAQ,EAAE,MAAM,CAAC;IACjB,qFAAqF;IACrF,WAAW,CAAC,EAAE;QACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,kEAAkE;IAClE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AA6RD;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAyK7B"}
@@ -0,0 +1,73 @@
1
+ import type { TaskApprovalResult, TaskProvisionResult, TaskStepContext, TaskStepExecutor, TaskSubmitResult, TaskTurnResult } from "./smithers-task-types";
2
+ /** Minimal ACP surface the executor needs. Satisfied by `AcpService`; faked in tests. */
3
+ export interface AcpLike {
4
+ spawnSession(opts: {
5
+ agentType?: string;
6
+ workdir?: string;
7
+ label?: string;
8
+ initialTask?: string;
9
+ }): Promise<{
10
+ sessionId: string;
11
+ }>;
12
+ sendPrompt(sessionId: string, text: string): Promise<{
13
+ stopReason?: string;
14
+ finalText?: string;
15
+ response?: string;
16
+ error?: string;
17
+ }>;
18
+ /** Reattach to a still-resumable session for this label (durable resume). */
19
+ findResumableSessionByLabel?(label: string): Promise<{
20
+ sessionId: string;
21
+ } | null | undefined>;
22
+ cancelSession?(sessionId: string): Promise<void>;
23
+ }
24
+ export interface SmithersTaskExecutorOptions {
25
+ agentType?: string;
26
+ workdir?: string;
27
+ /** Drive an already-spawned session instead of spawning/reattaching one. */
28
+ sessionId?: string;
29
+ /** Prompt sent on turns after the first when the agent isn't yet done. */
30
+ continuePrompt?: string;
31
+ onProvision?: (ctx: TaskStepContext) => Promise<TaskProvisionResult>;
32
+ onApproval?: (ctx: TaskStepContext) => Promise<TaskApprovalResult>;
33
+ onSubmit?: (ctx: TaskStepContext) => Promise<TaskSubmitResult>;
34
+ }
35
+ /**
36
+ * Decide whether an agent turn finished the task. A clean turn is treated as
37
+ * done (one-shot tasks complete in a single turn; the loop only sends another
38
+ * turn when this returns false). Truncated/interrupted turns are not done so the
39
+ * loop continues. Production may refine this via the `task_complete` event that
40
+ * `SubAgentRouter` already tracks.
41
+ */
42
+ export declare function detectTurnDone(result: {
43
+ stopReason?: string;
44
+ finalText?: string;
45
+ error?: string;
46
+ }): boolean;
47
+ /**
48
+ * {@link TaskStepExecutor} backed by the ACP services. Turns are driven through
49
+ * `sendPrompt` (which resolves when the agent's turn completes); the session is
50
+ * spawned lazily and reattached by label on resume so a crashed task continues
51
+ * against the same agent workspace rather than a fresh one. Provision / approval
52
+ * / submit are pluggable (workspace + approval-queue integration is injected by
53
+ * the caller) so this stays unit-testable without the full plugin.
54
+ */
55
+ export declare class SmithersTaskExecutor implements TaskStepExecutor {
56
+ private readonly acp;
57
+ private readonly opts;
58
+ private sessionId;
59
+ /** Final text from the most recent turn (for the host's task_complete event). */
60
+ lastResponse: string | undefined;
61
+ /**
62
+ * Last turn error. Recorded so callers can propagate it even when a low
63
+ * maxIterations loop swallows the throw via onMaxReached='return-last'.
64
+ */
65
+ lastError: Error | undefined;
66
+ constructor(acp: AcpLike, opts?: SmithersTaskExecutorOptions);
67
+ private ensureSession;
68
+ provision(ctx: TaskStepContext): Promise<TaskProvisionResult>;
69
+ runTurn(ctx: TaskStepContext): Promise<TaskTurnResult>;
70
+ requestApproval(ctx: TaskStepContext): Promise<TaskApprovalResult>;
71
+ submit(ctx: TaskStepContext): Promise<TaskSubmitResult>;
72
+ }
73
+ //# sourceMappingURL=smithers-task-executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smithers-task-executor.d.ts","sourceRoot":"","sources":["../../../../src/services/smithers-task-executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACf,MAAM,uBAAuB,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;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAWV;AAED;;;;;;;GAOG;AACH,qBAAa,oBAAqB,YAAW,gBAAgB;IAWzD,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAXvB,OAAO,CAAC,SAAS,CAAqB;IACtC,iFAAiF;IACjF,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC;;;OAGG;IACH,SAAS,EAAE,KAAK,GAAG,SAAS,CAAC;gBAGV,GAAG,EAAE,OAAO,EACZ,IAAI,GAAE,2BAAgC;YAK3C,aAAa;IAkBrB,SAAS,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAM7D,OAAO,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;IAoBtD,eAAe,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAKlE,MAAM,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAI9D"}
@@ -0,0 +1,52 @@
1
+ import type { AcpLike } from "./smithers-task-executor";
2
+ import type { TaskRunStatus } from "./smithers-task-types";
3
+ type PromptOut = {
4
+ stopReason?: string;
5
+ finalText?: string;
6
+ response?: string;
7
+ error?: string;
8
+ };
9
+ /** Structural subset of `AcpService` the durable task path uses (methods optional, as on the real service). */
10
+ export interface AcpTaskService {
11
+ spawnSession?(opts: {
12
+ agentType?: string;
13
+ workdir?: string;
14
+ metadata?: Record<string, unknown>;
15
+ }): Promise<{
16
+ sessionId: string;
17
+ }>;
18
+ sendPrompt?(sessionId: string, text: string, opts?: {
19
+ timeoutMs?: number;
20
+ model?: string;
21
+ }): Promise<PromptOut>;
22
+ sendToSession?(sessionId: string, text: string): Promise<PromptOut>;
23
+ }
24
+ /**
25
+ * Whether the durable Smithers task path is enabled. Default ON; set
26
+ * `ELIZA_ORCHESTRATOR_SMITHERS=0` to fall back to the direct prompt path.
27
+ */
28
+ export declare function shouldUseSmithersTaskRunner(): boolean;
29
+ /** Adapt the ACP service to the executor's minimal contract. */
30
+ export declare function acpServiceToAcpLike(service: AcpTaskService, defaults?: {
31
+ timeoutMs?: number;
32
+ model?: string;
33
+ }): AcpLike;
34
+ /**
35
+ * Drive one durable coding-task run against an already-spawned ACP session via
36
+ * the Smithers engine. Single-turn by default (`maxTurns: 1`) so it is a
37
+ * behaviour-preserving drop-in for a direct prompt, but the run is durable: a
38
+ * crash mid-task resumes from the same `runId` (the session id) on restart.
39
+ */
40
+ export declare function runDurableTask(service: AcpTaskService, session: {
41
+ sessionId: string;
42
+ }, task: string, opts?: {
43
+ timeoutMs?: number;
44
+ model?: string;
45
+ maxTurns?: number;
46
+ }): Promise<{
47
+ status: TaskRunStatus;
48
+ lastResponse: string | undefined;
49
+ turns: number;
50
+ }>;
51
+ export {};
52
+ //# sourceMappingURL=smithers-task-integration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smithers-task-integration.d.ts","sourceRoot":"","sources":["../../../../src/services/smithers-task-integration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAGxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,KAAK,SAAS,GAAG;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,+GAA+G;AAC/G,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,CAAC,IAAI,EAAE;QAClB,SAAS,CAAC,EAA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* Resolve the Smithers storage backend configuration from environment variables.
4
+ *
5
+ * SMITHERS_DB_PROVIDER: "sqlite" (default) | "postgres" | "pglite"
6
+ * SMITHERS_DB_URL: PostgreSQL connection string (used when provider = "postgres")
7
+ * SMITHERS_DB_DATA_DIR: PGlite data directory (used when provider = "pglite")
8
+ *
9
+ * The resolved config is threaded through the subprocess payload so the layer
10
+ * selection runs inside the subprocess script string.
11
+ */
12
+ export declare function resolveSmithersDbConfig(): {
13
+ provider: "sqlite" | "postgres" | "pglite";
14
+ connectionString?: string;
15
+ dataDir?: string;
16
+ };
17
+ /**
18
+ * Run a coding task on the durable Smithers engine, delegating each step to the
19
+ * given executor. Resolves with the assembled {@link TaskRunResult}. Re-invoking
20
+ * with the same `spec.runId` after a crash resumes the task from its last
21
+ * completed step/turn (completed work is not repeated); the result then reflects
22
+ * the steps re-driven in this invocation.
23
+ */
24
+ export declare function runTaskWithSmithers(spec: TaskRunSpec, executor: TaskStepExecutor, options?: {
25
+ signal?: AbortSignal;
26
+ }): Promise<TaskRunResult>;
27
+ //# sourceMappingURL=smithers-task-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smithers-task-runner.d.ts","sourceRoot":"","sources":["../../../../src/services/smithers-task-runner.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EAEX,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAoD/B;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,IAAI;IACzC,QAAQ,EAAE,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC3C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAQA;AA8JD;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAO,GACrC,OAAO,CAAC,aAAa,CAAC,CA0LxB"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Types for the durable Smithers-backed coding-task runner.
3
+ *
4
+ * A coding task is modelled as a durable Smithers workflow:
5
+ * provision → (durable loop of agent turns) → approval gate → submit → summarize
6
+ *
7
+ * Smithers owns scheduling + durable per-step/per-iteration SQLite state (so a
8
+ * crashed agent resumes from the last completed turn). The actual work of each
9
+ * step is delegated back to the host through a {@link TaskStepExecutor}; the
10
+ * runner never drives a coding agent itself — it drives the *control plane* and
11
+ * calls the executor, which in production is backed by the ACP services.
12
+ */
13
+ /** A coding task to run on the durable engine. */
14
+ export interface TaskRunSpec {
15
+ /** Stable task id (also used to name the per-task SQLite file). */
16
+ taskId: string;
17
+ /**
18
+ * Stable Smithers run id. Re-running with the same id resumes a crashed run
19
+ * from its last completed step/turn. Generate once per task, persist it, and
20
+ * reuse it on restart.
21
+ */
22
+ runId: string;
23
+ /** Initial prompt handed to the agent on the first turn. */
24
+ initialPrompt: string;
25
+ /** Adapter/agent type label (informational; the executor owns spawning). */
26
+ agentType?: string;
27
+ /** Run a provision step (workspace setup) before the agent loop. */
28
+ provision?: boolean;
29
+ /** Run a submit step (commit/push/PR) after the agent loop. */
30
+ submit?: boolean;
31
+ /** Require an approval decision before the submit step. */
32
+ approvalBeforeSubmit?: boolean;
33
+ /** Max agent turns before stopping (replaces the hand-rolled round-trip cap). */
34
+ maxTurns?: number;
35
+ /** Number of agents to fan out in parallel (default 1). */
36
+ parallelAgents?: number;
37
+ }
38
+ /** Per-step context passed to the executor. */
39
+ export interface TaskStepContext {
40
+ taskId: string;
41
+ runId: string;
42
+ /** 1-based turn counter for the current agent loop (best-effort across resume). */
43
+ turn?: number;
44
+ /** 0-based agent index when fanning out (`parallelAgents > 1`). */
45
+ agentIndex?: number;
46
+ /** The task's initial prompt. */
47
+ prompt?: string;
48
+ }
49
+ export interface TaskProvisionResult {
50
+ workspace: Record<string, unknown>;
51
+ }
52
+ /** Result of one agent turn. `done: true` ends the loop early (task complete). */
53
+ export interface TaskTurnResult {
54
+ done: boolean;
55
+ output?: Record<string, unknown>;
56
+ }
57
+ export interface TaskApprovalResult {
58
+ approved: boolean;
59
+ reason?: string;
60
+ }
61
+ export interface TaskSubmitResult {
62
+ output: Record<string, unknown>;
63
+ }
64
+ /**
65
+ * The seam between the durable control plane and the real coding-agent work.
66
+ * In production this is backed by `AcpService` / `CodingWorkspaceService`; in
67
+ * tests it is a fake. Only `runTurn` is required.
68
+ */
69
+ export interface TaskStepExecutor {
70
+ provision?(ctx: TaskStepContext): Promise<TaskProvisionResult>;
71
+ /** Advance the agent one turn; report whether the task is complete. */
72
+ runTurn(ctx: TaskStepContext): Promise<TaskTurnResult>;
73
+ requestApproval?(ctx: TaskStepContext): Promise<TaskApprovalResult>;
74
+ submit?(ctx: TaskStepContext): Promise<TaskSubmitResult>;
75
+ }
76
+ export type TaskRunStatus = "completed" | "incomplete" | "denied";
77
+ export interface TaskRunMetrics {
78
+ turns: number;
79
+ agents: number;
80
+ retries: number;
81
+ durationMs: number;
82
+ }
83
+ export interface TaskRunResult {
84
+ taskId: string;
85
+ runId: string;
86
+ status: TaskRunStatus;
87
+ /** Total agent turns executed across all agents. */
88
+ turns: number;
89
+ approved: boolean;
90
+ workspace?: Record<string, unknown>;
91
+ submit?: Record<string, unknown>;
92
+ /** Per-agent completion flags (length === parallelAgents). */
93
+ agentsDone: boolean[];
94
+ metrics: TaskRunMetrics;
95
+ }
96
+ //# sourceMappingURL=smithers-task-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smithers-task-types.d.ts","sourceRoot":"","sources":["../../../../src/services/smithers-task-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,aAAa,EAAE,MAAM,C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,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACpE,MAAM,CAAC,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC1D;AAED,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,YAAY,GAAG,QAAQ,CAAC;AAElE,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,aAAa,CAAC;IACtB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,8DAA8D;IAC9D,UAAU,EAAE,OAAO,EAAE,CAAC;IACtB,OAAO,EAAE,cAAc,CAAC;CACzB"}
@@ -0,0 +1,23 @@
1
+ import { type IAgentRuntime, type SpawnTrajectoryHandle } from "@elizaos/core";
2
+ export declare const TRAJECTORY_PARENT_STEP_METADATA_KEY = "parentTrajectoryStepId";
3
+ export declare const TRAJECTORY_CHILD_STEP_METADATA_KEY = "trajectoryChildStepId";
4
+ export declare const TRAJECTORY_LINK_SOURCE_METADATA_KEY = "trajectoryLinkSource";
5
+ export declare const TRAJECTORY_PARENT_STEP_ENV_KEY = "ELIZA_PARENT_TRAJECTORY_STEP_ID";
6
+ export declare const TRAJECTORY_CHILD_STEP_ENV_KEY = "ELIZA_TRAJECTORY_CHILD_STEP_ID";
7
+ export interface LinkedSpawnContext {
8
+ parentStepId?: string;
9
+ metadata: Record<string, unknown>;
10
+ env: Record<string, string> | undefined;
11
+ linkChild: SpawnTrajectoryHandle["linkChild"];
12
+ }
13
+ interface WithLinkedSpawnOptions<T> {
14
+ source: string;
15
+ metadata?: Record<string, unknown>;
16
+ env?: Record<string, string>;
17
+ childId?: (result: T) => string | undefined;
18
+ }
19
+ export declare function buildLinkedSpawnMetadata(metadata: Record<string, unknown> | undefined, handle: SpawnTrajectoryHandle, source: string): Record<string, unknown>;
20
+ export declare function buildLinkedSpawnEnv(env: Record<string, string> | undefined, handle: SpawnTrajectoryHandle): Record<string, string> | undefined;
21
+ export declare function withLinkedSpawn<T>(runtime: IAgentRuntime | null | undefined, options: WithLinkedSpawnOptions<T>, spawn: (context: LinkedSpawnContext) => Promise<T> | T): Promise<T>;
22
+ export {};
23
+ //# sourceMappingURL=spawn-trajectory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawn-trajectory.d.ts","sourceRoot":"","sources":["../../../../src/services/spawn-trajectory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAE3B,MAAM,eAAe,CAAC;AAEvB,eAAO,MAAM,mCAAmC,2BAA2B,CAAC;AAC5E,eAAO,MAAM,kCAAkC,0BAA0B,CAAC;AAC1E,eAAO,MAAM,mCAAmC,yBAAyB,CAAC;AAC1E,eAAO,MAAM,8BAA8B,oCAAoC,CAAC;AAChF,eAAO,MAAM,6BAA6B,mCAAmC,CAAC;AAE9E,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IACxC,SAAS,EAAE,qBAAqB,CAAC,WAAW,CAAC,CAAC;CAC/C;AAED,UAAU,sBAAsB,CAAC,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,GAAG,SAAS,CAAC;CAC7C;AAOD,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC7C,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWzB;AAED,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EACvC,MAAM,EAAE,qBAAqB,GAC5B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAOpC;AAED,wBAAsB,eAAe,CAAC,CAAC,EACrC,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,EACzC,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,EAClC,KAAK,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GACrD,OAAO,CAAC,CAAC,CAAC,CAuBZ"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Capped self-spend allowance for the parent-agent Cloud command broker.
3
+ *
4
+ * By default every `mutating` / `paid` / `destructive` Eliza Cloud command run
5
+ * through the broker requires an explicit human "yes" (see `runCloudCommand` in
6
+ * `parent-agent-broker.ts`). That invariant is safe but it means a `/goal`
7
+ * sub-agent can never *autonomously* drive the monetized-app loop — every app
8
+ * create, container deploy, and domain buy stalls on a confirmation turn.
9
+ *
10
+ * When an operator configures a spend cap (`ELIZA_AGENT_SPEND_CAP_USD`), the
11
+ * agent may self-authorize commands within a bounded per-session budget:
12
+ *
13
+ * - `read` / `dry-run` → never need authorization (unchanged);
14
+ * - `destructive` → ALWAYS require human confirmation;
15
+ * - self-spend commands → auto-authorize only while the running
16
+ * (debit our own credits) total + the command's estimated cost stays
17
+ * within the cap; otherwise fall back to
18
+ * confirmation;
19
+ * - other `mutating` / `paid` → auto-authorize while the allowance is
20
+ * (state changes + revenue active. These do not debit our balance
21
+ * ops the *payer* funds, e.g. (e.g. `apps.charges.create` creates a
22
+ * `apps.charges.create`) charge that someone else pays us).
23
+ *
24
+ * The cap is a SAFETY THROTTLE, not a durable accounting ledger: the running
25
+ * total is tracked in-memory per child session and resets on process restart.
26
+ * Real money is still ultimately gated server-side (credit balance, atomic
27
+ * debit/refund in the buy/charge routes). Default cap of `0` preserves the
28
+ * original "confirm everything" behavior exactly.
29
+ *
30
+ * @module services/spend-allowance
31
+ */
32
+ /** Mirror of the broker's `CloudCommandRisk` union (kept local to avoid a
33
+ * circular import; structurally identical so `definition.risk` is assignable). */
34
+ export type SpendRisk = "read" | "dry-run" | "mutating" | "paid" | "destructive";
35
+ /** Default daily cost of a container at the base tier ($0.67/day — see the
36
+ * `build-monetized-app` survival-economics docs and `cron/container-billing`).
37
+ * Used as the spend estimate for container deploys when no explicit hint is
38
+ * passed. */
39
+ export declare const CONTAINER_DAILY_COST_USD = 0.67;
40
+ /** Reserved param key the agent may pass to declare the expected USD cost of a
41
+ * self-spend command (e.g. the quoted price returned by `domains.check` before
42
+ * a `domains.buy`). It is read for the allowance decision and then STRIPPED by
43
+ * the broker before the request is built, so it never leaks into the Cloud API
44
+ * request body. */
45
+ export declare const SPEND_HINT_PARAM = "spendEstimateUsd";
46
+ /**
47
+ * Cloud commands that debit the caller's OWN credits / wallet (true self-spend).
48
+ * Only these are metered against the cap. Revenue/collection commands such as
49
+ * `apps.charges.*` and `x402.requests.*` are `paid`-risk but funded by the
50
+ * payer, so they are intentionally excluded.
51
+ */
52
+ export declare const SELF_SPEND_COMMANDS: ReadonlySet<string>;
53
+ /** Read the per-session spend cap (USD). `0` (the default) disables the
54
+ * allowance and preserves the original confirm-everything behavior. */
55
+ export declare function readSpendCapUsd(): number;
56
+ /**
57
+ * Estimate the USD a self-spend command will debit. Returns `null` when the
58
+ * cost cannot be determined — the caller treats `null` as "ask a human", so an
59
+ * unknown cost is never silently auto-spent.
60
+ */
61
+ export declare function estimateSelfSpendCostUsd(command: string, params?: Record<string, unknown>): number | null;
62
+ export interface SpendDecisionInput {
63
+ command: string;
64
+ risk: SpendRisk;
65
+ /** Per-session cap in USD (`0` = allowance disabled). */
66
+ capUsd: number;
67
+ /** USD already auto-authorized in this session. */
68
+ alreadySpentUsd: number;
69
+ params?: Record<string, unknown>;
70
+ }
71
+ export type SpendDecisionReason = "non-mutating" | "allowance-disabled" | "destructive-requires-human" | "within-cap" | "over-cap" | "unknown-cost" | "non-self-spend";
72
+ export interface SpendDecision {
73
+ /** When true the broker may run the command without a human confirmation. */
74
+ autoAuthorize: boolean;
75
+ /** Estimated USD to add to the session ledger when auto-authorized (self-spend
76
+ * only); `null` for non-self-spend or unknown. */
77
+ estimatedCostUsd: number | null;
78
+ reason: SpendDecisionReason;
79
+ }
80
+ /**
81
+ * Decide whether a Cloud command may be auto-authorized under the capped
82
+ * allowance. Pure: no env reads, no ledger mutation, no clock — fully testable.
83
+ */
84
+ export declare function decideSpendAuthorization(input: SpendDecisionInput): SpendDecision;
85
+ /**
86
+ * Durable store for per-session spend, implemented over the
87
+ * OrchestratorTaskStore (a `spendUsd` field on the session record) — see
88
+ * `createTaskStoreSpendLedger`.
89
+ */
90
+ export interface SpendLedgerBackend {
91
+ /** Persisted USD total for a session (0 when none recorded). */
92
+ load(sessionId: string): Promise<number>;
93
+ /** Persist the new running total for a session. */
94
+ save(sessionId: string, totalUsd: number): Promise<void>;
95
+ }
96
+ /** Install (or clear, with `null`) the durable spend backend. Called once at
97
+ * orchestrator boot; tests pass a fake backend. */
98
+ export declare function configureSpendLedger(backend: SpendLedgerBackend | null): void;
99
+ export declare function getSessionSpendUsd(sessionId: string): number;
100
+ /**
101
+ * Rehydrate the in-memory total for a session from the durable backend so the
102
+ * sync cap check sees money spent before a restart. No-op (returns the cached
103
+ * value) when no backend is installed. Call when a session is (re)attached.
104
+ */
105
+ export declare function hydrateSessionSpendUsd(sessionId: string): Promise<number>;
106
+ /**
107
+ * Run `fn` after any in-flight spend critical section for the same session has
108
+ * settled, so hydrate/check/commit is atomic per session. A prior section's
109
+ * failure does not reject the next. In-process only — cross-instance accuracy
110
+ * relies on the monotonic durable total, matching the cap's "safety throttle,
111
+ * not a durable ledger" contract.
112
+ */
113
+ export declare function withSessionSpendLock<T>(sessionId: string, fn: () => Promise<T>): Promise<T>;
114
+ /** Add to a session's running total; returns the new total. Negative/NaN
115
+ * amounts are ignored. With a durable backend the new total is persisted
116
+ * write-through; persistence failures are logged, never thrown (the cap stays
117
+ * enforced from the in-memory total). */
118
+ export declare function addSessionSpendUsd(sessionId: string, amountUsd: number): number;
119
+ /** Clear the in-memory ledger for one session, or all when omitted. Does NOT
120
+ * delete the durable record — that survives by design (cache reset for
121
+ * test/cleanup, and the path a restart simulates). */
122
+ export declare function resetSessionSpendUsd(sessionId?: string): void;
123
+ /** Minimal structural view of the OrchestratorTaskStore the ledger needs —
124
+ * structurally typed to avoid a hard import / circular dependency. */
125
+ export interface SpendLedgerStore {
126
+ findSession(sessionId: string): Promise<{
127
+ session: {
128
+ metadata: Record<string, unknown>;
129
+ };
130
+ } | null>;
131
+ updateSession(sessionId: string, patch: {
132
+ metadata: Record<string, unknown>;
133
+ }): Promise<void>;
134
+ }
135
+ /**
136
+ * Durable backend that persists per-session spend in the session record's
137
+ * `metadata.spendUsd` (#8924). Read-modify-write preserves any other metadata.
138
+ */
139
+ export declare function createTaskStoreSpendLedger(store: SpendLedgerStore): SpendLedgerBackend;
140
+ /** Return a shallow copy of `params` with the reserved spend-hint key removed,
141
+ * so it never reaches the Cloud API request. Returns `undefined` unchanged. */
142
+ export declare function stripSpendHints(params?: Record<string, unknown>): Record<string, unknown> | undefined;
143
+ //# sourceMappingURL=spend-allowance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spend-allowance.d.ts","sourceRoot":"","sources":["../../../../src/services/spend-allowance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAKH;kFACkF;AAClF,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,SAAS,GACT,UAAU,GACV,MAAM,GACN,aAAa,CAAC;AAElB;;;aAGa;AACb,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C;;;;mBAImB;AACnB,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAalD,CAAC;AAcH;uEACuE;AACvE,wBAAgB,eAAe,IAAI,MAAM,CAIxC;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,GAAG,IAAI,CASf;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;IAChB,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,MAAM,mBAAmB,GAC3B,cAAc,GACd,oBAAoB,GACpB,4BAA4B,GAC5B,YAAY,GACZ,UAAU,GACV,cAAc,GACd,gBAAgB,CAAC;AAErB,MAAM,WAAW,aAAa;IAC5B,6EAA6E;IAC7E,aAAa,EAAE,OAAO,CAAC;IACvB;sDACkD;IAClD,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAA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