@xopcai/xopc 0.0.443 → 0.0.444
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/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/src/plugin.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BDHgk3CW.js → automations-page-K3trjTZl.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-B7D9U89Z.js → automations-workspace-D7m3w_9B.js} +2 -2
- package/dist/gateway/static/root/assets/{chat-page-CAt7FyMT.js → chat-page-CeHOmJqM.js} +2 -2
- package/dist/gateway/static/root/assets/{home-page-CpbsTucI.js → home-page-Df3X6-Ko.js} +1 -1
- package/dist/gateway/static/root/assets/{index-CbhkKfcy.js → index-Cg0AgHw1.js} +4 -4
- package/dist/gateway/static/root/assets/{personal-page-Dah3dgRQ.js → personal-page-BZWJKyZ8.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-VPcXR1YD.js → project-detail-page-Bkxs8knZ.js} +1 -1
- package/dist/gateway/static/root/assets/{route-preload-Blmi-1Iq.js → route-preload-BVo8JPwW.js} +2 -2
- package/dist/gateway/static/root/assets/{settings-page-CMSYmtOu.js → settings-page-irv-JoTz.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-BuP1vEuu.js → task-detail-page-6awKGnOr.js} +1 -1
- package/dist/gateway/static/root/assets/{task-result-evidence-B1MHhqVR.js → task-result-evidence-Cy9txdqV.js} +1 -1
- package/dist/gateway/static/root/assets/use-composer-attachments-ClakaDU1.js +2 -0
- package/dist/gateway/static/root/index.html +4 -4
- package/dist/package.js +1 -1
- package/dist/src/agent/embedded/codemode-extension.js +10 -1
- package/dist/src/agent/embedded/run-turn.js +2 -1
- package/dist/src/agent/embedded/session-runner.js +1 -0
- package/dist/src/agent/orchestration/llm-turn-retry.d.ts +4 -0
- package/dist/src/agent/orchestration/llm-turn-retry.js +14 -1
- package/dist/src/agent/tools/task-collaboration-tool.js +10 -1
- package/dist/src/agent/tools/task-evidence.js +1 -0
- package/dist/src/channels/index.js +1 -1
- package/dist/src/channels/manager.js +1 -1
- package/dist/src/cli/commands/connectors.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/cli/commands/update.js +1 -1
- package/dist/src/extensions/sdk/index.js +1 -1
- package/dist/src/gateway/hono/routes/imports.js +1 -1
- package/dist/src/gateway/hono/routes/local-apps.js +1 -1
- package/dist/src/gateway/hono/routes/personal-agent.js +2 -2
- package/dist/src/gateway/hono/routes/update.js +2 -2
- package/dist/src/gateway/index.js +1 -1
- package/dist/src/gateway/run-loop.js +2 -2
- package/dist/src/gateway/service/run-gateway-agent.js +1 -1
- package/dist/src/gateway/service.js +12 -12
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/infra/gateway-processes.js +1 -1
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/infra/update-runner.js +2 -2
- package/dist/src/infra/update-startup.js +1 -1
- package/dist/src/notifications/service.js +2 -2
- package/dist/src/tasks/task-research-result.js +5 -2
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/use-composer-attachments-Brdrrzrp.js +0 -2
|
@@ -67,7 +67,7 @@ function createXopcCodemodeExtension(policy, tools, getSession) {
|
|
|
67
67
|
isError: true
|
|
68
68
|
};
|
|
69
69
|
try {
|
|
70
|
-
|
|
70
|
+
const override = await getSession()?.agent.afterToolCall?.({
|
|
71
71
|
...contextFor(event.toolCallId, event.toolName, event.input),
|
|
72
72
|
result: {
|
|
73
73
|
content: event.content,
|
|
@@ -77,6 +77,15 @@ function createXopcCodemodeExtension(policy, tools, getSession) {
|
|
|
77
77
|
},
|
|
78
78
|
isError: event.isError
|
|
79
79
|
}, active.signal);
|
|
80
|
+
pi.appendEntry("codemode-tool-result", {
|
|
81
|
+
parentToolCallId: event.parentToolCallId,
|
|
82
|
+
toolCallId: event.toolCallId,
|
|
83
|
+
toolName: event.toolName,
|
|
84
|
+
content: override?.content ?? event.content,
|
|
85
|
+
details: override?.details ?? event.details,
|
|
86
|
+
isError: override?.isError ?? event.isError
|
|
87
|
+
});
|
|
88
|
+
return override;
|
|
80
89
|
} catch {
|
|
81
90
|
return {
|
|
82
91
|
content: [{
|
|
@@ -18,7 +18,7 @@ import { resolveAgentAbortReason } from "../orchestration/run-termination.js";
|
|
|
18
18
|
import { isAgentTurnTimeoutError, isAgentTurnUnsettledError, resolveAgentTurnTimeoutMs, runAgentTurnWithTimeout } from "../orchestration/run-agent-turn-with-timeout.js";
|
|
19
19
|
import { isContextOverflowError } from "../orchestration/context-overflow.js";
|
|
20
20
|
import { ACCEPTANCE_REPAIR_READ_TOOLS, canResumeAfterModelFailure, completedRecoveryToolResult } from "../orchestration/turn-recovery.js";
|
|
21
|
-
import { classifyLlmFailure, getAssistantTurnErrorMessage, isAssistantTurnAborted, isAssistantTurnFailed, maybeRetryTurnAfterTransientLlmFailure, stripTrailingErrorAssistantMessages } from "../orchestration/llm-turn-retry.js";
|
|
21
|
+
import { classifyLlmFailure, getAssistantTurnErrorMessage, isAssistantTurnAborted, isAssistantTurnFailed, maybeRetryTurnAfterTransientLlmFailure, recordLlmRetryOutcome, stripTrailingErrorAssistantMessages } from "../orchestration/llm-turn-retry.js";
|
|
22
22
|
import { allowsExecutionTool, filterExecutionTools, resolveExecutionToolPolicy } from "./execution-tool-policy.js";
|
|
23
23
|
import { isPhoneAssistanceSuspended, phoneAssistance, phoneResumeForRun } from "../../phone/assistance.js";
|
|
24
24
|
import { runWithEmbeddedExecutionSession } from "./execution-context.js";
|
|
@@ -929,6 +929,7 @@ async function runXopcEmbeddedTurnInner(params) {
|
|
|
929
929
|
}, "Embedded first response text ready");
|
|
930
930
|
}
|
|
931
931
|
if (event.type === "message_end" && event.message.role === "assistant") {
|
|
932
|
+
recordLlmRetryOutcome(requestRetryBudget, event.message.stopReason);
|
|
932
933
|
recordPromptCacheTouch(conversationId, resolvedModel, event.message.usage);
|
|
933
934
|
if (event.message.stopReason === "error" || event.message.stopReason === "aborted") log.warn({
|
|
934
935
|
conversationId,
|
|
@@ -255,6 +255,7 @@ var EmbeddedSessionRunnerPool = class {
|
|
|
255
255
|
conversationId: params.transcriptRuntime.persistent ? runtimeId : void 0,
|
|
256
256
|
persistCustomTypes: [
|
|
257
257
|
"codemode-store",
|
|
258
|
+
"codemode-tool-result",
|
|
258
259
|
TOOL_DISCOVERY_STATE,
|
|
259
260
|
"coding_run_started",
|
|
260
261
|
"coding_verification",
|
|
@@ -35,6 +35,10 @@ export interface RetryTransientTurnOptions {
|
|
|
35
35
|
warn: (obj: Record<string, unknown>, msg: string) => void;
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
+
/** A completed model response ends a consecutive failure streak, including tool-use responses. */
|
|
39
|
+
export declare function recordLlmRetryOutcome(budget: {
|
|
40
|
+
continues: number;
|
|
41
|
+
}, stopReason: string): void;
|
|
38
42
|
/**
|
|
39
43
|
* After waitForIdle(), call this to optionally re-run the last user turn when the
|
|
40
44
|
* assistant message only contains a transient provider/network error.
|
|
@@ -53,6 +53,10 @@ function stripTrailingErrorAssistantMessages(messages) {
|
|
|
53
53
|
}
|
|
54
54
|
return out;
|
|
55
55
|
}
|
|
56
|
+
/** A completed model response ends a consecutive failure streak, including tool-use responses. */
|
|
57
|
+
function recordLlmRetryOutcome(budget, stopReason) {
|
|
58
|
+
if (stopReason === "stop" || stopReason === "toolUse") budget.continues = 0;
|
|
59
|
+
}
|
|
56
60
|
async function waitForRetryDelay(delayMs, signal) {
|
|
57
61
|
signal?.throwIfAborted();
|
|
58
62
|
if (delayMs <= 0) return;
|
|
@@ -126,6 +130,15 @@ async function maybeRetryTurnAfterTransientLlmFailure(agent, options) {
|
|
|
126
130
|
await agent.continue();
|
|
127
131
|
await agent.waitForIdle();
|
|
128
132
|
}
|
|
133
|
+
const errorMessage = getAssistantTurnErrorMessage(agent);
|
|
134
|
+
if (budget.continues >= maxContinues && errorMessage) options.log.warn({
|
|
135
|
+
conversationId: options.conversationId,
|
|
136
|
+
errorMessage,
|
|
137
|
+
phase: "model_request_recovery",
|
|
138
|
+
recoveryBlockedReason: "retry_budget_exhausted",
|
|
139
|
+
continueAttempts: budget.continues,
|
|
140
|
+
maxContinues
|
|
141
|
+
}, "Model recovery stopped after consecutive retry failures");
|
|
129
142
|
}
|
|
130
143
|
//#endregion
|
|
131
|
-
export { classifyLlmFailure, getAssistantTurnErrorMessage, getLastAssistantMessage, isAssistantTurnAborted, isAssistantTurnFailed, isTransientLlmErrorMessage, maybeRetryTurnAfterTransientLlmFailure, stripTrailingErrorAssistantMessages };
|
|
144
|
+
export { classifyLlmFailure, getAssistantTurnErrorMessage, getLastAssistantMessage, isAssistantTurnAborted, isAssistantTurnFailed, isTransientLlmErrorMessage, maybeRetryTurnAfterTransientLlmFailure, recordLlmRetryOutcome, stripTrailingErrorAssistantMessages };
|
|
@@ -179,7 +179,16 @@ function createTaskCollaborationTool(deps) {
|
|
|
179
179
|
const { tools } = taskResearchEvidence(conversationId);
|
|
180
180
|
if (input.toolCallId) {
|
|
181
181
|
const tool = tools.find((item) => item.toolCallId === input.toolCallId);
|
|
182
|
-
if (!tool) throw new Error(
|
|
182
|
+
if (!tool) throw new Error(JSON.stringify({
|
|
183
|
+
code: "evidence_read_not_found",
|
|
184
|
+
message: "Successful evidence read not found in this execution",
|
|
185
|
+
toolCallId: input.toolCallId,
|
|
186
|
+
recovery: "List section=evidence without toolCallId and use an exact returned ID. Only successful source reads from the current TaskRun qualify; evidence listing/replay calls are not new sources. Older Codemode call metadata may have no persisted output; use an available original source read instead. Do not retry the same missing ID.",
|
|
187
|
+
availableReads: tools.slice(-10).map(({ toolCallId, toolName }) => ({
|
|
188
|
+
toolCallId,
|
|
189
|
+
toolName
|
|
190
|
+
}))
|
|
191
|
+
}));
|
|
183
192
|
return reply({
|
|
184
193
|
toolCallId: tool.toolCallId,
|
|
185
194
|
toolName: tool.toolName,
|
|
@@ -19,6 +19,7 @@ function withTaskEvidenceIdentity(tool) {
|
|
|
19
19
|
...tool,
|
|
20
20
|
execute: async (...args) => {
|
|
21
21
|
const result = await tool.execute(args[0], args[1], args[2], args[3]);
|
|
22
|
+
if (tool.name === "task_collaboration" && !result.details?.taskSourceRead) return result;
|
|
22
23
|
const artifacts = tool.name === "publish_artifacts" ? result.details?.artifacts : void 0;
|
|
23
24
|
const receipt = artifacts ? [{
|
|
24
25
|
type: "text",
|
|
@@ -7,8 +7,8 @@ import { chunkMarkdownIR, markdownToIR, markdownToIRWithMeta } from "../markdown
|
|
|
7
7
|
import { renderMarkdownWithMarkers } from "../markdown/render.js";
|
|
8
8
|
import { convertMarkdownTables } from "../markdown/tables.js";
|
|
9
9
|
import { buildCodeSpanIndex, createInlineCodeState } from "../markdown/code-spans.js";
|
|
10
|
-
import { ChannelManager, createChannelManager } from "./manager.js";
|
|
11
10
|
import "./format.js";
|
|
12
11
|
import { MessagePipeline, createEnvelopeTimestampHandler, createFilterCommandsHandler, createFilterEmptyHandler, createFilterSelfHandler, createPipeline, standardPreflightHandlers, standardProcessHandlers } from "./pipeline.js";
|
|
12
|
+
import { ChannelManager, createChannelManager } from "./manager.js";
|
|
13
13
|
import { collectSetupWizardChannels } from "./setup-wizard-discovery.js";
|
|
14
14
|
export { ChannelManager, MessagePipeline, buildCodeSpanIndex, chunkMarkdownIR, chunkText, collectSetupWizardChannels, compileAllowlist, convertMarkdownTables, createChannelManager, createEnvelopeTimestampHandler, createFilterCommandsHandler, createFilterEmptyHandler, createFilterSelfHandler, createInlineCodeState, createPipeline, evaluateAccess, findFenceSpanAt, getChannelPlugin, getChannelRegistryVersion, hasBotMention, isSafeFenceBreak, listChannelPlugins, markdownToIR, markdownToIRWithMeta, parseFenceSpans, parseFrontmatterBlock, removeBotMention, renderMarkdownWithMarkers, resolveAllowlistMatch, resolveAllowlistMatchSimple, resolveDmPolicy, resolveGroupPolicy, standardPreflightHandlers, standardProcessHandlers, syncChannelPluginsFromManager };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createLogger } from "../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
3
|
import { ChannelHealthMonitor } from "./health-monitor.js";
|
|
4
|
-
import { ChannelPluginRegistry } from "./plugin-registry.js";
|
|
5
4
|
import { ChannelHeartbeatScheduler } from "./heartbeat-scheduler.js";
|
|
5
|
+
import { ChannelPluginRegistry } from "./plugin-registry.js";
|
|
6
6
|
import { ChannelOutboundSender } from "./outbound-sender.js";
|
|
7
7
|
import { ChannelLifecycleSupervisor } from "./lifecycle-supervisor.js";
|
|
8
8
|
//#region src/channels/manager.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getStoreConnectorInstallPlan, installStoreConnector, listStoreConnectors } from "../../capabilities/store-connector.js";
|
|
2
2
|
import { loadConfig, saveConfig } from "../../config/loader.js";
|
|
3
3
|
import { register } from "../registry.js";
|
|
4
|
-
import { Command } from "commander";
|
|
5
4
|
import { confirm } from "@inquirer/prompts";
|
|
5
|
+
import { Command } from "commander";
|
|
6
6
|
//#region src/cli/commands/connectors.ts
|
|
7
7
|
function parsePairs(values, option) {
|
|
8
8
|
const output = {};
|
|
@@ -16,8 +16,8 @@ import { existsSync, readFileSync, statSync } from "node:fs";
|
|
|
16
16
|
import { createHash } from "node:crypto";
|
|
17
17
|
import { execSync } from "node:child_process";
|
|
18
18
|
import semver from "semver";
|
|
19
|
-
import { Command } from "commander";
|
|
20
19
|
import { confirm } from "@inquirer/prompts";
|
|
20
|
+
import { Command } from "commander";
|
|
21
21
|
//#region src/cli/commands/extension-marketplace.ts
|
|
22
22
|
init_paths();
|
|
23
23
|
const MANIFEST = "xopc.extension.json";
|
|
@@ -3,8 +3,8 @@ import { loadConfig } from "../../../config/loader.js";
|
|
|
3
3
|
import "../../../config/index.js";
|
|
4
4
|
import { isRestartEnabled } from "../../../config/commands.flags.js";
|
|
5
5
|
import { resolveGatewayService } from "../../../daemon/service.js";
|
|
6
|
-
import { authorizeGatewaySigusr1Restart, writeGatewayRestartIntentSync } from "../../../infra/restart.js";
|
|
7
6
|
import { findVerifiedGatewayListenerPidsOnPortSync, formatGatewayPidList, signalVerifiedGatewayPidSync } from "../../../infra/gateway-processes.js";
|
|
7
|
+
import { authorizeGatewaySigusr1Restart, writeGatewayRestartIntentSync } from "../../../infra/restart.js";
|
|
8
8
|
import { runServiceRestart, runServiceStop } from "./lifecycle-core.js";
|
|
9
9
|
import { DEFAULT_RESTART_HEALTH_ATTEMPTS, renderGatewayPortHealthDiagnostics, waitForGatewayHealthyListener } from "./restart-health.js";
|
|
10
10
|
import { parsePortFromArgs, renderGatewayServiceStartHints, resolveGatewayPortFromConfig } from "./shared.js";
|
|
@@ -16,8 +16,8 @@ import { prepareUpdateGlobalDefaults } from "../../gateway/global-defaults-admin
|
|
|
16
16
|
import { disconnectProvider } from "../../providers/provider-disconnect.js";
|
|
17
17
|
import { colors } from "../utils/colors.js";
|
|
18
18
|
import { runCliOAuthLogin } from "../utils/oauth-login.js";
|
|
19
|
-
import { Command } from "commander";
|
|
20
19
|
import { input } from "@inquirer/prompts";
|
|
20
|
+
import { Command } from "commander";
|
|
21
21
|
//#region src/cli/commands/models.ts
|
|
22
22
|
init_credentials();
|
|
23
23
|
init_schema();
|
|
@@ -11,8 +11,8 @@ import { initWorkspace } from "../utils/init-workspace.js";
|
|
|
11
11
|
import { setupModel } from "./onboard/model.js";
|
|
12
12
|
import { getChannelConfigurators } from "./onboard/channels/registry.js";
|
|
13
13
|
import { setupChannels } from "./onboard/channels/index.js";
|
|
14
|
-
import { Command } from "commander";
|
|
15
14
|
import { select } from "@inquirer/prompts";
|
|
15
|
+
import { Command } from "commander";
|
|
16
16
|
//#region src/cli/commands/onboard.ts
|
|
17
17
|
init_repository();
|
|
18
18
|
init_schema();
|
|
@@ -2,9 +2,9 @@ import { PACKAGE_VERSION, init_package_version } from "../../package-version.js"
|
|
|
2
2
|
import { loadConfig } from "../../config/loader.js";
|
|
3
3
|
import { formatExamples, register } from "../registry.js";
|
|
4
4
|
import "../../config/index.js";
|
|
5
|
-
import { acquireUpdateLock } from "../../infra/update-lock.js";
|
|
6
5
|
import { normalizeUpdateChannel } from "../../infra/update-channels.js";
|
|
7
6
|
import { compareSemver, resolveNpmChannelTag } from "../../infra/update-check.js";
|
|
7
|
+
import { acquireUpdateLock } from "../../infra/update-lock.js";
|
|
8
8
|
import { formatUpdateApiResult, resolveUpdateInstallSurface, runGatewayUpdateWithPostSteps } from "../../infra/update-runner.js";
|
|
9
9
|
import { Command } from "commander";
|
|
10
10
|
//#region src/cli/commands/update.ts
|
|
@@ -7,8 +7,8 @@ import { DEFAULT_SECURITY_CONFIG, checkExtensionDirSafety, checkExtensionPathSaf
|
|
|
7
7
|
import { SlotRegistry, getSlotRegistry, registerSlotType } from "../slots.js";
|
|
8
8
|
import { ExtensionDiagnostics, ExtensionLoaderCacheImpl, getExtensionCache, getExtensionDiagnostics } from "../diagnostics.js";
|
|
9
9
|
import { ExtensionHookRunner, createHookContext, isHookEvent } from "../hooks.js";
|
|
10
|
-
import { registerExtensionCliProgram } from "./channel-helpers.js";
|
|
11
10
|
import { defineChannelPluginEntry } from "./channel-entry.js";
|
|
11
|
+
import { registerExtensionCliProgram } from "./channel-helpers.js";
|
|
12
12
|
import { lazyFunction, lazyModule } from "./lazy.js";
|
|
13
13
|
import { createMockExtensionApi, createTestGateway } from "./testing.js";
|
|
14
14
|
//#region src/extensions/sdk/index.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { getGatewayPrincipal } from "../../security/gateway-principal.js";
|
|
2
1
|
import { ImportError } from "../../../imports/types.js";
|
|
3
2
|
import { isImportSource } from "../../../imports/sources.js";
|
|
4
3
|
import { ImportSelectionRepository } from "../../../storage/sqlite/import-selection-repository.js";
|
|
5
4
|
import { getLiveInventory, previewInventoryItem, publicInventory, scanProduct } from "../../../imports/inventory.js";
|
|
6
5
|
import { importSelection, listImportSources } from "../../../imports/productImport.js";
|
|
7
6
|
import { createRuntimeImportService } from "../../../imports/runtime.js";
|
|
7
|
+
import { getGatewayPrincipal } from "../../security/gateway-principal.js";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
//#region src/gateway/hono/routes/imports.ts
|
|
10
10
|
const selectionSchema = z.object({
|
|
@@ -5,9 +5,9 @@ import "../../../capabilities/runtime/dispatcher.js";
|
|
|
5
5
|
import { parseLocalAppFixGuidanceInput } from "../../../local-apps/fix-guidance.js";
|
|
6
6
|
import { readLocalAppAcceptanceConfig } from "../../../local-apps/acceptance.js";
|
|
7
7
|
import { createProductDispatcher } from "../../../capabilities/runtime/product.js";
|
|
8
|
+
import { LOCAL_APP_RUNTIME_BRIDGE_HASH, injectLocalAppRuntimeBridge } from "../../../local-apps/preview-runtime-bridge.js";
|
|
8
9
|
import { extensionAssetMimeType } from "../lib/extension-assets.js";
|
|
9
10
|
import { capabilityHttpContext, capabilityHttpError } from "../../../capabilities/adapters/http.js";
|
|
10
|
-
import { LOCAL_APP_RUNTIME_BRIDGE_HASH, injectLocalAppRuntimeBridge } from "../../../local-apps/preview-runtime-bridge.js";
|
|
11
11
|
import { relative, resolve } from "node:path";
|
|
12
12
|
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
13
13
|
import { randomUUID } from "node:crypto";
|
|
@@ -3,11 +3,11 @@ import { getPersonalRequest, init_request_repository, listPersonalRequests } fro
|
|
|
3
3
|
import { getPersonalAgent } from "../../../personal-agent/repository.js";
|
|
4
4
|
import { TaskOriginRepository } from "../../../tasks/task-origin-repository.js";
|
|
5
5
|
import { cancelPersonalRequest, personalRequestSnapshot, publishPersonalRequest } from "../../../personal-agent/request-service.js";
|
|
6
|
-
import { writeAgentAvatarFromBase64 } from "../../agents-admin.js";
|
|
7
|
-
import { getGatewayPrincipal } from "../../security/gateway-principal.js";
|
|
8
6
|
import { PersonalOnboardingDraftSchema, PersonalOnboardingStepSchema, finishPersonalWelcome, getPersonalOnboarding, savePersonalOnboarding } from "../../../personal-agent/onboarding.js";
|
|
9
7
|
import { PersonalAppearanceSchema, createOrResumePersonalAgent, ensurePersonalConversationVisibility, listPersonalModels, patchPersonalProfile, refreshPersonalDelegationGuidance } from "../../../personal-agent/service.js";
|
|
10
8
|
import { markPersonalRead, personalUnreadSnapshot } from "../../../personal-agent/unread.js";
|
|
9
|
+
import { writeAgentAvatarFromBase64 } from "../../agents-admin.js";
|
|
10
|
+
import { getGatewayPrincipal } from "../../security/gateway-principal.js";
|
|
11
11
|
import { registerProactivityRoutes } from "../../../personal-agent/proactivity/routes.js";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
//#region src/gateway/hono/routes/personal-agent.ts
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PACKAGE_VERSION, init_package_version } from "../../../package-version.js";
|
|
2
2
|
import { loadConfig } from "../../../config/loader.js";
|
|
3
3
|
import "../../../config/index.js";
|
|
4
|
-
import { acquireUpdateLock } from "../../../infra/update-lock.js";
|
|
5
4
|
import { normalizeUpdateChannel } from "../../../infra/update-channels.js";
|
|
5
|
+
import { acquireUpdateLock } from "../../../infra/update-lock.js";
|
|
6
|
+
import { formatUpdateApiResult, runGatewayUpdateWithPostSteps } from "../../../infra/update-runner.js";
|
|
6
7
|
import { getUpdateAvailable, runGatewayUpdateCheck } from "../../../infra/update-startup.js";
|
|
7
8
|
import { createGatewayRouteLogger } from "../lib/route-logger.js";
|
|
8
|
-
import { formatUpdateApiResult, runGatewayUpdateWithPostSteps } from "../../../infra/update-runner.js";
|
|
9
9
|
import { streamSSE } from "hono/streaming";
|
|
10
10
|
//#region src/gateway/hono/routes/update.ts
|
|
11
11
|
init_package_version();
|
|
@@ -3,6 +3,7 @@ import { buildDefaultCorsOrigins, isAllInterfacesHost, isLoopbackHost, resolveEf
|
|
|
3
3
|
import { isGatewayStrictSecurityEnabled } from "./rate-limit/env-flags.js";
|
|
4
4
|
import "./rate-limit/index.js";
|
|
5
5
|
import { defaultGatewayBindMode, isContainerEnvironment, resolveGatewayBindHost, resolveGatewayBindHostSync, resolveGatewayBindMode, resolveGatewayEffectiveHost } from "../config/gateway-bind.js";
|
|
6
|
+
import { checkPortAvailable, forceFreePortAndWait, listPortListeners, parseLsofOutput } from "./ports.js";
|
|
6
7
|
import { assertGatewayAuthConfigured, extractToken, resolveGatewayAuth, validateToken } from "./auth.js";
|
|
7
8
|
import { resolveGatewayListenHost, resolveGatewayListenPlan } from "./listen.js";
|
|
8
9
|
import { assertGatewayRuntimeConfig } from "./runtime-config.js";
|
|
@@ -12,7 +13,6 @@ import { createHonoApp } from "./hono/app.js";
|
|
|
12
13
|
import { GatewayServer } from "./server.js";
|
|
13
14
|
import { GatewayLockError, acquireGatewayLock } from "./lock.js";
|
|
14
15
|
import { runGatewayLoop } from "./run-loop.js";
|
|
15
|
-
import { checkPortAvailable, forceFreePortAndWait, listPortListeners, parseLsofOutput } from "./ports.js";
|
|
16
16
|
import { apiError, apiOk } from "./protocol.js";
|
|
17
17
|
import "./hono/index.js";
|
|
18
18
|
import { assertSecureGatewayHttpUrl, assertSecureWebSocketUrl, isInsecurePrivateWsAllowed, isSecureWebSocketUrl } from "./ws-security.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { loadConfig } from "../config/loader.js";
|
|
2
2
|
import { isRestartEnabled } from "../config/commands.flags.js";
|
|
3
|
+
import { consumeGatewayRestartIntentSync, consumeGatewaySigusr1RestartAuthorization, isGatewaySigusr1RestartExternallyAllowed, resetGatewayRestartStateForInProcessRestart, scheduleGatewaySigusr1Restart, setGatewaySigusr1RestartPolicy } from "../infra/restart.js";
|
|
4
|
+
import { runBootstrapMigrationsSync } from "../migrations/runner.js";
|
|
3
5
|
import { restartGatewayProcessWithFreshPid } from "./respawn.js";
|
|
4
6
|
import { acquireGatewayLock } from "./lock.js";
|
|
5
|
-
import { runBootstrapMigrationsSync } from "../migrations/runner.js";
|
|
6
|
-
import { consumeGatewayRestartIntentSync, consumeGatewaySigusr1RestartAuthorization, isGatewaySigusr1RestartExternallyAllowed, resetGatewayRestartStateForInProcessRestart, scheduleGatewaySigusr1Restart, setGatewaySigusr1RestartPolicy } from "../infra/restart.js";
|
|
7
7
|
//#region src/gateway/run-loop.ts
|
|
8
8
|
/**
|
|
9
9
|
* Gateway Run Loop - Core run loop for gateway process management
|
|
@@ -20,8 +20,8 @@ import { recordPersonalPerformance } from "../../personal-agent/performance.js";
|
|
|
20
20
|
import { formatAgentRunErrorForClient } from "../../agent/client-error-format.js";
|
|
21
21
|
import "../chat-limits.js";
|
|
22
22
|
import { prependEnvelopeTimestamp } from "../../channels/envelope-timestamp.js";
|
|
23
|
-
import { ChatStreamMapper } from "../chat-stream/mapper.js";
|
|
24
23
|
import { markdownNotificationPreview } from "../../notifications/plain-text.js";
|
|
24
|
+
import { ChatStreamMapper } from "../chat-stream/mapper.js";
|
|
25
25
|
import { resolveWebchatConversationId } from "../resolve-webchat-session-key.js";
|
|
26
26
|
import { recordExplicitRelationshipFollowUp } from "../../user-context/relationship-continuity.js";
|
|
27
27
|
import { coalesceThinkingDeltas } from "../chat-stream/thinking-delta-coalescer.js";
|
|
@@ -82,6 +82,8 @@ import "../infra/bus/index.js";
|
|
|
82
82
|
import { collectMediaUrisFromMessages, deleteMediaUris } from "../media/session-references.js";
|
|
83
83
|
import { AgentService } from "../agent/service.js";
|
|
84
84
|
import { bootstrapApplicationStateSync } from "../bootstrap/application-state.js";
|
|
85
|
+
import { registerClarificationChannelRuntime } from "./clarify-runtime.js";
|
|
86
|
+
import { ChannelManager } from "../channels/manager.js";
|
|
85
87
|
import { ChatPreviewService } from "../chat-previews/service.js";
|
|
86
88
|
import "../chat-previews/index.js";
|
|
87
89
|
import { configureGatewayHttpProxy } from "../infra/http-proxy-env.js";
|
|
@@ -101,10 +103,19 @@ import { DiscussionSealer } from "../discussions/sealer.js";
|
|
|
101
103
|
import "../discussions/index.js";
|
|
102
104
|
import { EndpointToolRuntime } from "../endpoint-tools/runtime.js";
|
|
103
105
|
import "../endpoint-tools/index.js";
|
|
106
|
+
import { HomeCapabilityPreflightService } from "../home-intelligence/capability-preflight.js";
|
|
107
|
+
import { HomeAdviceGenerator } from "../home-intelligence/generator.js";
|
|
108
|
+
import { HomeIntelligenceHost } from "../home-intelligence/host.js";
|
|
109
|
+
import { HomeSnapshotBuilder } from "../home-intelligence/snapshot.js";
|
|
110
|
+
import { createBackgroundTask } from "../infra/background-task.js";
|
|
111
|
+
import { scheduleGatewayUpdateCheck } from "../infra/update-startup.js";
|
|
112
|
+
import "../local-apps/index.js";
|
|
113
|
+
import "../notes/index.js";
|
|
114
|
+
import { NotificationService } from "../notifications/service.js";
|
|
115
|
+
import { allowsPersonalTaskNotification, personalReplyNotification, personalRunDelegated } from "../personal-agent/notifications.js";
|
|
104
116
|
import { assertGatewayAuthConfigured, extractToken, resolveGatewayAuth, validateToken } from "./auth.js";
|
|
105
117
|
import { prepareAutomationAgentSession } from "./automation-agent-session.js";
|
|
106
118
|
import { deliverAutomationCompletion } from "./automation-completion-delivery.js";
|
|
107
|
-
import { registerClarificationChannelRuntime } from "./clarify-runtime.js";
|
|
108
119
|
import { stopTailscaleExposure } from "./tailscale-lifecycle.js";
|
|
109
120
|
import { getGatewayFileSpaceService } from "./file-space-service.js";
|
|
110
121
|
import { reconcileHomeIntelligenceAutomation } from "./home-intelligence-automation-reconciler.js";
|
|
@@ -115,7 +126,6 @@ import { withGatewayConfigWriteLock } from "./hono/lib/config-write-lock.js";
|
|
|
115
126
|
import { PhoneStreamGateway } from "../phone/stream-gateway.js";
|
|
116
127
|
import { PersonalProactivityService } from "../personal-agent/proactivity/service.js";
|
|
117
128
|
import { reconcilePersonalProactivityAutomation } from "../personal-agent/proactivity/automation.js";
|
|
118
|
-
import { createBackgroundTask } from "../infra/background-task.js";
|
|
119
129
|
import { buildFileAgentContext } from "../agent/source-context/file-context.js";
|
|
120
130
|
import { buildSessionAgentContext } from "../agent/source-context/session-context.js";
|
|
121
131
|
import { buildBrowserTabAgentContext } from "../agent/source-context/browser-tab.js";
|
|
@@ -123,8 +133,6 @@ import { WorkDiscoveryService } from "../work-discovery/service.js";
|
|
|
123
133
|
import { buildVoiceMemoryContext } from "../voice/realtime/memory-context.js";
|
|
124
134
|
import { buildVoicePersonaContext } from "../voice/realtime/persona-context.js";
|
|
125
135
|
import { voiceMemoryBudget, voicePersonaBudget } from "../voice/realtime/conversation-context.js";
|
|
126
|
-
import { ChannelManager } from "../channels/manager.js";
|
|
127
|
-
import "../notes/index.js";
|
|
128
136
|
import { EphemeralSideChatManager } from "./side-chat/manager.js";
|
|
129
137
|
import { SideChatRunService } from "./side-chat/run-service.js";
|
|
130
138
|
import { SideChatPromotionService } from "./side-chat/promotion-service.js";
|
|
@@ -137,11 +145,8 @@ import { assertGatewayRuntimeConfig } from "./runtime-config.js";
|
|
|
137
145
|
import { auditGatewayConfig } from "./security/audit.js";
|
|
138
146
|
import { getXopcCloudCatalogCoordinator } from "../providers/xopc-cloud-catalog-coordinator.js";
|
|
139
147
|
import { ModelCatalogSyncService } from "../providers/model-catalog-sync-service.js";
|
|
140
|
-
import { NotificationService } from "../notifications/service.js";
|
|
141
|
-
import "../local-apps/index.js";
|
|
142
148
|
import { TaskAllocationDispatcher } from "../tasks/task-allocation-service.js";
|
|
143
149
|
import { TaskResultDeliveryService } from "../tasks/task-result-delivery-service.js";
|
|
144
|
-
import { scheduleGatewayUpdateCheck } from "../infra/update-startup.js";
|
|
145
150
|
import { resolveChannelConnectDeferSet } from "./resolve-channel-connect-defer.js";
|
|
146
151
|
import { restartGatewayProcessWithFreshPid } from "./respawn.js";
|
|
147
152
|
import { GatewaySessionsApi } from "./service/sessions-api.js";
|
|
@@ -159,15 +164,10 @@ import { createGatewayStartupTrace } from "./startup-trace.js";
|
|
|
159
164
|
import { TaskCollaborationDelivery } from "../tasks/task-collaboration-delivery.js";
|
|
160
165
|
import { TaskMainUpdateExhaustedError } from "../tasks/task-main-update-retry.js";
|
|
161
166
|
import { TaskMainUpdateDelivery } from "../tasks/task-main-update-delivery.js";
|
|
162
|
-
import { allowsPersonalTaskNotification, personalReplyNotification, personalRunDelegated } from "../personal-agent/notifications.js";
|
|
163
167
|
import { TaskMainUpdateDecisionService } from "../tasks/task-main-update-decision-service.js";
|
|
164
168
|
import { selectTaskMainUpdateAttempt, submitAndConfirmTaskMainUpdate } from "../tasks/task-main-update-input.js";
|
|
165
169
|
import { checkAppContextAccess, prepareAppContext } from "./service/app-context-access.js";
|
|
166
170
|
import { applyAutomaticVoiceLanguage, inferProductLanguageFromEnvironment, initializeVoiceDefaults } from "../voice/language-profile.js";
|
|
167
|
-
import { HomeAdviceGenerator } from "../home-intelligence/generator.js";
|
|
168
|
-
import { HomeIntelligenceHost } from "../home-intelligence/host.js";
|
|
169
|
-
import { HomeSnapshotBuilder } from "../home-intelligence/snapshot.js";
|
|
170
|
-
import { HomeCapabilityPreflightService } from "../home-intelligence/capability-preflight.js";
|
|
171
171
|
import crypto from "node:crypto";
|
|
172
172
|
//#region src/gateway/service.ts
|
|
173
173
|
init_session_repository();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createLogger } from "../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
|
-
import { HomeAdviceBudgetExceededError, isHomeProseLocalized } from "./generator.js";
|
|
4
3
|
import { homePatternKey } from "./strategy.js";
|
|
5
|
-
import { HomeAdvicePolicy } from "./policy.js";
|
|
6
4
|
import { HomeIntelligenceRepository } from "./repository.js";
|
|
7
5
|
import { HomeOpportunityApplicationService } from "./application-service.js";
|
|
6
|
+
import { HomeAdvicePolicy } from "./policy.js";
|
|
7
|
+
import { HomeAdviceBudgetExceededError, isHomeProseLocalized } from "./generator.js";
|
|
8
8
|
import { buildHomeOpportunityNotification } from "./notification.js";
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
//#region src/home-intelligence/host.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { listPortListeners } from "../gateway/ports.js";
|
|
2
1
|
import { isGatewayArgv, parseProcCmdline } from "./gateway-process-argv.js";
|
|
2
|
+
import { listPortListeners } from "../gateway/ports.js";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import { spawnSync } from "node:child_process";
|
|
5
5
|
//#region src/infra/gateway-processes.ts
|
|
@@ -4,8 +4,8 @@ import { init_paths, resolveConfigPath } from "../config/paths.js";
|
|
|
4
4
|
import { loadConfig } from "../config/loader.js";
|
|
5
5
|
import { isRestartEnabled } from "../config/commands.flags.js";
|
|
6
6
|
import { resolveGatewayService } from "../daemon/service.js";
|
|
7
|
-
import { authorizeGatewaySigusr1Restart, writeGatewayRestartIntentSync } from "./restart.js";
|
|
8
7
|
import { findVerifiedGatewayListenerPidsOnPortSync, signalVerifiedGatewayPidSync } from "./gateway-processes.js";
|
|
8
|
+
import { authorizeGatewaySigusr1Restart, writeGatewayRestartIntentSync } from "./restart.js";
|
|
9
9
|
import { refreshGatewayServiceAfterUpdate } from "./update-service-refresh.js";
|
|
10
10
|
//#region src/infra/update-restart.ts
|
|
11
11
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { PACKAGE_VERSION, init_package_version } from "../package-version.js";
|
|
2
2
|
import { runPostUpdateExtensionSync } from "../extensions/update.js";
|
|
3
|
-
import "./update-channels.js";
|
|
4
|
-
import { compareSemver, resolveNpmChannelTag } from "./update-check.js";
|
|
5
3
|
import { readPackageName, readPackageVersion } from "./package-json.js";
|
|
6
4
|
import { runCommandWithTimeout } from "./run-command.js";
|
|
7
5
|
import { XOPC_PACKAGE_NAME, cleanupGlobalRenameDirs, createGlobalInstallEnv, detectGlobalInstallManagerForRoot, resolveGlobalInstallSpec, resolveGlobalInstallTarget } from "./update-global.js";
|
|
8
6
|
import { runGlobalPackageUpdateSteps } from "./package-update-steps.js";
|
|
9
7
|
import { resolveStableNodePath } from "./stable-node-path.js";
|
|
8
|
+
import "./update-channels.js";
|
|
9
|
+
import { compareSemver, resolveNpmChannelTag } from "./update-check.js";
|
|
10
10
|
import { trimLogTail } from "./update-log.js";
|
|
11
11
|
import { maybeRestartGatewayAfterUpdate, prepareGatewayRestart } from "./update-restart.js";
|
|
12
12
|
import path from "node:path";
|
|
@@ -3,9 +3,9 @@ import { init_paths_state, resolveUpdateCheckStatePath } from "../config/paths-s
|
|
|
3
3
|
import { createLogger } from "../utils/logger/index.js";
|
|
4
4
|
import { init_logger } from "../utils/logger.js";
|
|
5
5
|
import { init_write_file_atomic, writeTextAtomic } from "./write-file-atomic.js";
|
|
6
|
-
import { acquireUpdateLock } from "./update-lock.js";
|
|
7
6
|
import { normalizeUpdateChannel } from "./update-channels.js";
|
|
8
7
|
import { compareSemver, detectInstallKind, resolveNpmChannelTag, resolvePackageRoot } from "./update-check.js";
|
|
8
|
+
import { acquireUpdateLock } from "./update-lock.js";
|
|
9
9
|
import { createHash, randomUUID } from "node:crypto";
|
|
10
10
|
import { readFile } from "node:fs/promises";
|
|
11
11
|
//#region src/infra/update-startup.ts
|
|
@@ -3,11 +3,11 @@ import { init_logger } from "../utils/logger.js";
|
|
|
3
3
|
import { localizeNotification } from "../../packages/gateway-contract/src/notifications.js";
|
|
4
4
|
import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
5
5
|
import { getOrCreateGatewayIdentity } from "../storage/sqlite/gateway-identity-repository.js";
|
|
6
|
+
import { flushClarificationNotifications, isClarificationNotificationActionable } from "./clarification.js";
|
|
6
7
|
import { getNotificationDevice, listDeliverableNotificationDevices } from "./device-store.js";
|
|
8
|
+
import { sendHarmonyPush } from "./harmony-push.js";
|
|
7
9
|
import { notificationPlanFromGatewayEvent } from "./planner.js";
|
|
8
10
|
import { cancelNotificationDelivery, createNotificationEvent, expireUndeliverableNotificationDeliveries, listDueNotificationDeliveries, markNotificationDeliveryAccepted, markNotificationDeliveryDead, pruneNotificationEvents, rescheduleNotificationDelivery } from "./store.js";
|
|
9
|
-
import { sendHarmonyPush } from "./harmony-push.js";
|
|
10
|
-
import { flushClarificationNotifications, isClarificationNotificationActionable } from "./clarification.js";
|
|
11
11
|
//#region src/notifications/service.ts
|
|
12
12
|
init_src();
|
|
13
13
|
init_logger();
|
|
@@ -325,11 +325,14 @@ function taskResearchEvidence(conversationId) {
|
|
|
325
325
|
if (!link || !run || run.conversationId !== conversationId || !["running", "verifying"].includes(run.status)) throw new Error("No active Task execution");
|
|
326
326
|
const transcriptId = readCurrentTranscriptId(getSqliteDatabase(), conversationId);
|
|
327
327
|
const rows = getSqliteDatabase().prepare(`SELECT payload_json, created_at FROM transcript_entries
|
|
328
|
-
WHERE transcript_id = ? AND role = 'toolResult'
|
|
328
|
+
WHERE transcript_id = ? AND (role = 'toolResult' OR
|
|
329
|
+
(role IS NULL AND json_extract(payload_json, '$.customType') = 'codemode-tool-result'))
|
|
330
|
+
AND created_at >= ? ORDER BY seq`).all(transcriptId, run.startedAt ?? 0);
|
|
329
331
|
return {
|
|
330
332
|
rows,
|
|
331
333
|
tools: rows.flatMap((row) => {
|
|
332
|
-
const
|
|
334
|
+
const stored = JSON.parse(row.payload_json);
|
|
335
|
+
const value = stored.customType === "codemode-tool-result" ? stored.data : stored;
|
|
333
336
|
if (!RESEARCH_READ_TOOLS.has(value.toolName) || value.toolName === "managed_job" && (value.details?.status !== "success" || value.details?.exitCode !== 0) || value.toolName === "task_collaboration" && value.details?.taskSourceRead?.taskId !== link.taskId || value.isError || value.details?.error || [
|
|
334
337
|
"failed",
|
|
335
338
|
"blocked",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xopcai/xopc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.444",
|
|
4
4
|
"description": "An open-source AI assistant for work and everyday life. Remembers context and helps you get things done. Local-first, on a computer you choose.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-load-DrVGNxJm.js","assets/rolldown-runtime-aKtaBQYM.js","assets/attachment-utils-core-BIOUBrpT.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{i as a,n as o,o as s}from"./locale-store-Bld7_m-Q.js";import{t as c}from"./messages-CGO1P4mz.js";import{o as l,r as u,s as d,t as f}from"./dist-BGTk37IG.js";import{t as p}from"./chevron-left-DqFhpbvK.js";import{t as m}from"./chevron-right-BweFrslA.js";import{n as h,t as g}from"./file-BqMS_3DT.js";import{a as _,b as v,l as y,n as b,t as x,x as S}from"./use-file-preview-expanded-9DED7ohY.js";import{t as C}from"./mic-CuUb7zc-.js";import{n as w}from"./share-link-dialog-C_uYNUlp.js";import{t as T}from"./cn-0WouolD0.js";import{r as ee,t as E}from"./constants-CsVXarqA.js";import{r as D}from"./tasks-D_xuHn6V.js";import{a as O,i as k,o as A}from"./capabilities-DJYgOjeq.js";import{t as j}from"./capabilities-DDJJhQ40.js";import{r as M}from"./attachment-utils-core-BIOUBrpT.js";import{a as te,n as ne,s as N,t as re}from"./file-preview-surface-Dtla5oAW.js";import{n as P}from"./interaction-BdhHBbYa.js";import{n as ie}from"./electron-env-DHOGevH3.js";import{i as F}from"./skill-wire-pattern-BPpeIcCi.js";async function I(e){return D.parse(await s(a(`/api/tasks`),{method:`POST`,body:JSON.stringify(e)}))}async function L(e){return j(`xopc.tasks.get`,{id:e})}async function R(e){return s(a(`/api/tasks/${encodeURIComponent(e)}/conversation`),{method:`POST`})}async function z(e,t,n){return await s(a(`/api/tasks/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({...t,expectedVersion:n})}),L(e)}async function ae(e){await s(a(`/api/tasks/${encodeURIComponent(e)}`),{method:`DELETE`})}async function B(e,t,n,r=crypto.randomUUID(),i=`api`){return await s(a(`/api/tasks/${encodeURIComponent(e)}/commands`),{method:`POST`,body:JSON.stringify({idempotencyKey:r,expectedVersion:n,command:t,source:i})}),L(e)}async function V(e,t,n,r,i){return await s(a(`/api/tasks/${encodeURIComponent(e)}/criteria/${t}/review`),{method:`PUT`,body:JSON.stringify({status:n,expectedVersion:r,contractVersion:i})}),L(e)}async function H(e,t,n){return await s(a(`/api/task-runs/${encodeURIComponent(t)}/cancel`),{method:`POST`,body:JSON.stringify({expectedVersion:n,reason:`Cancelled by user`})}),L(e)}async function U(e,t,n){return await s(a(`/api/tasks/${encodeURIComponent(e)}/handoff`),{method:`POST`,body:JSON.stringify({toAgentId:t,expectedVersion:n,idempotencyKey:crypto.randomUUID()})}),L(e)}async function W(e,t,n){return await s(a(`/api/tasks/${encodeURIComponent(e)}/dependencies`),{method:`PUT`,body:JSON.stringify({dependsOnTaskIds:t,expectedVersion:n})}),L(e)}async function G(e,t,n){return await s(a(`/api/tasks/${encodeURIComponent(e)}/board-position`),{method:`PUT`,body:JSON.stringify({beforeTaskId:t,expectedVersion:n})}),L(e)}async function K(e,t,n){await s(a(`/api/task-runs/${encodeURIComponent(e)}/feedback`),{method:`POST`,headers:{"idempotency-key":crypto.randomUUID()},body:JSON.stringify({rating:t,reason:n?.trim()||void 0})})}function q(e,t=!1){let n=new URLSearchParams;return e&&n.set(`locale`,e),t&&n.set(`attention`,`all`),s(a(`/api/home${n.size?`?${n.toString()}`:``}`)).then(A)}function J(e){return s(a(`/api/home/advisor/refresh`),{method:`POST`,body:JSON.stringify({idempotencyKey:crypto.randomUUID(),locale:e})})}function Y(){return s(a(`/api/home/advisor/history`)).then(e=>O.parse(e))}async function X(e,t){return k.parse(await s(a(`/api/home/opportunities/${encodeURIComponent(e.id)}/action`),{method:`POST`,body:JSON.stringify({idempotencyKey:crypto.randomUUID(),expectedRevision:e.revision,mode:t})}))}function Z(e,t){let n=crypto.randomUUID();return s(a(`/api/home/opportunities/${encodeURIComponent(e.id)}/feedback`),{method:`POST`,body:JSON.stringify({...t,idempotencyKey:n,expectedRevision:e.revision})}).then(()=>({ok:!0,idempotencyKey:n}))}function oe(e,t){return s(a(`/api/home/opportunities/${encodeURIComponent(e)}/feedback/undo`),{method:`POST`,body:JSON.stringify({idempotencyKey:t})})}function se(e,t){return s(a(`/api/home/decisions/respond`),{method:`POST`,body:JSON.stringify({...e,decision:t})})}function ce(e){return s(a(`/api/home/attention/acknowledge`),{method:`POST`,body:JSON.stringify(e)})}function le(e){return s(a(`/api/home/attention/retry`),{method:`POST`,body:JSON.stringify(e)})}function ue(e,t){let n=e.trim(),r=t.trim();return n&&F(n)?`/skill:${n}${r?` ${r}`:` `}`:r||null}function de(e,t,n){let r=e.trim(),i=t?.trim()??``;if(!r&&!i)return null;let a=new URLSearchParams;return r&&a.set(`draft`,r),a.set(`autoSend`,`1`),i&&a.set(`attachmentsHandoff`,i),n?.projectScope===`none`&&a.set(`projectScope`,`none`),`/chat/new?${a.toString()}`}function fe(e){let t=e.startsWith(`?`)?e.slice(1):e;if(!t)return``;let n=new URLSearchParams(t),r=new URLSearchParams,i=n.get(`skill`),a=n.get(`slash`),o=n.get(`draft`),s=n.get(`autoSend`),c=n.get(`attachmentHandoff`),l=n.get(`attachmentsHandoff`),u=n.get(`agentSetup`);i&&r.set(`skill`,i),a&&r.set(`slash`,a),o&&r.set(`draft`,o),s===`1`&&r.set(`autoSend`,`1`),c&&r.set(`attachmentHandoff`,c),l&&r.set(`attachmentsHandoff`,l),n.get(`setup`)===`automation`&&r.set(`setup`,`automation`),u===`1`&&r.set(`agentSetup`,`1`),n.get(`scene`)===`find-skills`&&r.set(`scene`,`find-skills`);let d=r.toString();return d?`?${d}`:``}function pe(e){let t=e.startsWith(`?`)?e.slice(1):e,n=new URLSearchParams(t),r=n.get(`projectId`)?.trim();return r?{kind:`project`,projectId:r}:n.get(`projectScope`)===`none`?{kind:`none`}:{kind:`remember-last`}}function me(e){let t=e?.trim();return t?`/chat/new?projectId=${encodeURIComponent(t)}`:`/chat/new?projectScope=none`}var he=n(),Q=e(t(),1),$=r();function ge(e){let t=(0,he.c)(6),n=v(),r,i;if(t[0]!==n||t[1]!==e?(r=()=>{!n||e.embedded||!e.open||!e.attachment||(N.getState().openFile({attachment:e.attachment,images:e.images,conversationId:e.conversationId||void 0,resultRevision:e.resultRevision},n),e.onClose())},i=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),(0,Q.useEffect)(r,i),n&&!e.embedded)return null;let a;return t[4]===e?a=t[5]:(a=(0,$.jsx)(_e,{...e}),t[4]=e,t[5]=a),a}function _e({open:e,embedded:t=!1,tabId:n,attachment:r,images:i=[],resultRevision:a,onAttachmentChange:s,authToken:h,conversationId:g,layerClassName:_=`z-[81]`,onClose:v}){let C=o(e=>e.language),E=c(C).chat,D=y({open:e,attachment:r,authToken:h,conversationId:g,language:C}),O=te(),{expanded:k,setExpanded:A}=x(e,O.dialogOpen),[j,M]=(0,Q.useState)(!1),{preview:N,fileType:F,hasExtractedText:I}=D,L=r?i.findIndex(e=>e===r||e.id&&e.id===r.id||e.uri&&e.uri===r.uri||!e.id&&!e.uri&&e.name===r.name&&!!e.data&&e.data===r.data):-1,R=F===`image`&&i.length>1&&L>=0&&!!s,z=e=>{if(!R||O.dialogOpen)return;let t=L+(e===`previous`?-1:1);t>=0&&t<i.length&&s?.(i[t])},ae=F!==`image`&&F!==`text`&&F!==`pptx`&&I,B=N?.uri?ee(N.uri):null,V=!!(B||N?.uri?.startsWith(`media://`)&&(g||N.taskId)),H=()=>{!N?.uri||!V||O.createShareLink(B?{fileId:B,fileName:N.name}:{uri:N.uri,conversationId:g??void 0,taskId:N.taskId,fileName:N.name})},U=!!(N&&!D.loading&&!D.loadError),W=()=>{A(!1),v()},G=()=>{if(!N||!D.downloadBuffer)return;let e=new Blob([D.downloadBuffer],{type:D.descriptor.mimeType}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=N.name??`download`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},K=!!D.downloadBuffer,q=ie()&&F===`spreadsheet`&&/\.xlsx?$/i.test(D.fileName)&&!!D.downloadBuffer&&!!window.electronAPI?.shell?.openTemporaryFile,J=async()=>{let e=D.downloadBuffer,t=window.electronAPI?.shell?.openTemporaryFile;if(!(!e||!t||j)){M(!0);try{(await t({fileName:D.fileName,data:new Uint8Array(e)})).ok||S(`warning`,E.attachmentPreviewOpenLocalFailed)}catch{S(`warning`,E.attachmentPreviewOpenLocalFailed)}finally{M(!1)}}},Y={onDownload:G,canDownload:K},X=T(`min-h-0 min-w-0 flex-1 cursor-pointer border-0 p-0`,`bg-surface-base transition-colors`,`hover:bg-surface-hover/90 dark:bg-black/60 dark:hover:bg-black/70`,P.focusRingBase),Z=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(b,{header:{expanded:k,onToggleExpanded:U?()=>A(e=>!e):void 0,hideClose:t,hideExpand:!!n,onClose:W,share:V?{onClick:H,loading:O.loading}:void 0,openWithSystemApp:q?{onClick:()=>void J(),loading:j}:void 0,textView:ae?{active:D.showExtractedText,onChange:e=>{D.setShowExtractedText(e),D.clearLoadError()}}:void 0},chat:D.downloadBuffer?{conversationId:g,createFile:async()=>new File([D.downloadBuffer],D.fileName,{type:D.descriptor.mimeType})}:void 0,onImageSwipe:R?z:void 0,language:C,descriptor:n?{...D.descriptor,id:n}:D.descriptor,loading:D.loading,loadError:D.loadError,textContent:D.textContent,binaryBuffer:D.binaryBuffer,showExtractedText:D.showExtractedText,extractedText:D.extractedText,extractedTextTruncated:D.extractedTextTruncated,actions:Y}),a?(0,$.jsxs)(`p`,{className:`shrink-0 border-t border-edge px-4 py-2 text-xs text-fg-muted`,"data-result-revision":!0,children:[C===`zh`?`成果版本`:`Result version`,` `,a]}):null,R?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-center gap-4 border-t border-edge bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":E.attachmentPreviewPreviousImage,disabled:L===0,onClick:()=>z(`previous`),className:T(`flex size-11 touch-manipulation items-center justify-center rounded-lg hover:bg-surface-hover disabled:opacity-30`,P.focusRingBase),children:(0,$.jsx)(p,{size:20,"aria-hidden":`true`})}),(0,$.jsxs)(`span`,{role:`status`,className:`min-w-16 text-center text-sm tabular-nums text-fg-muted`,children:[L+1,` / `,i.length]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":E.attachmentPreviewNextImage,disabled:L===i.length-1,onClick:()=>z(`next`),className:T(`flex size-11 touch-manipulation items-center justify-center rounded-lg hover:bg-surface-hover disabled:opacity-30`,P.focusRingBase),children:(0,$.jsx)(m,{size:20,"aria-hidden":`true`})})]}):null]});return t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(re,{expanded:k,children:Z}),(0,$.jsx)(w,{open:O.dialogOpen,onOpenChange:O.handleOpenChange,loading:O.loading,error:O.error,result:O.result,pendingParams:O.pendingParams,onConfirm:e=>void O.confirmShareLink(e)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(f,{open:e,onOpenChange:e=>!e&&W(),children:(0,$.jsx)(l,{children:(0,$.jsxs)(u,{"aria-describedby":void 0,onKeyDown:e=>{!R||O.dialogOpen||e.altKey||e.ctrlKey||e.metaKey||e.target.closest(`input, textarea, select, [contenteditable="true"]`)||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),z(e.key===`ArrowLeft`?`previous`:`next`))},className:T(`xopc-dialog-content-fullscreen fixed inset-0 flex h-[100dvh] w-full flex-row overflow-hidden`,ne(),_,`border-0 bg-transparent p-0 shadow-none outline-none`),children:[(0,$.jsx)(d,{className:`sr-only`,children:N?.name??``}),(0,$.jsx)(`button`,{type:`button`,className:X,onClick:W,"aria-label":E.attachmentPreviewClose}),(0,$.jsx)(`div`,{className:T(`flex h-full min-h-0 shrink-0 flex-col overflow-hidden`,k?`w-full`:`w-[min(100%,var(--max-width-app-main))]`,`bg-surface-panel sm:border-x sm:border-edge dark:sm:border-edge`,`shadow-float dark:shadow-elevated`),children:Z}),(0,$.jsx)(`button`,{type:`button`,className:X,onClick:W,"aria-label":E.attachmentPreviewClose})]})})}),(0,$.jsx)(w,{open:O.dialogOpen,onOpenChange:O.handleOpenChange,loading:O.loading,error:O.error,result:O.result,pendingParams:O.pendingParams,onConfirm:e=>void O.confirmShareLink(e)})]})}function ve(e){let t=(0,he.c)(23),{attachments:n,conversationId:r,topPadded:i,onRemove:a,className:s}=e,l=o(ye),u;t[0]===l?u=t[1]:(u=c(l),t[0]=l,t[1]=u);let d=u.chat,[f,p]=(0,Q.useState)(null);if(n.length===0)return null;let m=i?`pt-2`:`pt-3`,_;t[2]!==s||t[3]!==m?(_=T(`flex flex-wrap gap-2 border-b border-edge-subtle/90 bg-surface-hover/20 px-4 pb-2 dark:border-edge-subtle`,m,s),t[2]=s,t[3]=m,t[4]=_):_=t[4];let v;if(t[5]!==n||t[6]!==d||t[7]!==a){let e;t[9]!==d||t[10]!==a?(e=(e,t)=>{let n=e.type===`pasted_text`?d.pastedText:e.name;return(0,$.jsxs)(`div`,{className:`flex max-w-[200px] items-center rounded-lg bg-surface-hover text-xs dark:bg-surface-hover/80`,children:[(0,$.jsxs)(`button`,{type:`button`,className:T(`flex min-w-0 flex-1 items-center gap-1.5 rounded-l-lg py-1 pl-2 pr-1 text-left hover:bg-surface-active`,P.transition,P.press,P.focusRingPanel),onClick:()=>p(e),"aria-label":`${d.attachmentPreviewOpen}: ${n}`,title:`${d.attachmentPreviewOpen}: ${n}`,children:[e.mimeType?.startsWith(`image/`)&&e.content?(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:``,className:`size-6 shrink-0 rounded object-cover`}):e.type===`voice`||e.mimeType?.startsWith(`audio/`)?(0,$.jsx)(C,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.type===`pasted_text`?(0,$.jsx)(h,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,$.jsx)(g,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),(0,$.jsx)(`span`,{className:`shrink-0 text-fg-disabled`,children:M(e.size)})]}),(0,$.jsx)(`button`,{type:`button`,className:T(`flex min-h-8 min-w-8 items-center justify-center rounded-r-lg text-fg-muted hover:bg-surface-active hover:text-fg`,P.transition,P.press,P.focusRingPanel),onClick:()=>a(t),"aria-label":`${d.attachmentPreviewRemove}: ${n}`,title:`${d.attachmentPreviewRemove}: ${n}`,children:(0,$.jsx)(`span`,{"aria-hidden":!0,children:`×`})})]},e.id??`${e.name}-${e.size}-${e.mimeType}-${e.content?.slice(0,16)??``}`)},t[9]=d,t[10]=a,t[11]=e):e=t[11],v=n.map(e),t[5]=n,t[6]=d,t[7]=a,t[8]=v}else v=t[8];let y;t[12]!==_||t[13]!==v?(y=(0,$.jsx)(`div`,{className:_,children:v}),t[12]=_,t[13]=v,t[14]=y):y=t[14];let b=f!==null,x;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>p(null),t[15]=x):x=t[15];let S;t[16]!==r||t[17]!==f||t[18]!==b?(S=(0,$.jsx)(ge,{open:b,attachment:f,conversationId:r,onClose:x}),t[16]=r,t[17]=f,t[18]=b,t[19]=S):S=t[19];let w;return t[20]!==y||t[21]!==S?(w=(0,$.jsxs)($.Fragment,{children:[y,S]}),t[20]=y,t[21]=S,t[22]=w):w=t[22],w}function ye(e){return e.language}function be(e){let{chat:t,initialAttachments:n=[],onAttachmentsChange:r}=e,[a,o]=(0,Q.useState)(n),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(null),u=(0,Q.useRef)(a),d=(0,Q.useRef)(r);u.current=a,d.current=r;let f=(0,Q.useCallback)(e=>{let t=typeof e==`function`?e(u.current):e;u.current=t,o(t),d.current?.(t)},[]),p=(0,Q.useCallback)(()=>{f([])},[]),m=(0,Q.useCallback)(e=>{f(t=>t.filter((t,n)=>n!==e))},[]),h=(0,Q.useCallback)(()=>u.current.map(e=>({type:e.type===`voice`?`voice`:e.type||`file`,mimeType:e.mimeType,data:e.content,name:e.name,size:e.size,...e.uri?{uri:e.uri}:{},...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}})),[]),g=(0,Q.useCallback)(async(e,n)=>{if(e.length===0)return;let r=10-u.current.length;if(r<=0){S(`warning`,t.maxAttachmentsReached,{max:10});return}let a=e.slice(0,r);e.length>a.length&&S(`warning`,t.maxAttachmentsTruncated,{max:10,dropped:e.length-a.length});let{loadAttachment:o}=await i(async()=>{let{loadAttachment:e}=await import(`./attachment-load-DrVGNxJm.js`).then(e=>e.t);return{loadAttachment:e}},__vite__mapDeps([0,1,2])),s=(await Promise.all(a.map(async e=>{if(e.size>33554432)return S(`warning`,t.attachmentFileTooLarge,{name:e.name,maxSize:M(E)}),null;try{return await o(e,e.name)}catch{return S(`error`,t.attachmentLoadFailed,{name:e.name}),null}}))).filter(e=>e!==null).map(e=>n?{...e,type:n}:e);f(e=>[...e,...s])},[t.attachmentFileTooLarge,t.attachmentLoadFailed,t.maxAttachmentsReached,t.maxAttachmentsTruncated]),v=(0,Q.useCallback)(e=>g(e),[g]);return(0,Q.useEffect)(()=>{if(e.conversationId)return _(e.conversationId,async e=>{let t=u.current.length;return await g([e]),u.current.length>t})},[g,e.conversationId]),{attachments:a,setAttachments:f,attachmentsRef:u,isDragging:s,setIsDragging:c,fileInputRef:l,processFiles:v,processPastedText:(0,Q.useCallback)(e=>g([new File([e.text],e.name,{type:e.mimeType})],`pasted_text`),[g]),removeAttachment:m,clearAttachments:p,wireAttachmentsPayload:h}}export{V as C,z as D,oe as E,G as O,le as S,K as T,Y as _,de as a,J as b,fe as c,H as d,B as f,q as g,R as h,ue as i,W as k,ce as l,ae as m,ve as n,me as o,I as p,ge as r,pe as s,be as t,X as u,L as v,Z as w,se as x,U as y};
|