@avocadostudio-ai/orchestrator-core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/LICENSE +201 -0
  2. package/dist/agent/agent-context.d.ts +19 -0
  3. package/dist/agent/agent-context.js +67 -0
  4. package/dist/agent/agent-logger.d.ts +5 -0
  5. package/dist/agent/agent-logger.js +22 -0
  6. package/dist/agent/agent-loop-openai.d.ts +8 -0
  7. package/dist/agent/agent-loop-openai.js +172 -0
  8. package/dist/agent/agent-loop.d.ts +56 -0
  9. package/dist/agent/agent-loop.js +167 -0
  10. package/dist/agent/agent-provider.d.ts +28 -0
  11. package/dist/agent/agent-provider.js +63 -0
  12. package/dist/agent/agent-tools.d.ts +28 -0
  13. package/dist/agent/agent-tools.js +899 -0
  14. package/dist/agent/context/editing-guidelines.md +46 -0
  15. package/dist/agent/context/role.md +39 -0
  16. package/dist/agent/integration-prompt.d.ts +9 -0
  17. package/dist/agent/integration-prompt.js +154 -0
  18. package/dist/agent/sites-agent-context.d.ts +12 -0
  19. package/dist/agent/sites-agent-context.js +316 -0
  20. package/dist/agent/sites-agent-shared.d.ts +161 -0
  21. package/dist/agent/sites-agent-shared.js +1101 -0
  22. package/dist/agent/sites-agent-tools.d.ts +18 -0
  23. package/dist/agent/sites-agent-tools.js +1227 -0
  24. package/dist/chat/anthropic-cache.d.ts +20 -0
  25. package/dist/chat/anthropic-cache.js +54 -0
  26. package/dist/chat/anthropic-planner.d.ts +98 -0
  27. package/dist/chat/anthropic-planner.js +1012 -0
  28. package/dist/chat/changelog-coverage-validator.d.ts +37 -0
  29. package/dist/chat/changelog-coverage-validator.js +215 -0
  30. package/dist/chat/chat-pipeline-context.d.ts +211 -0
  31. package/dist/chat/chat-pipeline-context.js +249 -0
  32. package/dist/chat/chat-pipeline-deterministic.d.ts +61 -0
  33. package/dist/chat/chat-pipeline-deterministic.js +407 -0
  34. package/dist/chat/chat-pipeline-image.d.ts +86 -0
  35. package/dist/chat/chat-pipeline-image.js +897 -0
  36. package/dist/chat/chat-pipeline-shared.d.ts +69 -0
  37. package/dist/chat/chat-pipeline-shared.js +212 -0
  38. package/dist/chat/chat-pipeline-translation.d.ts +27 -0
  39. package/dist/chat/chat-pipeline-translation.js +417 -0
  40. package/dist/chat/chat-pipeline-ui.d.ts +14 -0
  41. package/dist/chat/chat-pipeline-ui.js +244 -0
  42. package/dist/chat/chat-pipeline.d.ts +99 -0
  43. package/dist/chat/chat-pipeline.js +3999 -0
  44. package/dist/chat/decomposer.d.ts +21 -0
  45. package/dist/chat/decomposer.js +65 -0
  46. package/dist/chat/gemini-planner.d.ts +70 -0
  47. package/dist/chat/gemini-planner.js +541 -0
  48. package/dist/chat/hallucination-validator.d.ts +36 -0
  49. package/dist/chat/hallucination-validator.js +110 -0
  50. package/dist/chat/locale-strings.d.ts +47 -0
  51. package/dist/chat/locale-strings.js +100 -0
  52. package/dist/chat/plan-json-schema.d.ts +133 -0
  53. package/dist/chat/plan-json-schema.js +112 -0
  54. package/dist/chat/planner-types.d.ts +120 -0
  55. package/dist/chat/planner-types.js +66 -0
  56. package/dist/chat/planner.d.ts +148 -0
  57. package/dist/chat/planner.js +1361 -0
  58. package/dist/chat/prompts.d.ts +67 -0
  59. package/dist/chat/prompts.js +356 -0
  60. package/dist/chat/provider-routing.d.ts +14 -0
  61. package/dist/chat/provider-routing.js +27 -0
  62. package/dist/chat/variation-pipeline.d.ts +135 -0
  63. package/dist/chat/variation-pipeline.js +837 -0
  64. package/dist/chat/vision-alt-generator.d.ts +35 -0
  65. package/dist/chat/vision-alt-generator.js +152 -0
  66. package/dist/cms/adapter.d.ts +62 -0
  67. package/dist/cms/adapter.js +1 -0
  68. package/dist/cms/bootstrap.d.ts +17 -0
  69. package/dist/cms/bootstrap.js +85 -0
  70. package/dist/cms/editor-api-adapter.d.ts +23 -0
  71. package/dist/cms/editor-api-adapter.js +71 -0
  72. package/dist/cms/index.d.ts +4 -0
  73. package/dist/cms/index.js +3 -0
  74. package/dist/cms/json-file-adapter.d.ts +11 -0
  75. package/dist/cms/json-file-adapter.js +62 -0
  76. package/dist/demo-mode.d.ts +59 -0
  77. package/dist/demo-mode.js +201 -0
  78. package/dist/errors.d.ts +67 -0
  79. package/dist/errors.js +129 -0
  80. package/dist/http/chat-stream-resumable.d.ts +108 -0
  81. package/dist/http/chat-stream-resumable.js +290 -0
  82. package/dist/http/chat-stream.d.ts +99 -0
  83. package/dist/http/chat-stream.js +92 -0
  84. package/dist/image/gdrive-client.d.ts +22 -0
  85. package/dist/image/gdrive-client.js +215 -0
  86. package/dist/image/image-helpers.d.ts +95 -0
  87. package/dist/image/image-helpers.js +488 -0
  88. package/dist/index.d.ts +1 -0
  89. package/dist/index.js +1 -0
  90. package/dist/jira/jira-approval.d.ts +22 -0
  91. package/dist/jira/jira-approval.js +51 -0
  92. package/dist/jira/jira-client.d.ts +44 -0
  93. package/dist/jira/jira-client.js +313 -0
  94. package/dist/jira/jira-poller.d.ts +46 -0
  95. package/dist/jira/jira-poller.js +184 -0
  96. package/dist/jira/jira-processor.d.ts +103 -0
  97. package/dist/jira/jira-processor.js +1085 -0
  98. package/dist/jira/jira-types.d.ts +117 -0
  99. package/dist/jira/jira-types.js +38 -0
  100. package/dist/logger.d.ts +12 -0
  101. package/dist/logger.js +28 -0
  102. package/dist/migration/mcp-server-stdio.d.ts +8 -0
  103. package/dist/migration/mcp-server-stdio.js +672 -0
  104. package/dist/migration/migration-prompt.d.ts +7 -0
  105. package/dist/migration/migration-prompt.js +197 -0
  106. package/dist/migration/migration-tools.d.ts +17 -0
  107. package/dist/migration/migration-tools.js +159 -0
  108. package/dist/migration/scrape-cache.d.ts +9 -0
  109. package/dist/migration/scrape-cache.js +19 -0
  110. package/dist/nlp/deterministic-planner-context.d.ts +141 -0
  111. package/dist/nlp/deterministic-planner-context.js +362 -0
  112. package/dist/nlp/deterministic-planner-pages.d.ts +26 -0
  113. package/dist/nlp/deterministic-planner-pages.js +170 -0
  114. package/dist/nlp/deterministic-planner-patches.d.ts +80 -0
  115. package/dist/nlp/deterministic-planner-patches.js +508 -0
  116. package/dist/nlp/deterministic-planner-refs.d.ts +33 -0
  117. package/dist/nlp/deterministic-planner-refs.js +164 -0
  118. package/dist/nlp/deterministic-planner-suggestions.d.ts +49 -0
  119. package/dist/nlp/deterministic-planner-suggestions.js +579 -0
  120. package/dist/nlp/deterministic-planner.d.ts +85 -0
  121. package/dist/nlp/deterministic-planner.js +1631 -0
  122. package/dist/nlp/intent-detection.d.ts +309 -0
  123. package/dist/nlp/intent-detection.js +730 -0
  124. package/dist/nlp/intent-helpers.d.ts +15 -0
  125. package/dist/nlp/intent-helpers.js +243 -0
  126. package/dist/nlp/intent-patterns.d.ts +40 -0
  127. package/dist/nlp/intent-patterns.js +223 -0
  128. package/dist/nlp/plan-normalizer.d.ts +41 -0
  129. package/dist/nlp/plan-normalizer.js +1537 -0
  130. package/dist/ops/destructive-action-gate.d.ts +44 -0
  131. package/dist/ops/destructive-action-gate.js +90 -0
  132. package/dist/ops/ops-engine.d.ts +151 -0
  133. package/dist/ops/ops-engine.js +1394 -0
  134. package/dist/publish/diff-engine.d.ts +18 -0
  135. package/dist/publish/diff-engine.js +305 -0
  136. package/dist/publish/publish-helpers.d.ts +87 -0
  137. package/dist/publish/publish-helpers.js +521 -0
  138. package/dist/publish/publish-target-registry.d.ts +7 -0
  139. package/dist/publish/publish-target-registry.js +61 -0
  140. package/dist/publish/publish-target.d.ts +81 -0
  141. package/dist/publish/publish-target.js +1 -0
  142. package/dist/publish/targets/deploy-hook.d.ts +13 -0
  143. package/dist/publish/targets/deploy-hook.js +123 -0
  144. package/dist/publish/targets/git.d.ts +13 -0
  145. package/dist/publish/targets/git.js +55 -0
  146. package/dist/publish/targets/site-contract.d.ts +19 -0
  147. package/dist/publish/targets/site-contract.js +124 -0
  148. package/dist/state/content-source.d.ts +17 -0
  149. package/dist/state/content-source.js +1 -0
  150. package/dist/state/in-memory-content-source.d.ts +27 -0
  151. package/dist/state/in-memory-content-source.js +51 -0
  152. package/dist/state/session-lock.d.ts +13 -0
  153. package/dist/state/session-lock.js +29 -0
  154. package/dist/state/session-state.d.ts +310 -0
  155. package/dist/state/session-state.js +1083 -0
  156. package/dist/state/sqlite-store-singleton.d.ts +31 -0
  157. package/dist/state/sqlite-store-singleton.js +170 -0
  158. package/dist/state/sqlite-store.d.ts +135 -0
  159. package/dist/state/sqlite-store.js +421 -0
  160. package/dist/telemetry/chat-telemetry.d.ts +105 -0
  161. package/dist/telemetry/chat-telemetry.js +247 -0
  162. package/dist/telemetry/eval-candidate-store.d.ts +50 -0
  163. package/dist/telemetry/eval-candidate-store.js +120 -0
  164. package/dist/telemetry/feedback-store.d.ts +34 -0
  165. package/dist/telemetry/feedback-store.js +76 -0
  166. package/dist/telemetry/jira-telemetry.d.ts +57 -0
  167. package/dist/telemetry/jira-telemetry.js +68 -0
  168. package/dist/telemetry/migration-telemetry.d.ts +35 -0
  169. package/dist/telemetry/migration-telemetry.js +40 -0
  170. package/dist/telemetry/usage.d.ts +24 -0
  171. package/dist/telemetry/usage.js +80 -0
  172. package/dist/tools/builtin-registrations.d.ts +12 -0
  173. package/dist/tools/builtin-registrations.js +33 -0
  174. package/dist/tools/builtins/gdrive-browse.d.ts +3 -0
  175. package/dist/tools/builtins/gdrive-browse.js +68 -0
  176. package/dist/tools/builtins/image-generate.d.ts +3 -0
  177. package/dist/tools/builtins/image-generate.js +211 -0
  178. package/dist/tools/builtins/unsplash-get-by-id.d.ts +23 -0
  179. package/dist/tools/builtins/unsplash-get-by-id.js +119 -0
  180. package/dist/tools/builtins/unsplash-search.d.ts +3 -0
  181. package/dist/tools/builtins/unsplash-search.js +74 -0
  182. package/dist/tools/executor.d.ts +23 -0
  183. package/dist/tools/executor.js +169 -0
  184. package/dist/tools/index.d.ts +5 -0
  185. package/dist/tools/index.js +5 -0
  186. package/dist/tools/registry.d.ts +21 -0
  187. package/dist/tools/registry.js +75 -0
  188. package/dist/tools/runtime.d.ts +27 -0
  189. package/dist/tools/runtime.js +48 -0
  190. package/dist/tools/schema-validator.d.ts +24 -0
  191. package/dist/tools/schema-validator.js +88 -0
  192. package/dist/tools/types.d.ts +86 -0
  193. package/dist/tools/types.js +1 -0
  194. package/dist/variation-images.d.ts +19 -0
  195. package/dist/variation-images.js +12 -0
  196. package/package.json +78 -0
