@wix/ditto-codegen-public 1.0.456 → 1.0.458
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/out.js +688 -616
- package/package.json +2 -2
package/dist/out.js
CHANGED
|
@@ -10460,9 +10460,9 @@ var require_cjs3 = __commonJS({
|
|
|
10460
10460
|
}
|
|
10461
10461
|
});
|
|
10462
10462
|
|
|
10463
|
-
// dist/job-context-storage.js
|
|
10463
|
+
// dist/jobs/job-context-storage.js
|
|
10464
10464
|
var require_job_context_storage = __commonJS({
|
|
10465
|
-
"dist/job-context-storage.js"(exports2) {
|
|
10465
|
+
"dist/jobs/job-context-storage.js"(exports2) {
|
|
10466
10466
|
"use strict";
|
|
10467
10467
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10468
10468
|
exports2.jobContextStorage = void 0;
|
|
@@ -10471,9 +10471,9 @@ var require_job_context_storage = __commonJS({
|
|
|
10471
10471
|
}
|
|
10472
10472
|
});
|
|
10473
10473
|
|
|
10474
|
-
// dist/logger.js
|
|
10474
|
+
// dist/telemetry/logger.js
|
|
10475
10475
|
var require_logger = __commonJS({
|
|
10476
|
-
"dist/logger.js"(exports2) {
|
|
10476
|
+
"dist/telemetry/logger.js"(exports2) {
|
|
10477
10477
|
"use strict";
|
|
10478
10478
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10479
10479
|
exports2.logger = void 0;
|
|
@@ -11566,7 +11566,6 @@ var require_codegen_prompt = __commonJS({
|
|
|
11566
11566
|
"use strict";
|
|
11567
11567
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11568
11568
|
exports2.buildInitPrompt = buildInitPrompt;
|
|
11569
|
-
exports2.buildIterationBasePrompt = buildIterationBasePrompt;
|
|
11570
11569
|
exports2.buildIterationPrompt = buildIterationPrompt;
|
|
11571
11570
|
exports2.buildRecoveryPrompt = buildRecoveryPrompt;
|
|
11572
11571
|
var prompt_utils_1 = require_prompt_utils();
|
|
@@ -11705,131 +11704,19 @@ var require_prompts = __commonJS({
|
|
|
11705
11704
|
}
|
|
11706
11705
|
});
|
|
11707
11706
|
|
|
11708
|
-
// dist/opencode-integration/
|
|
11707
|
+
// dist/opencode-integration/configuration/constants.js
|
|
11709
11708
|
var require_constants5 = __commonJS({
|
|
11710
|
-
"dist/opencode-integration/
|
|
11709
|
+
"dist/opencode-integration/configuration/constants.js"(exports2) {
|
|
11711
11710
|
"use strict";
|
|
11712
11711
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11713
|
-
exports2.
|
|
11714
|
-
exports2.resolveFileOperation = resolveFileOperation;
|
|
11715
|
-
exports2.isSpiExtension = isSpiExtension;
|
|
11716
|
-
exports2.normalizeFilePath = normalizeFilePath;
|
|
11717
|
-
exports2.isExtensionsFile = isExtensionsFile;
|
|
11718
|
-
exports2.detectExtension = detectExtension;
|
|
11719
|
-
exports2.toTitleCase = toTitleCase;
|
|
11720
|
-
exports2.extractExtensionName = extractExtensionName;
|
|
11721
|
-
exports2.matchQuotedExtensionConfigProperty = matchQuotedExtensionConfigProperty;
|
|
11722
|
-
exports2.extractExtensionDisplayTitle = extractExtensionDisplayTitle;
|
|
11723
|
-
exports2.injectCreatedBy = injectCreatedBy;
|
|
11724
|
-
var ditto_codegen_types_12 = require_dist4();
|
|
11725
|
-
exports2.CONTAINER_ROOT_PREFIX = /^\/user-code\//;
|
|
11712
|
+
exports2.WIX_MCP_SERVER_NAME = void 0;
|
|
11726
11713
|
exports2.WIX_MCP_SERVER_NAME = "wix-mcp";
|
|
11727
|
-
var EXTENSION_FILE_PATTERN = /\/extensions\.ts$|\.extension\.ts$/;
|
|
11728
|
-
function resolveFileOperation(tool, metadata) {
|
|
11729
|
-
if (tool === "write") {
|
|
11730
|
-
return metadata?.exists ? ditto_codegen_types_12.ExtensionGenerationOperation.EDIT : ditto_codegen_types_12.ExtensionGenerationOperation.INSERT;
|
|
11731
|
-
}
|
|
11732
|
-
if (tool === "edit") {
|
|
11733
|
-
return ditto_codegen_types_12.ExtensionGenerationOperation.EDIT;
|
|
11734
|
-
}
|
|
11735
|
-
return null;
|
|
11736
|
-
}
|
|
11737
|
-
var SPI_EXTENSION_TYPES = [
|
|
11738
|
-
"ecomShippingRates",
|
|
11739
|
-
"ecomAdditionalFees",
|
|
11740
|
-
"ecomValidations",
|
|
11741
|
-
"ecomDiscountTriggers",
|
|
11742
|
-
"ecomGiftCards",
|
|
11743
|
-
"ecomPaymentSettings",
|
|
11744
|
-
"bookingsStaffSortingProvider"
|
|
11745
|
-
];
|
|
11746
|
-
exports2.BUILDER_EXTENSION_TYPES = [
|
|
11747
|
-
"dashboardPage",
|
|
11748
|
-
"dashboardModal",
|
|
11749
|
-
"dashboardPlugin",
|
|
11750
|
-
"dashboardMenuPlugin",
|
|
11751
|
-
"embeddedScript",
|
|
11752
|
-
"event",
|
|
11753
|
-
"customElement",
|
|
11754
|
-
"siteComponent",
|
|
11755
|
-
"editorReactComponent",
|
|
11756
|
-
"sitePlugin",
|
|
11757
|
-
...SPI_EXTENSION_TYPES,
|
|
11758
|
-
"contextProvider",
|
|
11759
|
-
"functionLibrary",
|
|
11760
|
-
"dataCollections"
|
|
11761
|
-
];
|
|
11762
|
-
var SPI_EXTENSION_TYPE_SET = new Set(SPI_EXTENSION_TYPES);
|
|
11763
|
-
function isSpiExtension(extensionType) {
|
|
11764
|
-
return SPI_EXTENSION_TYPE_SET.has(extensionType);
|
|
11765
|
-
}
|
|
11766
|
-
function normalizeFilePath(filePath) {
|
|
11767
|
-
return filePath.replace(exports2.CONTAINER_ROOT_PREFIX, "");
|
|
11768
|
-
}
|
|
11769
|
-
function isExtensionsFile(filePath) {
|
|
11770
|
-
return EXTENSION_FILE_PATTERN.test(filePath);
|
|
11771
|
-
}
|
|
11772
|
-
function detectExtension(content) {
|
|
11773
|
-
for (const extensionType of exports2.BUILDER_EXTENSION_TYPES) {
|
|
11774
|
-
if (content.includes(`extensions.${extensionType}(`) || content.includes(`experimentalExtensions.${extensionType}(`)) {
|
|
11775
|
-
return extensionType;
|
|
11776
|
-
}
|
|
11777
|
-
}
|
|
11778
|
-
return null;
|
|
11779
|
-
}
|
|
11780
|
-
function toTitleCase(str) {
|
|
11781
|
-
return str.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
11782
|
-
}
|
|
11783
|
-
function extractExtensionName(filePath) {
|
|
11784
|
-
const parts = normalizeFilePath(filePath).split("/");
|
|
11785
|
-
const folderName = parts[parts.length - 2] || "";
|
|
11786
|
-
return toTitleCase(folderName);
|
|
11787
|
-
}
|
|
11788
|
-
function matchQuotedExtensionConfigProperty(content, propName) {
|
|
11789
|
-
const objectPropertyQuotedStringValuePattern = `\\b${propName}\\s*:\\s*(?:"([^"\\\\]*)"|'([^'\\\\]*)')`;
|
|
11790
|
-
const objectPropertyQuotedStringValueRegex = new RegExp(
|
|
11791
|
-
objectPropertyQuotedStringValuePattern,
|
|
11792
|
-
// `m` = multiline: `^` / `$` match line starts/ends, not only the whole string.
|
|
11793
|
-
"m"
|
|
11794
|
-
);
|
|
11795
|
-
const quotedStringValueMatch = content.match(objectPropertyQuotedStringValueRegex);
|
|
11796
|
-
if (!quotedStringValueMatch)
|
|
11797
|
-
return null;
|
|
11798
|
-
return quotedStringValueMatch[1] ?? quotedStringValueMatch[2] ?? null;
|
|
11799
|
-
}
|
|
11800
|
-
function extractExtensionDisplayTitle(content, filePath) {
|
|
11801
|
-
const title = matchQuotedExtensionConfigProperty(content, "title");
|
|
11802
|
-
if (title)
|
|
11803
|
-
return title;
|
|
11804
|
-
const name = matchQuotedExtensionConfigProperty(content, "name");
|
|
11805
|
-
if (name)
|
|
11806
|
-
return name;
|
|
11807
|
-
const displayName = matchQuotedExtensionConfigProperty(content, "displayName");
|
|
11808
|
-
if (displayName)
|
|
11809
|
-
return displayName;
|
|
11810
|
-
const idSuffix = matchQuotedExtensionConfigProperty(content, "idSuffix");
|
|
11811
|
-
if (idSuffix)
|
|
11812
|
-
return idSuffix;
|
|
11813
|
-
return extractExtensionName(filePath);
|
|
11814
|
-
}
|
|
11815
|
-
function injectCreatedBy(content) {
|
|
11816
|
-
if (content.includes("createdBy"))
|
|
11817
|
-
return content;
|
|
11818
|
-
const isGeneric = content.includes("genericExtension(");
|
|
11819
|
-
const createdByValue = isGeneric ? ' createdBy: "CODE_GEN",' : ' createdBy: {\n author: "CODE_GEN",\n },';
|
|
11820
|
-
return content.replace(/(\S)(\n)(}\))(;?\s*)$/, (_match, preChar, newline, closeBrace, tail) => {
|
|
11821
|
-
const needsComma = preChar !== "," && preChar !== "{";
|
|
11822
|
-
const separator = needsComma ? `${preChar},` : preChar;
|
|
11823
|
-
return `${separator}${newline}${createdByValue}
|
|
11824
|
-
${closeBrace}${tail}`;
|
|
11825
|
-
});
|
|
11826
|
-
}
|
|
11827
11714
|
}
|
|
11828
11715
|
});
|
|
11829
11716
|
|
|
11830
|
-
// dist/opencode-integration/model-knobs.js
|
|
11717
|
+
// dist/opencode-integration/configuration/model-knobs.js
|
|
11831
11718
|
var require_model_knobs = __commonJS({
|
|
11832
|
-
"dist/opencode-integration/model-knobs.js"(exports2) {
|
|
11719
|
+
"dist/opencode-integration/configuration/model-knobs.js"(exports2) {
|
|
11833
11720
|
"use strict";
|
|
11834
11721
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11835
11722
|
exports2.DEFAULT_SMALL_MODEL = exports2.DEFAULT_MODEL = void 0;
|
|
@@ -11931,9 +11818,9 @@ var require_types4 = __commonJS({
|
|
|
11931
11818
|
}
|
|
11932
11819
|
});
|
|
11933
11820
|
|
|
11934
|
-
// dist/opencode-integration/
|
|
11935
|
-
var
|
|
11936
|
-
"dist/opencode-integration/
|
|
11821
|
+
// dist/opencode-integration/configuration/subagents.js
|
|
11822
|
+
var require_subagents = __commonJS({
|
|
11823
|
+
"dist/opencode-integration/configuration/subagents.js"(exports2) {
|
|
11937
11824
|
"use strict";
|
|
11938
11825
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11939
11826
|
exports2.SUBAGENT_AGENT_NAMES = exports2.WDS_DOCS_SUBAGENT_NAME = exports2.WIX_DOCS_SUBAGENT_NAME = exports2.VALIDATOR_SUBAGENT_NAME = exports2.PRIMARY_AGENT_NAME = void 0;
|
|
@@ -12225,9 +12112,9 @@ skills already cover. Read-only.`;
|
|
|
12225
12112
|
}
|
|
12226
12113
|
});
|
|
12227
12114
|
|
|
12228
|
-
// dist/opencode-integration/rules-writer.js
|
|
12115
|
+
// dist/opencode-integration/configuration/rules-writer.js
|
|
12229
12116
|
var require_rules_writer = __commonJS({
|
|
12230
|
-
"dist/opencode-integration/rules-writer.js"(exports2) {
|
|
12117
|
+
"dist/opencode-integration/configuration/rules-writer.js"(exports2) {
|
|
12231
12118
|
"use strict";
|
|
12232
12119
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12233
12120
|
exports2.getRulePath = getRulePath;
|
|
@@ -15297,14 +15184,13 @@ WORKFLOW:
|
|
|
15297
15184
|
}
|
|
15298
15185
|
});
|
|
15299
15186
|
|
|
15300
|
-
// dist/job-decision-manager.js
|
|
15187
|
+
// dist/jobs/job-decision-manager.js
|
|
15301
15188
|
var require_job_decision_manager = __commonJS({
|
|
15302
|
-
"dist/job-decision-manager.js"(exports2) {
|
|
15189
|
+
"dist/jobs/job-decision-manager.js"(exports2) {
|
|
15303
15190
|
"use strict";
|
|
15304
15191
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15305
15192
|
exports2.pauseForUserDecision = pauseForUserDecision;
|
|
15306
15193
|
exports2.askJobChoice = askJobChoice;
|
|
15307
|
-
exports2.askJobConfirmation = askJobConfirmation;
|
|
15308
15194
|
var types_1 = require_types_impl();
|
|
15309
15195
|
var codeGenerationService_12 = require_codeGenerationService();
|
|
15310
15196
|
var types_2 = require_types_impl();
|
|
@@ -15369,18 +15255,6 @@ var require_job_decision_manager = __commonJS({
|
|
|
15369
15255
|
}
|
|
15370
15256
|
return response.selectedOptionId;
|
|
15371
15257
|
}
|
|
15372
|
-
async function askJobConfirmation(jobId, question, context) {
|
|
15373
|
-
const response = await pauseForUserDecision(jobId, {
|
|
15374
|
-
question,
|
|
15375
|
-
questionType: types_1.UserDecisionQuestionType.UI_COMPONENT_TYPE,
|
|
15376
|
-
options: [
|
|
15377
|
-
{ id: "yes", label: "Yes" },
|
|
15378
|
-
{ id: "no", label: "No" }
|
|
15379
|
-
],
|
|
15380
|
-
context
|
|
15381
|
-
});
|
|
15382
|
-
return response.selectedOptionId === "yes";
|
|
15383
|
-
}
|
|
15384
15258
|
}
|
|
15385
15259
|
});
|
|
15386
15260
|
|
|
@@ -15455,12 +15329,12 @@ var require_environments = __commonJS({
|
|
|
15455
15329
|
}
|
|
15456
15330
|
});
|
|
15457
15331
|
|
|
15458
|
-
// dist/opencode-integration/config.js
|
|
15332
|
+
// dist/opencode-integration/configuration/config.js
|
|
15459
15333
|
var require_config = __commonJS({
|
|
15460
|
-
"dist/opencode-integration/config.js"(exports2) {
|
|
15334
|
+
"dist/opencode-integration/configuration/config.js"(exports2) {
|
|
15461
15335
|
"use strict";
|
|
15462
15336
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15463
|
-
exports2.DEFAULT_TIMEOUT_MS = void 0;
|
|
15337
|
+
exports2.PROVIDER_CHUNK_TIMEOUT_MS = exports2.DEFAULT_TIMEOUT_MS = void 0;
|
|
15464
15338
|
exports2.getAnthropicBaseUrl = getAnthropicBaseUrl;
|
|
15465
15339
|
exports2.getOpenAiBaseUrl = getOpenAiBaseUrl;
|
|
15466
15340
|
exports2.getGoogleBaseUrl = getGoogleBaseUrl;
|
|
@@ -15471,7 +15345,7 @@ var require_config = __commonJS({
|
|
|
15471
15345
|
var ditto_codegen_types_12 = require_dist4();
|
|
15472
15346
|
var constants_1 = require_constants5();
|
|
15473
15347
|
var model_knobs_1 = require_model_knobs();
|
|
15474
|
-
var
|
|
15348
|
+
var subagents_1 = require_subagents();
|
|
15475
15349
|
var rules_writer_12 = require_rules_writer();
|
|
15476
15350
|
var environments_12 = require_environments();
|
|
15477
15351
|
var CodeGenService_12 = require_CodeGenService();
|
|
@@ -15506,6 +15380,7 @@ var require_config = __commonJS({
|
|
|
15506
15380
|
".git/**",
|
|
15507
15381
|
".astro/**"
|
|
15508
15382
|
];
|
|
15383
|
+
exports2.PROVIDER_CHUNK_TIMEOUT_MS = 9e4;
|
|
15509
15384
|
function getProviderConfig(projectId) {
|
|
15510
15385
|
const environment = (0, environments_12.getValidatedCodegenEnvironment)();
|
|
15511
15386
|
const chargingMode = (0, environments_12.getCodegenEnvironmentConfig)().chargingMode ?? "app";
|
|
@@ -15524,7 +15399,8 @@ var require_config = __commonJS({
|
|
|
15524
15399
|
options: {
|
|
15525
15400
|
apiKey: "proxy-handled",
|
|
15526
15401
|
cacheControl: true,
|
|
15527
|
-
headers
|
|
15402
|
+
headers,
|
|
15403
|
+
chunkTimeout: exports2.PROVIDER_CHUNK_TIMEOUT_MS
|
|
15528
15404
|
}
|
|
15529
15405
|
}
|
|
15530
15406
|
};
|
|
@@ -15536,7 +15412,8 @@ var require_config = __commonJS({
|
|
|
15536
15412
|
// don't "clean up" apiKey — removing it 403s every openai request.
|
|
15537
15413
|
apiKey: "proxy-handled",
|
|
15538
15414
|
baseURL: getOpenAiBaseUrl(projectId),
|
|
15539
|
-
headers
|
|
15415
|
+
headers,
|
|
15416
|
+
chunkTimeout: exports2.PROVIDER_CHUNK_TIMEOUT_MS
|
|
15540
15417
|
}
|
|
15541
15418
|
};
|
|
15542
15419
|
}
|
|
@@ -15545,7 +15422,8 @@ var require_config = __commonJS({
|
|
|
15545
15422
|
options: {
|
|
15546
15423
|
apiKey: "proxy-handled",
|
|
15547
15424
|
baseURL: getGoogleBaseUrl(projectId),
|
|
15548
|
-
headers
|
|
15425
|
+
headers,
|
|
15426
|
+
chunkTimeout: exports2.PROVIDER_CHUNK_TIMEOUT_MS
|
|
15549
15427
|
},
|
|
15550
15428
|
// Wix AI proxy aliases not in models.dev — opencode would reject them
|
|
15551
15429
|
// with ModelNotFoundError without these stubs. Empty records are enough;
|
|
@@ -15657,8 +15535,8 @@ var require_config = __commonJS({
|
|
|
15657
15535
|
external_directory: READABLE_EXTERNAL_DIRS
|
|
15658
15536
|
};
|
|
15659
15537
|
function buildConfig(projectId, instructionPaths, permission, { isCodeWritingFlow = false, withAgents = false } = {}) {
|
|
15660
|
-
const main2 = (0,
|
|
15661
|
-
const subagent = (0,
|
|
15538
|
+
const main2 = (0, subagents_1.getMainAgentModel)();
|
|
15539
|
+
const subagent = (0, subagents_1.getSubagentModel)();
|
|
15662
15540
|
return {
|
|
15663
15541
|
model: (0, model_knobs_1.getModel)(),
|
|
15664
15542
|
small_model: (0, model_knobs_1.getSmallModel)(),
|
|
@@ -15675,8 +15553,8 @@ var require_config = __commonJS({
|
|
|
15675
15553
|
// not: its primary agent re-opens `task`, which would let the write-capable
|
|
15676
15554
|
// validator subagent run in a flow meant to stay read-only.
|
|
15677
15555
|
...withAgents ? {
|
|
15678
|
-
agent: (0,
|
|
15679
|
-
default_agent:
|
|
15556
|
+
agent: (0, subagents_1.getAgentConfig)(main2, subagent),
|
|
15557
|
+
default_agent: subagents_1.PRIMARY_AGENT_NAME
|
|
15680
15558
|
} : {}
|
|
15681
15559
|
};
|
|
15682
15560
|
}
|
|
@@ -15731,44 +15609,45 @@ var require_config = __commonJS({
|
|
|
15731
15609
|
}
|
|
15732
15610
|
});
|
|
15733
15611
|
|
|
15734
|
-
// dist/opencode-integration/
|
|
15735
|
-
var
|
|
15736
|
-
"dist/opencode-integration/
|
|
15612
|
+
// dist/opencode-integration/plugins/write-plugin.js
|
|
15613
|
+
var require_write_plugin = __commonJS({
|
|
15614
|
+
"dist/opencode-integration/plugins/write-plugin.js"(exports2) {
|
|
15737
15615
|
"use strict";
|
|
15738
15616
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15739
|
-
exports2.OPENCODE_PLUGIN_DIR = void 0;
|
|
15740
15617
|
exports2.writeGeneratedPlugin = writeGeneratedPlugin;
|
|
15741
15618
|
var promises_1 = require("fs/promises");
|
|
15742
15619
|
var os_1 = require("os");
|
|
15743
15620
|
var path_12 = require("path");
|
|
15744
15621
|
var logger_12 = require_logger();
|
|
15745
|
-
|
|
15622
|
+
var OPENCODE_PLUGIN_DIR = (0, path_12.join)((0, os_1.homedir)(), ".config", "opencode", "plugin");
|
|
15746
15623
|
async function writeGeneratedPlugin(filename, source) {
|
|
15747
|
-
await (0, promises_1.mkdir)(
|
|
15748
|
-
await (0, promises_1.writeFile)((0, path_12.join)(
|
|
15624
|
+
await (0, promises_1.mkdir)(OPENCODE_PLUGIN_DIR, { recursive: true });
|
|
15625
|
+
await (0, promises_1.writeFile)((0, path_12.join)(OPENCODE_PLUGIN_DIR, filename), source, "utf-8");
|
|
15749
15626
|
logger_12.logger.info("[OpenCode] Wrote generated plugin", { plugin: filename });
|
|
15750
15627
|
}
|
|
15751
15628
|
}
|
|
15752
15629
|
});
|
|
15753
15630
|
|
|
15754
|
-
// dist/opencode-integration/subagent-tool-logger.js
|
|
15631
|
+
// dist/opencode-integration/plugins/subagent-tool-logger.js
|
|
15755
15632
|
var require_subagent_tool_logger = __commonJS({
|
|
15756
|
-
"dist/opencode-integration/subagent-tool-logger.js"(exports2) {
|
|
15633
|
+
"dist/opencode-integration/plugins/subagent-tool-logger.js"(exports2) {
|
|
15757
15634
|
"use strict";
|
|
15758
15635
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15759
|
-
exports2.SUBAGENT_STARTED_EVENT_TYPE = exports2.SUBAGENT_TOOL_EVENT_TYPE = void 0;
|
|
15636
|
+
exports2.SUBAGENT_TOOL_LOGGER_FILENAME = exports2.TOOL_STARTED_EVENT_TYPE = exports2.SUBAGENT_STARTED_EVENT_TYPE = exports2.SUBAGENT_TOOL_EVENT_TYPE = void 0;
|
|
15760
15637
|
exports2.buildSubagentToolLoggerPluginSource = buildSubagentToolLoggerPluginSource;
|
|
15761
15638
|
exports2.writeSubagentToolLoggerPlugin = writeSubagentToolLoggerPlugin;
|
|
15762
|
-
var
|
|
15763
|
-
var
|
|
15639
|
+
var write_plugin_1 = require_write_plugin();
|
|
15640
|
+
var subagents_1 = require_subagents();
|
|
15764
15641
|
exports2.SUBAGENT_TOOL_EVENT_TYPE = "subagent_tool_use";
|
|
15765
15642
|
exports2.SUBAGENT_STARTED_EVENT_TYPE = "subagent_started";
|
|
15766
|
-
|
|
15643
|
+
exports2.TOOL_STARTED_EVENT_TYPE = "tool_started";
|
|
15644
|
+
exports2.SUBAGENT_TOOL_LOGGER_FILENAME = "subagent-tool-logger.ts";
|
|
15767
15645
|
function buildSubagentToolLoggerPluginSource() {
|
|
15768
15646
|
return `// Generated by @wix/ditto-codegen (subagent-tool-logger) \u2014 do not edit.
|
|
15769
15647
|
const EVENT_TYPE = ${JSON.stringify(exports2.SUBAGENT_TOOL_EVENT_TYPE)};
|
|
15770
15648
|
const STARTED_EVENT_TYPE = ${JSON.stringify(exports2.SUBAGENT_STARTED_EVENT_TYPE)};
|
|
15771
|
-
const
|
|
15649
|
+
const TOOL_STARTED_EVENT_TYPE = ${JSON.stringify(exports2.TOOL_STARTED_EVENT_TYPE)};
|
|
15650
|
+
const SUBAGENT_AGENTS = new Set(${JSON.stringify(subagents_1.SUBAGENT_AGENT_NAMES)});
|
|
15772
15651
|
|
|
15773
15652
|
export const SubagentToolLogger = async () => {
|
|
15774
15653
|
// sessionID -> agent name, learned from session.* / message.updated (both
|
|
@@ -15779,6 +15658,8 @@ export const SubagentToolLogger = async () => {
|
|
|
15779
15658
|
const emitted = new Set();
|
|
15780
15659
|
// sessions we've already emitted a start marker for (events repeat).
|
|
15781
15660
|
const started = new Set();
|
|
15661
|
+
// callIDs we've announced as started \u2014 a running part updates repeatedly.
|
|
15662
|
+
const toolStarted = new Set();
|
|
15782
15663
|
|
|
15783
15664
|
// Emit the start marker once per subagent session, stamped with opencode's
|
|
15784
15665
|
// own creation time \u2014 NOT the plugin's observation time (Date.now), which
|
|
@@ -15835,6 +15716,25 @@ export const SubagentToolLogger = async () => {
|
|
|
15835
15716
|
if (part?.type !== "tool") return;
|
|
15836
15717
|
|
|
15837
15718
|
const status = part.state?.status;
|
|
15719
|
+
|
|
15720
|
+
// Before the subagent filter: root parts are never in agentBySession.
|
|
15721
|
+
if (status === "running") {
|
|
15722
|
+
if (!part.callID || toolStarted.has(part.callID)) return;
|
|
15723
|
+
toolStarted.add(part.callID);
|
|
15724
|
+
const startedAt = part.state?.time?.start;
|
|
15725
|
+
process.stdout.write(
|
|
15726
|
+
JSON.stringify({
|
|
15727
|
+
type: TOOL_STARTED_EVENT_TYPE,
|
|
15728
|
+
timestamp: startedAt || Date.now(),
|
|
15729
|
+
exactTime: startedAt != null,
|
|
15730
|
+
sessionID: part.sessionID,
|
|
15731
|
+
callID: part.callID,
|
|
15732
|
+
tool: part.tool,
|
|
15733
|
+
}) + "\\n",
|
|
15734
|
+
);
|
|
15735
|
+
return;
|
|
15736
|
+
}
|
|
15737
|
+
|
|
15838
15738
|
if (status !== "completed" && status !== "error") return;
|
|
15839
15739
|
|
|
15840
15740
|
const agent = agentBySession.get(part.sessionID);
|
|
@@ -15877,14 +15777,14 @@ export const SubagentToolLogger = async () => {
|
|
|
15877
15777
|
`;
|
|
15878
15778
|
}
|
|
15879
15779
|
async function writeSubagentToolLoggerPlugin() {
|
|
15880
|
-
await (0,
|
|
15780
|
+
await (0, write_plugin_1.writeGeneratedPlugin)(exports2.SUBAGENT_TOOL_LOGGER_FILENAME, buildSubagentToolLoggerPluginSource());
|
|
15881
15781
|
}
|
|
15882
15782
|
}
|
|
15883
15783
|
});
|
|
15884
15784
|
|
|
15885
|
-
// dist/opencode-integration/parser.js
|
|
15785
|
+
// dist/opencode-integration/execution/parser.js
|
|
15886
15786
|
var require_parser = __commonJS({
|
|
15887
|
-
"dist/opencode-integration/parser.js"(exports2) {
|
|
15787
|
+
"dist/opencode-integration/execution/parser.js"(exports2) {
|
|
15888
15788
|
"use strict";
|
|
15889
15789
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15890
15790
|
exports2.parseRequiredPermissions = parseRequiredPermissions;
|
|
@@ -15898,8 +15798,8 @@ var require_parser = __commonJS({
|
|
|
15898
15798
|
exports2.parseValidatorTaskOutputs = parseValidatorTaskOutputs;
|
|
15899
15799
|
exports2.summarizeOpenCodeLine = summarizeOpenCodeLine;
|
|
15900
15800
|
var types_1 = require_types4();
|
|
15901
|
-
var
|
|
15902
|
-
var
|
|
15801
|
+
var subagents_1 = require_subagents();
|
|
15802
|
+
var subagent_tool_logger_1 = require_subagent_tool_logger();
|
|
15903
15803
|
function parseRequiredPermissions(output) {
|
|
15904
15804
|
let permissions = [];
|
|
15905
15805
|
const lines = output.split("\n");
|
|
@@ -16042,7 +15942,7 @@ var require_parser = __commonJS({
|
|
|
16042
15942
|
continue;
|
|
16043
15943
|
}
|
|
16044
15944
|
const { title, output, input } = event.part.state;
|
|
16045
|
-
const isValidator = input?.subagent_type ===
|
|
15945
|
+
const isValidator = input?.subagent_type === subagents_1.VALIDATOR_SUBAGENT_NAME || title?.includes(subagents_1.VALIDATOR_SUBAGENT_NAME);
|
|
16046
15946
|
if (isValidator && output) {
|
|
16047
15947
|
outputs.push(output.trim());
|
|
16048
15948
|
}
|
|
@@ -16050,7 +15950,7 @@ var require_parser = __commonJS({
|
|
|
16050
15950
|
return outputs;
|
|
16051
15951
|
}
|
|
16052
15952
|
function summarizeOpenCodeLine(line) {
|
|
16053
|
-
if (line.type !== "tool_use" && line.type !==
|
|
15953
|
+
if (line.type !== "tool_use" && line.type !== subagent_tool_logger_1.SUBAGENT_TOOL_EVENT_TYPE) {
|
|
16054
15954
|
return line;
|
|
16055
15955
|
}
|
|
16056
15956
|
const { part } = line;
|
|
@@ -16072,9 +15972,9 @@ var require_parser = __commonJS({
|
|
|
16072
15972
|
}
|
|
16073
15973
|
});
|
|
16074
15974
|
|
|
16075
|
-
// dist/
|
|
15975
|
+
// dist/git/internal-paths.js
|
|
16076
15976
|
var require_internal_paths = __commonJS({
|
|
16077
|
-
"dist/
|
|
15977
|
+
"dist/git/internal-paths.js"(exports2) {
|
|
16078
15978
|
"use strict";
|
|
16079
15979
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16080
15980
|
exports2.isInternalPath = isInternalPath;
|
|
@@ -16085,9 +15985,9 @@ var require_internal_paths = __commonJS({
|
|
|
16085
15985
|
}
|
|
16086
15986
|
});
|
|
16087
15987
|
|
|
16088
|
-
// dist/
|
|
16089
|
-
var
|
|
16090
|
-
"dist/
|
|
15988
|
+
// dist/git/file-changes.js
|
|
15989
|
+
var require_file_changes = __commonJS({
|
|
15990
|
+
"dist/git/file-changes.js"(exports2) {
|
|
16091
15991
|
"use strict";
|
|
16092
15992
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16093
15993
|
exports2.captureGitBaseline = captureGitBaseline;
|
|
@@ -16166,9 +16066,9 @@ var require_git_file_changes = __commonJS({
|
|
|
16166
16066
|
}
|
|
16167
16067
|
});
|
|
16168
16068
|
|
|
16169
|
-
// dist/opencode-integration/cost-tracker.js
|
|
16069
|
+
// dist/opencode-integration/execution/cost-tracker.js
|
|
16170
16070
|
var require_cost_tracker = __commonJS({
|
|
16171
|
-
"dist/opencode-integration/cost-tracker.js"(exports2) {
|
|
16071
|
+
"dist/opencode-integration/execution/cost-tracker.js"(exports2) {
|
|
16172
16072
|
"use strict";
|
|
16173
16073
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16174
16074
|
exports2.fetchOpenCodeStats = fetchOpenCodeStats;
|
|
@@ -16287,6 +16187,113 @@ var require_progress_handler = __commonJS({
|
|
|
16287
16187
|
}
|
|
16288
16188
|
});
|
|
16289
16189
|
|
|
16190
|
+
// dist/extension-reporting/detect.js
|
|
16191
|
+
var require_detect = __commonJS({
|
|
16192
|
+
"dist/extension-reporting/detect.js"(exports2) {
|
|
16193
|
+
"use strict";
|
|
16194
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16195
|
+
exports2.BUILDER_EXTENSION_TYPES = void 0;
|
|
16196
|
+
exports2.isSpiExtension = isSpiExtension;
|
|
16197
|
+
exports2.isExtensionsFile = isExtensionsFile;
|
|
16198
|
+
exports2.detectExtension = detectExtension;
|
|
16199
|
+
exports2.matchQuotedExtensionConfigProperty = matchQuotedExtensionConfigProperty;
|
|
16200
|
+
exports2.extractExtensionDisplayTitle = extractExtensionDisplayTitle;
|
|
16201
|
+
exports2.injectCreatedBy = injectCreatedBy;
|
|
16202
|
+
var CONTAINER_ROOT_PREFIX = /^\/user-code\//;
|
|
16203
|
+
var EXTENSION_FILE_PATTERN = /\/extensions\.ts$|\.extension\.ts$/;
|
|
16204
|
+
var SPI_EXTENSION_TYPES = [
|
|
16205
|
+
"ecomShippingRates",
|
|
16206
|
+
"ecomAdditionalFees",
|
|
16207
|
+
"ecomValidations",
|
|
16208
|
+
"ecomDiscountTriggers",
|
|
16209
|
+
"ecomGiftCards",
|
|
16210
|
+
"ecomPaymentSettings",
|
|
16211
|
+
"bookingsStaffSortingProvider"
|
|
16212
|
+
];
|
|
16213
|
+
exports2.BUILDER_EXTENSION_TYPES = [
|
|
16214
|
+
"dashboardPage",
|
|
16215
|
+
"dashboardModal",
|
|
16216
|
+
"dashboardPlugin",
|
|
16217
|
+
"dashboardMenuPlugin",
|
|
16218
|
+
"embeddedScript",
|
|
16219
|
+
"event",
|
|
16220
|
+
"customElement",
|
|
16221
|
+
"siteComponent",
|
|
16222
|
+
"editorReactComponent",
|
|
16223
|
+
"sitePlugin",
|
|
16224
|
+
...SPI_EXTENSION_TYPES,
|
|
16225
|
+
"contextProvider",
|
|
16226
|
+
"functionLibrary",
|
|
16227
|
+
"dataCollections"
|
|
16228
|
+
];
|
|
16229
|
+
var SPI_EXTENSION_TYPE_SET = new Set(SPI_EXTENSION_TYPES);
|
|
16230
|
+
function isSpiExtension(extensionType) {
|
|
16231
|
+
return SPI_EXTENSION_TYPE_SET.has(extensionType);
|
|
16232
|
+
}
|
|
16233
|
+
function normalizeFilePath(filePath) {
|
|
16234
|
+
return filePath.replace(CONTAINER_ROOT_PREFIX, "");
|
|
16235
|
+
}
|
|
16236
|
+
function isExtensionsFile(filePath) {
|
|
16237
|
+
return EXTENSION_FILE_PATTERN.test(filePath);
|
|
16238
|
+
}
|
|
16239
|
+
function detectExtension(content) {
|
|
16240
|
+
for (const extensionType of exports2.BUILDER_EXTENSION_TYPES) {
|
|
16241
|
+
if (content.includes(`extensions.${extensionType}(`) || content.includes(`experimentalExtensions.${extensionType}(`)) {
|
|
16242
|
+
return extensionType;
|
|
16243
|
+
}
|
|
16244
|
+
}
|
|
16245
|
+
return null;
|
|
16246
|
+
}
|
|
16247
|
+
function toTitleCase(str) {
|
|
16248
|
+
return str.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
16249
|
+
}
|
|
16250
|
+
function extractExtensionName(filePath) {
|
|
16251
|
+
const parts = normalizeFilePath(filePath).split("/");
|
|
16252
|
+
const folderName = parts[parts.length - 2] || "";
|
|
16253
|
+
return toTitleCase(folderName);
|
|
16254
|
+
}
|
|
16255
|
+
function matchQuotedExtensionConfigProperty(content, propName) {
|
|
16256
|
+
const objectPropertyQuotedStringValuePattern = `\\b${propName}\\s*:\\s*(?:"([^"\\\\]*)"|'([^'\\\\]*)')`;
|
|
16257
|
+
const objectPropertyQuotedStringValueRegex = new RegExp(
|
|
16258
|
+
objectPropertyQuotedStringValuePattern,
|
|
16259
|
+
// `m` = multiline: `^` / `$` match line starts/ends, not only the whole string.
|
|
16260
|
+
"m"
|
|
16261
|
+
);
|
|
16262
|
+
const quotedStringValueMatch = content.match(objectPropertyQuotedStringValueRegex);
|
|
16263
|
+
if (!quotedStringValueMatch)
|
|
16264
|
+
return null;
|
|
16265
|
+
return quotedStringValueMatch[1] ?? quotedStringValueMatch[2] ?? null;
|
|
16266
|
+
}
|
|
16267
|
+
function extractExtensionDisplayTitle(content, filePath) {
|
|
16268
|
+
const title = matchQuotedExtensionConfigProperty(content, "title");
|
|
16269
|
+
if (title)
|
|
16270
|
+
return title;
|
|
16271
|
+
const name = matchQuotedExtensionConfigProperty(content, "name");
|
|
16272
|
+
if (name)
|
|
16273
|
+
return name;
|
|
16274
|
+
const displayName = matchQuotedExtensionConfigProperty(content, "displayName");
|
|
16275
|
+
if (displayName)
|
|
16276
|
+
return displayName;
|
|
16277
|
+
const idSuffix = matchQuotedExtensionConfigProperty(content, "idSuffix");
|
|
16278
|
+
if (idSuffix)
|
|
16279
|
+
return idSuffix;
|
|
16280
|
+
return extractExtensionName(filePath);
|
|
16281
|
+
}
|
|
16282
|
+
function injectCreatedBy(content) {
|
|
16283
|
+
if (content.includes("createdBy"))
|
|
16284
|
+
return content;
|
|
16285
|
+
const isGeneric = content.includes("genericExtension(");
|
|
16286
|
+
const createdByValue = isGeneric ? ' createdBy: "CODE_GEN",' : ' createdBy: {\n author: "CODE_GEN",\n },';
|
|
16287
|
+
return content.replace(/(\S)(\n)(}\))(;?\s*)$/, (_match, preChar, newline, closeBrace, tail) => {
|
|
16288
|
+
const needsComma = preChar !== "," && preChar !== "{";
|
|
16289
|
+
const separator = needsComma ? `${preChar},` : preChar;
|
|
16290
|
+
return `${separator}${newline}${createdByValue}
|
|
16291
|
+
${closeBrace}${tail}`;
|
|
16292
|
+
});
|
|
16293
|
+
}
|
|
16294
|
+
}
|
|
16295
|
+
});
|
|
16296
|
+
|
|
16290
16297
|
// dist/opencode-integration/task-tracker/derived-progress.js
|
|
16291
16298
|
var require_derived_progress = __commonJS({
|
|
16292
16299
|
"dist/opencode-integration/task-tracker/derived-progress.js"(exports2) {
|
|
@@ -16295,12 +16302,12 @@ var require_derived_progress = __commonJS({
|
|
|
16295
16302
|
exports2.DerivedProgressReporter = void 0;
|
|
16296
16303
|
exports2.deriveProgressSteps = deriveProgressSteps;
|
|
16297
16304
|
var ditto_codegen_types_12 = require_dist4();
|
|
16298
|
-
var
|
|
16299
|
-
var
|
|
16305
|
+
var detect_1 = require_detect();
|
|
16306
|
+
var subagents_1 = require_subagents();
|
|
16300
16307
|
var SUBAGENT_STEPS = {
|
|
16301
|
-
[
|
|
16302
|
-
[
|
|
16303
|
-
[
|
|
16308
|
+
[subagents_1.VALIDATOR_SUBAGENT_NAME]: "Building project",
|
|
16309
|
+
[subagents_1.WIX_DOCS_SUBAGENT_NAME]: "Reading documentation",
|
|
16310
|
+
[subagents_1.WDS_DOCS_SUBAGENT_NAME]: "Reading documentation"
|
|
16304
16311
|
};
|
|
16305
16312
|
var REGISTRY_FILE_PATTERN = /(^|\/)extensions\.ts$/;
|
|
16306
16313
|
var EXTENSION_DEFINITION_PATTERN = /\.extension\.ts$/;
|
|
@@ -16308,7 +16315,7 @@ var require_derived_progress = __commonJS({
|
|
|
16308
16315
|
return token.replace(/[_-]+/g, " ").replace(/([a-z\d])([A-Z])/g, "$1 $2").split(/\s+/).filter(Boolean).map((word) => word[0].toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
16309
16316
|
}
|
|
16310
16317
|
function humanizeExtensionType(type) {
|
|
16311
|
-
return (0,
|
|
16318
|
+
return (0, detect_1.isSpiExtension)(type) ? "Service Plugin" : toTitleCaseWords(type);
|
|
16312
16319
|
}
|
|
16313
16320
|
function extensionStep(verb, type) {
|
|
16314
16321
|
return `${verb} ${humanizeExtensionType(type)}`;
|
|
@@ -16357,7 +16364,7 @@ var require_derived_progress = __commonJS({
|
|
|
16357
16364
|
if (REGISTRY_FILE_PATTERN.test(file.path)) {
|
|
16358
16365
|
steps.push("Registering extensions");
|
|
16359
16366
|
} else if (EXTENSION_DEFINITION_PATTERN.test(file.path) && file.content) {
|
|
16360
|
-
const type = (0,
|
|
16367
|
+
const type = (0, detect_1.detectExtension)(file.content);
|
|
16361
16368
|
if (type)
|
|
16362
16369
|
steps.push(extensionStep("Editing", type));
|
|
16363
16370
|
}
|
|
@@ -16464,9 +16471,9 @@ var require_utils9 = __commonJS({
|
|
|
16464
16471
|
}
|
|
16465
16472
|
});
|
|
16466
16473
|
|
|
16467
|
-
// dist/plugins-runtime.js
|
|
16474
|
+
// dist/plugin-system/plugins-runtime.js
|
|
16468
16475
|
var require_plugins_runtime = __commonJS({
|
|
16469
|
-
"dist/plugins-runtime.js"(exports2) {
|
|
16476
|
+
"dist/plugin-system/plugins-runtime.js"(exports2) {
|
|
16470
16477
|
"use strict";
|
|
16471
16478
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16472
16479
|
exports2.getActivePlugins = getActivePlugins;
|
|
@@ -16616,15 +16623,15 @@ var require_task_tracker2 = __commonJS({
|
|
|
16616
16623
|
}
|
|
16617
16624
|
});
|
|
16618
16625
|
|
|
16619
|
-
// dist/opencode-integration/tool-usage.js
|
|
16626
|
+
// dist/opencode-integration/execution/tool-usage.js
|
|
16620
16627
|
var require_tool_usage = __commonJS({
|
|
16621
|
-
"dist/opencode-integration/tool-usage.js"(exports2) {
|
|
16628
|
+
"dist/opencode-integration/execution/tool-usage.js"(exports2) {
|
|
16622
16629
|
"use strict";
|
|
16623
16630
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16624
16631
|
exports2.ToolUsageCollector = void 0;
|
|
16625
16632
|
exports2.commandSignature = commandSignature;
|
|
16626
16633
|
exports2.emptyToolUsage = emptyToolUsage;
|
|
16627
|
-
var
|
|
16634
|
+
var subagent_tool_logger_1 = require_subagent_tool_logger();
|
|
16628
16635
|
var MAX_REPORTED_TOOLS = 50;
|
|
16629
16636
|
var MAX_DETAIL_CHARS = 200;
|
|
16630
16637
|
var MAX_DETAIL_LABELS = 2;
|
|
@@ -16661,7 +16668,7 @@ var require_tool_usage = __commonJS({
|
|
|
16661
16668
|
return duration > 0 ? duration : 0;
|
|
16662
16669
|
}
|
|
16663
16670
|
function isCompletedToolCall(event) {
|
|
16664
|
-
if (event.type !== "tool_use" && event.type !==
|
|
16671
|
+
if (event.type !== "tool_use" && event.type !== subagent_tool_logger_1.SUBAGENT_TOOL_EVENT_TYPE) {
|
|
16665
16672
|
return false;
|
|
16666
16673
|
}
|
|
16667
16674
|
if (!event.part?.tool)
|
|
@@ -16717,18 +16724,19 @@ var require_tool_usage = __commonJS({
|
|
|
16717
16724
|
}
|
|
16718
16725
|
});
|
|
16719
16726
|
|
|
16720
|
-
// dist/opencode-integration/process-manager.js
|
|
16727
|
+
// dist/opencode-integration/execution/process-manager.js
|
|
16721
16728
|
var require_process_manager = __commonJS({
|
|
16722
|
-
"dist/opencode-integration/process-manager.js"(exports2) {
|
|
16729
|
+
"dist/opencode-integration/execution/process-manager.js"(exports2) {
|
|
16723
16730
|
"use strict";
|
|
16724
16731
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16725
|
-
exports2.MAX_STARTS_WITHOUT_FINISH = exports2.
|
|
16732
|
+
exports2.MAX_STARTS_WITHOUT_FINISH = exports2.IDLE_CHECK_INTERVAL_MS = exports2.GENERATING_IDLE_TIMEOUT_MS = exports2.IDLE_TIMEOUT_MS = void 0;
|
|
16726
16733
|
exports2.clearTimers = clearTimers;
|
|
16727
16734
|
exports2.killProcess = killProcess;
|
|
16728
16735
|
var logger_12 = require_logger();
|
|
16729
16736
|
exports2.IDLE_TIMEOUT_MS = 6e5;
|
|
16737
|
+
exports2.GENERATING_IDLE_TIMEOUT_MS = 18e4;
|
|
16730
16738
|
exports2.IDLE_CHECK_INTERVAL_MS = 15e3;
|
|
16731
|
-
|
|
16739
|
+
var KILL_GRACE_PERIOD_MS = 5e3;
|
|
16732
16740
|
exports2.MAX_STARTS_WITHOUT_FINISH = 3;
|
|
16733
16741
|
function clearTimers(timers) {
|
|
16734
16742
|
if (timers.timeoutId) {
|
|
@@ -16764,14 +16772,14 @@ var require_process_manager = __commonJS({
|
|
|
16764
16772
|
if (child && !resolved) {
|
|
16765
16773
|
killSignal("SIGKILL");
|
|
16766
16774
|
}
|
|
16767
|
-
},
|
|
16775
|
+
}, KILL_GRACE_PERIOD_MS);
|
|
16768
16776
|
}
|
|
16769
16777
|
}
|
|
16770
16778
|
});
|
|
16771
16779
|
|
|
16772
|
-
// dist/opencode-integration/result-builder.js
|
|
16780
|
+
// dist/opencode-integration/execution/result-builder.js
|
|
16773
16781
|
var require_result_builder = __commonJS({
|
|
16774
|
-
"dist/opencode-integration/result-builder.js"(exports2) {
|
|
16782
|
+
"dist/opencode-integration/execution/result-builder.js"(exports2) {
|
|
16775
16783
|
"use strict";
|
|
16776
16784
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16777
16785
|
exports2.createTimeoutResult = createTimeoutResult;
|
|
@@ -16839,12 +16847,14 @@ var require_result_builder = __commonJS({
|
|
|
16839
16847
|
}
|
|
16840
16848
|
});
|
|
16841
16849
|
|
|
16842
|
-
// dist/opencode-integration/process-handlers.js
|
|
16850
|
+
// dist/opencode-integration/execution/process-handlers.js
|
|
16843
16851
|
var require_process_handlers = __commonJS({
|
|
16844
|
-
"dist/opencode-integration/process-handlers.js"(exports2) {
|
|
16852
|
+
"dist/opencode-integration/execution/process-handlers.js"(exports2) {
|
|
16845
16853
|
"use strict";
|
|
16846
16854
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16847
16855
|
exports2.setupTotalTimeout = setupTotalTimeout;
|
|
16856
|
+
exports2.trackToolActivity = trackToolActivity;
|
|
16857
|
+
exports2.idleBudgetMs = idleBudgetMs;
|
|
16848
16858
|
exports2.setupIdleWatchdog = setupIdleWatchdog;
|
|
16849
16859
|
exports2.trackTurnProgress = trackTurnProgress;
|
|
16850
16860
|
exports2.setupStdoutHandler = setupStdoutHandler;
|
|
@@ -16854,6 +16864,7 @@ var require_process_handlers = __commonJS({
|
|
|
16854
16864
|
var parser_1 = require_parser();
|
|
16855
16865
|
var config_12 = require_config();
|
|
16856
16866
|
var ditto_codegen_types_12 = require_dist4();
|
|
16867
|
+
var subagent_tool_logger_1 = require_subagent_tool_logger();
|
|
16857
16868
|
var process_manager_1 = require_process_manager();
|
|
16858
16869
|
var result_builder_1 = require_result_builder();
|
|
16859
16870
|
var logger_12 = require_logger();
|
|
@@ -16866,15 +16877,43 @@ var require_process_handlers = __commonJS({
|
|
|
16866
16877
|
}
|
|
16867
16878
|
}, config_12.DEFAULT_TIMEOUT_MS);
|
|
16868
16879
|
}
|
|
16880
|
+
function trackToolActivity(state, event) {
|
|
16881
|
+
if (event.type === subagent_tool_logger_1.TOOL_STARTED_EVENT_TYPE) {
|
|
16882
|
+
state.toolActivitySeen = true;
|
|
16883
|
+
const { callID } = event;
|
|
16884
|
+
if (callID)
|
|
16885
|
+
state.inFlightToolCalls.add(callID);
|
|
16886
|
+
return;
|
|
16887
|
+
}
|
|
16888
|
+
if (event.type === "tool_use" || event.type === subagent_tool_logger_1.SUBAGENT_TOOL_EVENT_TYPE) {
|
|
16889
|
+
const callID = event.part?.callID;
|
|
16890
|
+
if (callID)
|
|
16891
|
+
state.inFlightToolCalls.delete(callID);
|
|
16892
|
+
return;
|
|
16893
|
+
}
|
|
16894
|
+
if (event.type === "step_finish")
|
|
16895
|
+
state.inFlightToolCalls.clear();
|
|
16896
|
+
}
|
|
16897
|
+
function idleBudgetMs(state) {
|
|
16898
|
+
if (!state.toolActivitySeen)
|
|
16899
|
+
return process_manager_1.IDLE_TIMEOUT_MS;
|
|
16900
|
+
return state.inFlightToolCalls.size > 0 ? process_manager_1.IDLE_TIMEOUT_MS : process_manager_1.GENERATING_IDLE_TIMEOUT_MS;
|
|
16901
|
+
}
|
|
16869
16902
|
function setupIdleWatchdog(ctx) {
|
|
16870
16903
|
return setInterval(() => {
|
|
16871
16904
|
if (ctx.state.resolved)
|
|
16872
16905
|
return;
|
|
16873
16906
|
const idleTime = Date.now() - ctx.state.lastOutputTime;
|
|
16874
|
-
|
|
16875
|
-
|
|
16907
|
+
const budget = idleBudgetMs(ctx.state);
|
|
16908
|
+
if (idleTime >= budget) {
|
|
16909
|
+
const seconds = Math.round(idleTime / 1e3);
|
|
16910
|
+
logger_12.logger.warn(`[OpenCode] Process appears stuck - no output for ${seconds}s. Killing process.`, {
|
|
16911
|
+
budgetMs: budget,
|
|
16912
|
+
inFlightToolCalls: ctx.state.inFlightToolCalls.size,
|
|
16913
|
+
toolActivitySeen: ctx.state.toolActivitySeen
|
|
16914
|
+
});
|
|
16876
16915
|
(0, process_manager_1.killProcess)(ctx.child, ctx.state.resolved);
|
|
16877
|
-
ctx.finalize((0, result_builder_1.createTimeoutResult)(`Process stuck - no output for ${
|
|
16916
|
+
ctx.finalize((0, result_builder_1.createTimeoutResult)(`Process stuck - no output for ${seconds} seconds (idle timeout)`, ctx.state.stdout, ctx.state.stderr, ctx.startTime));
|
|
16878
16917
|
}
|
|
16879
16918
|
}, process_manager_1.IDLE_CHECK_INTERVAL_MS);
|
|
16880
16919
|
}
|
|
@@ -16901,7 +16940,10 @@ var require_process_handlers = __commonJS({
|
|
|
16901
16940
|
} catch {
|
|
16902
16941
|
logger_12.logger.debug("[OpenCode] stdout", { line: line.slice(0, 200) });
|
|
16903
16942
|
}
|
|
16904
|
-
if (!event
|
|
16943
|
+
if (!event)
|
|
16944
|
+
return null;
|
|
16945
|
+
trackToolActivity(ctx.state, event);
|
|
16946
|
+
if (!trackProgress)
|
|
16905
16947
|
return null;
|
|
16906
16948
|
try {
|
|
16907
16949
|
trackTurnProgress(ctx.state, event);
|
|
@@ -16971,12 +17013,11 @@ var require_process_handlers = __commonJS({
|
|
|
16971
17013
|
}
|
|
16972
17014
|
});
|
|
16973
17015
|
|
|
16974
|
-
// dist/opencode-integration/executor.js
|
|
17016
|
+
// dist/opencode-integration/execution/executor.js
|
|
16975
17017
|
var require_executor = __commonJS({
|
|
16976
|
-
"dist/opencode-integration/executor.js"(exports2) {
|
|
17018
|
+
"dist/opencode-integration/execution/executor.js"(exports2) {
|
|
16977
17019
|
"use strict";
|
|
16978
17020
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16979
|
-
exports2.notifyValidatorOutputsToSlack = notifyValidatorOutputsToSlack;
|
|
16980
17021
|
exports2.classifyAttempt = classifyAttempt;
|
|
16981
17022
|
exports2.executeOpenCode = executeOpenCode;
|
|
16982
17023
|
exports2.resolveFinalRunCost = resolveFinalRunCost;
|
|
@@ -16986,9 +17027,8 @@ var require_executor = __commonJS({
|
|
|
16986
17027
|
var model_knobs_1 = require_model_knobs();
|
|
16987
17028
|
var job_context_storage_12 = require_job_context_storage();
|
|
16988
17029
|
var parser_1 = require_parser();
|
|
16989
|
-
var codeGenerationService_12 = require_codeGenerationService();
|
|
16990
17030
|
var prompts_1 = require_prompts();
|
|
16991
|
-
var
|
|
17031
|
+
var file_changes_1 = require_file_changes();
|
|
16992
17032
|
var cost_tracker_1 = require_cost_tracker();
|
|
16993
17033
|
var task_tracker_1 = require_task_tracker2();
|
|
16994
17034
|
var tool_usage_1 = require_tool_usage();
|
|
@@ -16997,37 +17037,6 @@ var require_executor = __commonJS({
|
|
|
16997
17037
|
var logger_12 = require_logger();
|
|
16998
17038
|
var MAX_RETRIES = 5;
|
|
16999
17039
|
var MAX_STALL_ATTEMPTS = 2;
|
|
17000
|
-
async function notifyValidatorOutputsToSlack(stdout, costUsd) {
|
|
17001
|
-
try {
|
|
17002
|
-
const store = job_context_storage_12.jobContextStorage.getStore();
|
|
17003
|
-
const outputs = (0, parser_1.parseValidatorTaskOutputs)(stdout);
|
|
17004
|
-
if (outputs.length === 0)
|
|
17005
|
-
return;
|
|
17006
|
-
const durationMs = store?.flowStartTime ? Date.now() - store.flowStartTime : void 0;
|
|
17007
|
-
const context = {
|
|
17008
|
-
jobId: store?.jobId,
|
|
17009
|
-
metasiteId: store?.metasiteId,
|
|
17010
|
-
costUsd: costUsd > 0 ? costUsd : void 0,
|
|
17011
|
-
durationMs
|
|
17012
|
-
};
|
|
17013
|
-
for (const output of outputs) {
|
|
17014
|
-
if (!(0, parser_1.shouldReportValidatorOutput)(output)) {
|
|
17015
|
-
continue;
|
|
17016
|
-
}
|
|
17017
|
-
try {
|
|
17018
|
-
await codeGenerationService_12.codeGenerationService.handleValidationErrors(output, context);
|
|
17019
|
-
} catch (err) {
|
|
17020
|
-
logger_12.logger.warn("[OpenCode] Failed to report validator output to Slack", {
|
|
17021
|
-
error: err instanceof Error ? err.message : String(err)
|
|
17022
|
-
});
|
|
17023
|
-
}
|
|
17024
|
-
}
|
|
17025
|
-
} catch (err) {
|
|
17026
|
-
logger_12.logger.warn("[OpenCode] Unexpected error in notifyValidatorOutputsToSlack", {
|
|
17027
|
-
error: err instanceof Error ? err.message : String(err)
|
|
17028
|
-
});
|
|
17029
|
-
}
|
|
17030
|
-
}
|
|
17031
17040
|
function failureReason(result) {
|
|
17032
17041
|
if (result.stalled)
|
|
17033
17042
|
return "stall";
|
|
@@ -17064,7 +17073,7 @@ var require_executor = __commonJS({
|
|
|
17064
17073
|
if (attempt > 1) {
|
|
17065
17074
|
const failureDetail = lastResult?.error?.message || lastResult?.stderr || "Process timed out";
|
|
17066
17075
|
logger_12.logger.info(`[OpenCode] Retry attempt ${attempt}/${MAX_RETRIES} after ${lastFailureReason} - starting fresh session with recovery context`, { reason: lastFailureReason, detail: failureDetail.slice(0, 500) });
|
|
17067
|
-
const filesChanged = await (0,
|
|
17076
|
+
const filesChanged = await (0, file_changes_1.collectGitFileChanges)(options.outputPath, options.gitBaseline);
|
|
17068
17077
|
currentPrompt = (0, prompts_1.buildRecoveryPrompt)(options.prompt, filesChanged, failureDetail, lastFailureReason);
|
|
17069
17078
|
continueSession = false;
|
|
17070
17079
|
}
|
|
@@ -17149,7 +17158,9 @@ var require_executor = __commonJS({
|
|
|
17149
17158
|
lineBuffer: "",
|
|
17150
17159
|
lastOutputTime: Date.now(),
|
|
17151
17160
|
resolved: false,
|
|
17152
|
-
startsWithoutFinish: 0
|
|
17161
|
+
startsWithoutFinish: 0,
|
|
17162
|
+
inFlightToolCalls: /* @__PURE__ */ new Set(),
|
|
17163
|
+
toolActivitySeen: false
|
|
17153
17164
|
};
|
|
17154
17165
|
const timers = {
|
|
17155
17166
|
timeoutId: null,
|
|
@@ -17218,9 +17229,9 @@ var require_executor = __commonJS({
|
|
|
17218
17229
|
}
|
|
17219
17230
|
});
|
|
17220
17231
|
|
|
17221
|
-
// dist/opencode-integration/opencode-runner.js
|
|
17232
|
+
// dist/opencode-integration/execution/opencode-runner.js
|
|
17222
17233
|
var require_opencode_runner = __commonJS({
|
|
17223
|
-
"dist/opencode-integration/opencode-runner.js"(exports2) {
|
|
17234
|
+
"dist/opencode-integration/execution/opencode-runner.js"(exports2) {
|
|
17224
17235
|
"use strict";
|
|
17225
17236
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17226
17237
|
exports2.runOpenCodeInit = runOpenCodeInit;
|
|
@@ -17289,20 +17300,106 @@ var require_opencode_runner = __commonJS({
|
|
|
17289
17300
|
}
|
|
17290
17301
|
});
|
|
17291
17302
|
|
|
17292
|
-
// dist/opencode-integration/
|
|
17293
|
-
var
|
|
17294
|
-
"dist/opencode-integration/
|
|
17303
|
+
// dist/opencode-integration/index.js
|
|
17304
|
+
var require_opencode_integration = __commonJS({
|
|
17305
|
+
"dist/opencode-integration/index.js"(exports2) {
|
|
17295
17306
|
"use strict";
|
|
17296
17307
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17297
|
-
exports2.
|
|
17308
|
+
exports2.OpenCodeTaskTracker = exports2.runOpenCodeGitConflicts = exports2.runOpenCodeAsk = exports2.runOpenCodeIteration = exports2.runOpenCodeInit = void 0;
|
|
17309
|
+
var opencode_runner_1 = require_opencode_runner();
|
|
17310
|
+
Object.defineProperty(exports2, "runOpenCodeInit", { enumerable: true, get: function() {
|
|
17311
|
+
return opencode_runner_1.runOpenCodeInit;
|
|
17312
|
+
} });
|
|
17313
|
+
Object.defineProperty(exports2, "runOpenCodeIteration", { enumerable: true, get: function() {
|
|
17314
|
+
return opencode_runner_1.runOpenCodeIteration;
|
|
17315
|
+
} });
|
|
17316
|
+
Object.defineProperty(exports2, "runOpenCodeAsk", { enumerable: true, get: function() {
|
|
17317
|
+
return opencode_runner_1.runOpenCodeAsk;
|
|
17318
|
+
} });
|
|
17319
|
+
Object.defineProperty(exports2, "runOpenCodeGitConflicts", { enumerable: true, get: function() {
|
|
17320
|
+
return opencode_runner_1.runOpenCodeGitConflicts;
|
|
17321
|
+
} });
|
|
17322
|
+
var task_tracker_1 = require_task_tracker2();
|
|
17323
|
+
Object.defineProperty(exports2, "OpenCodeTaskTracker", { enumerable: true, get: function() {
|
|
17324
|
+
return task_tracker_1.OpenCodeTaskTracker;
|
|
17325
|
+
} });
|
|
17326
|
+
}
|
|
17327
|
+
});
|
|
17328
|
+
|
|
17329
|
+
// dist/orchestrators/opencode-orchestrator.js
|
|
17330
|
+
var require_opencode_orchestrator = __commonJS({
|
|
17331
|
+
"dist/orchestrators/opencode-orchestrator.js"(exports2) {
|
|
17332
|
+
"use strict";
|
|
17333
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17334
|
+
exports2.OpenCodeOrchestrator = void 0;
|
|
17335
|
+
var ditto_codegen_types_12 = require_dist4();
|
|
17336
|
+
var DittoEventEmitter_1 = require_DittoEventEmitter();
|
|
17337
|
+
var opencode_integration_1 = require_opencode_integration();
|
|
17338
|
+
var logger_12 = require_logger();
|
|
17339
|
+
var OpenCodeOrchestrator = class extends DittoEventEmitter_1.DittoEventEmitter {
|
|
17340
|
+
constructor() {
|
|
17341
|
+
super();
|
|
17342
|
+
}
|
|
17343
|
+
async generateCode(request) {
|
|
17344
|
+
const { blueprint, outputPath, projectId, chatHistory, gitBaseline } = request;
|
|
17345
|
+
this.emitEvent("start:init", {
|
|
17346
|
+
appName: blueprint.appName ?? "",
|
|
17347
|
+
summary: blueprint.summary ?? "",
|
|
17348
|
+
outputPath,
|
|
17349
|
+
extensionsCount: blueprint.extensions?.length || 0
|
|
17350
|
+
});
|
|
17351
|
+
const start = Date.now();
|
|
17352
|
+
this.emitEvent("opencode:start", { outputPath });
|
|
17353
|
+
const result = await (0, opencode_integration_1.runOpenCodeInit)({
|
|
17354
|
+
blueprint,
|
|
17355
|
+
outputPath,
|
|
17356
|
+
projectId,
|
|
17357
|
+
chatHistory,
|
|
17358
|
+
gitBaseline,
|
|
17359
|
+
onStdout: (data) => {
|
|
17360
|
+
this.emitEvent("opencode:output", { data });
|
|
17361
|
+
},
|
|
17362
|
+
onStderr: (data) => {
|
|
17363
|
+
logger_12.logger.error("[OpenCode] stderr", { output: data });
|
|
17364
|
+
}
|
|
17365
|
+
});
|
|
17366
|
+
this.lastUsage = result.usage;
|
|
17367
|
+
this.lastStdout = result.stdout;
|
|
17368
|
+
const durationMs = Date.now() - start;
|
|
17369
|
+
if (!result.success) {
|
|
17370
|
+
this.emitEvent("opencode:error", {
|
|
17371
|
+
error: result.error?.message,
|
|
17372
|
+
exitCode: result.exitCode,
|
|
17373
|
+
durationMs
|
|
17374
|
+
});
|
|
17375
|
+
throw result.error ?? new ditto_codegen_types_12.ProcessExecutionError(`Code generation failed (exit code ${result.exitCode})`, {
|
|
17376
|
+
processType: ditto_codegen_types_12.ProcessType.EXECUTION,
|
|
17377
|
+
exitCode: result.exitCode ?? void 0
|
|
17378
|
+
});
|
|
17379
|
+
}
|
|
17380
|
+
this.emitEvent("opencode:done", { durationMs });
|
|
17381
|
+
this.emitEvent("finish:init", { outputPath, durationMs });
|
|
17382
|
+
return result;
|
|
17383
|
+
}
|
|
17384
|
+
};
|
|
17385
|
+
exports2.OpenCodeOrchestrator = OpenCodeOrchestrator;
|
|
17386
|
+
OpenCodeOrchestrator.DEFAULT_OUTPUT_PATH = "generated-app";
|
|
17387
|
+
}
|
|
17388
|
+
});
|
|
17389
|
+
|
|
17390
|
+
// dist/extension-reporting/metadata.js
|
|
17391
|
+
var require_metadata = __commonJS({
|
|
17392
|
+
"dist/extension-reporting/metadata.js"(exports2) {
|
|
17393
|
+
"use strict";
|
|
17394
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17395
|
+
exports2.buildJobExtension = exports2.resolveFilePath = exports2.isFileInExtensionFolder = void 0;
|
|
17298
17396
|
exports2.collectDataCollectionEntries = collectDataCollectionEntries;
|
|
17299
17397
|
var path_12 = require("path");
|
|
17300
17398
|
var promises_1 = require("fs/promises");
|
|
17301
|
-
var
|
|
17399
|
+
var detect_1 = require_detect();
|
|
17302
17400
|
var DATA_COLLECTION_MARKER = /import\s+(?:type\s+)?\{[^}]*\bDataCollection\b[^}]*\}\s+from\s+['"](?:@wix\/astro\/builders|@wix\/custom-extensions)['"]/;
|
|
17303
17401
|
var getExtensionDirectory = (extensionDefinitionPath) => `${path_12.posix.dirname(extensionDefinitionPath)}/`;
|
|
17304
|
-
|
|
17305
|
-
var isFileInExtensionFolder = (filePath, extensionDefinitionPath) => filePath === extensionDefinitionPath || filePath.startsWith((0, exports2.getExtensionDirectory)(extensionDefinitionPath));
|
|
17402
|
+
var isFileInExtensionFolder = (filePath, extensionDefinitionPath) => filePath === extensionDefinitionPath || filePath.startsWith(getExtensionDirectory(extensionDefinitionPath));
|
|
17306
17403
|
exports2.isFileInExtensionFolder = isFileInExtensionFolder;
|
|
17307
17404
|
var resolveFilePath = (outputPath, filePath) => (0, path_12.isAbsolute)(filePath) ? filePath : (0, path_12.join)(outputPath, filePath);
|
|
17308
17405
|
exports2.resolveFilePath = resolveFilePath;
|
|
@@ -17324,51 +17421,51 @@ var require_extension_metadata = __commonJS({
|
|
|
17324
17421
|
return entries;
|
|
17325
17422
|
}
|
|
17326
17423
|
var buildJobExtension = (definitionPath, extensionType, contentForTitle, titlePath, files) => {
|
|
17327
|
-
const routePath = (0,
|
|
17328
|
-
const id = (0,
|
|
17424
|
+
const routePath = (0, detect_1.matchQuotedExtensionConfigProperty)(contentForTitle, "routePath");
|
|
17425
|
+
const id = (0, detect_1.matchQuotedExtensionConfigProperty)(contentForTitle, "id");
|
|
17329
17426
|
return {
|
|
17330
17427
|
path: definitionPath,
|
|
17331
17428
|
extensionType,
|
|
17332
|
-
title: (0,
|
|
17429
|
+
title: (0, detect_1.extractExtensionDisplayTitle)(contentForTitle, titlePath),
|
|
17333
17430
|
...routePath !== null && { routePath },
|
|
17334
17431
|
...id !== null && { id },
|
|
17335
17432
|
files: [...files],
|
|
17336
|
-
isSpi: (0,
|
|
17433
|
+
isSpi: (0, detect_1.isSpiExtension)(extensionType)
|
|
17337
17434
|
};
|
|
17338
17435
|
};
|
|
17339
17436
|
exports2.buildJobExtension = buildJobExtension;
|
|
17340
17437
|
}
|
|
17341
17438
|
});
|
|
17342
17439
|
|
|
17343
|
-
// dist/
|
|
17344
|
-
var
|
|
17345
|
-
"dist/
|
|
17440
|
+
// dist/extension-reporting/collect-created.js
|
|
17441
|
+
var require_collect_created = __commonJS({
|
|
17442
|
+
"dist/extension-reporting/collect-created.js"(exports2) {
|
|
17346
17443
|
"use strict";
|
|
17347
17444
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17348
17445
|
exports2.collectInsertedExtensionsMetadata = collectInsertedExtensionsMetadata;
|
|
17349
17446
|
var promises_1 = require("fs/promises");
|
|
17350
17447
|
var ditto_codegen_types_12 = require_dist4();
|
|
17351
|
-
var
|
|
17352
|
-
var
|
|
17448
|
+
var detect_1 = require_detect();
|
|
17449
|
+
var metadata_1 = require_metadata();
|
|
17353
17450
|
async function collectInsertedExtensionsMetadata(outputPath, files) {
|
|
17354
17451
|
const results = [];
|
|
17355
17452
|
for (const fileChange of files) {
|
|
17356
17453
|
if (fileChange.operation !== ditto_codegen_types_12.ExtensionGenerationOperation.INSERT)
|
|
17357
17454
|
continue;
|
|
17358
|
-
if (!(0,
|
|
17455
|
+
if (!(0, detect_1.isExtensionsFile)(fileChange.path))
|
|
17359
17456
|
continue;
|
|
17360
17457
|
try {
|
|
17361
|
-
const content = await (0, promises_1.readFile)((0,
|
|
17362
|
-
const extensionType = (0,
|
|
17458
|
+
const content = await (0, promises_1.readFile)((0, metadata_1.resolveFilePath)(outputPath, fileChange.path), "utf-8");
|
|
17459
|
+
const extensionType = (0, detect_1.detectExtension)(content);
|
|
17363
17460
|
if (!extensionType)
|
|
17364
17461
|
continue;
|
|
17365
|
-
const folderFiles = files.filter((file) => (0,
|
|
17462
|
+
const folderFiles = files.filter((file) => (0, metadata_1.isFileInExtensionFolder)(file.path, fileChange.path));
|
|
17366
17463
|
if (extensionType === "dataCollections") {
|
|
17367
|
-
const dataCollectionEntries = await (0,
|
|
17464
|
+
const dataCollectionEntries = await (0, metadata_1.collectDataCollectionEntries)(outputPath, fileChange.path, folderFiles);
|
|
17368
17465
|
results.push(...dataCollectionEntries);
|
|
17369
17466
|
continue;
|
|
17370
17467
|
}
|
|
17371
|
-
results.push((0,
|
|
17468
|
+
results.push((0, metadata_1.buildJobExtension)(fileChange.path, extensionType, content, fileChange.path, folderFiles));
|
|
17372
17469
|
} catch {
|
|
17373
17470
|
continue;
|
|
17374
17471
|
}
|
|
@@ -17378,9 +17475,9 @@ var require_collect_extensions_created = __commonJS({
|
|
|
17378
17475
|
}
|
|
17379
17476
|
});
|
|
17380
17477
|
|
|
17381
|
-
// dist/
|
|
17382
|
-
var
|
|
17383
|
-
"dist/
|
|
17478
|
+
// dist/extension-reporting/collect-updated.js
|
|
17479
|
+
var require_collect_updated = __commonJS({
|
|
17480
|
+
"dist/extension-reporting/collect-updated.js"(exports2) {
|
|
17384
17481
|
"use strict";
|
|
17385
17482
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17386
17483
|
exports2.collectUpdatedExtensionsMetadata = collectUpdatedExtensionsMetadata;
|
|
@@ -17388,12 +17485,12 @@ var require_collect_extensions_updated = __commonJS({
|
|
|
17388
17485
|
var path_12 = require("path");
|
|
17389
17486
|
var util_1 = require("util");
|
|
17390
17487
|
var promises_1 = require("fs/promises");
|
|
17391
|
-
var
|
|
17488
|
+
var detect_1 = require_detect();
|
|
17392
17489
|
var logger_12 = require_logger();
|
|
17393
|
-
var
|
|
17490
|
+
var metadata_1 = require_metadata();
|
|
17394
17491
|
var execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
|
|
17395
17492
|
var ownsItsFolder = (candidate) => {
|
|
17396
|
-
if (!(0,
|
|
17493
|
+
if (!(0, detect_1.isExtensionsFile)(candidate))
|
|
17397
17494
|
return false;
|
|
17398
17495
|
const directory = path_12.posix.dirname(candidate);
|
|
17399
17496
|
return directory !== "." && path_12.posix.dirname(directory) !== ".";
|
|
@@ -17413,7 +17510,7 @@ var require_collect_extensions_updated = __commonJS({
|
|
|
17413
17510
|
}
|
|
17414
17511
|
}
|
|
17415
17512
|
var resolveOwningDefinitionPath = (filePath, candidates) => {
|
|
17416
|
-
if ((0,
|
|
17513
|
+
if ((0, detect_1.isExtensionsFile)(filePath))
|
|
17417
17514
|
return filePath;
|
|
17418
17515
|
let longest;
|
|
17419
17516
|
let longestFolderLength = -1;
|
|
@@ -17429,146 +17526,51 @@ var require_collect_extensions_updated = __commonJS({
|
|
|
17429
17526
|
async function collectUpdatedExtensionsMetadata(outputPath, files, insertedDefinitionPaths) {
|
|
17430
17527
|
const candidates = await listCandidateDefinitionPaths(outputPath);
|
|
17431
17528
|
const definitionPaths = /* @__PURE__ */ new Set();
|
|
17432
|
-
for (const fileChange of files) {
|
|
17433
|
-
const definitionPath = resolveOwningDefinitionPath(fileChange.path, candidates);
|
|
17434
|
-
if (definitionPath && !insertedDefinitionPaths.has(definitionPath)) {
|
|
17435
|
-
definitionPaths.add(definitionPath);
|
|
17436
|
-
}
|
|
17437
|
-
}
|
|
17438
|
-
const results = [];
|
|
17439
|
-
for (const definitionPath of definitionPaths) {
|
|
17440
|
-
try {
|
|
17441
|
-
const content = await (0, promises_1.readFile)((0,
|
|
17442
|
-
const extensionType = (0,
|
|
17443
|
-
if (!extensionType)
|
|
17444
|
-
continue;
|
|
17445
|
-
const folderFiles = files.filter((file) => (0,
|
|
17446
|
-
if (extensionType === "dataCollections") {
|
|
17447
|
-
const dataCollectionEntries = await (0,
|
|
17448
|
-
results.push(...dataCollectionEntries);
|
|
17449
|
-
continue;
|
|
17450
|
-
}
|
|
17451
|
-
results.push((0,
|
|
17452
|
-
} catch {
|
|
17453
|
-
continue;
|
|
17454
|
-
}
|
|
17455
|
-
}
|
|
17456
|
-
return results;
|
|
17457
|
-
}
|
|
17458
|
-
}
|
|
17459
|
-
});
|
|
17460
|
-
|
|
17461
|
-
// dist/opencode-integration/extensions-job-payload.js
|
|
17462
|
-
var require_extensions_job_payload = __commonJS({
|
|
17463
|
-
"dist/opencode-integration/extensions-job-payload.js"(exports2) {
|
|
17464
|
-
"use strict";
|
|
17465
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17466
|
-
exports2.buildExtensionsJobPayload = buildExtensionsJobPayload;
|
|
17467
|
-
var ditto_codegen_types_12 = require_dist4();
|
|
17468
|
-
var constants_1 = require_constants5();
|
|
17469
|
-
var collect_extensions_created_1 = require_collect_extensions_created();
|
|
17470
|
-
var collect_extensions_updated_1 = require_collect_extensions_updated();
|
|
17471
|
-
async function buildExtensionsJobPayload(outputPath, files) {
|
|
17472
|
-
const created = await (0, collect_extensions_created_1.collectInsertedExtensionsMetadata)(outputPath, files);
|
|
17473
|
-
const insertedDefinitionPaths = new Set(files.filter((file) => file.operation === ditto_codegen_types_12.ExtensionGenerationOperation.INSERT && (0, constants_1.isExtensionsFile)(file.path)).map((file) => file.path));
|
|
17474
|
-
const updated = await (0, collect_extensions_updated_1.collectUpdatedExtensionsMetadata)(outputPath, files, insertedDefinitionPaths);
|
|
17475
|
-
return { created, updated };
|
|
17476
|
-
}
|
|
17477
|
-
}
|
|
17478
|
-
});
|
|
17479
|
-
|
|
17480
|
-
// dist/opencode-integration/index.js
|
|
17481
|
-
var require_opencode_integration = __commonJS({
|
|
17482
|
-
"dist/opencode-integration/index.js"(exports2) {
|
|
17483
|
-
"use strict";
|
|
17484
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17485
|
-
exports2.buildExtensionsJobPayload = exports2.collectInsertedExtensionsMetadata = exports2.OpenCodeTaskTracker = exports2.runOpenCodeGitConflicts = exports2.runOpenCodeAsk = exports2.runOpenCodeIteration = exports2.runOpenCodeInit = void 0;
|
|
17486
|
-
var opencode_runner_1 = require_opencode_runner();
|
|
17487
|
-
Object.defineProperty(exports2, "runOpenCodeInit", { enumerable: true, get: function() {
|
|
17488
|
-
return opencode_runner_1.runOpenCodeInit;
|
|
17489
|
-
} });
|
|
17490
|
-
Object.defineProperty(exports2, "runOpenCodeIteration", { enumerable: true, get: function() {
|
|
17491
|
-
return opencode_runner_1.runOpenCodeIteration;
|
|
17492
|
-
} });
|
|
17493
|
-
Object.defineProperty(exports2, "runOpenCodeAsk", { enumerable: true, get: function() {
|
|
17494
|
-
return opencode_runner_1.runOpenCodeAsk;
|
|
17495
|
-
} });
|
|
17496
|
-
Object.defineProperty(exports2, "runOpenCodeGitConflicts", { enumerable: true, get: function() {
|
|
17497
|
-
return opencode_runner_1.runOpenCodeGitConflicts;
|
|
17498
|
-
} });
|
|
17499
|
-
var task_tracker_1 = require_task_tracker2();
|
|
17500
|
-
Object.defineProperty(exports2, "OpenCodeTaskTracker", { enumerable: true, get: function() {
|
|
17501
|
-
return task_tracker_1.OpenCodeTaskTracker;
|
|
17502
|
-
} });
|
|
17503
|
-
var collect_extensions_created_1 = require_collect_extensions_created();
|
|
17504
|
-
Object.defineProperty(exports2, "collectInsertedExtensionsMetadata", { enumerable: true, get: function() {
|
|
17505
|
-
return collect_extensions_created_1.collectInsertedExtensionsMetadata;
|
|
17506
|
-
} });
|
|
17507
|
-
var extensions_job_payload_1 = require_extensions_job_payload();
|
|
17508
|
-
Object.defineProperty(exports2, "buildExtensionsJobPayload", { enumerable: true, get: function() {
|
|
17509
|
-
return extensions_job_payload_1.buildExtensionsJobPayload;
|
|
17510
|
-
} });
|
|
17529
|
+
for (const fileChange of files) {
|
|
17530
|
+
const definitionPath = resolveOwningDefinitionPath(fileChange.path, candidates);
|
|
17531
|
+
if (definitionPath && !insertedDefinitionPaths.has(definitionPath)) {
|
|
17532
|
+
definitionPaths.add(definitionPath);
|
|
17533
|
+
}
|
|
17534
|
+
}
|
|
17535
|
+
const results = [];
|
|
17536
|
+
for (const definitionPath of definitionPaths) {
|
|
17537
|
+
try {
|
|
17538
|
+
const content = await (0, promises_1.readFile)((0, metadata_1.resolveFilePath)(outputPath, definitionPath), "utf-8");
|
|
17539
|
+
const extensionType = (0, detect_1.detectExtension)(content);
|
|
17540
|
+
if (!extensionType)
|
|
17541
|
+
continue;
|
|
17542
|
+
const folderFiles = files.filter((file) => (0, metadata_1.isFileInExtensionFolder)(file.path, definitionPath));
|
|
17543
|
+
if (extensionType === "dataCollections") {
|
|
17544
|
+
const dataCollectionEntries = await (0, metadata_1.collectDataCollectionEntries)(outputPath, definitionPath, folderFiles);
|
|
17545
|
+
results.push(...dataCollectionEntries);
|
|
17546
|
+
continue;
|
|
17547
|
+
}
|
|
17548
|
+
results.push((0, metadata_1.buildJobExtension)(definitionPath, extensionType, content, definitionPath, folderFiles));
|
|
17549
|
+
} catch {
|
|
17550
|
+
continue;
|
|
17551
|
+
}
|
|
17552
|
+
}
|
|
17553
|
+
return results;
|
|
17554
|
+
}
|
|
17511
17555
|
}
|
|
17512
17556
|
});
|
|
17513
17557
|
|
|
17514
|
-
// dist/
|
|
17515
|
-
var
|
|
17516
|
-
"dist/
|
|
17558
|
+
// dist/extension-reporting/job-payload.js
|
|
17559
|
+
var require_job_payload2 = __commonJS({
|
|
17560
|
+
"dist/extension-reporting/job-payload.js"(exports2) {
|
|
17517
17561
|
"use strict";
|
|
17518
17562
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17519
|
-
exports2.
|
|
17563
|
+
exports2.buildExtensionsJobPayload = buildExtensionsJobPayload;
|
|
17520
17564
|
var ditto_codegen_types_12 = require_dist4();
|
|
17521
|
-
var
|
|
17522
|
-
var
|
|
17523
|
-
var
|
|
17524
|
-
|
|
17525
|
-
|
|
17526
|
-
|
|
17527
|
-
|
|
17528
|
-
|
|
17529
|
-
|
|
17530
|
-
this.emitEvent("start:init", {
|
|
17531
|
-
appName: blueprint.appName ?? "",
|
|
17532
|
-
summary: blueprint.summary ?? "",
|
|
17533
|
-
outputPath,
|
|
17534
|
-
extensionsCount: blueprint.extensions?.length || 0
|
|
17535
|
-
});
|
|
17536
|
-
const start = Date.now();
|
|
17537
|
-
this.emitEvent("opencode:start", { outputPath });
|
|
17538
|
-
const result = await (0, opencode_integration_1.runOpenCodeInit)({
|
|
17539
|
-
blueprint,
|
|
17540
|
-
outputPath,
|
|
17541
|
-
projectId,
|
|
17542
|
-
chatHistory,
|
|
17543
|
-
gitBaseline,
|
|
17544
|
-
onStdout: (data) => {
|
|
17545
|
-
this.emitEvent("opencode:output", { data });
|
|
17546
|
-
},
|
|
17547
|
-
onStderr: (data) => {
|
|
17548
|
-
logger_12.logger.error("[OpenCode] stderr", { output: data });
|
|
17549
|
-
}
|
|
17550
|
-
});
|
|
17551
|
-
this.lastUsage = result.usage;
|
|
17552
|
-
this.lastStdout = result.stdout;
|
|
17553
|
-
const durationMs = Date.now() - start;
|
|
17554
|
-
if (!result.success) {
|
|
17555
|
-
this.emitEvent("opencode:error", {
|
|
17556
|
-
error: result.error?.message,
|
|
17557
|
-
exitCode: result.exitCode,
|
|
17558
|
-
durationMs
|
|
17559
|
-
});
|
|
17560
|
-
throw result.error ?? new ditto_codegen_types_12.ProcessExecutionError(`Code generation failed (exit code ${result.exitCode})`, {
|
|
17561
|
-
processType: ditto_codegen_types_12.ProcessType.EXECUTION,
|
|
17562
|
-
exitCode: result.exitCode ?? void 0
|
|
17563
|
-
});
|
|
17564
|
-
}
|
|
17565
|
-
this.emitEvent("opencode:done", { durationMs });
|
|
17566
|
-
this.emitEvent("finish:init", { outputPath, durationMs });
|
|
17567
|
-
return result;
|
|
17568
|
-
}
|
|
17569
|
-
};
|
|
17570
|
-
exports2.OpenCodeOrchestrator = OpenCodeOrchestrator;
|
|
17571
|
-
OpenCodeOrchestrator.DEFAULT_OUTPUT_PATH = "generated-app";
|
|
17565
|
+
var detect_1 = require_detect();
|
|
17566
|
+
var collect_created_1 = require_collect_created();
|
|
17567
|
+
var collect_updated_1 = require_collect_updated();
|
|
17568
|
+
async function buildExtensionsJobPayload(outputPath, files) {
|
|
17569
|
+
const created = await (0, collect_created_1.collectInsertedExtensionsMetadata)(outputPath, files);
|
|
17570
|
+
const insertedDefinitionPaths = new Set(files.filter((file) => file.operation === ditto_codegen_types_12.ExtensionGenerationOperation.INSERT && (0, detect_1.isExtensionsFile)(file.path)).map((file) => file.path));
|
|
17571
|
+
const updated = await (0, collect_updated_1.collectUpdatedExtensionsMetadata)(outputPath, files, insertedDefinitionPaths);
|
|
17572
|
+
return { created, updated };
|
|
17573
|
+
}
|
|
17572
17574
|
}
|
|
17573
17575
|
});
|
|
17574
17576
|
|
|
@@ -17646,8 +17648,8 @@ var require_codegen_flow_helpers = __commonJS({
|
|
|
17646
17648
|
exports2.getOutputPath = getOutputPath;
|
|
17647
17649
|
var path_12 = __importDefault2(require("path"));
|
|
17648
17650
|
var codeGenerationService_12 = require_codeGenerationService();
|
|
17649
|
-
var
|
|
17650
|
-
var
|
|
17651
|
+
var file_changes_1 = require_file_changes();
|
|
17652
|
+
var job_payload_1 = require_job_payload2();
|
|
17651
17653
|
var agent_io_1 = require_agent_io();
|
|
17652
17654
|
var utils_12 = require_utils9();
|
|
17653
17655
|
var DEFAULT_OUTPUT_PATH = "generated-app";
|
|
@@ -17655,8 +17657,8 @@ var require_codegen_flow_helpers = __commonJS({
|
|
|
17655
17657
|
await codeGenerationService_12.codeGenerationService.updateJob(jobContext.jobId, payload);
|
|
17656
17658
|
}
|
|
17657
17659
|
async function buildFailedRunPayload(error, outputPath, gitBaseline) {
|
|
17658
|
-
const files = await (0,
|
|
17659
|
-
const extensions = await (0,
|
|
17660
|
+
const files = await (0, file_changes_1.collectGitFileChanges)(outputPath, gitBaseline);
|
|
17661
|
+
const extensions = await (0, job_payload_1.buildExtensionsJobPayload)(outputPath, files);
|
|
17660
17662
|
return {
|
|
17661
17663
|
requiredPermissions: [],
|
|
17662
17664
|
error,
|
|
@@ -17677,22 +17679,22 @@ var require_codegen_flow_helpers = __commonJS({
|
|
|
17677
17679
|
}
|
|
17678
17680
|
});
|
|
17679
17681
|
|
|
17680
|
-
// dist/
|
|
17682
|
+
// dist/extension-reporting/inject-created-by.js
|
|
17681
17683
|
var require_inject_created_by = __commonJS({
|
|
17682
|
-
"dist/
|
|
17684
|
+
"dist/extension-reporting/inject-created-by.js"(exports2) {
|
|
17683
17685
|
"use strict";
|
|
17684
17686
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17685
17687
|
exports2.injectCreatedByIntoExtensionFiles = injectCreatedByIntoExtensionFiles;
|
|
17686
17688
|
var promises_1 = require("fs/promises");
|
|
17687
17689
|
var path_12 = require("path");
|
|
17688
17690
|
var logger_12 = require_logger();
|
|
17689
|
-
var
|
|
17691
|
+
var detect_1 = require_detect();
|
|
17690
17692
|
async function injectCreatedByIntoExtensionFiles(cwd, createdExtensions) {
|
|
17691
17693
|
for (const { path: filePath } of createdExtensions) {
|
|
17692
17694
|
const absolutePath = (0, path_12.join)(cwd, filePath);
|
|
17693
17695
|
try {
|
|
17694
17696
|
const original = await (0, promises_1.readFile)(absolutePath, "utf-8");
|
|
17695
|
-
const injected = (0,
|
|
17697
|
+
const injected = (0, detect_1.injectCreatedBy)(original);
|
|
17696
17698
|
if (injected !== original) {
|
|
17697
17699
|
await (0, promises_1.writeFile)(absolutePath, injected, "utf-8");
|
|
17698
17700
|
logger_12.logger.info("[OpenCode] Injected createdBy into extension file", {
|
|
@@ -22518,9 +22520,9 @@ var require_src2 = __commonJS({
|
|
|
22518
22520
|
}
|
|
22519
22521
|
});
|
|
22520
22522
|
|
|
22521
|
-
// dist/
|
|
22522
|
-
var
|
|
22523
|
-
"dist/
|
|
22523
|
+
// dist/telemetry/bi-logger.js
|
|
22524
|
+
var require_bi_logger2 = __commonJS({
|
|
22525
|
+
"dist/telemetry/bi-logger.js"(exports2) {
|
|
22524
22526
|
"use strict";
|
|
22525
22527
|
var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
|
|
22526
22528
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
@@ -22539,9 +22541,9 @@ var require_biLogger = __commonJS({
|
|
|
22539
22541
|
}
|
|
22540
22542
|
});
|
|
22541
22543
|
|
|
22542
|
-
// dist/
|
|
22543
|
-
var
|
|
22544
|
-
"dist/
|
|
22544
|
+
// dist/telemetry/bi-events.js
|
|
22545
|
+
var require_bi_events = __commonJS({
|
|
22546
|
+
"dist/telemetry/bi-events.js"(exports2) {
|
|
22545
22547
|
"use strict";
|
|
22546
22548
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
22547
22549
|
exports2.reportSessionStart = reportSessionStart;
|
|
@@ -22550,7 +22552,7 @@ var require_biEvents = __commonJS({
|
|
|
22550
22552
|
var v2_1 = require_v2();
|
|
22551
22553
|
var v2_2 = require_v22();
|
|
22552
22554
|
var types_1 = require_types_impl();
|
|
22553
|
-
var
|
|
22555
|
+
var bi_logger_1 = require_bi_logger2();
|
|
22554
22556
|
var logger_12 = require_logger();
|
|
22555
22557
|
var MAX_JOB_INPUT_LENGTH = 3e4;
|
|
22556
22558
|
var TRUNCATION_SUFFIX = "\u2026";
|
|
@@ -22588,7 +22590,7 @@ var require_biEvents = __commonJS({
|
|
|
22588
22590
|
if (report.environment === types_1.Environment.APP_BUILDER) {
|
|
22589
22591
|
logger_12.logger.info("Reporting BI event 200 (session start)", devibeParams);
|
|
22590
22592
|
try {
|
|
22591
|
-
await
|
|
22593
|
+
await bi_logger_1.biLogger.report((0, v2_1.devibeCodegenAgentSessionStartSrc196Evid200)(devibeParams));
|
|
22592
22594
|
} catch (err) {
|
|
22593
22595
|
logger_12.logger.warn("BI event 200 report failed", { error: err });
|
|
22594
22596
|
}
|
|
@@ -22606,7 +22608,7 @@ var require_biEvents = __commonJS({
|
|
|
22606
22608
|
};
|
|
22607
22609
|
logger_12.logger.info("Reporting BI event 299 (generic session start)", codegenAgentParams);
|
|
22608
22610
|
try {
|
|
22609
|
-
await
|
|
22611
|
+
await bi_logger_1.biLogger.report((0, v2_2.codegenAgentSessionStartSrc11Evid299)(codegenAgentParams));
|
|
22610
22612
|
} catch (err) {
|
|
22611
22613
|
logger_12.logger.warn("BI event 299 report failed", { error: err });
|
|
22612
22614
|
}
|
|
@@ -22633,7 +22635,7 @@ var require_biEvents = __commonJS({
|
|
|
22633
22635
|
if (report.environment === types_1.Environment.APP_BUILDER) {
|
|
22634
22636
|
logger_12.logger.info("Reporting BI event 201 (session end)", devibeParams);
|
|
22635
22637
|
try {
|
|
22636
|
-
await
|
|
22638
|
+
await bi_logger_1.biLogger.report((0, v2_1.devibeCodegenAgentSessionEndSrc196Evid201)(devibeParams));
|
|
22637
22639
|
} catch (err) {
|
|
22638
22640
|
logger_12.logger.warn("BI event 201 report failed", { error: err });
|
|
22639
22641
|
}
|
|
@@ -22655,7 +22657,7 @@ var require_biEvents = __commonJS({
|
|
|
22655
22657
|
};
|
|
22656
22658
|
logger_12.logger.info("Reporting BI event 304 (generic session end)", codegenAgentParams);
|
|
22657
22659
|
try {
|
|
22658
|
-
await
|
|
22660
|
+
await bi_logger_1.biLogger.report((0, v2_2.codegenAgentSessionEndSrc11Evid304)(codegenAgentParams));
|
|
22659
22661
|
} catch (err) {
|
|
22660
22662
|
logger_12.logger.warn("BI event 304 report failed", { error: err });
|
|
22661
22663
|
}
|
|
@@ -22682,7 +22684,7 @@ var require_biEvents = __commonJS({
|
|
|
22682
22684
|
if (report.environment === types_1.Environment.APP_BUILDER) {
|
|
22683
22685
|
logger_12.logger.info("Reporting BI event 202 (session error)", devibeParams);
|
|
22684
22686
|
try {
|
|
22685
|
-
await
|
|
22687
|
+
await bi_logger_1.biLogger.report((0, v2_1.devibeCodegenAgentSessionErrorSrc196Evid202)(devibeParams));
|
|
22686
22688
|
} catch (err) {
|
|
22687
22689
|
logger_12.logger.warn("BI event 202 report failed", { error: err });
|
|
22688
22690
|
}
|
|
@@ -22705,7 +22707,7 @@ var require_biEvents = __commonJS({
|
|
|
22705
22707
|
};
|
|
22706
22708
|
logger_12.logger.info("Reporting BI event 305 (generic session error)", codegenAgentParams);
|
|
22707
22709
|
try {
|
|
22708
|
-
await
|
|
22710
|
+
await bi_logger_1.biLogger.report((0, v2_2.codegenAgentSessionErrorSrc11Evid305)(codegenAgentParams));
|
|
22709
22711
|
} catch (err) {
|
|
22710
22712
|
logger_12.logger.warn("BI event 305 report failed", { error: err });
|
|
22711
22713
|
}
|
|
@@ -22713,9 +22715,53 @@ var require_biEvents = __commonJS({
|
|
|
22713
22715
|
}
|
|
22714
22716
|
});
|
|
22715
22717
|
|
|
22716
|
-
// dist/opencode-integration/
|
|
22717
|
-
var
|
|
22718
|
-
"dist/opencode-integration/
|
|
22718
|
+
// dist/opencode-integration/slack-reports/validator-outputs.js
|
|
22719
|
+
var require_validator_outputs = __commonJS({
|
|
22720
|
+
"dist/opencode-integration/slack-reports/validator-outputs.js"(exports2) {
|
|
22721
|
+
"use strict";
|
|
22722
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
22723
|
+
exports2.notifyValidatorOutputsToSlack = notifyValidatorOutputsToSlack;
|
|
22724
|
+
var logger_12 = require_logger();
|
|
22725
|
+
var job_context_storage_12 = require_job_context_storage();
|
|
22726
|
+
var codeGenerationService_12 = require_codeGenerationService();
|
|
22727
|
+
var parser_1 = require_parser();
|
|
22728
|
+
async function notifyValidatorOutputsToSlack(stdout, costUsd) {
|
|
22729
|
+
try {
|
|
22730
|
+
const store = job_context_storage_12.jobContextStorage.getStore();
|
|
22731
|
+
const outputs = (0, parser_1.parseValidatorTaskOutputs)(stdout);
|
|
22732
|
+
if (outputs.length === 0)
|
|
22733
|
+
return;
|
|
22734
|
+
const durationMs = store?.flowStartTime ? Date.now() - store.flowStartTime : void 0;
|
|
22735
|
+
const context = {
|
|
22736
|
+
jobId: store?.jobId,
|
|
22737
|
+
metasiteId: store?.metasiteId,
|
|
22738
|
+
costUsd: costUsd > 0 ? costUsd : void 0,
|
|
22739
|
+
durationMs
|
|
22740
|
+
};
|
|
22741
|
+
for (const output of outputs) {
|
|
22742
|
+
if (!(0, parser_1.shouldReportValidatorOutput)(output)) {
|
|
22743
|
+
continue;
|
|
22744
|
+
}
|
|
22745
|
+
try {
|
|
22746
|
+
await codeGenerationService_12.codeGenerationService.handleValidationErrors(output, context);
|
|
22747
|
+
} catch (err) {
|
|
22748
|
+
logger_12.logger.warn("[OpenCode] Failed to report validator output to Slack", {
|
|
22749
|
+
error: err instanceof Error ? err.message : String(err)
|
|
22750
|
+
});
|
|
22751
|
+
}
|
|
22752
|
+
}
|
|
22753
|
+
} catch (err) {
|
|
22754
|
+
logger_12.logger.warn("[OpenCode] Unexpected error in notifyValidatorOutputsToSlack", {
|
|
22755
|
+
error: err instanceof Error ? err.message : String(err)
|
|
22756
|
+
});
|
|
22757
|
+
}
|
|
22758
|
+
}
|
|
22759
|
+
}
|
|
22760
|
+
});
|
|
22761
|
+
|
|
22762
|
+
// dist/opencode-integration/slack-reports/expensive-run.js
|
|
22763
|
+
var require_expensive_run = __commonJS({
|
|
22764
|
+
"dist/opencode-integration/slack-reports/expensive-run.js"(exports2) {
|
|
22719
22765
|
"use strict";
|
|
22720
22766
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
22721
22767
|
exports2.notifyExpensiveRunToSlack = notifyExpensiveRunToSlack;
|
|
@@ -22782,7 +22828,7 @@ var require_opencode_init = __commonJS({
|
|
|
22782
22828
|
var codeGenerationService_12 = require_codeGenerationService();
|
|
22783
22829
|
var cli_listeners_1 = require_cli_listeners();
|
|
22784
22830
|
var job_context_storage_12 = require_job_context_storage();
|
|
22785
|
-
var
|
|
22831
|
+
var opencode_orchestrator_1 = require_opencode_orchestrator();
|
|
22786
22832
|
var ditto_codegen_types_12 = require_dist4();
|
|
22787
22833
|
var codegen_flow_helpers_12 = require_codegen_flow_helpers();
|
|
22788
22834
|
var agent_io_1 = require_agent_io();
|
|
@@ -22791,12 +22837,12 @@ var require_opencode_init = __commonJS({
|
|
|
22791
22837
|
var context_12 = require_context();
|
|
22792
22838
|
var logger_12 = require_logger();
|
|
22793
22839
|
var model_knobs_1 = require_model_knobs();
|
|
22794
|
-
var
|
|
22840
|
+
var file_changes_1 = require_file_changes();
|
|
22795
22841
|
var inject_created_by_1 = require_inject_created_by();
|
|
22796
|
-
var
|
|
22797
|
-
var
|
|
22798
|
-
var
|
|
22799
|
-
var
|
|
22842
|
+
var job_payload_1 = require_job_payload2();
|
|
22843
|
+
var bi_events_1 = require_bi_events();
|
|
22844
|
+
var validator_outputs_1 = require_validator_outputs();
|
|
22845
|
+
var expensive_run_1 = require_expensive_run();
|
|
22800
22846
|
var pre_run_decision_1 = require_pre_run_decision();
|
|
22801
22847
|
var environments_12 = require_environments();
|
|
22802
22848
|
var plugins_runtime_1 = require_plugins_runtime();
|
|
@@ -22823,16 +22869,16 @@ var require_opencode_init = __commonJS({
|
|
|
22823
22869
|
logger_12.logger.info("[OpenCode Init] Starting task", { taskId });
|
|
22824
22870
|
await codeGenerationService_12.codeGenerationService.updateTask(jobId, taskId, ditto_codegen_types_12.Status.RUNNING, {});
|
|
22825
22871
|
logger_12.logger.info("[OpenCode Init] Marked task RUNNING", { taskId });
|
|
22826
|
-
await (0,
|
|
22872
|
+
await (0, bi_events_1.reportSessionStart)({
|
|
22827
22873
|
...biBase,
|
|
22828
22874
|
taskModel,
|
|
22829
22875
|
taskType: kind,
|
|
22830
22876
|
jobInput: userInput
|
|
22831
22877
|
});
|
|
22832
22878
|
const outputPath = (0, codegen_flow_helpers_12.getOutputPath)();
|
|
22833
|
-
const gitBaseline = await (0,
|
|
22879
|
+
const gitBaseline = await (0, file_changes_1.captureGitBaseline)(outputPath);
|
|
22834
22880
|
store.gitBaseline = gitBaseline;
|
|
22835
|
-
const orchestrator = new
|
|
22881
|
+
const orchestrator = new opencode_orchestrator_1.OpenCodeOrchestrator();
|
|
22836
22882
|
let caughtError;
|
|
22837
22883
|
try {
|
|
22838
22884
|
(0, agent_io_1.writeAgentInput)(outputPath, agentData);
|
|
@@ -22854,9 +22900,9 @@ var require_opencode_init = __commonJS({
|
|
|
22854
22900
|
gitBaseline
|
|
22855
22901
|
});
|
|
22856
22902
|
store.lastAgentMessage = result.agentMessage;
|
|
22857
|
-
const files = await (0,
|
|
22903
|
+
const files = await (0, file_changes_1.collectGitFileChanges)(outputPath, gitBaseline);
|
|
22858
22904
|
const agentOutput = (0, agent_io_1.readAgentOutput)(outputPath);
|
|
22859
|
-
const extensions = await (0,
|
|
22905
|
+
const extensions = await (0, job_payload_1.buildExtensionsJobPayload)(outputPath, files);
|
|
22860
22906
|
await (0, inject_created_by_1.injectCreatedByIntoExtensionFiles)(outputPath, extensions.created);
|
|
22861
22907
|
await (0, codegen_flow_helpers_12.updateJobPayload)(localJobContext, {
|
|
22862
22908
|
requiredPermissions: result.requiredPermissions,
|
|
@@ -22872,8 +22918,8 @@ var require_opencode_init = __commonJS({
|
|
|
22872
22918
|
requiredPermissions: result.requiredPermissions
|
|
22873
22919
|
});
|
|
22874
22920
|
if (orchestrator.lastStdout && !(0, model_knobs_1.hasModelOverride)() && !(0, model_knobs_1.hasSmallModelOverride)()) {
|
|
22875
|
-
void (0,
|
|
22876
|
-
void (0,
|
|
22921
|
+
void (0, validator_outputs_1.notifyValidatorOutputsToSlack)(orchestrator.lastStdout, result.usage.cost);
|
|
22922
|
+
void (0, expensive_run_1.notifyExpensiveRunToSlack)({
|
|
22877
22923
|
usage: result.usage,
|
|
22878
22924
|
durationMs: Date.now() - flowStartTime,
|
|
22879
22925
|
agentMessage: result.agentMessage,
|
|
@@ -22883,7 +22929,7 @@ var require_opencode_init = __commonJS({
|
|
|
22883
22929
|
if (!store.isCompleted) {
|
|
22884
22930
|
await codeGenerationService_12.codeGenerationService.updateTask(jobId, taskId, ditto_codegen_types_12.Status.COMPLETED, {});
|
|
22885
22931
|
}
|
|
22886
|
-
await (0,
|
|
22932
|
+
await (0, bi_events_1.reportSessionEnd)({
|
|
22887
22933
|
...biBase,
|
|
22888
22934
|
taskModel,
|
|
22889
22935
|
taskType: kind,
|
|
@@ -22902,7 +22948,7 @@ var require_opencode_init = __commonJS({
|
|
|
22902
22948
|
await (0, codegen_flow_helpers_12.updateJobPayload)(localJobContext, failedRunPayload);
|
|
22903
22949
|
await (0, codegen_flow_helpers_12.updateParentTaskStatus)(localJobContext, ditto_codegen_types_12.Status.FAILED, codegenError);
|
|
22904
22950
|
const taskCost = orchestrator.lastUsage ? Math.round(orchestrator.lastUsage.cost * 1e6) : void 0;
|
|
22905
|
-
await (0,
|
|
22951
|
+
await (0, bi_events_1.reportSessionEnd)({
|
|
22906
22952
|
...biBase,
|
|
22907
22953
|
taskModel,
|
|
22908
22954
|
taskType: kind,
|
|
@@ -22911,7 +22957,7 @@ var require_opencode_init = __commonJS({
|
|
|
22911
22957
|
agentOutput: JSON.stringify({ files: failedRunPayload.files }),
|
|
22912
22958
|
jobDuration: String(Date.now() - flowStartTime)
|
|
22913
22959
|
});
|
|
22914
|
-
await (0,
|
|
22960
|
+
await (0, bi_events_1.reportSessionError)({
|
|
22915
22961
|
...biBase,
|
|
22916
22962
|
taskModel,
|
|
22917
22963
|
taskType: kind,
|
|
@@ -22935,9 +22981,9 @@ var require_opencode_init = __commonJS({
|
|
|
22935
22981
|
}
|
|
22936
22982
|
});
|
|
22937
22983
|
|
|
22938
|
-
// dist/
|
|
22939
|
-
var
|
|
22940
|
-
"dist/
|
|
22984
|
+
// dist/orchestrators/opencode-iteration-orchestrator.js
|
|
22985
|
+
var require_opencode_iteration_orchestrator = __commonJS({
|
|
22986
|
+
"dist/orchestrators/opencode-iteration-orchestrator.js"(exports2) {
|
|
22941
22987
|
"use strict";
|
|
22942
22988
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
22943
22989
|
exports2.OpenCodeIterationOrchestrator = void 0;
|
|
@@ -22999,7 +23045,7 @@ var require_opencode_iterate = __commonJS({
|
|
|
22999
23045
|
var cli_listeners_1 = require_cli_listeners();
|
|
23000
23046
|
var job_context_storage_12 = require_job_context_storage();
|
|
23001
23047
|
var ditto_codegen_types_12 = require_dist4();
|
|
23002
|
-
var
|
|
23048
|
+
var opencode_iteration_orchestrator_1 = require_opencode_iteration_orchestrator();
|
|
23003
23049
|
var types_1 = require_types_impl();
|
|
23004
23050
|
var codegen_flow_helpers_12 = require_codegen_flow_helpers();
|
|
23005
23051
|
var agent_io_1 = require_agent_io();
|
|
@@ -23007,12 +23053,12 @@ var require_opencode_iterate = __commonJS({
|
|
|
23007
23053
|
var context_12 = require_context();
|
|
23008
23054
|
var logger_12 = require_logger();
|
|
23009
23055
|
var model_knobs_1 = require_model_knobs();
|
|
23010
|
-
var
|
|
23056
|
+
var file_changes_1 = require_file_changes();
|
|
23011
23057
|
var inject_created_by_1 = require_inject_created_by();
|
|
23012
|
-
var
|
|
23013
|
-
var
|
|
23014
|
-
var
|
|
23015
|
-
var
|
|
23058
|
+
var job_payload_1 = require_job_payload2();
|
|
23059
|
+
var validator_outputs_1 = require_validator_outputs();
|
|
23060
|
+
var expensive_run_1 = require_expensive_run();
|
|
23061
|
+
var bi_events_1 = require_bi_events();
|
|
23016
23062
|
var plugins_runtime_1 = require_plugins_runtime();
|
|
23017
23063
|
var runOpencodeIterateFlow = async (chatHistory, agentData) => {
|
|
23018
23064
|
const store = job_context_storage_12.jobContextStorage.getStore();
|
|
@@ -23037,16 +23083,16 @@ var require_opencode_iterate = __commonJS({
|
|
|
23037
23083
|
logger_12.logger.info("[OpenCode Iterate] Starting task", { taskId });
|
|
23038
23084
|
await codeGenerationService_12.codeGenerationService.updateTask(jobId, taskId, ditto_codegen_types_12.Status.RUNNING, {});
|
|
23039
23085
|
logger_12.logger.info("[OpenCode Iterate] Marked task RUNNING", { taskId });
|
|
23040
|
-
await (0,
|
|
23086
|
+
await (0, bi_events_1.reportSessionStart)({
|
|
23041
23087
|
...biBase,
|
|
23042
23088
|
taskModel,
|
|
23043
23089
|
taskType: kind,
|
|
23044
23090
|
jobInput: userInput
|
|
23045
23091
|
});
|
|
23046
23092
|
const outputPath = (0, codegen_flow_helpers_12.getOutputPath)();
|
|
23047
|
-
const gitBaseline = await (0,
|
|
23093
|
+
const gitBaseline = await (0, file_changes_1.captureGitBaseline)(outputPath);
|
|
23048
23094
|
store.gitBaseline = gitBaseline;
|
|
23049
|
-
const iterationOrchestrator = new
|
|
23095
|
+
const iterationOrchestrator = new opencode_iteration_orchestrator_1.OpenCodeIterationOrchestrator();
|
|
23050
23096
|
let caughtError;
|
|
23051
23097
|
try {
|
|
23052
23098
|
(0, agent_io_1.writeAgentInput)(outputPath, agentData);
|
|
@@ -23058,9 +23104,9 @@ var require_opencode_iterate = __commonJS({
|
|
|
23058
23104
|
gitBaseline
|
|
23059
23105
|
});
|
|
23060
23106
|
store.lastAgentMessage = result.agentMessage;
|
|
23061
|
-
const files = await (0,
|
|
23107
|
+
const files = await (0, file_changes_1.collectGitFileChanges)(outputPath, gitBaseline);
|
|
23062
23108
|
const agentOutput = (0, agent_io_1.readAgentOutput)(outputPath);
|
|
23063
|
-
const extensions = await (0,
|
|
23109
|
+
const extensions = await (0, job_payload_1.buildExtensionsJobPayload)(outputPath, files);
|
|
23064
23110
|
await (0, inject_created_by_1.injectCreatedByIntoExtensionFiles)(outputPath, extensions.created);
|
|
23065
23111
|
await (0, codegen_flow_helpers_12.updateJobPayload)(localJobContext, {
|
|
23066
23112
|
requiredPermissions: result.requiredPermissions,
|
|
@@ -23076,8 +23122,8 @@ var require_opencode_iterate = __commonJS({
|
|
|
23076
23122
|
requiredPermissions: result.requiredPermissions
|
|
23077
23123
|
});
|
|
23078
23124
|
if (iterationOrchestrator.lastStdout && !(0, model_knobs_1.hasModelOverride)() && !(0, model_knobs_1.hasSmallModelOverride)()) {
|
|
23079
|
-
void (0,
|
|
23080
|
-
void (0,
|
|
23125
|
+
void (0, validator_outputs_1.notifyValidatorOutputsToSlack)(iterationOrchestrator.lastStdout, result.usage.cost);
|
|
23126
|
+
void (0, expensive_run_1.notifyExpensiveRunToSlack)({
|
|
23081
23127
|
usage: result.usage,
|
|
23082
23128
|
durationMs: Date.now() - flowStartTime,
|
|
23083
23129
|
agentMessage: result.agentMessage,
|
|
@@ -23087,7 +23133,7 @@ var require_opencode_iterate = __commonJS({
|
|
|
23087
23133
|
await codeGenerationService_12.codeGenerationService.updateTask(jobId, taskId, ditto_codegen_types_12.Status.COMPLETED, {
|
|
23088
23134
|
taskOutput: { files }
|
|
23089
23135
|
});
|
|
23090
|
-
await (0,
|
|
23136
|
+
await (0, bi_events_1.reportSessionEnd)({
|
|
23091
23137
|
...biBase,
|
|
23092
23138
|
taskModel,
|
|
23093
23139
|
taskType: kind,
|
|
@@ -23106,7 +23152,7 @@ var require_opencode_iterate = __commonJS({
|
|
|
23106
23152
|
await (0, codegen_flow_helpers_12.updateJobPayload)(localJobContext, failedRunPayload);
|
|
23107
23153
|
await (0, codegen_flow_helpers_12.updateParentTaskStatus)(localJobContext, ditto_codegen_types_12.Status.FAILED, codegenError);
|
|
23108
23154
|
const taskCost = iterationOrchestrator.lastUsage ? Math.round(iterationOrchestrator.lastUsage.cost * 1e6) : void 0;
|
|
23109
|
-
await (0,
|
|
23155
|
+
await (0, bi_events_1.reportSessionEnd)({
|
|
23110
23156
|
...biBase,
|
|
23111
23157
|
taskModel,
|
|
23112
23158
|
taskType: kind,
|
|
@@ -23115,7 +23161,7 @@ var require_opencode_iterate = __commonJS({
|
|
|
23115
23161
|
agentOutput: JSON.stringify({ files: failedRunPayload.files }),
|
|
23116
23162
|
jobDuration: String(Date.now() - flowStartTime)
|
|
23117
23163
|
});
|
|
23118
|
-
await (0,
|
|
23164
|
+
await (0, bi_events_1.reportSessionError)({
|
|
23119
23165
|
...biBase,
|
|
23120
23166
|
taskModel,
|
|
23121
23167
|
taskType: kind,
|
|
@@ -23139,9 +23185,9 @@ var require_opencode_iterate = __commonJS({
|
|
|
23139
23185
|
}
|
|
23140
23186
|
});
|
|
23141
23187
|
|
|
23142
|
-
// dist/
|
|
23143
|
-
var
|
|
23144
|
-
"dist/
|
|
23188
|
+
// dist/orchestrators/opencode-ask-orchestrator.js
|
|
23189
|
+
var require_opencode_ask_orchestrator = __commonJS({
|
|
23190
|
+
"dist/orchestrators/opencode-ask-orchestrator.js"(exports2) {
|
|
23145
23191
|
"use strict";
|
|
23146
23192
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
23147
23193
|
exports2.OpenCodeAskOrchestrator = void 0;
|
|
@@ -23201,17 +23247,17 @@ var require_opencode_ask = __commonJS({
|
|
|
23201
23247
|
var cli_listeners_1 = require_cli_listeners();
|
|
23202
23248
|
var job_context_storage_12 = require_job_context_storage();
|
|
23203
23249
|
var ditto_codegen_types_12 = require_dist4();
|
|
23204
|
-
var
|
|
23250
|
+
var opencode_ask_orchestrator_1 = require_opencode_ask_orchestrator();
|
|
23205
23251
|
var types_1 = require_types_impl();
|
|
23206
23252
|
var codegen_flow_helpers_12 = require_codegen_flow_helpers();
|
|
23207
23253
|
var ditto_codegen_types_2 = require_dist4();
|
|
23208
23254
|
var context_12 = require_context();
|
|
23209
23255
|
var logger_12 = require_logger();
|
|
23210
23256
|
var model_knobs_1 = require_model_knobs();
|
|
23211
|
-
var
|
|
23257
|
+
var file_changes_1 = require_file_changes();
|
|
23212
23258
|
var inject_created_by_1 = require_inject_created_by();
|
|
23213
|
-
var
|
|
23214
|
-
var
|
|
23259
|
+
var job_payload_1 = require_job_payload2();
|
|
23260
|
+
var bi_events_1 = require_bi_events();
|
|
23215
23261
|
var runOpencodeAskFlow = async (chatHistory) => {
|
|
23216
23262
|
const store = job_context_storage_12.jobContextStorage.getStore();
|
|
23217
23263
|
if (!store?.jobId || !store?.taskId) {
|
|
@@ -23235,16 +23281,16 @@ var require_opencode_ask = __commonJS({
|
|
|
23235
23281
|
logger_12.logger.info("[OpenCode Ask] Starting task", { taskId });
|
|
23236
23282
|
await codeGenerationService_12.codeGenerationService.updateTask(jobId, taskId, ditto_codegen_types_12.Status.RUNNING, {});
|
|
23237
23283
|
logger_12.logger.info("[OpenCode Ask] Marked task RUNNING", { taskId });
|
|
23238
|
-
await (0,
|
|
23284
|
+
await (0, bi_events_1.reportSessionStart)({
|
|
23239
23285
|
...biBase,
|
|
23240
23286
|
taskModel,
|
|
23241
23287
|
taskType: kind,
|
|
23242
23288
|
jobInput: userInput
|
|
23243
23289
|
});
|
|
23244
23290
|
const outputPath = (0, codegen_flow_helpers_12.getOutputPath)();
|
|
23245
|
-
const gitBaseline = await (0,
|
|
23291
|
+
const gitBaseline = await (0, file_changes_1.captureGitBaseline)(outputPath);
|
|
23246
23292
|
store.gitBaseline = gitBaseline;
|
|
23247
|
-
const askOrchestrator = new
|
|
23293
|
+
const askOrchestrator = new opencode_ask_orchestrator_1.OpenCodeAskOrchestrator();
|
|
23248
23294
|
try {
|
|
23249
23295
|
(0, cli_listeners_1.attachOrchestratorListeners)(askOrchestrator);
|
|
23250
23296
|
const result = await askOrchestrator.ask({
|
|
@@ -23253,8 +23299,8 @@ var require_opencode_ask = __commonJS({
|
|
|
23253
23299
|
chatHistory,
|
|
23254
23300
|
gitBaseline
|
|
23255
23301
|
});
|
|
23256
|
-
const files = await (0,
|
|
23257
|
-
const extensions = await (0,
|
|
23302
|
+
const files = await (0, file_changes_1.collectGitFileChanges)(outputPath, gitBaseline);
|
|
23303
|
+
const extensions = await (0, job_payload_1.buildExtensionsJobPayload)(outputPath, files);
|
|
23258
23304
|
await (0, inject_created_by_1.injectCreatedByIntoExtensionFiles)(outputPath, extensions.created);
|
|
23259
23305
|
await (0, codegen_flow_helpers_12.updateJobPayload)(localJobContext, {
|
|
23260
23306
|
files,
|
|
@@ -23266,7 +23312,7 @@ var require_opencode_ask = __commonJS({
|
|
|
23266
23312
|
answer: result.answer
|
|
23267
23313
|
}
|
|
23268
23314
|
});
|
|
23269
|
-
await (0,
|
|
23315
|
+
await (0, bi_events_1.reportSessionEnd)({
|
|
23270
23316
|
...biBase,
|
|
23271
23317
|
taskModel,
|
|
23272
23318
|
taskType: kind,
|
|
@@ -23279,8 +23325,8 @@ var require_opencode_ask = __commonJS({
|
|
|
23279
23325
|
logger_12.logger.info("[OpenCode Ask] Completed task", { taskId });
|
|
23280
23326
|
} catch (error) {
|
|
23281
23327
|
const codegenError = (0, ditto_codegen_types_2.toCodegenError)(error);
|
|
23282
|
-
const files = await (0,
|
|
23283
|
-
const extensions = await (0,
|
|
23328
|
+
const files = await (0, file_changes_1.collectGitFileChanges)(outputPath, gitBaseline);
|
|
23329
|
+
const extensions = await (0, job_payload_1.buildExtensionsJobPayload)(outputPath, files);
|
|
23284
23330
|
await (0, codegen_flow_helpers_12.updateJobPayload)(localJobContext, {
|
|
23285
23331
|
files,
|
|
23286
23332
|
extensions,
|
|
@@ -23288,7 +23334,7 @@ var require_opencode_ask = __commonJS({
|
|
|
23288
23334
|
});
|
|
23289
23335
|
await (0, codegen_flow_helpers_12.updateParentTaskStatus)(localJobContext, ditto_codegen_types_12.Status.FAILED, codegenError);
|
|
23290
23336
|
const taskCost = askOrchestrator.lastUsage ? Math.round(askOrchestrator.lastUsage.cost * 1e6) : void 0;
|
|
23291
|
-
await (0,
|
|
23337
|
+
await (0, bi_events_1.reportSessionEnd)({
|
|
23292
23338
|
...biBase,
|
|
23293
23339
|
taskModel,
|
|
23294
23340
|
taskType: kind,
|
|
@@ -23297,7 +23343,7 @@ var require_opencode_ask = __commonJS({
|
|
|
23297
23343
|
agentOutput: JSON.stringify({ files }),
|
|
23298
23344
|
jobDuration: String(Date.now() - flowStartTime)
|
|
23299
23345
|
});
|
|
23300
|
-
await (0,
|
|
23346
|
+
await (0, bi_events_1.reportSessionError)({
|
|
23301
23347
|
...biBase,
|
|
23302
23348
|
taskModel,
|
|
23303
23349
|
taskType: kind,
|
|
@@ -23319,9 +23365,9 @@ var require_opencode_ask = __commonJS({
|
|
|
23319
23365
|
}
|
|
23320
23366
|
});
|
|
23321
23367
|
|
|
23322
|
-
// dist/
|
|
23323
|
-
var
|
|
23324
|
-
"dist/
|
|
23368
|
+
// dist/orchestrators/opencode-git-conflicts-orchestrator.js
|
|
23369
|
+
var require_opencode_git_conflicts_orchestrator = __commonJS({
|
|
23370
|
+
"dist/orchestrators/opencode-git-conflicts-orchestrator.js"(exports2) {
|
|
23325
23371
|
"use strict";
|
|
23326
23372
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
23327
23373
|
exports2.OpenCodeGitConflictsOrchestrator = void 0;
|
|
@@ -23383,17 +23429,17 @@ var require_opencode_fix_git_conflicts = __commonJS({
|
|
|
23383
23429
|
var cli_listeners_1 = require_cli_listeners();
|
|
23384
23430
|
var job_context_storage_12 = require_job_context_storage();
|
|
23385
23431
|
var ditto_codegen_types_12 = require_dist4();
|
|
23386
|
-
var
|
|
23432
|
+
var opencode_git_conflicts_orchestrator_1 = require_opencode_git_conflicts_orchestrator();
|
|
23387
23433
|
var types_1 = require_types_impl();
|
|
23388
23434
|
var codegen_flow_helpers_12 = require_codegen_flow_helpers();
|
|
23389
23435
|
var context_12 = require_context();
|
|
23390
23436
|
var logger_12 = require_logger();
|
|
23391
23437
|
var model_knobs_1 = require_model_knobs();
|
|
23392
|
-
var
|
|
23393
|
-
var
|
|
23394
|
-
var
|
|
23395
|
-
var
|
|
23396
|
-
var
|
|
23438
|
+
var file_changes_1 = require_file_changes();
|
|
23439
|
+
var job_payload_1 = require_job_payload2();
|
|
23440
|
+
var validator_outputs_1 = require_validator_outputs();
|
|
23441
|
+
var expensive_run_1 = require_expensive_run();
|
|
23442
|
+
var bi_events_1 = require_bi_events();
|
|
23397
23443
|
var plugins_runtime_1 = require_plugins_runtime();
|
|
23398
23444
|
var runOpencodeGitConflictsFlow = async (chatHistory) => {
|
|
23399
23445
|
const store = job_context_storage_12.jobContextStorage.getStore();
|
|
@@ -23418,15 +23464,15 @@ var require_opencode_fix_git_conflicts = __commonJS({
|
|
|
23418
23464
|
logger_12.logger.info("[OpenCode Git Conflicts] Starting task", { taskId });
|
|
23419
23465
|
await codeGenerationService_12.codeGenerationService.updateTask(jobId, taskId, ditto_codegen_types_12.Status.RUNNING, {});
|
|
23420
23466
|
logger_12.logger.info("[OpenCode Git Conflicts] Marked task RUNNING", { taskId });
|
|
23421
|
-
await (0,
|
|
23467
|
+
await (0, bi_events_1.reportSessionStart)({
|
|
23422
23468
|
...biBase,
|
|
23423
23469
|
taskModel,
|
|
23424
23470
|
taskType: kind
|
|
23425
23471
|
});
|
|
23426
23472
|
const outputPath = (0, codegen_flow_helpers_12.getOutputPath)();
|
|
23427
|
-
const gitBaseline = await (0,
|
|
23473
|
+
const gitBaseline = await (0, file_changes_1.captureGitBaseline)(outputPath);
|
|
23428
23474
|
store.gitBaseline = gitBaseline;
|
|
23429
|
-
const orchestrator = new
|
|
23475
|
+
const orchestrator = new opencode_git_conflicts_orchestrator_1.OpenCodeGitConflictsOrchestrator();
|
|
23430
23476
|
let caughtError;
|
|
23431
23477
|
try {
|
|
23432
23478
|
(0, cli_listeners_1.attachOrchestratorListeners)(orchestrator);
|
|
@@ -23437,8 +23483,8 @@ var require_opencode_fix_git_conflicts = __commonJS({
|
|
|
23437
23483
|
gitBaseline
|
|
23438
23484
|
});
|
|
23439
23485
|
store.lastAgentMessage = result.agentMessage;
|
|
23440
|
-
const files = await (0,
|
|
23441
|
-
const extensions = await (0,
|
|
23486
|
+
const files = await (0, file_changes_1.collectGitFileChanges)(outputPath, gitBaseline);
|
|
23487
|
+
const extensions = await (0, job_payload_1.buildExtensionsJobPayload)(outputPath, files);
|
|
23442
23488
|
await (0, codegen_flow_helpers_12.updateJobPayload)(localJobContext, {
|
|
23443
23489
|
requiredPermissions: result.requiredPermissions,
|
|
23444
23490
|
agentMessage: result.agentMessage,
|
|
@@ -23452,8 +23498,8 @@ var require_opencode_fix_git_conflicts = __commonJS({
|
|
|
23452
23498
|
requiredPermissions: result.requiredPermissions
|
|
23453
23499
|
});
|
|
23454
23500
|
if (orchestrator.lastStdout && !(0, model_knobs_1.hasModelOverride)() && !(0, model_knobs_1.hasSmallModelOverride)()) {
|
|
23455
|
-
void (0,
|
|
23456
|
-
void (0,
|
|
23501
|
+
void (0, validator_outputs_1.notifyValidatorOutputsToSlack)(orchestrator.lastStdout, result.usage.cost);
|
|
23502
|
+
void (0, expensive_run_1.notifyExpensiveRunToSlack)({
|
|
23457
23503
|
usage: result.usage,
|
|
23458
23504
|
durationMs: Date.now() - flowStartTime,
|
|
23459
23505
|
agentMessage: result.agentMessage,
|
|
@@ -23463,7 +23509,7 @@ var require_opencode_fix_git_conflicts = __commonJS({
|
|
|
23463
23509
|
await codeGenerationService_12.codeGenerationService.updateTask(jobId, taskId, ditto_codegen_types_12.Status.COMPLETED, {
|
|
23464
23510
|
taskOutput: { files }
|
|
23465
23511
|
});
|
|
23466
|
-
await (0,
|
|
23512
|
+
await (0, bi_events_1.reportSessionEnd)({
|
|
23467
23513
|
...biBase,
|
|
23468
23514
|
taskModel,
|
|
23469
23515
|
taskType: kind,
|
|
@@ -23477,8 +23523,8 @@ var require_opencode_fix_git_conflicts = __commonJS({
|
|
|
23477
23523
|
} catch (error) {
|
|
23478
23524
|
caughtError = error;
|
|
23479
23525
|
const codegenError = (0, ditto_codegen_types_12.toCodegenError)(error);
|
|
23480
|
-
const files = await (0,
|
|
23481
|
-
const extensions = await (0,
|
|
23526
|
+
const files = await (0, file_changes_1.collectGitFileChanges)(outputPath, gitBaseline);
|
|
23527
|
+
const extensions = await (0, job_payload_1.buildExtensionsJobPayload)(outputPath, files);
|
|
23482
23528
|
await (0, codegen_flow_helpers_12.updateJobPayload)(localJobContext, {
|
|
23483
23529
|
requiredPermissions: [],
|
|
23484
23530
|
error: codegenError,
|
|
@@ -23487,7 +23533,7 @@ var require_opencode_fix_git_conflicts = __commonJS({
|
|
|
23487
23533
|
});
|
|
23488
23534
|
await (0, codegen_flow_helpers_12.updateParentTaskStatus)(localJobContext, ditto_codegen_types_12.Status.FAILED, codegenError);
|
|
23489
23535
|
const taskCost = orchestrator.lastUsage ? Math.round(orchestrator.lastUsage.cost * 1e6) : void 0;
|
|
23490
|
-
await (0,
|
|
23536
|
+
await (0, bi_events_1.reportSessionEnd)({
|
|
23491
23537
|
...biBase,
|
|
23492
23538
|
taskModel,
|
|
23493
23539
|
taskType: kind,
|
|
@@ -23496,7 +23542,7 @@ var require_opencode_fix_git_conflicts = __commonJS({
|
|
|
23496
23542
|
agentOutput: JSON.stringify({ files }),
|
|
23497
23543
|
jobDuration: String(Date.now() - flowStartTime)
|
|
23498
23544
|
});
|
|
23499
|
-
await (0,
|
|
23545
|
+
await (0, bi_events_1.reportSessionError)({
|
|
23500
23546
|
...biBase,
|
|
23501
23547
|
taskModel,
|
|
23502
23548
|
taskType: kind,
|
|
@@ -23520,9 +23566,9 @@ var require_opencode_fix_git_conflicts = __commonJS({
|
|
|
23520
23566
|
}
|
|
23521
23567
|
});
|
|
23522
23568
|
|
|
23523
|
-
// dist/job-cancellation-monitor.js
|
|
23569
|
+
// dist/jobs/job-cancellation-monitor.js
|
|
23524
23570
|
var require_job_cancellation_monitor = __commonJS({
|
|
23525
|
-
"dist/job-cancellation-monitor.js"(exports2) {
|
|
23571
|
+
"dist/jobs/job-cancellation-monitor.js"(exports2) {
|
|
23526
23572
|
"use strict";
|
|
23527
23573
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
23528
23574
|
exports2.JobCancellationMonitor = void 0;
|
|
@@ -23531,7 +23577,7 @@ var require_job_cancellation_monitor = __commonJS({
|
|
|
23531
23577
|
var logger_12 = require_logger();
|
|
23532
23578
|
var job_context_storage_12 = require_job_context_storage();
|
|
23533
23579
|
var types_1 = require_types_impl();
|
|
23534
|
-
var
|
|
23580
|
+
var bi_events_1 = require_bi_events();
|
|
23535
23581
|
var STATUS_CHECK_INTERVAL_MS = 2e3;
|
|
23536
23582
|
var JobCancellationMonitor = class {
|
|
23537
23583
|
constructor(codeGenerationService) {
|
|
@@ -23579,7 +23625,7 @@ var require_job_cancellation_monitor = __commonJS({
|
|
|
23579
23625
|
if (!store)
|
|
23580
23626
|
return;
|
|
23581
23627
|
const jobDuration = store.flowStartTime ? String(Date.now() - store.flowStartTime) : void 0;
|
|
23582
|
-
await (0,
|
|
23628
|
+
await (0, bi_events_1.reportSessionEnd)({
|
|
23583
23629
|
jobId,
|
|
23584
23630
|
taskId: store.taskId,
|
|
23585
23631
|
appId: this.projectId,
|
|
@@ -23596,9 +23642,9 @@ var require_job_cancellation_monitor = __commonJS({
|
|
|
23596
23642
|
}
|
|
23597
23643
|
});
|
|
23598
23644
|
|
|
23599
|
-
// dist/job-timeout-monitor.js
|
|
23645
|
+
// dist/jobs/job-timeout-monitor.js
|
|
23600
23646
|
var require_job_timeout_monitor = __commonJS({
|
|
23601
|
-
"dist/job-timeout-monitor.js"(exports2) {
|
|
23647
|
+
"dist/jobs/job-timeout-monitor.js"(exports2) {
|
|
23602
23648
|
"use strict";
|
|
23603
23649
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
23604
23650
|
exports2.JobTimeoutMonitor = exports2.JOB_TIMEOUT_MS = void 0;
|
|
@@ -23609,7 +23655,7 @@ var require_job_timeout_monitor = __commonJS({
|
|
|
23609
23655
|
var job_context_storage_12 = require_job_context_storage();
|
|
23610
23656
|
var codegen_flow_helpers_12 = require_codegen_flow_helpers();
|
|
23611
23657
|
var types_1 = require_types_impl();
|
|
23612
|
-
var
|
|
23658
|
+
var bi_events_1 = require_bi_events();
|
|
23613
23659
|
exports2.JOB_TIMEOUT_MS = 1e3 * 60 * 20;
|
|
23614
23660
|
var JobTimeoutMonitor = class {
|
|
23615
23661
|
constructor(codeGenerationService) {
|
|
@@ -23677,12 +23723,12 @@ var require_job_timeout_monitor = __commonJS({
|
|
|
23677
23723
|
runKind: store.kind,
|
|
23678
23724
|
environment
|
|
23679
23725
|
};
|
|
23680
|
-
await (0,
|
|
23726
|
+
await (0, bi_events_1.reportSessionEnd)({
|
|
23681
23727
|
...biBase,
|
|
23682
23728
|
taskStatus: ditto_codegen_types_12.Status.FAILED,
|
|
23683
23729
|
jobDuration
|
|
23684
23730
|
});
|
|
23685
|
-
await (0,
|
|
23731
|
+
await (0, bi_events_1.reportSessionError)({
|
|
23686
23732
|
...biBase,
|
|
23687
23733
|
errorDesc: codegenError.errorType,
|
|
23688
23734
|
errorMessage: codegenError.message,
|
|
@@ -23696,9 +23742,9 @@ var require_job_timeout_monitor = __commonJS({
|
|
|
23696
23742
|
}
|
|
23697
23743
|
});
|
|
23698
23744
|
|
|
23699
|
-
// dist/opencode-integration/skills-override.js
|
|
23745
|
+
// dist/opencode-integration/skills/skills-override.js
|
|
23700
23746
|
var require_skills_override = __commonJS({
|
|
23701
|
-
"dist/opencode-integration/skills-override.js"(exports2) {
|
|
23747
|
+
"dist/opencode-integration/skills/skills-override.js"(exports2) {
|
|
23702
23748
|
"use strict";
|
|
23703
23749
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
23704
23750
|
exports2.SKILLS_DIR = void 0;
|
|
@@ -23758,9 +23804,9 @@ var require_skills_override = __commonJS({
|
|
|
23758
23804
|
}
|
|
23759
23805
|
});
|
|
23760
23806
|
|
|
23761
|
-
// dist/opencode-integration/skills-installer.js
|
|
23807
|
+
// dist/opencode-integration/skills/skills-installer.js
|
|
23762
23808
|
var require_skills_installer = __commonJS({
|
|
23763
|
-
"dist/opencode-integration/skills-installer.js"(exports2) {
|
|
23809
|
+
"dist/opencode-integration/skills/skills-installer.js"(exports2) {
|
|
23764
23810
|
"use strict";
|
|
23765
23811
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
23766
23812
|
exports2.applySkillsOverride = applySkillsOverride;
|
|
@@ -23898,31 +23944,79 @@ var require_tools_writer = __commonJS({
|
|
|
23898
23944
|
}
|
|
23899
23945
|
});
|
|
23900
23946
|
|
|
23901
|
-
// dist/opencode-integration/
|
|
23947
|
+
// dist/opencode-integration/plugins/generated-files-guard.js
|
|
23948
|
+
var require_generated_files_guard = __commonJS({
|
|
23949
|
+
"dist/opencode-integration/plugins/generated-files-guard.js"(exports2) {
|
|
23950
|
+
"use strict";
|
|
23951
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
23952
|
+
exports2.GUARD_PLUGIN_FILENAME = exports2.GUARD_MESSAGE = void 0;
|
|
23953
|
+
exports2.isEditorComponentManifest = isEditorComponentManifest;
|
|
23954
|
+
exports2.extractWritePaths = extractWritePaths;
|
|
23955
|
+
exports2.buildGeneratedFilesGuardSource = buildGeneratedFilesGuardSource;
|
|
23956
|
+
exports2.writeGeneratedFilesGuardPlugin = writeGeneratedFilesGuardPlugin;
|
|
23957
|
+
var write_plugin_1 = require_write_plugin();
|
|
23958
|
+
var ERC_MANIFEST_RE = /(^|\/)src\/extensions\/site\/components\/.+\.generated\.tsx?$/;
|
|
23959
|
+
exports2.GUARD_MESSAGE = "BLOCKED: this editor-react-component manifest is auto-generated. Do not create or edit it by hand \u2014 edit the *.tsx / *.module.css / *.props.ts source and regenerate with `npx wix build && npx wix generate manifest`, or override values in the component's *.extension.ts. Do not re-attempt the blocked path; the whole call was rejected, so resubmit any other paths it carried \u2014 they were not written. Only *.generated.ts under src/extensions/site/components/ is blocked.";
|
|
23960
|
+
function isEditorComponentManifest(path) {
|
|
23961
|
+
return ERC_MANIFEST_RE.test(path);
|
|
23962
|
+
}
|
|
23963
|
+
function extractWritePaths(tool, args) {
|
|
23964
|
+
if (tool === "write" || tool === "edit") {
|
|
23965
|
+
return typeof args.filePath === "string" ? [args.filePath] : [];
|
|
23966
|
+
}
|
|
23967
|
+
const list = tool === "batch-write" ? args.files : tool === "multi-edit" ? args.edits : void 0;
|
|
23968
|
+
if (!list)
|
|
23969
|
+
return [];
|
|
23970
|
+
return list.map((item) => item.path).filter((p) => typeof p === "string");
|
|
23971
|
+
}
|
|
23972
|
+
exports2.GUARD_PLUGIN_FILENAME = "generated-files-guard.ts";
|
|
23973
|
+
function buildGeneratedFilesGuardSource() {
|
|
23974
|
+
return `// Generated by @wix/ditto-codegen (generated-files-guard). Do not edit.
|
|
23975
|
+
const ERC_MANIFEST_RE = /${ERC_MANIFEST_RE.source}/;
|
|
23976
|
+
const GUARD_MESSAGE = ${JSON.stringify(exports2.GUARD_MESSAGE)};
|
|
23977
|
+
|
|
23978
|
+
function extractWritePaths(tool, args) {
|
|
23979
|
+
if (tool === "${"write"}" || tool === "${"edit"}") {
|
|
23980
|
+
return typeof args.filePath === "string" ? [args.filePath] : [];
|
|
23981
|
+
}
|
|
23982
|
+
const list =
|
|
23983
|
+
tool === "${"batch-write"}" ? args.files : tool === "${"multi-edit"}" ? args.edits : undefined;
|
|
23984
|
+
if (!list) return [];
|
|
23985
|
+
return list
|
|
23986
|
+
.map((item) => item.path)
|
|
23987
|
+
.filter((p) => typeof p === "string");
|
|
23988
|
+
}
|
|
23989
|
+
|
|
23990
|
+
export const GeneratedFilesGuard = async () => ({
|
|
23991
|
+
"tool.execute.before": async (input, output) => {
|
|
23992
|
+
const blocked = extractWritePaths(input.tool, output.args).filter((p) =>
|
|
23993
|
+
ERC_MANIFEST_RE.test(p),
|
|
23994
|
+
);
|
|
23995
|
+
if (blocked.length > 0) {
|
|
23996
|
+
throw new Error(GUARD_MESSAGE + " (blocked: " + blocked.join(", ") + ")");
|
|
23997
|
+
}
|
|
23998
|
+
},
|
|
23999
|
+
});
|
|
24000
|
+
`;
|
|
24001
|
+
}
|
|
24002
|
+
async function writeGeneratedFilesGuardPlugin() {
|
|
24003
|
+
await (0, write_plugin_1.writeGeneratedPlugin)(exports2.GUARD_PLUGIN_FILENAME, buildGeneratedFilesGuardSource());
|
|
24004
|
+
}
|
|
24005
|
+
}
|
|
24006
|
+
});
|
|
24007
|
+
|
|
24008
|
+
// dist/opencode-integration/plugins/tool-policies.js
|
|
23902
24009
|
var require_tool_policies3 = __commonJS({
|
|
23903
|
-
"dist/opencode-integration/tool-policies.js"(exports2) {
|
|
24010
|
+
"dist/opencode-integration/plugins/tool-policies.js"(exports2) {
|
|
23904
24011
|
"use strict";
|
|
23905
24012
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
23906
|
-
exports2.
|
|
23907
|
-
exports2.policyMatchesPath = policyMatchesPath;
|
|
23908
|
-
exports2.skillRootOf = skillRootOf;
|
|
24013
|
+
exports2.TOOL_POLICIES_FILENAME = exports2.GENERATE_CMD_RE = void 0;
|
|
23909
24014
|
exports2.buildToolPoliciesPluginSource = buildToolPoliciesPluginSource;
|
|
23910
24015
|
exports2.writeToolPoliciesPlugin = writeToolPoliciesPlugin;
|
|
23911
|
-
exports2.validateToolPolicies = validateToolPolicies;
|
|
23912
|
-
var promises_1 = require("fs/promises");
|
|
23913
|
-
var path_12 = require("path");
|
|
23914
24016
|
var ditto_codegen_types_12 = require_dist4();
|
|
23915
|
-
var
|
|
23916
|
-
var generated_plugins_1 = require_generated_plugins();
|
|
23917
|
-
var skills_override_12 = require_skills_override();
|
|
24017
|
+
var write_plugin_1 = require_write_plugin();
|
|
23918
24018
|
exports2.GENERATE_CMD_RE = /\bwix\s+(schema\s+)?generate\b/;
|
|
23919
|
-
|
|
23920
|
-
return policy.pathFragments.some((fragment) => path.includes(fragment));
|
|
23921
|
-
}
|
|
23922
|
-
function skillRootOf(fragment) {
|
|
23923
|
-
return fragment.split("/")[0];
|
|
23924
|
-
}
|
|
23925
|
-
exports2.TOOL_POLICIES_PLUGIN_FILENAME = "tool-policies.ts";
|
|
24019
|
+
exports2.TOOL_POLICIES_FILENAME = "tool-policies.ts";
|
|
23926
24020
|
function buildToolPoliciesPluginSource(policies) {
|
|
23927
24021
|
const emitKind = (type, toRuntime, extraFilter = () => true) => JSON.stringify(policies.filter((policy) => policy.type === type).filter(extraFilter).map(toRuntime));
|
|
23928
24022
|
const emitReads = (mode) => emitKind("read", ({ pathFragments, message }) => ({ pathFragments, message }), (policy) => policy.mode === mode);
|
|
@@ -24045,7 +24139,26 @@ export const ToolPolicies = async () => ({
|
|
|
24045
24139
|
`;
|
|
24046
24140
|
}
|
|
24047
24141
|
async function writeToolPoliciesPlugin(policies) {
|
|
24048
|
-
await (0,
|
|
24142
|
+
await (0, write_plugin_1.writeGeneratedPlugin)(exports2.TOOL_POLICIES_FILENAME, buildToolPoliciesPluginSource(policies));
|
|
24143
|
+
}
|
|
24144
|
+
}
|
|
24145
|
+
});
|
|
24146
|
+
|
|
24147
|
+
// dist/opencode-integration/plugins/tool-policies-drift.js
|
|
24148
|
+
var require_tool_policies_drift = __commonJS({
|
|
24149
|
+
"dist/opencode-integration/plugins/tool-policies-drift.js"(exports2) {
|
|
24150
|
+
"use strict";
|
|
24151
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
24152
|
+
exports2.validateToolPolicies = validateToolPolicies;
|
|
24153
|
+
var promises_1 = require("fs/promises");
|
|
24154
|
+
var path_12 = require("path");
|
|
24155
|
+
var logger_12 = require_logger();
|
|
24156
|
+
var skills_override_12 = require_skills_override();
|
|
24157
|
+
function policyMatchesPath(policy, path) {
|
|
24158
|
+
return policy.pathFragments.some((fragment) => path.includes(fragment));
|
|
24159
|
+
}
|
|
24160
|
+
function skillRootOf(fragment) {
|
|
24161
|
+
return fragment.split("/")[0];
|
|
24049
24162
|
}
|
|
24050
24163
|
async function walkFiles(dir, depth = 6) {
|
|
24051
24164
|
if (depth === 0)
|
|
@@ -24147,70 +24260,33 @@ export const ToolPolicies = async () => ({
|
|
|
24147
24260
|
}
|
|
24148
24261
|
});
|
|
24149
24262
|
|
|
24150
|
-
// dist/opencode-integration/
|
|
24151
|
-
var
|
|
24152
|
-
"dist/opencode-integration/
|
|
24263
|
+
// dist/opencode-integration/plugins/index.js
|
|
24264
|
+
var require_plugins3 = __commonJS({
|
|
24265
|
+
"dist/opencode-integration/plugins/index.js"(exports2) {
|
|
24153
24266
|
"use strict";
|
|
24154
24267
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
24155
|
-
exports2.
|
|
24156
|
-
exports2.
|
|
24157
|
-
|
|
24158
|
-
|
|
24159
|
-
|
|
24160
|
-
var
|
|
24161
|
-
|
|
24162
|
-
|
|
24163
|
-
|
|
24164
|
-
|
|
24165
|
-
|
|
24166
|
-
|
|
24167
|
-
|
|
24168
|
-
|
|
24169
|
-
|
|
24170
|
-
const list = tool === "batch-write" ? args.files : tool === "multi-edit" ? args.edits : void 0;
|
|
24171
|
-
if (!list)
|
|
24172
|
-
return [];
|
|
24173
|
-
return list.map((item) => item.path).filter((p) => typeof p === "string");
|
|
24174
|
-
}
|
|
24175
|
-
var GUARD_PLUGIN_FILENAME = "generated-files-guard.ts";
|
|
24176
|
-
function buildGeneratedFilesGuardSource() {
|
|
24177
|
-
return `// Generated by @wix/ditto-codegen (generated-files-guard). Do not edit.
|
|
24178
|
-
const ERC_MANIFEST_RE = /${ERC_MANIFEST_RE.source}/;
|
|
24179
|
-
const GUARD_MESSAGE = ${JSON.stringify(exports2.GUARD_MESSAGE)};
|
|
24180
|
-
|
|
24181
|
-
function extractWritePaths(tool, args) {
|
|
24182
|
-
if (tool === "${"write"}" || tool === "${"edit"}") {
|
|
24183
|
-
return typeof args.filePath === "string" ? [args.filePath] : [];
|
|
24184
|
-
}
|
|
24185
|
-
const list =
|
|
24186
|
-
tool === "${"batch-write"}" ? args.files : tool === "${"multi-edit"}" ? args.edits : undefined;
|
|
24187
|
-
if (!list) return [];
|
|
24188
|
-
return list
|
|
24189
|
-
.map((item) => item.path)
|
|
24190
|
-
.filter((p) => typeof p === "string");
|
|
24191
|
-
}
|
|
24192
|
-
|
|
24193
|
-
export const GeneratedFilesGuard = async () => ({
|
|
24194
|
-
"tool.execute.before": async (input, output) => {
|
|
24195
|
-
const blocked = extractWritePaths(input.tool, output.args).filter((p) =>
|
|
24196
|
-
ERC_MANIFEST_RE.test(p),
|
|
24197
|
-
);
|
|
24198
|
-
if (blocked.length > 0) {
|
|
24199
|
-
throw new Error(GUARD_MESSAGE + " (blocked: " + blocked.join(", ") + ")");
|
|
24200
|
-
}
|
|
24201
|
-
},
|
|
24202
|
-
});
|
|
24203
|
-
`;
|
|
24204
|
-
}
|
|
24205
|
-
async function writeGeneratedFilesGuardPlugin() {
|
|
24206
|
-
await (0, generated_plugins_1.writeGeneratedPlugin)(GUARD_PLUGIN_FILENAME, buildGeneratedFilesGuardSource());
|
|
24268
|
+
exports2.validateToolPolicies = void 0;
|
|
24269
|
+
exports2.writeGeneratedPlugins = writeGeneratedPlugins;
|
|
24270
|
+
var generated_files_guard_1 = require_generated_files_guard();
|
|
24271
|
+
var subagent_tool_logger_1 = require_subagent_tool_logger();
|
|
24272
|
+
var tool_policies_1 = require_tool_policies3();
|
|
24273
|
+
var tool_policies_drift_1 = require_tool_policies_drift();
|
|
24274
|
+
Object.defineProperty(exports2, "validateToolPolicies", { enumerable: true, get: function() {
|
|
24275
|
+
return tool_policies_drift_1.validateToolPolicies;
|
|
24276
|
+
} });
|
|
24277
|
+
async function writeGeneratedPlugins(toolPolicies) {
|
|
24278
|
+
await Promise.all([
|
|
24279
|
+
(0, generated_files_guard_1.writeGeneratedFilesGuardPlugin)(),
|
|
24280
|
+
(0, subagent_tool_logger_1.writeSubagentToolLoggerPlugin)(),
|
|
24281
|
+
(0, tool_policies_1.writeToolPoliciesPlugin)(toolPolicies)
|
|
24282
|
+
]);
|
|
24207
24283
|
}
|
|
24208
24284
|
}
|
|
24209
24285
|
});
|
|
24210
24286
|
|
|
24211
|
-
// dist/plugin-host.js
|
|
24287
|
+
// dist/plugin-system/plugin-host.js
|
|
24212
24288
|
var require_plugin_host = __commonJS({
|
|
24213
|
-
"dist/plugin-host.js"(exports2) {
|
|
24289
|
+
"dist/plugin-system/plugin-host.js"(exports2) {
|
|
24214
24290
|
"use strict";
|
|
24215
24291
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
24216
24292
|
exports2.buildPluginHost = void 0;
|
|
@@ -24230,9 +24306,9 @@ var require_plugin_host = __commonJS({
|
|
|
24230
24306
|
}
|
|
24231
24307
|
});
|
|
24232
24308
|
|
|
24233
|
-
// dist/plugin-artifacts.js
|
|
24309
|
+
// dist/plugin-system/plugin-artifacts.js
|
|
24234
24310
|
var require_plugin_artifacts = __commonJS({
|
|
24235
|
-
"dist/plugin-artifacts.js"(exports2) {
|
|
24311
|
+
"dist/plugin-system/plugin-artifacts.js"(exports2) {
|
|
24236
24312
|
"use strict";
|
|
24237
24313
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
24238
24314
|
exports2.collectPluginArtifacts = collectPluginArtifacts;
|
|
@@ -24256,9 +24332,9 @@ var require_plugin_artifacts = __commonJS({
|
|
|
24256
24332
|
}
|
|
24257
24333
|
});
|
|
24258
24334
|
|
|
24259
|
-
// dist/fetch-scheduler.js
|
|
24335
|
+
// dist/jobs/fetch-scheduler.js
|
|
24260
24336
|
var require_fetch_scheduler = __commonJS({
|
|
24261
|
-
"dist/fetch-scheduler.js"(exports2) {
|
|
24337
|
+
"dist/jobs/fetch-scheduler.js"(exports2) {
|
|
24262
24338
|
"use strict";
|
|
24263
24339
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
24264
24340
|
exports2.FetchScheduler = exports2.MAX_AWAITED_JOB_IDS = exports2.MAX_MISSING_JOB_RECHECKS = exports2.ERROR_BACKOFF_MS = exports2.POST_JOB_INTERVAL_MS = exports2.MIN_FETCH_INTERVAL_MS = void 0;
|
|
@@ -24408,21 +24484,21 @@ var require_fetch_scheduler = __commonJS({
|
|
|
24408
24484
|
}
|
|
24409
24485
|
});
|
|
24410
24486
|
|
|
24411
|
-
// dist/nudge-listener-server.js
|
|
24487
|
+
// dist/jobs/nudge-listener-server.js
|
|
24412
24488
|
var require_nudge_listener_server = __commonJS({
|
|
24413
|
-
"dist/nudge-listener-server.js"(exports2) {
|
|
24489
|
+
"dist/jobs/nudge-listener-server.js"(exports2) {
|
|
24414
24490
|
"use strict";
|
|
24415
24491
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
24416
|
-
exports2.NudgeListenerServer = exports2.BIND_RETRY_DELAY_MS = exports2.
|
|
24492
|
+
exports2.NudgeListenerServer = exports2.BIND_RETRY_DELAY_MS = exports2.MAX_LOGGED_PATH_LENGTH = exports2.JOB_FETCH_PATH = exports2.JOB_FETCH_PORT = void 0;
|
|
24417
24493
|
var node_http_1 = require("node:http");
|
|
24418
24494
|
var logger_12 = require_logger();
|
|
24419
24495
|
var utils_12 = require_utils9();
|
|
24420
24496
|
var fetch_scheduler_1 = require_fetch_scheduler();
|
|
24421
24497
|
exports2.JOB_FETCH_PORT = 52402;
|
|
24422
24498
|
exports2.JOB_FETCH_PATH = "/_wix/codegen/fetch-jobs";
|
|
24423
|
-
|
|
24499
|
+
var JOB_ID_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
|
|
24424
24500
|
exports2.MAX_LOGGED_PATH_LENGTH = 128;
|
|
24425
|
-
|
|
24501
|
+
var BIND_RETRIES = 5;
|
|
24426
24502
|
exports2.BIND_RETRY_DELAY_MS = 300;
|
|
24427
24503
|
var NudgeListenerServer = class {
|
|
24428
24504
|
constructor(deps, port = exports2.JOB_FETCH_PORT) {
|
|
@@ -24474,7 +24550,7 @@ var require_nudge_listener_server = __commonJS({
|
|
|
24474
24550
|
try {
|
|
24475
24551
|
return await this.listenOnce();
|
|
24476
24552
|
} catch (error) {
|
|
24477
|
-
const inUse = error?.code === "EADDRINUSE" && attempt <
|
|
24553
|
+
const inUse = error?.code === "EADDRINUSE" && attempt < BIND_RETRIES;
|
|
24478
24554
|
if (!inUse)
|
|
24479
24555
|
throw error;
|
|
24480
24556
|
await (0, utils_12.delay)(exports2.BIND_RETRY_DELAY_MS);
|
|
@@ -24522,7 +24598,7 @@ var require_nudge_listener_server = __commonJS({
|
|
|
24522
24598
|
return;
|
|
24523
24599
|
}
|
|
24524
24600
|
const nudgedId = url.searchParams.get("jobId");
|
|
24525
|
-
const usable = nudgedId === null ||
|
|
24601
|
+
const usable = nudgedId === null || JOB_ID_PATTERN.test(nudgedId);
|
|
24526
24602
|
if (!usable) {
|
|
24527
24603
|
logger_12.logger.warn("[JobFetch] Nudge carried an unusable jobId", {
|
|
24528
24604
|
length: nudgedId.length
|
|
@@ -24546,9 +24622,9 @@ var require_nudge_listener_server = __commonJS({
|
|
|
24546
24622
|
}
|
|
24547
24623
|
});
|
|
24548
24624
|
|
|
24549
|
-
// dist/job-fetching.js
|
|
24625
|
+
// dist/jobs/job-fetching.js
|
|
24550
24626
|
var require_job_fetching = __commonJS({
|
|
24551
|
-
"dist/job-fetching.js"(exports2) {
|
|
24627
|
+
"dist/jobs/job-fetching.js"(exports2) {
|
|
24552
24628
|
"use strict";
|
|
24553
24629
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
24554
24630
|
exports2.JobDeliveryMode = void 0;
|
|
@@ -24638,10 +24714,8 @@ var logger_1 = require_logger();
|
|
|
24638
24714
|
var skills_installer_1 = require_skills_installer();
|
|
24639
24715
|
var rules_writer_1 = require_rules_writer();
|
|
24640
24716
|
var tools_writer_1 = require_tools_writer();
|
|
24641
|
-
var
|
|
24717
|
+
var plugins_1 = require_plugins3();
|
|
24642
24718
|
var skills_override_1 = require_skills_override();
|
|
24643
|
-
var generated_files_guard_1 = require_generated_files_guard();
|
|
24644
|
-
var subagent_tool_logger_1 = require_subagent_tool_logger();
|
|
24645
24719
|
var plugin_artifacts_1 = require_plugin_artifacts();
|
|
24646
24720
|
var config_1 = require_config();
|
|
24647
24721
|
var environments_1 = require_environments();
|
|
@@ -24725,11 +24799,9 @@ async function initOpenCode() {
|
|
|
24725
24799
|
]),
|
|
24726
24800
|
(0, skills_installer_1.applySkillsOverride)((0, codegen_flow_helpers_1.getOutputPath)(), logger_1.logger),
|
|
24727
24801
|
(0, tools_writer_1.writeToolFiles)(pluginArtifacts.tools),
|
|
24728
|
-
(0,
|
|
24729
|
-
(0, subagent_tool_logger_1.writeSubagentToolLoggerPlugin)(),
|
|
24730
|
-
(0, tool_policies_1.writeToolPoliciesPlugin)(toolPolicies)
|
|
24802
|
+
(0, plugins_1.writeGeneratedPlugins)(toolPolicies)
|
|
24731
24803
|
]);
|
|
24732
|
-
void (0,
|
|
24804
|
+
void (0, plugins_1.validateToolPolicies)(toolPolicies, [
|
|
24733
24805
|
skills_override_1.SKILLS_DIR,
|
|
24734
24806
|
(0, path_1.join)((0, codegen_flow_helpers_1.getOutputPath)(), ".agents", "skills")
|
|
24735
24807
|
]);
|