ryco-cli 0.1.5 → 0.1.7
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/README.md +50 -2
- package/dist/{AzureDevOpsSourceControlProvider-CdgNqZ5j.cjs → AzureDevOpsSourceControlProvider-5exivY-1.cjs} +2 -2
- package/dist/{AzureDevOpsSourceControlProvider-OsyDSESj.mjs → AzureDevOpsSourceControlProvider-CF5LuCHp.mjs} +3 -3
- package/dist/{BitbucketSourceControlProvider-DBTH98i4.cjs → BitbucketSourceControlProvider-1GWENqcl.cjs} +2 -2
- package/dist/{BitbucketSourceControlProvider-SQ3gKdFs.mjs → BitbucketSourceControlProvider-CKH09tfT.mjs} +3 -3
- package/dist/{BunPTY-B_vjRZN4.mjs → BunPTY-BWhtEA50.mjs} +1 -1
- package/dist/{ClaudeDriver-D9yC2F0b.cjs → ClaudeDriver-BXLdjrht.cjs} +187 -8
- package/dist/{ClaudeDriver-2dTtrsFD.mjs → ClaudeDriver-WwWFTu61.mjs} +188 -9
- package/dist/{CodexDriver-CIDYevQX.mjs → CodexDriver-93-TmCrO.mjs} +16 -8
- package/dist/{CodexDriver-BC2B-qpT.cjs → CodexDriver-BboMT9uk.cjs} +15 -7
- package/dist/{CodexTextGeneration-DNeO-8GE.cjs → CodexTextGeneration-0pRbJji3.cjs} +3 -3
- package/dist/{CodexTextGeneration-CjknB1Xl.mjs → CodexTextGeneration-BU9Myn87.mjs} +4 -4
- package/dist/{CopilotDriver-NPhlLrk2.mjs → CopilotDriver-BASi8pJ0.mjs} +15 -8
- package/dist/{CopilotDriver-BGChrP5c.cjs → CopilotDriver-DCsv-17W.cjs} +14 -7
- package/dist/{CursorDriver-CYxn4_c1.cjs → CursorDriver-BTSiM3A8.cjs} +163 -16
- package/dist/{CursorDriver-BcAVbT8D.mjs → CursorDriver-D5LvIqUk.mjs} +164 -17
- package/dist/{ForgejoSourceControlProvider-D3wP2Cav.cjs → ForgejoSourceControlProvider-BTXRDCGB.cjs} +2 -2
- package/dist/{ForgejoSourceControlProvider-BjCE3730.mjs → ForgejoSourceControlProvider-e-4hvvZ_.mjs} +3 -3
- package/dist/{GitHubSourceControlProvider-DByZ_cnw.mjs → GitHubSourceControlProvider-26IofDAO.mjs} +3 -3
- package/dist/{GitHubSourceControlProvider-DU_7IvMa.cjs → GitHubSourceControlProvider-DWmwkA_y.cjs} +2 -2
- package/dist/{GitLabSourceControlProvider-BVJ5IqTS.cjs → GitLabSourceControlProvider-D-YHnxRe.cjs} +2 -2
- package/dist/{GitLabSourceControlProvider-BdMCIjXb.mjs → GitLabSourceControlProvider-DePct78W.mjs} +3 -3
- package/dist/{Metrics-BCOc3Ml2.mjs → Metrics-6Xj17Se3.mjs} +94 -2
- package/dist/{Metrics-DNOriWhP.cjs → Metrics-CIW1QH7M.cjs} +128 -0
- package/dist/{NodePTY-_u3kQLvd.mjs → NodePTY-C_cR3Ayy.mjs} +1 -1
- package/dist/{OpenCodeDriver-fwqXoVyH.mjs → OpenCodeDriver-BhvLOmvn.mjs} +336 -43
- package/dist/{OpenCodeDriver-DyR83FcY.cjs → OpenCodeDriver-CVeZ4n9-.cjs} +335 -42
- package/dist/{SourceControlProviderDiscoveryCatalog-DqQVhwYM.cjs → SourceControlProviderDiscoveryCatalog-DeFR5xH3.cjs} +98 -161
- package/dist/{SourceControlProviderDiscoveryCatalog-CQiMyDCC.mjs → SourceControlProviderDiscoveryCatalog-mJV_Xitr.mjs} +100 -145
- package/dist/bin.cjs +30639 -28744
- package/dist/bin.mjs +30602 -28709
- package/dist/client/assets/{AnimatedHeight-CYuVQOpY.js → AnimatedHeight-BSU0lzYs.js} +1 -1
- package/dist/client/assets/AppearanceSettings-D7q0ujGK.js +1 -0
- package/dist/client/assets/BranchToolbar.logic-CZIFSvhd.js +1 -0
- package/dist/client/assets/ChatRightPanel-CWHOIuiQ.js +188 -0
- package/dist/client/assets/ChatThreadRouteView-bA7xWXzc.js +1 -0
- package/dist/client/assets/CommandPaletteDialog-DNYaVOZO.js +1 -0
- package/dist/client/assets/CompositeRoot-B_KEfCUE.js +1 -0
- package/dist/client/assets/ConnectionsSettings-CLZPbx_K.js +1 -0
- package/dist/client/assets/DiagnosticsSettings-DtzPCb6N.js +1 -0
- package/dist/client/assets/DialogHandle-DuHnmWoE.js +1 -0
- package/dist/client/assets/{DialogRoot-DaMwpoP_.js → DialogRoot-BV25qAcA.js} +1 -1
- package/dist/client/assets/DialogTitle-DQsi-RTa.js +1 -0
- package/dist/client/assets/DialogTrigger-D0fA01C6.js +1 -0
- package/dist/client/assets/DialogViewport-CMV_BePU.js +1 -0
- package/dist/client/assets/DraftChatThreadRouteView-BoiKnrii.js +1 -0
- package/dist/client/assets/JetBrainsIcons-BcPxJlMf.js +1 -0
- package/dist/client/assets/KeybindingsSettings-LuI98pdF.js +7 -0
- package/dist/client/assets/McpServersSettings-BFMuWYVV.js +6 -0
- package/dist/client/assets/NoActiveThreadState-C2q_O1kP.js +1 -0
- package/dist/client/assets/OpinionatedPluginsSettings-Bqwct37O.js +1 -0
- package/dist/client/assets/ProjectFavicon-D2imiJ8M.js +1 -0
- package/dist/client/assets/{ProviderUpdateLaunchNotification.logic-BFzNCo3I.js → ProviderUpdateLaunchNotification.logic-CJgA--nK.js} +1 -1
- package/dist/client/assets/ProvidersSettingsPanel-B97vbeu6.js +1 -0
- package/dist/client/assets/{RedactedSensitiveText-UnZZJnFF.js → RedactedSensitiveText-B2GFTyfq.js} +1 -1
- package/dist/client/assets/RootAppShell-C1xTR98P.js +12 -0
- package/dist/client/assets/SettingsDialog-Q0Q8O5oH.js +2 -0
- package/dist/client/assets/SourceControlSettings-KAvoPTNi.js +1 -0
- package/dist/client/assets/StatisticsPanel-BzsQ444K.js +64 -0
- package/dist/client/assets/ThreadStatusIndicators-Cw_jLVQf.js +1 -0
- package/dist/client/assets/{ThreadTerminalDrawer-BXoXAbsR.js → ThreadTerminalDrawer-D1WnSemH.js} +17 -17
- package/dist/client/assets/ThreadWorkspacePanel-L4qCPTOA.js +166 -0
- package/dist/client/assets/{alert-dialog-BJQbh5gX.js → alert-dialog-CNmKa0BK.js} +1 -1
- package/dist/client/assets/chart-column-BWSKYZ_a.js +1 -0
- package/dist/client/assets/{chatThreadActions--n7v5mnB.js → chatThreadActions-TtDsiwDC.js} +1 -1
- package/dist/client/assets/chevron-up-zopJ_99l.js +1 -0
- package/dist/client/assets/{clamp-NYtK3f5s.js → clamp-Ds6WJu8j.js} +1 -1
- package/dist/client/assets/clipboard-copy-BoJGpdmJ.js +1 -0
- package/dist/client/assets/clock-CzUHThzk.js +1 -0
- package/dist/client/assets/commandPaletteStore-KebG835b.js +1 -0
- package/dist/client/assets/composerDraftStore-DpPEQ6BN.js +21 -0
- package/dist/client/assets/desktopUpdateAtoms-BQ0GGEfM.js +2 -0
- package/dist/client/assets/{download-Bi4-cFbc.js → download-CUiRE0N9.js} +1 -1
- package/dist/client/assets/{draft-input-BGSRgOW7.js → draft-input-CwpGDtoT.js} +1 -1
- package/dist/client/assets/editorPreferences-jN7DKbyt.js +1 -0
- package/dist/client/assets/empty-CBuXePtg.js +1 -0
- package/dist/client/assets/{group-Dwm-OV-r.js → group-BpZvxjG5.js} +1 -1
- package/dist/client/assets/{index-BI5yFj9n.js → index-BKzXTNJ_.js} +2 -2
- package/dist/client/assets/{input-BfUa3JUD.js → input-CgDawd6k.js} +1 -1
- package/dist/client/assets/kbd-QYSL97CK.js +1 -0
- package/dist/client/assets/{keybindings--G1bkIjA.js → keybindings-CUTRYI_A.js} +1 -1
- package/dist/client/assets/{keyboard-B87VTfPa.js → keyboard-DFFiI7JY.js} +1 -1
- package/dist/client/assets/keyedQuery-DiOCbGH0.js +0 -0
- package/dist/client/assets/main-BgFGju3e.js +9 -0
- package/dist/client/assets/main-D0UFdwts.css +2 -0
- package/dist/client/assets/palette-BXCL909c.js +1 -0
- package/dist/client/assets/play-DI2LZohg.js +1 -0
- package/dist/client/assets/plus-DzgIfHUF.js +1 -0
- package/dist/client/assets/projectAtoms-DXXpuERK.js +1 -0
- package/dist/client/assets/providerDriverMeta-CRNNp0q3.js +1 -0
- package/dist/client/assets/providerIconUtils-D-DFhem2.js +47 -0
- package/dist/client/assets/radio-group-_PPYg3YY.js +1 -0
- package/dist/client/assets/{refresh-cw-CRxaXR0E.js → refresh-cw-BsQTNBXl.js} +1 -1
- package/dist/client/assets/{resolveAriaLabelledBy-D4fWpj84.js → resolveAriaLabelledBy-CRHo_s16.js} +1 -1
- package/dist/client/assets/rightPanelRouteSearch-CfmZ7osj.js +1 -0
- package/dist/client/assets/scale-DDEJ-tvn.js +1 -0
- package/dist/client/assets/scroll-area-HgsI-ErG.js +1 -0
- package/dist/client/assets/separator-ClnL4mUB.js +1 -0
- package/dist/client/assets/{server-tdx7WxLI.js → server-Bbs3L-6_.js} +1 -1
- package/dist/client/assets/session-logic-CKQkgIwo.js +4 -0
- package/dist/client/assets/settingsDialogStore-SG-W1q0A.js +1 -0
- package/dist/client/assets/settingsLayout-G5xVm-ZT.js +1 -0
- package/dist/client/assets/shallow-Dmd-gez1.js +1 -0
- package/dist/client/assets/sidebar-_u7SGgmC.js +1 -0
- package/dist/client/assets/sidebarStatusText-BTYnwflG.js +1 -0
- package/dist/client/assets/skeleton-CmUvhZGP.js +1 -0
- package/dist/client/assets/storeSelectors-DhJRpdiw.js +1 -0
- package/dist/client/assets/threadSelectionStore-ygmA4DNA.js +1 -0
- package/dist/client/assets/toast-DmA_ziPT.js +1 -0
- package/dist/client/assets/toggle-DGS7tKuj.js +1 -0
- package/dist/client/assets/{toggle-group-DdKXHoT3.js → toggle-group-Dtv1ZUFW.js} +1 -1
- package/dist/client/assets/tokenModePresentation-Dor1DnBx.js +1 -0
- package/dist/client/assets/{trash-2-CZQem-sz.js → trash-2-C2G3VGoV.js} +1 -1
- package/dist/client/assets/triangle-alert-Bpz3xGu5.js +1 -0
- package/dist/client/assets/undo-2-C3rtxuqZ.js +1 -0
- package/dist/client/assets/useHandleNewThread-ypSbzG0P.js +1 -0
- package/dist/client/assets/useLabelableId-Bc7KEnHU.js +1 -0
- package/dist/client/assets/useNavigate-_4hWGSey.js +1 -0
- package/dist/client/assets/useTheme-HcKmBfpF.js +1 -0
- package/dist/client/assets/{vscode-icons-E8NUFd62.js → vscode-icons-DdSTtxYd.js} +1 -1
- package/dist/client/assets/{wrench-DEteICtk.js → wrench-C4jdis40.js} +1 -1
- package/dist/client/assets/x-CG2WU63t.js +1 -0
- package/dist/client/index.html +1 -1
- package/dist/{collectUint8StreamText-DuFJyaQh.mjs → collectUint8StreamText-Lv4GGI79.mjs} +488 -16
- package/dist/{collectUint8StreamText-DbCOJom3.cjs → collectUint8StreamText-uNXVRHOf.cjs} +510 -14
- package/dist/{makeManagedServerProvider-C3cQUDkZ.cjs → makeManagedServerProvider-3SD-Q5xh.cjs} +1 -1
- package/dist/{makeManagedServerProvider-wFGZ2-vd.mjs → makeManagedServerProvider-CkPEptun.mjs} +2 -2
- package/package.json +1 -1
- package/dist/client/assets/AppearanceSettings-BBbC8CV5.js +0 -1
- package/dist/client/assets/BranchToolbar.logic-Di2EkKiO.js +0 -1
- package/dist/client/assets/ChatRightPanel-BJ_cVP66.js +0 -188
- package/dist/client/assets/ChatThreadRouteView-DmxD3m2U.js +0 -1
- package/dist/client/assets/CommandPaletteDialog-CAzz6bsT.js +0 -1
- package/dist/client/assets/CompositeRoot-BvXCwn2c.js +0 -1
- package/dist/client/assets/ConnectionsSettings-Cmxm0y2u.js +0 -1
- package/dist/client/assets/DialogHandle-CXNAm3QY.js +0 -1
- package/dist/client/assets/DialogTitle-KXmfgzP3.js +0 -1
- package/dist/client/assets/DialogTrigger-NHyQnW3X.js +0 -1
- package/dist/client/assets/DialogViewport-CL0WR9a5.js +0 -1
- package/dist/client/assets/DraftChatThreadRouteView-C_hqauF6.js +0 -1
- package/dist/client/assets/JetBrainsIcons-BcR8pCma.js +0 -1
- package/dist/client/assets/KeybindingsSettings-m2AteGOl.js +0 -7
- package/dist/client/assets/McpServersSettings-DndIDxgA.js +0 -6
- package/dist/client/assets/NoActiveThreadState-Bt-Wkv-C.js +0 -1
- package/dist/client/assets/OpinionatedPluginsSettings-oDtdE6qx.js +0 -1
- package/dist/client/assets/ProjectFavicon-j9IX_7-B.js +0 -1
- package/dist/client/assets/ProvidersSettingsPanel-CvlIBNVJ.js +0 -1
- package/dist/client/assets/QueryClientProvider-BZxRKpeb.js +0 -1
- package/dist/client/assets/RootAppShell-CyHZ_F5P.js +0 -12
- package/dist/client/assets/SettingsDialog-BYJ8AhQp.js +0 -2
- package/dist/client/assets/SourceControlSettings-7xU6VH6N.js +0 -1
- package/dist/client/assets/ThreadStatusIndicators-M9FWDEex.js +0 -1
- package/dist/client/assets/ThreadWorkspacePanel-D1J63TVD.js +0 -166
- package/dist/client/assets/codexUsageLimits-BJQiZCqn.js +0 -1
- package/dist/client/assets/commandPaletteStore-oFMPKPmp.js +0 -1
- package/dist/client/assets/composerDraftStore-xu3n5gdX.js +0 -21
- package/dist/client/assets/desktopUpdateReactQuery-YSCkifKp.js +0 -2
- package/dist/client/assets/empty-BTxheW4B.js +0 -1
- package/dist/client/assets/environmentApi-BFHi_M02.js +0 -1
- package/dist/client/assets/folder-open-DJmHEPv9.js +0 -1
- package/dist/client/assets/kbd-Dd57M8OY.js +0 -1
- package/dist/client/assets/main-BQf5U-fz.js +0 -9
- package/dist/client/assets/main-DrwkwNo9.css +0 -2
- package/dist/client/assets/mutation-DJZgOJRu.js +0 -1
- package/dist/client/assets/plus-B10j9MbZ.js +0 -1
- package/dist/client/assets/providerDriverMeta-B6xuq7ij.js +0 -1
- package/dist/client/assets/providerIconUtils-Ch6hejVW.js +0 -47
- package/dist/client/assets/rightPanelRouteSearch-CTMFCS6R.js +0 -1
- package/dist/client/assets/scroll-area-BgFq7GRd.js +0 -1
- package/dist/client/assets/separator-CB3Ctlvi.js +0 -1
- package/dist/client/assets/session-logic-CaiGe4hy.js +0 -4
- package/dist/client/assets/settingsDialogStore-9vo22xKp.js +0 -1
- package/dist/client/assets/settingsLayout-B5o13iGO.js +0 -1
- package/dist/client/assets/sidebar-Bbdql7Af.js +0 -1
- package/dist/client/assets/skeleton-C8OZcsPq.js +0 -1
- package/dist/client/assets/storeSelectors-DBRyhCGm.js +0 -1
- package/dist/client/assets/threadRoutes-CfldSp4X.js +0 -1
- package/dist/client/assets/threadSelectionStore-BggKwzmQ.js +0 -1
- package/dist/client/assets/toast-DE-WwLMa.js +0 -1
- package/dist/client/assets/toggle-BFMa0a0Y.js +0 -1
- package/dist/client/assets/useHandleNewThread-DOPZAFqE.js +0 -1
- package/dist/client/assets/useLabelableId-BzWaBebJ.js +0 -1
- package/dist/client/assets/useNavigate-B1qgM5mt.js +0 -1
- package/dist/client/assets/useTheme-C7Ji7x06.js +0 -1
- package/dist/client/assets/x-b9324xm-.js +0 -1
- package/dist/{NodeSqliteClient-BXy61fAd.mjs → NodeSqliteClient-A1TEgwj_.mjs} +1 -1
- package/dist/{NodeSqliteClient-homCO8-6.cjs → NodeSqliteClient-B5aDHbNc.cjs} +2 -2
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { a as buildIssueContentTitlePrompt, c as extractJsonObject, d as sanitizePrTitle, f as sanitizeThreadTitle, i as buildIssueContentPolishPrompt, n as buildBranchNamePrompt, o as buildPrContentPrompt, r as buildCommitMessagePrompt, s as buildThreadTitlePrompt, t as makeManagedServerProvider, u as sanitizeCommitSubject } from "./makeManagedServerProvider-
|
|
3
|
+
import { Bn as ProviderInstanceId, Sr as TurnId, V as OpenCodeSettings, _r as RuntimeRequestId, gr as RuntimeItemId, hr as ProviderItemId, lr as EventId, vr as RuntimeSubagentId, x as TextGenerationError, zn as ProviderDriverKind } from "./collectUint8StreamText-Lv4GGI79.mjs";
|
|
4
|
+
import { U as sanitizeBranchFragment, W as sanitizeFeatureBranchName, Y as ServerConfig } from "./Metrics-6Xj17Se3.mjs";
|
|
5
|
+
import { A as nonEmptyTrimmed, E as buildServerProvider, F as ProviderAdapterRequestError, I as ProviderAdapterSessionClosedError, L as ProviderAdapterSessionNotFoundError, M as providerModelsFromSettings, P as ProviderAdapterProcessError, Qt as makePackageManagedProviderMaintenanceResolver, R as ProviderAdapterValidationError, Xt as enrichProviderSnapshotWithVersionAdvisory, a as OpenCodeRuntime, an as resolveAttachmentPath, c as openCodeQuestionId, cn as createModelCapabilities, d as runOpenCodeSdk, f as toOpenCodeFileParts, g as makeEventNdjsonLogger, h as ProviderEventLoggers, in as ServerSettingsService, j as parseGenericCliVersion, l as openCodeRuntimeErrorDetail, m as toOpenCodeQuestionAnswers, nn as resolveProviderMaintenanceCapabilitiesEffect, o as OpenCodeRuntimeError, p as toOpenCodePermissionReply, rn as compareCliVersions, s as buildOpenCodePermissionRules, t as makeServerQueueMetrics, tn as normalizeCommandPath, u as parseOpenCodeModelSlug, un as getModelSelectionStringOptionValue, y as mergeProviderInstanceEnvironment, z as ProviderDriverError } from "./bin.mjs";
|
|
6
|
+
import { a as buildIssueContentTitlePrompt, c as extractJsonObject, d as sanitizePrTitle, f as sanitizeThreadTitle, i as buildIssueContentPolishPrompt, n as buildBranchNamePrompt, o as buildPrContentPrompt, r as buildCommitMessagePrompt, s as buildThreadTitlePrompt, t as makeManagedServerProvider, u as sanitizeCommitSubject } from "./makeManagedServerProvider-CkPEptun.mjs";
|
|
7
7
|
import { t as formatSourceControlContextsForAgent } from "./sourceControlContextFormatter-DEwpnVAH.mjs";
|
|
8
8
|
import { t as defaultProviderContinuationIdentity } from "./ProviderDriver-kCV60GKk.mjs";
|
|
9
9
|
import { Cause, Data, Effect, Exit, Fiber, Queue, Random, Ref, Schema, Scope, Stream } from "effect";
|
|
10
10
|
import { HttpClient } from "effect/unstable/http";
|
|
11
|
-
import * as Semaphore$1 from "effect/Semaphore";
|
|
12
11
|
import "effect/unstable/process";
|
|
12
|
+
import * as Semaphore$1 from "effect/Semaphore";
|
|
13
13
|
//#region src/textGeneration/OpenCodeTextGeneration.ts
|
|
14
14
|
const OPENCODE_TEXT_GENERATION_IDLE_TTL = "30 seconds";
|
|
15
15
|
function getOpenCodePromptErrorMessage(error) {
|
|
@@ -279,6 +279,68 @@ const PROVIDER$1 = ProviderDriverKind.make("opencode");
|
|
|
279
279
|
function nowIso() {
|
|
280
280
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
281
281
|
}
|
|
282
|
+
function nonEmptyString(value) {
|
|
283
|
+
const trimmed = value?.trim();
|
|
284
|
+
return trimmed && trimmed.length > 0 ? trimmed : void 0;
|
|
285
|
+
}
|
|
286
|
+
function scopedOpenCodeId(sessionId, id) {
|
|
287
|
+
return `${sessionId}:${id}`;
|
|
288
|
+
}
|
|
289
|
+
function openCodeSubagentId(kind, id) {
|
|
290
|
+
return RuntimeSubagentId.make(`opencode:${kind}:${id}`);
|
|
291
|
+
}
|
|
292
|
+
function subagentKey(subagentId) {
|
|
293
|
+
return String(subagentId);
|
|
294
|
+
}
|
|
295
|
+
function statusFromOpenCodeSubagentState(status) {
|
|
296
|
+
return status;
|
|
297
|
+
}
|
|
298
|
+
function subagentCompletionStatus(status) {
|
|
299
|
+
return status;
|
|
300
|
+
}
|
|
301
|
+
function metadataWithEntries(entries) {
|
|
302
|
+
const metadata = Object.fromEntries(entries.filter(([, value]) => value !== void 0 && value !== null && value !== ""));
|
|
303
|
+
return Object.keys(metadata).length > 0 ? metadata : void 0;
|
|
304
|
+
}
|
|
305
|
+
function makeSubtaskSubagentRef(part) {
|
|
306
|
+
const description = nonEmptyString(part.description) ?? nonEmptyString(part.prompt);
|
|
307
|
+
const label = nonEmptyString(part.agent) ?? nonEmptyString(part.command) ?? (description ? "OpenCode subtask" : void 0);
|
|
308
|
+
return {
|
|
309
|
+
subagentId: openCodeSubagentId("subtask", part.id),
|
|
310
|
+
origin: "native",
|
|
311
|
+
capability: "summary",
|
|
312
|
+
...label ? { label } : {},
|
|
313
|
+
...description ? { description } : {},
|
|
314
|
+
parentProviderItemId: ProviderItemId.make(part.id),
|
|
315
|
+
metadata: metadataWithEntries([
|
|
316
|
+
["source", "opencode.subtask"],
|
|
317
|
+
["prompt", nonEmptyString(part.prompt)],
|
|
318
|
+
["agent", nonEmptyString(part.agent)],
|
|
319
|
+
["command", nonEmptyString(part.command)],
|
|
320
|
+
["model", part.model]
|
|
321
|
+
])
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function mergeOpenCodeChildSessionRef(existing, session, parentSessionId) {
|
|
325
|
+
const label = nonEmptyString(session.title) ?? existing?.label ?? "OpenCode subagent";
|
|
326
|
+
return {
|
|
327
|
+
subagentId: existing?.subagentId ?? openCodeSubagentId("session", session.id),
|
|
328
|
+
origin: "native",
|
|
329
|
+
capability: "transcript",
|
|
330
|
+
label,
|
|
331
|
+
...existing?.description ? { description: existing.description } : {},
|
|
332
|
+
providerSessionId: session.id,
|
|
333
|
+
providerThreadId: session.id,
|
|
334
|
+
...existing?.parentProviderItemId && { parentProviderItemId: existing.parentProviderItemId },
|
|
335
|
+
metadata: {
|
|
336
|
+
...existing?.metadata,
|
|
337
|
+
source: "opencode.session",
|
|
338
|
+
parentSessionId,
|
|
339
|
+
slug: session.slug,
|
|
340
|
+
directory: session.directory
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
}
|
|
282
344
|
/**
|
|
283
345
|
* Map a tagged OpenCodeRuntimeError produced by {@link runOpenCodeSdk} into
|
|
284
346
|
* the adapter-boundary `ProviderAdapterRequestError`. SDK-method-level call
|
|
@@ -422,7 +484,7 @@ function isoFromEpochMs(value) {
|
|
|
422
484
|
return new Date(value).toISOString();
|
|
423
485
|
}
|
|
424
486
|
function messageRoleForPart(context, part) {
|
|
425
|
-
const known = context.messageRoleById.get(part.messageID);
|
|
487
|
+
const known = context.messageRoleById.get(scopedOpenCodeId(part.sessionID, part.messageID));
|
|
426
488
|
if (known) return known;
|
|
427
489
|
return part.type === "tool" ? "assistant" : void 0;
|
|
428
490
|
}
|
|
@@ -474,6 +536,12 @@ function makeOpenCodeAdapter(openCodeSettings, options) {
|
|
|
474
536
|
const nativeEventLogger = options?.nativeEventLogger ?? (options?.nativeEventLogPath !== void 0 ? yield* makeEventNdjsonLogger(options.nativeEventLogPath, { stream: "native" }) : void 0);
|
|
475
537
|
const managedNativeEventLogger = options?.nativeEventLogger === void 0 ? nativeEventLogger : void 0;
|
|
476
538
|
const runtimeEvents = yield* Queue.unbounded();
|
|
539
|
+
const runtimeEventQueueMetrics = yield* makeServerQueueMetrics({
|
|
540
|
+
queue: "provider.adapter.runtimeEvents",
|
|
541
|
+
component: "OpenCodeAdapter",
|
|
542
|
+
provider: PROVIDER$1,
|
|
543
|
+
providerInstanceId: boundInstanceId
|
|
544
|
+
});
|
|
477
545
|
const sessions = /* @__PURE__ */ new Map();
|
|
478
546
|
yield* Effect.addFinalizer(() => Effect.gen(function* () {
|
|
479
547
|
const contexts = [...sessions.values()];
|
|
@@ -483,10 +551,126 @@ function makeOpenCodeAdapter(openCodeSettings, options) {
|
|
|
483
551
|
discard: true
|
|
484
552
|
});
|
|
485
553
|
if (managedNativeEventLogger !== void 0) yield* managedNativeEventLogger.close();
|
|
486
|
-
}).pipe(Effect.ensuring(Queue.shutdown(runtimeEvents))));
|
|
487
|
-
const emit = (event) => Queue.offer(runtimeEvents, event).pipe(Effect.asVoid);
|
|
554
|
+
}).pipe(Effect.ensuring(runtimeEventQueueMetrics.reset), Effect.ensuring(Queue.shutdown(runtimeEvents))));
|
|
555
|
+
const emit = (event) => Queue.offer(runtimeEvents, event).pipe(Effect.andThen(runtimeEventQueueMetrics.recordEnqueued()), Effect.asVoid);
|
|
488
556
|
const writeNativeEvent = (threadId, event) => nativeEventLogger ? nativeEventLogger.write(event, threadId) : Effect.void;
|
|
489
557
|
const writeNativeEventBestEffort = (threadId, event) => writeNativeEvent(threadId, event).pipe(Effect.catchCause(() => Effect.void));
|
|
558
|
+
const emitOpenCodeSubagentStarted = Effect.fn("emitOpenCodeSubagentStarted")(function* (context, subagent, raw) {
|
|
559
|
+
const key = subagentKey(subagent.subagentId);
|
|
560
|
+
if (context.startedSubagentIds.has(key)) return;
|
|
561
|
+
context.startedSubagentIds.add(key);
|
|
562
|
+
yield* emit({
|
|
563
|
+
...yield* buildEventBase({
|
|
564
|
+
threadId: context.session.threadId,
|
|
565
|
+
turnId: context.activeTurnId,
|
|
566
|
+
raw
|
|
567
|
+
}),
|
|
568
|
+
type: "subagent.started",
|
|
569
|
+
payload: { subagent }
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
const emitOpenCodeSubagentUpdated = Effect.fn("emitOpenCodeSubagentUpdated")(function* (context, input) {
|
|
573
|
+
yield* emitOpenCodeSubagentStarted(context, input.subagent, input.raw);
|
|
574
|
+
yield* emit({
|
|
575
|
+
...yield* buildEventBase({
|
|
576
|
+
threadId: context.session.threadId,
|
|
577
|
+
turnId: context.activeTurnId,
|
|
578
|
+
raw: input.raw
|
|
579
|
+
}),
|
|
580
|
+
type: "subagent.updated",
|
|
581
|
+
payload: {
|
|
582
|
+
subagent: input.subagent,
|
|
583
|
+
...input.status ? { status: input.status } : {},
|
|
584
|
+
...input.summary ? { summary: input.summary } : {},
|
|
585
|
+
...input.detail ? { detail: input.detail } : {}
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
});
|
|
589
|
+
const emitOpenCodeSubagentCompleted = Effect.fn("emitOpenCodeSubagentCompleted")(function* (context, input) {
|
|
590
|
+
const key = subagentKey(input.subagent.subagentId);
|
|
591
|
+
if (context.completedSubagentIds.has(key)) return;
|
|
592
|
+
yield* emitOpenCodeSubagentStarted(context, input.subagent, input.raw);
|
|
593
|
+
context.completedSubagentIds.add(key);
|
|
594
|
+
yield* emit({
|
|
595
|
+
...yield* buildEventBase({
|
|
596
|
+
threadId: context.session.threadId,
|
|
597
|
+
turnId: context.activeTurnId,
|
|
598
|
+
raw: input.raw
|
|
599
|
+
}),
|
|
600
|
+
type: "subagent.completed",
|
|
601
|
+
payload: {
|
|
602
|
+
subagent: input.subagent,
|
|
603
|
+
status: input.status,
|
|
604
|
+
...input.summary ? { summary: input.summary } : {}
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
const bindOpenCodeSubtaskPart = Effect.fn("bindOpenCodeSubtaskPart")(function* (context, part, raw) {
|
|
609
|
+
const partKey = scopedOpenCodeId(part.sessionID, part.id);
|
|
610
|
+
const existing = context.subagentBySubtaskPartId.get(partKey);
|
|
611
|
+
const subagent = existing ?? makeSubtaskSubagentRef(part);
|
|
612
|
+
context.subagentBySubtaskPartId.set(partKey, subagent);
|
|
613
|
+
if (!existing && !context.unboundSubtaskPartIds.includes(partKey)) context.unboundSubtaskPartIds.push(partKey);
|
|
614
|
+
yield* emitOpenCodeSubagentUpdated(context, {
|
|
615
|
+
subagent,
|
|
616
|
+
status: statusFromOpenCodeSubagentState("starting"),
|
|
617
|
+
summary: nonEmptyString(part.description) ?? nonEmptyString(part.prompt),
|
|
618
|
+
detail: nonEmptyString(part.prompt),
|
|
619
|
+
raw
|
|
620
|
+
});
|
|
621
|
+
return subagent;
|
|
622
|
+
});
|
|
623
|
+
const takeUnboundOpenCodeSubtask = (context) => {
|
|
624
|
+
const partKey = context.unboundSubtaskPartIds.shift();
|
|
625
|
+
if (!partKey) return;
|
|
626
|
+
return context.subagentBySubtaskPartId.get(partKey);
|
|
627
|
+
};
|
|
628
|
+
const registerOpenCodeChildSession = Effect.fn("registerOpenCodeChildSession")(function* (context, session, raw) {
|
|
629
|
+
if (session.parentID !== context.openCodeSessionId) return;
|
|
630
|
+
const subagent = mergeOpenCodeChildSessionRef(context.subagentBySessionId.get(session.id) ?? takeUnboundOpenCodeSubtask(context), session, context.openCodeSessionId);
|
|
631
|
+
const known = context.childSessionIds.has(session.id);
|
|
632
|
+
context.childSessionIds.add(session.id);
|
|
633
|
+
context.subagentBySessionId.set(session.id, subagent);
|
|
634
|
+
if (known) {
|
|
635
|
+
yield* emitOpenCodeSubagentUpdated(context, {
|
|
636
|
+
subagent,
|
|
637
|
+
status: statusFromOpenCodeSubagentState("running"),
|
|
638
|
+
raw
|
|
639
|
+
});
|
|
640
|
+
return subagent;
|
|
641
|
+
}
|
|
642
|
+
const wasStartedFromSubtask = context.startedSubagentIds.has(subagentKey(subagent.subagentId));
|
|
643
|
+
yield* emitOpenCodeSubagentStarted(context, subagent, raw);
|
|
644
|
+
if (wasStartedFromSubtask) yield* emitOpenCodeSubagentUpdated(context, {
|
|
645
|
+
subagent,
|
|
646
|
+
status: statusFromOpenCodeSubagentState("running"),
|
|
647
|
+
raw
|
|
648
|
+
});
|
|
649
|
+
return subagent;
|
|
650
|
+
});
|
|
651
|
+
const hydrateOpenCodeChildSessions = Effect.fn("hydrateOpenCodeChildSessions")(function* (context) {
|
|
652
|
+
const children = yield* runOpenCodeSdk("session.children", () => context.client.session.children({ sessionID: context.openCodeSessionId })).pipe(Effect.map((response) => {
|
|
653
|
+
const value = response;
|
|
654
|
+
if (Array.isArray(value)) return value;
|
|
655
|
+
const data = value.data;
|
|
656
|
+
return Array.isArray(data) ? data : [];
|
|
657
|
+
}), Effect.catchCause((cause) => Effect.gen(function* () {
|
|
658
|
+
const error = Cause.squash(cause);
|
|
659
|
+
yield* emit({
|
|
660
|
+
...yield* buildEventBase({ threadId: context.session.threadId }),
|
|
661
|
+
type: "runtime.warning",
|
|
662
|
+
payload: {
|
|
663
|
+
message: "OpenCode child session hydration failed.",
|
|
664
|
+
detail: OpenCodeRuntimeError.is(error) ? error.detail : openCodeRuntimeErrorDetail(error)
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
return [];
|
|
668
|
+
})));
|
|
669
|
+
for (const child of children) yield* registerOpenCodeChildSession(context, child, {
|
|
670
|
+
method: "session.children",
|
|
671
|
+
child
|
|
672
|
+
});
|
|
673
|
+
});
|
|
490
674
|
const emitUnexpectedExit = Effect.fn("emitUnexpectedExit")(function* (context, message) {
|
|
491
675
|
if (yield* Ref.getAndSet(context.stopped, true)) return;
|
|
492
676
|
const turnId = context.activeTurnId;
|
|
@@ -521,29 +705,52 @@ function makeOpenCodeAdapter(openCodeSettings, options) {
|
|
|
521
705
|
const emitAssistantTextDelta = Effect.fn("emitAssistantTextDelta")(function* (context, part, turnId, raw) {
|
|
522
706
|
const text = textFromPart(part);
|
|
523
707
|
if (text === void 0) return;
|
|
524
|
-
const
|
|
525
|
-
context.emittedTextByPartId.
|
|
526
|
-
|
|
708
|
+
const partKey = scopedOpenCodeId(part.sessionID, part.id);
|
|
709
|
+
const { latestText, deltaToEmit } = mergeOpenCodeAssistantText(context.emittedTextByPartId.get(partKey), text);
|
|
710
|
+
context.emittedTextByPartId.set(partKey, latestText);
|
|
711
|
+
if (latestText !== text) context.partById.set(partKey, part.type === "text" || part.type === "reasoning" ? {
|
|
527
712
|
...part,
|
|
528
713
|
text: latestText
|
|
529
714
|
} : part);
|
|
530
|
-
if (deltaToEmit.length > 0)
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
715
|
+
if (deltaToEmit.length > 0) {
|
|
716
|
+
const subagent = context.subagentBySessionId.get(part.sessionID);
|
|
717
|
+
if (subagent) yield* emit({
|
|
718
|
+
...yield* buildEventBase({
|
|
719
|
+
threadId: context.session.threadId,
|
|
720
|
+
turnId,
|
|
721
|
+
itemId: part.id,
|
|
722
|
+
createdAt: part.type === "text" || part.type === "reasoning" ? isoFromEpochMs(part.time?.start) : void 0,
|
|
723
|
+
raw
|
|
724
|
+
}),
|
|
725
|
+
type: "subagent.message.delta",
|
|
726
|
+
payload: {
|
|
727
|
+
subagentId: subagent.subagentId,
|
|
728
|
+
delta: deltaToEmit,
|
|
729
|
+
streamKind: resolveTextStreamKind(part),
|
|
730
|
+
role: "assistant",
|
|
731
|
+
providerSessionId: part.sessionID,
|
|
732
|
+
providerThreadId: part.sessionID,
|
|
733
|
+
providerMessageId: part.messageID
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
else yield* emit({
|
|
737
|
+
...yield* buildEventBase({
|
|
738
|
+
threadId: context.session.threadId,
|
|
739
|
+
turnId,
|
|
740
|
+
itemId: part.id,
|
|
741
|
+
createdAt: part.type === "text" || part.type === "reasoning" ? isoFromEpochMs(part.time?.start) : void 0,
|
|
742
|
+
raw
|
|
743
|
+
}),
|
|
744
|
+
type: "content.delta",
|
|
745
|
+
payload: {
|
|
746
|
+
streamKind: resolveTextStreamKind(part),
|
|
747
|
+
delta: deltaToEmit
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
if (part.type === "text" && part.time?.end !== void 0 && !context.completedAssistantPartIds.has(partKey)) {
|
|
752
|
+
context.completedAssistantPartIds.add(partKey);
|
|
753
|
+
if (!context.subagentBySessionId.get(part.sessionID)) yield* emit({
|
|
547
754
|
...yield* buildEventBase({
|
|
548
755
|
threadId: context.session.threadId,
|
|
549
756
|
turnId,
|
|
@@ -562,45 +769,73 @@ function makeOpenCodeAdapter(openCodeSettings, options) {
|
|
|
562
769
|
}
|
|
563
770
|
});
|
|
564
771
|
const handleSubscribedEvent = Effect.fn("handleSubscribedEvent")(function* (context, event) {
|
|
565
|
-
|
|
772
|
+
const payloadSessionId = "properties" in event ? event.properties.sessionID : void 0;
|
|
773
|
+
const eventSessionId = typeof payloadSessionId === "string" ? payloadSessionId : void 0;
|
|
774
|
+
const isRootSessionEvent = eventSessionId === context.openCodeSessionId;
|
|
775
|
+
const isKnownChildSessionEvent = eventSessionId !== void 0 && context.childSessionIds.has(eventSessionId);
|
|
776
|
+
const isChildSessionCreatedEvent = event.type === "session.created" && event.properties.info.parentID === context.openCodeSessionId;
|
|
777
|
+
if (!isRootSessionEvent && !isKnownChildSessionEvent && !isChildSessionCreatedEvent) return;
|
|
566
778
|
const turnId = context.activeTurnId;
|
|
567
779
|
yield* writeNativeEventBestEffort(context.session.threadId, {
|
|
568
780
|
observedAt: nowIso(),
|
|
569
781
|
event: {
|
|
570
782
|
provider: PROVIDER$1,
|
|
571
783
|
threadId: context.session.threadId,
|
|
572
|
-
providerThreadId: context.openCodeSessionId,
|
|
784
|
+
providerThreadId: eventSessionId ?? context.openCodeSessionId,
|
|
573
785
|
type: event.type,
|
|
574
786
|
...turnId ? { turnId } : {},
|
|
575
787
|
payload: event
|
|
576
788
|
}
|
|
577
789
|
});
|
|
578
790
|
switch (event.type) {
|
|
791
|
+
case "session.created":
|
|
792
|
+
yield* registerOpenCodeChildSession(context, event.properties.info, event);
|
|
793
|
+
break;
|
|
579
794
|
case "message.updated":
|
|
580
|
-
context.messageRoleById.set(event.properties.info.id, event.properties.info.role);
|
|
795
|
+
context.messageRoleById.set(scopedOpenCodeId(event.properties.sessionID, event.properties.info.id), event.properties.info.role);
|
|
581
796
|
if (event.properties.info.role === "assistant") for (const part of context.partById.values()) {
|
|
582
|
-
if (part.messageID !== event.properties.info.id) continue;
|
|
797
|
+
if (part.sessionID !== event.properties.sessionID || part.messageID !== event.properties.info.id) continue;
|
|
583
798
|
yield* emitAssistantTextDelta(context, part, turnId, event);
|
|
584
799
|
}
|
|
585
800
|
break;
|
|
586
801
|
case "message.removed":
|
|
587
|
-
context.messageRoleById.delete(event.properties.messageID);
|
|
802
|
+
context.messageRoleById.delete(scopedOpenCodeId(event.properties.sessionID, event.properties.messageID));
|
|
588
803
|
break;
|
|
589
804
|
case "message.part.delta": {
|
|
590
|
-
const
|
|
805
|
+
const partKey = scopedOpenCodeId(event.properties.sessionID, event.properties.partID);
|
|
806
|
+
const existingPart = context.partById.get(partKey);
|
|
591
807
|
if (!existingPart) break;
|
|
592
808
|
if (messageRoleForPart(context, existingPart) !== "assistant") break;
|
|
593
809
|
const streamKind = resolveTextStreamKind(existingPart);
|
|
594
810
|
const delta = event.properties.delta;
|
|
595
811
|
if (delta.length === 0) break;
|
|
596
|
-
const { nextText, deltaToEmit } = appendOpenCodeAssistantTextDelta(context.emittedTextByPartId.get(
|
|
812
|
+
const { nextText, deltaToEmit } = appendOpenCodeAssistantTextDelta(context.emittedTextByPartId.get(partKey) ?? textFromPart(existingPart) ?? "", delta);
|
|
597
813
|
if (deltaToEmit.length === 0) break;
|
|
598
|
-
context.emittedTextByPartId.set(
|
|
599
|
-
if (existingPart.type === "text" || existingPart.type === "reasoning") context.partById.set(
|
|
814
|
+
context.emittedTextByPartId.set(partKey, nextText);
|
|
815
|
+
if (existingPart.type === "text" || existingPart.type === "reasoning") context.partById.set(partKey, {
|
|
600
816
|
...existingPart,
|
|
601
817
|
text: nextText
|
|
602
818
|
});
|
|
603
|
-
|
|
819
|
+
const subagent = context.subagentBySessionId.get(event.properties.sessionID);
|
|
820
|
+
if (subagent) yield* emit({
|
|
821
|
+
...yield* buildEventBase({
|
|
822
|
+
threadId: context.session.threadId,
|
|
823
|
+
turnId,
|
|
824
|
+
itemId: event.properties.partID,
|
|
825
|
+
raw: event
|
|
826
|
+
}),
|
|
827
|
+
type: "subagent.message.delta",
|
|
828
|
+
payload: {
|
|
829
|
+
subagentId: subagent.subagentId,
|
|
830
|
+
delta: deltaToEmit,
|
|
831
|
+
streamKind,
|
|
832
|
+
role: "assistant",
|
|
833
|
+
providerSessionId: event.properties.sessionID,
|
|
834
|
+
providerThreadId: event.properties.sessionID,
|
|
835
|
+
providerMessageId: event.properties.messageID
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
else yield* emit({
|
|
604
839
|
...yield* buildEventBase({
|
|
605
840
|
threadId: context.session.threadId,
|
|
606
841
|
turnId,
|
|
@@ -617,12 +852,24 @@ function makeOpenCodeAdapter(openCodeSettings, options) {
|
|
|
617
852
|
}
|
|
618
853
|
case "message.part.updated": {
|
|
619
854
|
const part = event.properties.part;
|
|
620
|
-
context.partById.set(part.id, part);
|
|
855
|
+
context.partById.set(scopedOpenCodeId(part.sessionID, part.id), part);
|
|
621
856
|
if (messageRoleForPart(context, part) === "assistant") yield* emitAssistantTextDelta(context, part, turnId, event);
|
|
857
|
+
if (part.type === "subtask" && part.sessionID === context.openCodeSessionId) yield* bindOpenCodeSubtaskPart(context, part, event);
|
|
622
858
|
if (part.type === "tool") {
|
|
623
859
|
const itemType = toToolLifecycleItemType(part.tool);
|
|
624
860
|
const title = part.state.status === "running" ? part.state.title ?? part.tool : part.tool;
|
|
625
861
|
const detail = detailFromToolPart(part);
|
|
862
|
+
const childSubagent = context.subagentBySessionId.get(part.sessionID);
|
|
863
|
+
if (childSubagent) {
|
|
864
|
+
yield* emitOpenCodeSubagentUpdated(context, {
|
|
865
|
+
subagent: childSubagent,
|
|
866
|
+
status: statusFromOpenCodeSubagentState("running"),
|
|
867
|
+
summary: title,
|
|
868
|
+
detail,
|
|
869
|
+
raw: event
|
|
870
|
+
});
|
|
871
|
+
break;
|
|
872
|
+
}
|
|
626
873
|
const payload = {
|
|
627
874
|
itemType,
|
|
628
875
|
...part.state.status === "error" ? { status: "failed" } : part.state.status === "completed" ? { status: "completed" } : { status: "inProgress" },
|
|
@@ -724,7 +971,25 @@ function makeOpenCodeAdapter(openCodeSettings, options) {
|
|
|
724
971
|
payload: { answers: {} }
|
|
725
972
|
});
|
|
726
973
|
break;
|
|
727
|
-
case "session.status":
|
|
974
|
+
case "session.status": {
|
|
975
|
+
const childSubagent = context.subagentBySessionId.get(event.properties.sessionID);
|
|
976
|
+
if (childSubagent) {
|
|
977
|
+
if (event.properties.status.type === "idle") {
|
|
978
|
+
yield* emitOpenCodeSubagentCompleted(context, {
|
|
979
|
+
subagent: childSubagent,
|
|
980
|
+
status: subagentCompletionStatus("completed"),
|
|
981
|
+
raw: event
|
|
982
|
+
});
|
|
983
|
+
break;
|
|
984
|
+
}
|
|
985
|
+
yield* emitOpenCodeSubagentUpdated(context, {
|
|
986
|
+
subagent: childSubagent,
|
|
987
|
+
status: statusFromOpenCodeSubagentState("running"),
|
|
988
|
+
...event.properties.status.type === "retry" ? { detail: event.properties.status.message } : {},
|
|
989
|
+
raw: event
|
|
990
|
+
});
|
|
991
|
+
break;
|
|
992
|
+
}
|
|
728
993
|
if (event.properties.status.type === "busy") updateProviderSession(context, {
|
|
729
994
|
status: "running",
|
|
730
995
|
activeTurnId: turnId
|
|
@@ -758,8 +1023,28 @@ function makeOpenCodeAdapter(openCodeSettings, options) {
|
|
|
758
1023
|
});
|
|
759
1024
|
}
|
|
760
1025
|
break;
|
|
1026
|
+
}
|
|
1027
|
+
case "session.idle": {
|
|
1028
|
+
const childSubagent = context.subagentBySessionId.get(event.properties.sessionID);
|
|
1029
|
+
if (childSubagent) yield* emitOpenCodeSubagentCompleted(context, {
|
|
1030
|
+
subagent: childSubagent,
|
|
1031
|
+
status: subagentCompletionStatus("completed"),
|
|
1032
|
+
raw: event
|
|
1033
|
+
});
|
|
1034
|
+
break;
|
|
1035
|
+
}
|
|
761
1036
|
case "session.error": {
|
|
762
1037
|
const message = sessionErrorMessage(event.properties.error);
|
|
1038
|
+
const childSubagent = event.properties.sessionID !== void 0 ? context.subagentBySessionId.get(event.properties.sessionID) : void 0;
|
|
1039
|
+
if (childSubagent) {
|
|
1040
|
+
yield* emitOpenCodeSubagentCompleted(context, {
|
|
1041
|
+
subagent: childSubagent,
|
|
1042
|
+
status: subagentCompletionStatus("failed"),
|
|
1043
|
+
summary: message,
|
|
1044
|
+
raw: event
|
|
1045
|
+
});
|
|
1046
|
+
break;
|
|
1047
|
+
}
|
|
763
1048
|
const activeTurnId = context.activeTurnId;
|
|
764
1049
|
context.activeTurnId = void 0;
|
|
765
1050
|
updateProviderSession(context, {
|
|
@@ -887,6 +1172,12 @@ function makeOpenCodeAdapter(openCodeSettings, options) {
|
|
|
887
1172
|
emittedTextByPartId: /* @__PURE__ */ new Map(),
|
|
888
1173
|
messageRoleById: /* @__PURE__ */ new Map(),
|
|
889
1174
|
completedAssistantPartIds: /* @__PURE__ */ new Set(),
|
|
1175
|
+
childSessionIds: /* @__PURE__ */ new Set(),
|
|
1176
|
+
subagentBySessionId: /* @__PURE__ */ new Map(),
|
|
1177
|
+
subagentBySubtaskPartId: /* @__PURE__ */ new Map(),
|
|
1178
|
+
unboundSubtaskPartIds: [],
|
|
1179
|
+
startedSubagentIds: /* @__PURE__ */ new Set(),
|
|
1180
|
+
completedSubagentIds: /* @__PURE__ */ new Set(),
|
|
890
1181
|
turns: [],
|
|
891
1182
|
activeTurnId: void 0,
|
|
892
1183
|
activeAgent: void 0,
|
|
@@ -895,7 +1186,6 @@ function makeOpenCodeAdapter(openCodeSettings, options) {
|
|
|
895
1186
|
sessionScope: started.sessionScope
|
|
896
1187
|
};
|
|
897
1188
|
sessions.set(input.threadId, context);
|
|
898
|
-
yield* startEventPump(context);
|
|
899
1189
|
yield* emit({
|
|
900
1190
|
...yield* buildEventBase({ threadId: input.threadId }),
|
|
901
1191
|
type: "session.started",
|
|
@@ -906,6 +1196,8 @@ function makeOpenCodeAdapter(openCodeSettings, options) {
|
|
|
906
1196
|
type: "thread.started",
|
|
907
1197
|
payload: { providerThreadId: started.openCodeSession.id }
|
|
908
1198
|
});
|
|
1199
|
+
yield* startEventPump(context);
|
|
1200
|
+
yield* hydrateOpenCodeChildSessions(context).pipe(Effect.forkIn(context.sessionScope));
|
|
909
1201
|
return session;
|
|
910
1202
|
});
|
|
911
1203
|
const sendTurn = Effect.fn("sendTurn")(function* (input) {
|
|
@@ -1095,7 +1387,7 @@ function makeOpenCodeAdapter(openCodeSettings, options) {
|
|
|
1095
1387
|
rollbackThread,
|
|
1096
1388
|
stopAll,
|
|
1097
1389
|
get streamEvents() {
|
|
1098
|
-
return Stream.fromQueue(runtimeEvents);
|
|
1390
|
+
return Stream.fromQueue(runtimeEvents).pipe(Stream.tap(() => runtimeEventQueueMetrics.recordDequeued()));
|
|
1099
1391
|
}
|
|
1100
1392
|
};
|
|
1101
1393
|
});
|
|
@@ -1428,6 +1720,7 @@ const OpenCodeDriver = {
|
|
|
1428
1720
|
const openCodeRuntime = yield* OpenCodeRuntime;
|
|
1429
1721
|
const serverConfig = yield* ServerConfig;
|
|
1430
1722
|
const httpClient = yield* HttpClient.HttpClient;
|
|
1723
|
+
const serverSettings = yield* ServerSettingsService;
|
|
1431
1724
|
const eventLoggers = yield* ProviderEventLoggers;
|
|
1432
1725
|
const processEnv = mergeProviderInstanceEnvironment(environment);
|
|
1433
1726
|
const continuationIdentity = defaultProviderContinuationIdentity({
|
|
@@ -1469,7 +1762,7 @@ const OpenCodeDriver = {
|
|
|
1469
1762
|
haveSettingsChanged: () => false,
|
|
1470
1763
|
initialSnapshot: (settings) => stampIdentity(makePendingOpenCodeProvider(settings)),
|
|
1471
1764
|
checkProvider,
|
|
1472
|
-
enrichSnapshot: ({ snapshot, publishSnapshot }) => enrichProviderSnapshotWithVersionAdvisory(snapshot, maintenanceCapabilities).pipe(Effect.provideService(HttpClient.HttpClient, httpClient), Effect.flatMap((enrichedSnapshot) => publishSnapshot(enrichedSnapshot))),
|
|
1765
|
+
enrichSnapshot: ({ snapshot, publishSnapshot }) => enrichProviderSnapshotWithVersionAdvisory(snapshot, maintenanceCapabilities).pipe(Effect.provideService(HttpClient.HttpClient, httpClient), Effect.provideService(ServerSettingsService, serverSettings), Effect.flatMap((enrichedSnapshot) => publishSnapshot(enrichedSnapshot))),
|
|
1473
1766
|
refreshInterval: null
|
|
1474
1767
|
}).pipe(Effect.mapError((cause) => new ProviderDriverError({
|
|
1475
1768
|
driver: DRIVER_KIND,
|