@@ -0,0 +1,117 @@
1
+ /**
2
+ * JIRA integration types.
3
+ * Covers webhook payloads, REST API responses, and internal processing types.
4
+ */
5
+ export type JiraUser = {
6
+ accountId?: string;
7
+ name?: string;
8
+ displayName: string;
9
+ emailAddress?: string;
10
+ };
11
+ export type JiraIssue = {
12
+ key: string;
13
+ id: string;
14
+ fields: {
15
+ summary: string;
16
+ description: unknown;
17
+ status: {
18
+ name: string;
19
+ id: string;
20
+ };
21
+ labels: string[];
22
+ attachment: JiraAttachment[];
23
+ reporter?: JiraUser;
24
+ assignee?: JiraUser | null;
25
+ creator?: JiraUser;
26
+ comment?: {
27
+ comments: JiraComment[];
28
+ };
29
+ /** Custom fields can carry siteId, slug, etc. */
30
+ [key: string]: unknown;
31
+ };
32
+ };
33
+ export type JiraComment = {
34
+ id: string;
35
+ author: JiraUser;
36
+ body: unknown;
37
+ created: string;
38
+ updated: string;
39
+ };
40
+ export type JiraAttachment = {
41
+ id: string;
42
+ filename: string;
43
+ mimeType: string;
44
+ size: number;
45
+ content: string;
46
+ };
47
+ export type JiraTransition = {
48
+ id: string;
49
+ name: string;
50
+ to: {
51
+ name: string;
52
+ id: string;
53
+ };
54
+ };
55
+ export type JiraWebhookPayload = {
56
+ webhookEvent: string;
57
+ issue_event_type_name?: string;
58
+ timestamp: number;
59
+ issue: JiraIssue;
60
+ comment?: JiraComment;
61
+ changelog?: {
62
+ items: Array<{
63
+ field: string;
64
+ fieldtype: string;
65
+ from: string | null;
66
+ fromString: string | null;
67
+ to: string | null;
68
+ toString: string | null;
69
+ }>;
70
+ };
71
+ user?: JiraUser;
72
+ };
73
+ export type JiraProcessingResult = {
74
+ issueKey: string;
75
+ status: "success" | "error";
76
+ summary: string;
77
+ changes: string[];
78
+ durationMs: number;
79
+ modelUsed?: string;
80
+ published?: boolean;
81
+ error?: string;
82
+ };
83
+ export type JiraProcessingEntry = {
84
+ issueKey: string;
85
+ state: "queued" | "processing" | "done" | "error";
86
+ queuedAt: number;
87
+ startedAt?: number;
88
+ completedAt?: number;
89
+ result?: JiraProcessingResult;
90
+ };
91
+ export type JiraConfig = {
92
+ baseUrl: string;
93
+ email: string;
94
+ apiToken: string;
95
+ webhookSecret?: string;
96
+ agentAccountId?: string;
97
+ /** Legacy alias for reviewStatus — kept so pre-3-stage configs keep working. */
98
+ triggerStatus: string;
99
+ /** Status where tickets wait for agent review / reporter approval before edits. */
100
+ reviewStatus: string;
101
+ /** Status the agent transitions tickets to when it starts applying edits. */
102
+ executeStatus: string;
103
+ /** Status the agent transitions tickets to once draft edits are ready for preview. */
104
+ previewStatus: string;
105
+ doneStatus: string;
106
+ failedStatus?: string;
107
+ siteId: string;
108
+ session: string;
109
+ /** Skip the preview stage: auto-publish after execute and close the ticket. */
110
+ autoPublish: boolean;
111
+ /** Max review rounds per ticket before the agent forces a proceed-or-stop. */
112
+ maxReviewPasses: number;
113
+ pollEnabled: boolean;
114
+ pollJql: string;
115
+ pollIntervalMs: number;
116
+ };
117
+ export declare function loadJiraConfig(): JiraConfig | null;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * JIRA integration types.
3
+ * Covers webhook payloads, REST API responses, and internal processing types.
4
+ */
5
+ export function loadJiraConfig() {
6
+ const baseUrl = process.env.JIRA_BASE_URL?.trim();
7
+ const apiToken = process.env.JIRA_API_TOKEN?.trim();
8
+ if (!baseUrl || !apiToken)
9
+ return null;
10
+ // Status names: prefer the new 3-stage config, fall back to legacy triggerStatus.
11
+ const reviewStatus = process.env.JIRA_REVIEW_STATUS?.trim()
12
+ || process.env.JIRA_TRIGGER_STATUS?.trim()
13
+ || "To Do";
14
+ const executeStatus = process.env.JIRA_EXECUTE_STATUS?.trim() || "In Progress";
15
+ const previewStatus = process.env.JIRA_PREVIEW_STATUS?.trim() || "In Review";
16
+ const doneStatus = process.env.JIRA_DONE_STATUS?.trim() || "Done";
17
+ return {
18
+ baseUrl: baseUrl.replace(/\/+$/, ""),
19
+ email: process.env.JIRA_USER_EMAIL?.trim() ?? "",
20
+ apiToken,
21
+ webhookSecret: process.env.JIRA_WEBHOOK_SECRET?.trim() || undefined,
22
+ agentAccountId: process.env.JIRA_AGENT_ACCOUNT_ID?.trim() || undefined,
23
+ triggerStatus: reviewStatus,
24
+ reviewStatus,
25
+ executeStatus,
26
+ previewStatus,
27
+ doneStatus,
28
+ failedStatus: process.env.JIRA_FAILED_STATUS?.trim() || undefined,
29
+ siteId: process.env.JIRA_SITE_ID?.trim() || "avocado-stories",
30
+ session: process.env.JIRA_SESSION?.trim() || "dev",
31
+ autoPublish: process.env.JIRA_AUTO_PUBLISH === "1",
32
+ maxReviewPasses: Number(process.env.JIRA_MAX_REVIEW_PASSES) || 3,
33
+ pollEnabled: process.env.JIRA_POLL_ENABLED === "1",
34
+ pollJql: process.env.JIRA_POLL_JQL?.trim()
35
+ || `status in ("${reviewStatus}", "${previewStatus}")`,
36
+ pollIntervalMs: Number(process.env.JIRA_POLL_INTERVAL_MS) || 60_000,
37
+ };
38
+ }
@@ -0,0 +1,12 @@
1
+ export interface Logger {
2
+ info(obj: object, msg?: string): void;
3
+ info(msg: string): void;
4
+ warn(obj: object, msg?: string): void;
5
+ warn(msg: string): void;
6
+ error(obj: object, msg?: string): void;
7
+ error(msg: string): void;
8
+ debug(obj: object, msg?: string): void;
9
+ debug(msg: string): void;
10
+ }
11
+ /** Console-backed Logger. Useful as a default in createOrchestrator(). */
12
+ export declare function consoleLogger(): Logger;
package/dist/logger.js ADDED
@@ -0,0 +1,28 @@
1
+ /** Console-backed Logger. Useful as a default in createOrchestrator(). */
2
+ export function consoleLogger() {
3
+ const fmt = (level, a, b) => {
4
+ if (typeof a === "string")
5
+ return `[${level}] ${a}`;
6
+ if (b !== undefined)
7
+ return [`[${level}] ${b}`, a];
8
+ return [`[${level}]`, a];
9
+ };
10
+ return {
11
+ info: (a, b) => {
12
+ const out = fmt("info", a, b);
13
+ Array.isArray(out) ? console.log(...out) : console.log(out);
14
+ },
15
+ warn: (a, b) => {
16
+ const out = fmt("warn", a, b);
17
+ Array.isArray(out) ? console.warn(...out) : console.warn(out);
18
+ },
19
+ error: (a, b) => {
20
+ const out = fmt("error", a, b);
21
+ Array.isArray(out) ? console.error(...out) : console.error(out);
22
+ },
23
+ debug: (a, b) => {
24
+ const out = fmt("debug", a, b);
25
+ Array.isArray(out) ? console.debug(...out) : console.debug(out);
26
+ },
27
+ };
28
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env npx tsx
2
+ /**
3
+ * Standalone MCP stdio server for site migration tools.
4
+ * Spawned by the Claude CLI via --mcp-config.
5
+ *
6
+ * Usage: MIGRATION_SESSION=dev npx tsx apps/orchestrator/src/migration/mcp-server-stdio.ts
7
+ */
8
+ export {};