@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.
- package/LICENSE +201 -0
- package/dist/agent/agent-context.d.ts +19 -0
- package/dist/agent/agent-context.js +67 -0
- package/dist/agent/agent-logger.d.ts +5 -0
- package/dist/agent/agent-logger.js +22 -0
- package/dist/agent/agent-loop-openai.d.ts +8 -0
- package/dist/agent/agent-loop-openai.js +172 -0
- package/dist/agent/agent-loop.d.ts +56 -0
- package/dist/agent/agent-loop.js +167 -0
- package/dist/agent/agent-provider.d.ts +28 -0
- package/dist/agent/agent-provider.js +63 -0
- package/dist/agent/agent-tools.d.ts +28 -0
- package/dist/agent/agent-tools.js +899 -0
- package/dist/agent/context/editing-guidelines.md +46 -0
- package/dist/agent/context/role.md +39 -0
- package/dist/agent/integration-prompt.d.ts +9 -0
- package/dist/agent/integration-prompt.js +154 -0
- package/dist/agent/sites-agent-context.d.ts +12 -0
- package/dist/agent/sites-agent-context.js +316 -0
- package/dist/agent/sites-agent-shared.d.ts +161 -0
- package/dist/agent/sites-agent-shared.js +1101 -0
- package/dist/agent/sites-agent-tools.d.ts +18 -0
- package/dist/agent/sites-agent-tools.js +1227 -0
- package/dist/chat/anthropic-cache.d.ts +20 -0
- package/dist/chat/anthropic-cache.js +54 -0
- package/dist/chat/anthropic-planner.d.ts +98 -0
- package/dist/chat/anthropic-planner.js +1012 -0
- package/dist/chat/changelog-coverage-validator.d.ts +37 -0
- package/dist/chat/changelog-coverage-validator.js +215 -0
- package/dist/chat/chat-pipeline-context.d.ts +211 -0
- package/dist/chat/chat-pipeline-context.js +249 -0
- package/dist/chat/chat-pipeline-deterministic.d.ts +61 -0
- package/dist/chat/chat-pipeline-deterministic.js +407 -0
- package/dist/chat/chat-pipeline-image.d.ts +86 -0
- package/dist/chat/chat-pipeline-image.js +897 -0
- package/dist/chat/chat-pipeline-shared.d.ts +69 -0
- package/dist/chat/chat-pipeline-shared.js +212 -0
- package/dist/chat/chat-pipeline-translation.d.ts +27 -0
- package/dist/chat/chat-pipeline-translation.js +417 -0
- package/dist/chat/chat-pipeline-ui.d.ts +14 -0
- package/dist/chat/chat-pipeline-ui.js +244 -0
- package/dist/chat/chat-pipeline.d.ts +99 -0
- package/dist/chat/chat-pipeline.js +3999 -0
- package/dist/chat/decomposer.d.ts +21 -0
- package/dist/chat/decomposer.js +65 -0
- package/dist/chat/gemini-planner.d.ts +70 -0
- package/dist/chat/gemini-planner.js +541 -0
- package/dist/chat/hallucination-validator.d.ts +36 -0
- package/dist/chat/hallucination-validator.js +110 -0
- package/dist/chat/locale-strings.d.ts +47 -0
- package/dist/chat/locale-strings.js +100 -0
- package/dist/chat/plan-json-schema.d.ts +133 -0
- package/dist/chat/plan-json-schema.js +112 -0
- package/dist/chat/planner-types.d.ts +120 -0
- package/dist/chat/planner-types.js +66 -0
- package/dist/chat/planner.d.ts +148 -0
- package/dist/chat/planner.js +1361 -0
- package/dist/chat/prompts.d.ts +67 -0
- package/dist/chat/prompts.js +356 -0
- package/dist/chat/provider-routing.d.ts +14 -0
- package/dist/chat/provider-routing.js +27 -0
- package/dist/chat/variation-pipeline.d.ts +135 -0
- package/dist/chat/variation-pipeline.js +837 -0
- package/dist/chat/vision-alt-generator.d.ts +35 -0
- package/dist/chat/vision-alt-generator.js +152 -0
- package/dist/cms/adapter.d.ts +62 -0
- package/dist/cms/adapter.js +1 -0
- package/dist/cms/bootstrap.d.ts +17 -0
- package/dist/cms/bootstrap.js +85 -0
- package/dist/cms/editor-api-adapter.d.ts +23 -0
- package/dist/cms/editor-api-adapter.js +71 -0
- package/dist/cms/index.d.ts +4 -0
- package/dist/cms/index.js +3 -0
- package/dist/cms/json-file-adapter.d.ts +11 -0
- package/dist/cms/json-file-adapter.js +62 -0
- package/dist/demo-mode.d.ts +59 -0
- package/dist/demo-mode.js +201 -0
- package/dist/errors.d.ts +67 -0
- package/dist/errors.js +129 -0
- package/dist/http/chat-stream-resumable.d.ts +108 -0
- package/dist/http/chat-stream-resumable.js +290 -0
- package/dist/http/chat-stream.d.ts +99 -0
- package/dist/http/chat-stream.js +92 -0
- package/dist/image/gdrive-client.d.ts +22 -0
- package/dist/image/gdrive-client.js +215 -0
- package/dist/image/image-helpers.d.ts +95 -0
- package/dist/image/image-helpers.js +488 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/jira/jira-approval.d.ts +22 -0
- package/dist/jira/jira-approval.js +51 -0
- package/dist/jira/jira-client.d.ts +44 -0
- package/dist/jira/jira-client.js +313 -0
- package/dist/jira/jira-poller.d.ts +46 -0
- package/dist/jira/jira-poller.js +184 -0
- package/dist/jira/jira-processor.d.ts +103 -0
- package/dist/jira/jira-processor.js +1085 -0
- package/dist/jira/jira-types.d.ts +117 -0
- package/dist/jira/jira-types.js +38 -0
- package/dist/logger.d.ts +12 -0
- package/dist/logger.js +28 -0
- package/dist/migration/mcp-server-stdio.d.ts +8 -0
- package/dist/migration/mcp-server-stdio.js +672 -0
- package/dist/migration/migration-prompt.d.ts +7 -0
- package/dist/migration/migration-prompt.js +197 -0
- package/dist/migration/migration-tools.d.ts +17 -0
- package/dist/migration/migration-tools.js +159 -0
- package/dist/migration/scrape-cache.d.ts +9 -0
- package/dist/migration/scrape-cache.js +19 -0
- package/dist/nlp/deterministic-planner-context.d.ts +141 -0
- package/dist/nlp/deterministic-planner-context.js +362 -0
- package/dist/nlp/deterministic-planner-pages.d.ts +26 -0
- package/dist/nlp/deterministic-planner-pages.js +170 -0
- package/dist/nlp/deterministic-planner-patches.d.ts +80 -0
- package/dist/nlp/deterministic-planner-patches.js +508 -0
- package/dist/nlp/deterministic-planner-refs.d.ts +33 -0
- package/dist/nlp/deterministic-planner-refs.js +164 -0
- package/dist/nlp/deterministic-planner-suggestions.d.ts +49 -0
- package/dist/nlp/deterministic-planner-suggestions.js +579 -0
- package/dist/nlp/deterministic-planner.d.ts +85 -0
- package/dist/nlp/deterministic-planner.js +1631 -0
- package/dist/nlp/intent-detection.d.ts +309 -0
- package/dist/nlp/intent-detection.js +730 -0
- package/dist/nlp/intent-helpers.d.ts +15 -0
- package/dist/nlp/intent-helpers.js +243 -0
- package/dist/nlp/intent-patterns.d.ts +40 -0
- package/dist/nlp/intent-patterns.js +223 -0
- package/dist/nlp/plan-normalizer.d.ts +41 -0
- package/dist/nlp/plan-normalizer.js +1537 -0
- package/dist/ops/destructive-action-gate.d.ts +44 -0
- package/dist/ops/destructive-action-gate.js +90 -0
- package/dist/ops/ops-engine.d.ts +151 -0
- package/dist/ops/ops-engine.js +1394 -0
- package/dist/publish/diff-engine.d.ts +18 -0
- package/dist/publish/diff-engine.js +305 -0
- package/dist/publish/publish-helpers.d.ts +87 -0
- package/dist/publish/publish-helpers.js +521 -0
- package/dist/publish/publish-target-registry.d.ts +7 -0
- package/dist/publish/publish-target-registry.js +61 -0
- package/dist/publish/publish-target.d.ts +81 -0
- package/dist/publish/publish-target.js +1 -0
- package/dist/publish/targets/deploy-hook.d.ts +13 -0
- package/dist/publish/targets/deploy-hook.js +123 -0
- package/dist/publish/targets/git.d.ts +13 -0
- package/dist/publish/targets/git.js +55 -0
- package/dist/publish/targets/site-contract.d.ts +19 -0
- package/dist/publish/targets/site-contract.js +124 -0
- package/dist/state/content-source.d.ts +17 -0
- package/dist/state/content-source.js +1 -0
- package/dist/state/in-memory-content-source.d.ts +27 -0
- package/dist/state/in-memory-content-source.js +51 -0
- package/dist/state/session-lock.d.ts +13 -0
- package/dist/state/session-lock.js +29 -0
- package/dist/state/session-state.d.ts +310 -0
- package/dist/state/session-state.js +1083 -0
- package/dist/state/sqlite-store-singleton.d.ts +31 -0
- package/dist/state/sqlite-store-singleton.js +170 -0
- package/dist/state/sqlite-store.d.ts +135 -0
- package/dist/state/sqlite-store.js +421 -0
- package/dist/telemetry/chat-telemetry.d.ts +105 -0
- package/dist/telemetry/chat-telemetry.js +247 -0
- package/dist/telemetry/eval-candidate-store.d.ts +50 -0
- package/dist/telemetry/eval-candidate-store.js +120 -0
- package/dist/telemetry/feedback-store.d.ts +34 -0
- package/dist/telemetry/feedback-store.js +76 -0
- package/dist/telemetry/jira-telemetry.d.ts +57 -0
- package/dist/telemetry/jira-telemetry.js +68 -0
- package/dist/telemetry/migration-telemetry.d.ts +35 -0
- package/dist/telemetry/migration-telemetry.js +40 -0
- package/dist/telemetry/usage.d.ts +24 -0
- package/dist/telemetry/usage.js +80 -0
- package/dist/tools/builtin-registrations.d.ts +12 -0
- package/dist/tools/builtin-registrations.js +33 -0
- package/dist/tools/builtins/gdrive-browse.d.ts +3 -0
- package/dist/tools/builtins/gdrive-browse.js +68 -0
- package/dist/tools/builtins/image-generate.d.ts +3 -0
- package/dist/tools/builtins/image-generate.js +211 -0
- package/dist/tools/builtins/unsplash-get-by-id.d.ts +23 -0
- package/dist/tools/builtins/unsplash-get-by-id.js +119 -0
- package/dist/tools/builtins/unsplash-search.d.ts +3 -0
- package/dist/tools/builtins/unsplash-search.js +74 -0
- package/dist/tools/executor.d.ts +23 -0
- package/dist/tools/executor.js +169 -0
- package/dist/tools/index.d.ts +5 -0
- package/dist/tools/index.js +5 -0
- package/dist/tools/registry.d.ts +21 -0
- package/dist/tools/registry.js +75 -0
- package/dist/tools/runtime.d.ts +27 -0
- package/dist/tools/runtime.js +48 -0
- package/dist/tools/schema-validator.d.ts +24 -0
- package/dist/tools/schema-validator.js +88 -0
- package/dist/tools/types.d.ts +86 -0
- package/dist/tools/types.js +1 -0
- package/dist/variation-images.d.ts +19 -0
- package/dist/variation-images.js +12 -0
- package/package.json +78 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PageDoc } from "@avocadostudio-ai/shared";
|
|
2
|
+
export declare function isMultiStepCandidate(message: string): boolean;
|
|
3
|
+
export type DecomposeResult = {
|
|
4
|
+
steps: string[];
|
|
5
|
+
labels: string[];
|
|
6
|
+
};
|
|
7
|
+
export declare function decomposeRequest(args: {
|
|
8
|
+
message: string;
|
|
9
|
+
currentPage: PageDoc;
|
|
10
|
+
slug: string;
|
|
11
|
+
model: string;
|
|
12
|
+
siteContextBlock?: string | null;
|
|
13
|
+
locale?: string;
|
|
14
|
+
client?: {
|
|
15
|
+
chat: {
|
|
16
|
+
completions: {
|
|
17
|
+
create: (a: unknown) => any;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}): Promise<DecomposeResult>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import OpenAI from "openai";
|
|
2
|
+
import { buildDecomposerSystemPrompt } from "./prompts.js";
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Heuristic: does this message look like a multi-step request?
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
const MULTI_STEP_SIGNALS = [
|
|
7
|
+
// Plural "pages" + creation verb
|
|
8
|
+
/\b(?:create|generate|build|make|draft|add)\b[^.\n]{0,80}\bpages\b/,
|
|
9
|
+
// "for each" / "for every" / "for all" + action
|
|
10
|
+
/\bfor\s+(?:each|every|all)\b/,
|
|
11
|
+
// Count + "pages"/"blocks" + conjunction
|
|
12
|
+
/\b(?:\d+|two|three|four|five|six|seven|eight|nine|ten)\s+(?:new\s+)?pages\b/,
|
|
13
|
+
// Multiple distinct actions separated by "and"/"then"
|
|
14
|
+
/\b(?:create|add|build)\b.{5,80}\b(?:and|then)\b.{5,80}\b(?:update|link|change|set|connect)\b/,
|
|
15
|
+
// "page for each card/item/feature"
|
|
16
|
+
/\bpages?\s+for\s+(?:each|every)\b/,
|
|
17
|
+
];
|
|
18
|
+
export function isMultiStepCandidate(message) {
|
|
19
|
+
const m = message.toLowerCase().replace(/\s+/g, " ").trim();
|
|
20
|
+
return MULTI_STEP_SIGNALS.some((re) => re.test(m));
|
|
21
|
+
}
|
|
22
|
+
export async function decomposeRequest(args) {
|
|
23
|
+
const { message, currentPage, slug, model, siteContextBlock, locale } = args;
|
|
24
|
+
const blocksSummary = currentPage.blocks
|
|
25
|
+
.map((b) => {
|
|
26
|
+
const props = b.props;
|
|
27
|
+
const title = typeof props.title === "string" ? props.title
|
|
28
|
+
: typeof props.heading === "string" ? props.heading : "";
|
|
29
|
+
return `- ${b.type} (id: ${b.id})${title ? `: "${title}"` : ""}`;
|
|
30
|
+
})
|
|
31
|
+
.join("\n");
|
|
32
|
+
const systemPrompt = buildDecomposerSystemPrompt({
|
|
33
|
+
slug,
|
|
34
|
+
pageTitle: currentPage.title,
|
|
35
|
+
blocksSummary,
|
|
36
|
+
siteContextBlock,
|
|
37
|
+
locale,
|
|
38
|
+
});
|
|
39
|
+
const client = args.client ?? new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
40
|
+
const response = await client.chat.completions.create({
|
|
41
|
+
model,
|
|
42
|
+
messages: [
|
|
43
|
+
{ role: "system", content: systemPrompt },
|
|
44
|
+
{ role: "user", content: message }
|
|
45
|
+
],
|
|
46
|
+
temperature: 0,
|
|
47
|
+
response_format: { type: "json_object" }
|
|
48
|
+
});
|
|
49
|
+
const raw = response.choices?.[0]?.message?.content ?? "{}";
|
|
50
|
+
try {
|
|
51
|
+
const parsed = JSON.parse(raw);
|
|
52
|
+
const steps = Array.isArray(parsed.steps) ? parsed.steps.filter((s) => typeof s === "string") : [];
|
|
53
|
+
const labels = Array.isArray(parsed.labels) ? parsed.labels.filter((s) => typeof s === "string") : [];
|
|
54
|
+
if (steps.length === 0)
|
|
55
|
+
return { steps: [message], labels: [message.slice(0, 40)] };
|
|
56
|
+
// Ensure labels array matches steps length
|
|
57
|
+
while (labels.length < steps.length) {
|
|
58
|
+
labels.push(`Step ${labels.length + 1}`);
|
|
59
|
+
}
|
|
60
|
+
return { steps, labels: labels.slice(0, steps.length) };
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return { steps: [message], labels: [message.slice(0, 40)] };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type BlockManifest, type EditPlan, type Operation, type PageDoc } from "@avocadostudio-ai/shared";
|
|
2
|
+
import { type ParsedIntent, plannerContextPack } from "../nlp/deterministic-planner.ts";
|
|
3
|
+
import { type TokenUsage } from "../telemetry/usage.ts";
|
|
4
|
+
import { type ToolRuntime } from "../tools/runtime.ts";
|
|
5
|
+
import type { ToolExecutionEvent } from "../tools/types.ts";
|
|
6
|
+
import { type PlannerSchemaContextMeta } from "./planner.ts";
|
|
7
|
+
import { type DeferredNativeImageCall } from "./chat-pipeline-shared.ts";
|
|
8
|
+
export declare function parseIntentWithGemini(args: {
|
|
9
|
+
message: string;
|
|
10
|
+
slug: string;
|
|
11
|
+
currentPage: PageDoc;
|
|
12
|
+
activeBlockId?: string;
|
|
13
|
+
activeBlockType?: string;
|
|
14
|
+
activeEditablePath?: string;
|
|
15
|
+
model: string;
|
|
16
|
+
log?: {
|
|
17
|
+
warn: (obj: Record<string, unknown>, msg: string) => void;
|
|
18
|
+
};
|
|
19
|
+
}): Promise<ParsedIntent>;
|
|
20
|
+
export declare function generatePlanWithGemini(args: {
|
|
21
|
+
message: string;
|
|
22
|
+
slug: string;
|
|
23
|
+
currentPage: PageDoc;
|
|
24
|
+
contextPack: ReturnType<typeof plannerContextPack>;
|
|
25
|
+
model: string;
|
|
26
|
+
history?: Array<{
|
|
27
|
+
role: "user" | "assistant";
|
|
28
|
+
content: string;
|
|
29
|
+
}>;
|
|
30
|
+
feedback?: string;
|
|
31
|
+
onToken?: (token: string) => void;
|
|
32
|
+
onFieldDraft?: (draft: {
|
|
33
|
+
blockId: string;
|
|
34
|
+
editablePath: string;
|
|
35
|
+
value: string;
|
|
36
|
+
pageSlug?: string;
|
|
37
|
+
}) => void;
|
|
38
|
+
onPlannedOp?: (op: Operation, index: number) => void;
|
|
39
|
+
onSummaryChunk?: (text: string) => void;
|
|
40
|
+
onChangeLogEntry?: (entry: string) => void;
|
|
41
|
+
onToolExecution?: (event: ToolExecutionEvent) => void;
|
|
42
|
+
onStatusUpdate?: (message: string) => void;
|
|
43
|
+
onImageProgress?: (event: {
|
|
44
|
+
percent: number;
|
|
45
|
+
stage: string;
|
|
46
|
+
}) => void;
|
|
47
|
+
toolRuntime?: ToolRuntime;
|
|
48
|
+
toolCallContext?: {
|
|
49
|
+
siteId: string;
|
|
50
|
+
sessionId: string;
|
|
51
|
+
userId?: string;
|
|
52
|
+
traceId: string;
|
|
53
|
+
gdriveFolderId?: string;
|
|
54
|
+
};
|
|
55
|
+
siteContextBlock?: string | null;
|
|
56
|
+
log?: {
|
|
57
|
+
warn: (obj: Record<string, unknown>, msg: string) => void;
|
|
58
|
+
};
|
|
59
|
+
forceFullSchemaContracts?: boolean;
|
|
60
|
+
componentsManifest?: BlockManifest;
|
|
61
|
+
lightweight?: boolean;
|
|
62
|
+
signal?: AbortSignal;
|
|
63
|
+
locale?: string;
|
|
64
|
+
imageSourceChoiceOpen?: boolean;
|
|
65
|
+
}): Promise<{
|
|
66
|
+
plan: EditPlan;
|
|
67
|
+
usage: TokenUsage;
|
|
68
|
+
schemaContext: PlannerSchemaContextMeta;
|
|
69
|
+
deferredNativeImageCalls?: DeferredNativeImageCall[];
|
|
70
|
+
}>;
|