@xopcai/xopc 0.0.384 → 0.0.385
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/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BSel9yf8.js → agent-avatar-dicebear-Cb9eaXxR.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-DgHMyhuY.js → agent-defaults-settings-panel-DEV-xtgm.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-BosuN4dO.js → agent-plugin-dialog-DXKc3Luj.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-B-pw5RKI.js → agents-DcNxwpJQ.js} +3 -3
- package/dist/gateway/static/root/assets/{app-management-settings-panel-DuOqKkfH.js → app-management-settings-panel-X5i0Tz7_.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-8JF9rXFr.js → appearance-settings-CmHHzquT.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-Cuclpk0A.js → apps-page-ChFA4Zp0.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-D7NwNy2I.js → automations-page-BFqsIqOI.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-CSxW4wX0.js → automations-workspace-Blfak-fT.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Dnb7CH_l.js → block-editor-CpOLG3Co.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-GBgDe21o.js → browser-automations-page-BSbTJ9j2.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-B2FXaO3n.js → browser-settings-page-BUlILJrB.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-f2-MquJn.js → capabilities-page-CeRdkwRf.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-D9F0mw16.js → capabilities-settings-panel-S-cKsGja.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-header-actions-DVRxJPQP.js → capability-header-actions-6w8pQhnn.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-CnDm5T1t.js → channels-DfNTGBmp.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-BxSCDbK7.js → chat-terminal-dock-DnoQHpDc.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-DVAB-kQw.js → computer-settings-page-7yliE7sG.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-D2EeLXei.js → connector-service-page-DOLAUFSW.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-DK9n4hgZ.js → connectors-page-DAsn97XG.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-Cl9KfFj8.js → date-picker-DNDqr4Fk.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-Ei6aX5WM.js → dependency-picker-B5oG7RgE.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-4Evl4RKX.js → desktop-pet-K7kUCX1O.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DAD_OWcX.js → desktop-pet-settings-KgOAuqSh.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-BA21epMn.js → device-pairing-wizard-DvqniZDm.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-B_Zb5nNR.js → directory-picker-path-field-BmOguLDl.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-8gWSThWP.js → extension-page-DSSuMQxp.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CunUbB09.js → extension-settings-page-DSd__mNd.js} +1 -1
- package/dist/gateway/static/root/assets/{fallback-models-BSAfzXby.js → fallback-models-D7bjbiwZ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-CN-2229W.js → gateway-settings-hSXGWumL.js} +1 -1
- package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-DktBCtHF.js → highlighted-body-KQOG7T2V-C7xJwE61.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-CUJcNW3H.js → home-page-DJNmlMfH.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-DQm1MNNC.js → imports-page-BufZPzGE.js} +1 -1
- package/dist/gateway/static/root/assets/index-DBRwvWzm.css +1 -0
- package/dist/gateway/static/root/assets/{index-BPNL54bv.js → index-K8SXDtxr.js} +9 -9
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DaC5YjuJ.js → keyboard-shortcuts-settings-B8pPP5RF.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-DwQyyo7a.js → local-app-workbench-page-zEtvE7pJ.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-CpZhivpf.js → local-apps-page-Bli7e_eg.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-Db43nh1M.js → logs-page-BimZk3R4.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-DrKejBEZ.js → management-settings-5Y4COyU9.js} +1 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-DBRj4-1-.js +1 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-a8NSwmmW.js → note-detail-panel-KLDPLVg7.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-page-BKRke43F.js → notes-page-DST0oPXD.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-DUaMkmxv.js → page-context-capture-button-Bmed83-6.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-BqF-HHw1.js → personal-page-BG4Ystrm.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-GrhtTQIz.js → product-open-page-CXkYP9xE.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-zdP7gN0y.js → product-preview-content-DjmupQSq.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-9Vd_AqDW.js → project-detail-page-CzBmV0P6.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-DGunhjoM.js → projects-page-DByqe5Em.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BoRsF3Lx.js → remote-access-hub-DTjj-odF.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-W0HDm--J.js → runtime-tools-settings-panel-B_ptn3T8.js} +1 -1
- package/dist/gateway/static/root/assets/{scenes-page-CYsFOfVJ.js → scenes-page-wkua4l5y.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-CBxEbBQq.js → schema-form-VvOSM84Y.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-Dthfx_vc.js → sessions-page-D06XwYAT.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DoAHy1wj.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-CFs-WP_2.js → settings-page-C-6BJdb1.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-D2-9fXYL.js → setup-status-panel-L0JSG0K-.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-DTb88RHD.js → shares-settings-BbgAUM3v.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-DJ8UBsxq.js → skill-api-BFU1tPyw.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-DjbBOikT.js → skills-page-DZw6el4o.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-Dt5GkLhM.js → system-settings-panel-DshSGWNg.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-88EShcbs.js → task-detail-page-CfZhq4XZ.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-JHttXi63.js → tunnel-api-DFDXwWnU.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-B3rUa0fW.js → usage-page-2RJLg54s.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-Cq1VSsZw.js → user-model-page-y1gjGYPI.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BAtG_JHv.js → work-discovery-overlay-Ch-KfpCF.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Cw12NFgx.js → workflow-run-setup-panel-CTu297Hc.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-kR5ouOuM.js → workflows-page-CRZXG_rm.js} +1 -1
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-BTBVKpSg.js → xopc-cloud-account-card-hEfjVjnc.js} +1 -1
- package/dist/gateway/static/root/index.html +2 -2
- package/dist/package.js +1 -1
- package/dist/src/agent/child-agent-factory.js +7 -1
- package/dist/src/agent/embedded/execution-tool-policy.d.ts +1 -1
- package/dist/src/agent/embedded/execution-tool-policy.js +3 -2
- package/dist/src/agent/embedded/run-for-session.js +32 -12
- package/dist/src/agent/embedded/run-turn.js +108 -24
- package/dist/src/agent/embedded/session-runner.js +9 -1
- package/dist/src/agent/embedded/types.d.ts +2 -1
- package/dist/src/agent/external-tools/cliProvider.d.ts +1 -0
- package/dist/src/agent/external-tools/cliProvider.js +1 -0
- package/dist/src/agent/external-tools/composio-provider.js +2 -0
- package/dist/src/agent/external-tools/gateway-tools.js +8 -2
- package/dist/src/agent/external-tools/service.d.ts +1 -0
- package/dist/src/agent/external-tools/service.js +3 -1
- package/dist/src/agent/external-tools/types.d.ts +4 -0
- package/dist/src/agent/orchestration/agent-turn-policy.d.ts +1 -0
- package/dist/src/agent/orchestration/delegation-budget.js +2 -1
- package/dist/src/agent/orchestration/llm-turn-retry.d.ts +5 -0
- package/dist/src/agent/orchestration/llm-turn-retry.js +15 -5
- package/dist/src/agent/orchestration/turn-recovery.d.ts +6 -0
- package/dist/src/agent/orchestration/turn-recovery.js +29 -0
- package/dist/src/agent/service/direct-turn-helpers.js +6 -5
- package/dist/src/agent/service/process-direct-streaming.js +7 -1
- package/dist/src/agent/tasks/task-judge-service.js +28 -10
- package/dist/src/agent/tools/factory.js +10 -1
- package/dist/src/agent/tools/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +2 -1
- package/dist/src/agent/tools/personal-request-result-tool.js +20 -3
- package/dist/src/agent/tools/personal-request-tool.js +162 -15
- package/dist/src/agent/tools/personal-task-tool.d.ts +5 -1
- package/dist/src/agent/tools/personal-task-tool.js +137 -15
- package/dist/src/agent/tools/task-collaboration-tool.d.ts +16 -0
- package/dist/src/agent/tools/task-collaboration-tool.js +153 -0
- package/dist/src/agent/tools/xopc-use-tool.js +1 -1
- package/dist/src/cli/commands/channels.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/models.js +1 -1
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/connectors/connection-recovery-service.d.ts +6 -0
- package/dist/src/connectors/connection-recovery-service.js +151 -32
- package/dist/src/extensions/sdk/index.js +1 -1
- package/dist/src/gateway/hono/routes/connection-waits.js +3 -1
- package/dist/src/gateway/service/run-gateway-agent.js +9 -5
- package/dist/src/gateway/service/session-input-coordinator.js +4 -2
- package/dist/src/gateway/service.js +9 -9
- package/dist/src/personal-agent/prompts.js +6 -2
- package/dist/src/personal-agent/reply-composer.js +23 -9
- package/dist/src/personal-agent/request-access.d.ts +3 -0
- package/dist/src/personal-agent/request-access.js +31 -0
- package/dist/src/personal-agent/request-delivery.js +9 -4
- package/dist/src/personal-agent/request-repository.d.ts +1 -0
- package/dist/src/personal-agent/request-service.d.ts +2 -0
- package/dist/src/personal-agent/request-service.js +32 -7
- package/dist/src/providers/model-response.js +13 -2
- package/dist/src/session/store.js +19 -6
- package/dist/src/storage/sqlite/connection-wait-repository.d.ts +2 -0
- package/dist/src/storage/sqlite/connection-wait-repository.js +83 -4
- package/dist/src/storage/sqlite/transcript-repository.d.ts +2 -0
- package/dist/src/storage/sqlite/transcript-repository.js +25 -1
- package/dist/src/tasks/task-application-service.js +1 -1
- package/dist/src/tasks/task-collaboration-delivery.js +4 -1
- package/dist/src/tasks/task-collaboration-repository.d.ts +3 -0
- package/dist/src/tasks/task-collaboration-repository.js +11 -1
- package/dist/src/tasks/task-context-assembler.js +13 -5
- package/dist/src/tasks/task-continuation.d.ts +5 -0
- package/dist/src/tasks/task-continuation.js +32 -0
- package/dist/src/tasks/task-main-update-delivery.js +13 -8
- package/dist/src/tasks/task-read-model-projector.js +1 -1
- package/dist/src/tasks/task-run-coordinator.d.ts +1 -0
- package/dist/src/tasks/task-run-coordinator.js +21 -6
- package/dist/src/tasks/task-run-dispatcher.js +11 -0
- package/dist/src/tasks/task-run-repository.d.ts +8 -0
- package/dist/src/tasks/task-run-repository.js +32 -1
- package/package.json +5 -5
- package/dist/gateway/static/root/assets/index-yseLAt9D.css +0 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-C4VzqE9z.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-O_0Lk38S.js +0 -1
|
@@ -9,9 +9,9 @@ import { parseSlashCommand } from "../../chat-commands/command-parse.js";
|
|
|
9
9
|
import { personalCommandRejection } from "../../chat-commands/personal-command-policy.js";
|
|
10
10
|
import { commandRegistry } from "../../chat-commands/registry.js";
|
|
11
11
|
import "../../chat-commands/index.js";
|
|
12
|
+
import { getTaskContinuation } from "../../tasks/task-continuation.js";
|
|
12
13
|
import { runEmbeddedTurnForSession } from "../embedded/run-for-session.js";
|
|
13
14
|
import { injectSourceContextsIntoUserMessage } from "../source-context/injector.js";
|
|
14
|
-
import { prependAgentContext } from "../context/prepend.js";
|
|
15
15
|
import crypto from "node:crypto";
|
|
16
16
|
//#region src/agent/service/direct-turn-helpers.ts
|
|
17
17
|
/**
|
|
@@ -113,10 +113,11 @@ async function runDirectAgentTurn(deps, input) {
|
|
|
113
113
|
const turnId = input.runId ?? crypto.randomUUID();
|
|
114
114
|
const isConnectionResume = Boolean(getConnectionResumeInput(input.conversationId, turnId));
|
|
115
115
|
const isClarificationResume = Boolean(getClarificationResumeInput(input.conversationId, turnId));
|
|
116
|
-
const isResume = isConnectionResume || isClarificationResume;
|
|
116
|
+
const isResume = isConnectionResume || isClarificationResume || Boolean(getTaskContinuation(input.conversationId, turnId));
|
|
117
117
|
const userContext = await deps.agentManager.prepareUserTurnContext(input.userMessage, input.conversationId, turnId);
|
|
118
118
|
const sourceContexts = input.sourceContexts ?? [];
|
|
119
|
-
const
|
|
119
|
+
const sourceEnrichedMessage = injectSourceContextsIntoUserMessage(input.userMessage, sourceContexts);
|
|
120
|
+
const taskContext = [buildTaskExecutionDirective(input.conversationId), buildDelegatedTaskDirective(input.conversationId)].filter(Boolean).join("\n");
|
|
120
121
|
const modelRef = deps.modelManager.getModelForSession(input.conversationId);
|
|
121
122
|
const llmTurn = await hydrateUserTurnForLlm({
|
|
122
123
|
message: input.userMessage,
|
|
@@ -128,8 +129,8 @@ async function runDirectAgentTurn(deps, input) {
|
|
|
128
129
|
const result = await runEmbeddedTurnForSession({
|
|
129
130
|
conversationId: input.conversationId,
|
|
130
131
|
runId: turnId,
|
|
131
|
-
userMessage:
|
|
132
|
-
dynamicSystemContext: userContext.dynamicSystemContext,
|
|
132
|
+
userMessage: sourceEnrichedMessage,
|
|
133
|
+
dynamicSystemContext: [userContext.dynamicSystemContext, taskContext].filter(Boolean).join("\n\n"),
|
|
133
134
|
llmImages,
|
|
134
135
|
presentation: input.presentation,
|
|
135
136
|
requireVisibleReply: input.requireVisibleReply,
|
|
@@ -14,6 +14,7 @@ import { formatAgentRunErrorForClient } from "../client-error-format.js";
|
|
|
14
14
|
import { resolveConfiguredActivityDetailDefault, resolveEffectiveReasoningLevel } from "../../session/thinking-resolve.js";
|
|
15
15
|
import { initSessionTurn } from "../../session/init-session-turn.js";
|
|
16
16
|
import "../../session/index.js";
|
|
17
|
+
import { getTaskContinuation } from "../../tasks/task-continuation.js";
|
|
17
18
|
import { stripEnvelopeTimestampPrefix } from "../../channels/envelope-timestamp.js";
|
|
18
19
|
import { isVoiceLikeAttachment, mergeVoiceTranscriptsIntoUserText, requestsOriginalVoiceInspection } from "../../channels/attachments/voice-stt-webchat.js";
|
|
19
20
|
import { applyReasoningVisibility } from "../streaming/reasoning-visibility.js";
|
|
@@ -141,7 +142,7 @@ async function* runProcessDirectStreaming(deps, input) {
|
|
|
141
142
|
deps.sessionStore?.idleCompaction?.interrupt(conversationId);
|
|
142
143
|
const isConnectionResume = Boolean(input.runId && getConnectionResumeInput(conversationId, input.runId));
|
|
143
144
|
const isClarificationResume = Boolean(input.runId && getClarificationResumeInput(conversationId, input.runId));
|
|
144
|
-
const isInternalResume = isConnectionResume || isClarificationResume;
|
|
145
|
+
const isInternalResume = isConnectionResume || isClarificationResume || Boolean(input.runId && getTaskContinuation(conversationId, input.runId));
|
|
145
146
|
const isTaskUpdate = input.origin.type === "system" && input.origin.source === "task_update";
|
|
146
147
|
const { channel, chatId } = await deps.resolveSessionEndpoint(conversationId);
|
|
147
148
|
const context = deps.initDirectStreamingSession(conversationId, channel, chatId, input.origin);
|
|
@@ -402,6 +403,11 @@ async function* runProcessDirectStreaming(deps, input) {
|
|
|
402
403
|
try {
|
|
403
404
|
for await (const event of queue) yield event;
|
|
404
405
|
await taskPromise;
|
|
406
|
+
if (streamOverflowed) yield {
|
|
407
|
+
type: "error",
|
|
408
|
+
runId: input.runId,
|
|
409
|
+
content: formatStreamError("Agent stream stopped because its critical event buffer overflowed")
|
|
410
|
+
};
|
|
405
411
|
if (channel === "webchat" && ranSlashCommand) try {
|
|
406
412
|
const userMsg = {
|
|
407
413
|
role: "user",
|
|
@@ -6,12 +6,14 @@ import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profi
|
|
|
6
6
|
import { getAgentDefaultModelRef, init_schema } from "../../config/schema.js";
|
|
7
7
|
import { getApiKey, init_providers, resolveModel } from "../../providers/index.js";
|
|
8
8
|
import { completeWithResolvedCredentials } from "../../providers/model-call.js";
|
|
9
|
-
import { extractAssistantText, getAssistantMessageErrorReason, stripCodeFences } from "../../providers/model-response.js";
|
|
9
|
+
import { extractAssistantText, getAssistantMessageErrorReason, isTransientProviderErrorMessage, stripCodeFences } from "../../providers/model-response.js";
|
|
10
|
+
import { canResumeAfterModelFailure } from "../orchestration/turn-recovery.js";
|
|
10
11
|
import { resolveTaskLocale } from "../../tasks/task-language.js";
|
|
11
12
|
import { TaskConversationRepository } from "../../tasks/task-conversation-repository.js";
|
|
12
13
|
import { readWorkspaceRevision } from "../coding/workspace-revision.js";
|
|
13
14
|
import { buildResponseLanguageSection } from "../prompt/sections/response-language.js";
|
|
14
15
|
import { resolveResponseLanguageForSession } from "../prompt/response-language.js";
|
|
16
|
+
import { TaskCollaborationRepository } from "../../tasks/task-collaboration-repository.js";
|
|
15
17
|
import { TaskApplicationService } from "../../tasks/task-application-service.js";
|
|
16
18
|
//#region src/agent/tasks/task-judge-service.ts
|
|
17
19
|
init_schema();
|
|
@@ -62,13 +64,13 @@ function parseTaskJudgeDecision(raw, criteriaCount, locale = "en") {
|
|
|
62
64
|
}
|
|
63
65
|
async function requestTaskJudgeDecision(complete, criteriaCount, locale = "en") {
|
|
64
66
|
let parseError;
|
|
65
|
-
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
for (let attempt = 0; attempt < 2; attempt += 1) try {
|
|
68
|
+
return parseTaskJudgeDecision(await complete(attempt), criteriaCount, locale);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
if (error instanceof Error && isTransientProviderErrorMessage(error.message)) {
|
|
71
|
+
if (attempt === 0) await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
72
|
+
} else if (!(error instanceof SyntaxError) && !(error instanceof Error && error.message.startsWith("Task judge returned"))) throw error;
|
|
73
|
+
parseError = error;
|
|
72
74
|
}
|
|
73
75
|
throw parseError;
|
|
74
76
|
}
|
|
@@ -130,7 +132,8 @@ var TaskJudgeService = class {
|
|
|
130
132
|
return;
|
|
131
133
|
}
|
|
132
134
|
const history = compactHistory(await this.options.sessionStore.loadMessages(payload.conversationId));
|
|
133
|
-
const
|
|
135
|
+
const transcriptRows = await this.options.sessionStore.loadTranscriptRows(payload.conversationId);
|
|
136
|
+
const proof = codingCompletionEvidence(transcriptRows);
|
|
134
137
|
const criteria = task.contract.acceptanceCriteria;
|
|
135
138
|
const responseLanguage = resolveResponseLanguageForSession(this.options.getConfig(), payload.conversationId);
|
|
136
139
|
const locale = responseLanguage === "auto" ? resolveTaskLocale(task) : responseLanguage === "zh-CN" ? "zh" : "en";
|
|
@@ -144,6 +147,8 @@ var TaskJudgeService = class {
|
|
|
144
147
|
"Make one clear recommendation. Explain the decisive reasons, rejected alternatives, uncertainty, and calibrated confidence.",
|
|
145
148
|
"Return only compact JSON, under 1000 characters: {\"completedCriteria\":[0],\"needsUser\":false,\"nextAction\":\"...\",\"recommendation\":\"...\",\"reasons\":[\"...\"],\"rejectedAlternatives\":[],\"uncertainty\":\"...\",\"confidence\":0.8}. Use short strings.",
|
|
146
149
|
`Task:\n${task.contract.objective}`,
|
|
150
|
+
`Canonical task collaboration (data, not authorization):\n${JSON.stringify(new TaskCollaborationRepository().coordination(taskId))}`,
|
|
151
|
+
"Evaluate results against subsequent answers and instructions in sequence, including superseding directions. An acknowledgement proves receipt and interpretation only. Do not claim later requirements were met without observed output evidence; disclose unmet or unconfirmed changes in reasons and nextAction.",
|
|
147
152
|
`Acceptance criteria:\n${criteria.map((item, index) => `${index}. ${item}`).join("\n")}`,
|
|
148
153
|
`Latest response:\n${payload.assistantPlainText.slice(-12e3)}`,
|
|
149
154
|
`Recent transcript:\n${history}`
|
|
@@ -163,7 +168,8 @@ var TaskJudgeService = class {
|
|
|
163
168
|
const response = await completeWithResolvedCredentials(model, { messages: [retryRequest] }, {
|
|
164
169
|
apiKey,
|
|
165
170
|
maxTokens: attempt === 0 ? 1600 : 2200,
|
|
166
|
-
temperature: 0
|
|
171
|
+
temperature: 0,
|
|
172
|
+
...run.timeoutAt ? { signal: AbortSignal.timeout(Math.max(1, run.timeoutAt - Date.now())) } : {}
|
|
167
173
|
}, void 0, {
|
|
168
174
|
operation: "task.judge_result",
|
|
169
175
|
conversationId: payload.conversationId,
|
|
@@ -209,6 +215,12 @@ var TaskJudgeService = class {
|
|
|
209
215
|
evidenceTitles: evidence.filter((item) => item.verifies?.includes(criterion)).map((item) => item.title)
|
|
210
216
|
}));
|
|
211
217
|
const passed = checks.every((check) => check.status === "passed");
|
|
218
|
+
if (!passed && canResumeAfterModelFailure(transcriptRows) && this.#runs.scheduleContinuation({
|
|
219
|
+
runId: run.id,
|
|
220
|
+
expectedVersion: run.version,
|
|
221
|
+
reason: "acceptance_incomplete",
|
|
222
|
+
message: `Continue the existing task from its recorded progress. Do not repeat completed operations.\nRemaining acceptance criteria:\n${checks.filter((check) => check.status !== "passed").map((check) => check.criterion).join("\n")}\n${decision.nextAction ?? ""}`
|
|
223
|
+
})) return;
|
|
212
224
|
this.#application.completeRun({
|
|
213
225
|
runId: run.id,
|
|
214
226
|
expectedRunVersion: run.version,
|
|
@@ -234,6 +246,12 @@ var TaskJudgeService = class {
|
|
|
234
246
|
taskId,
|
|
235
247
|
conversationId: payload.conversationId
|
|
236
248
|
}, "Task review failed");
|
|
249
|
+
if (isTransientProviderErrorMessage(error instanceof Error ? error.message : String(error)) && canResumeAfterModelFailure(transcriptRows)) this.#runs.scheduleContinuation({
|
|
250
|
+
runId: run.id,
|
|
251
|
+
expectedVersion: run.version,
|
|
252
|
+
reason: "acceptance_check_failed",
|
|
253
|
+
message: "The independent acceptance check failed because of a temporary model error. Continue from the recorded results and verify the remaining acceptance criteria. Do not repeat completed operations."
|
|
254
|
+
});
|
|
237
255
|
}
|
|
238
256
|
}
|
|
239
257
|
};
|
|
@@ -69,6 +69,7 @@ import { createManagedJobTool } from "./managed-job-tool.js";
|
|
|
69
69
|
import { createImageTool } from "./image-tool.js";
|
|
70
70
|
import { createImageGenerateTool } from "./image-generate-tool.js";
|
|
71
71
|
import { createPersonalReadTool } from "./personal-read-tool.js";
|
|
72
|
+
import { createTaskCollaborationTool } from "./task-collaboration-tool.js";
|
|
72
73
|
import "./index.js";
|
|
73
74
|
import { createPersonalTaskTool } from "./personal-task-tool.js";
|
|
74
75
|
import { createPersonalRequestTools } from "./personal-request-tool.js";
|
|
@@ -272,6 +273,7 @@ var AgentToolsFactory = class AgentToolsFactory {
|
|
|
272
273
|
allowed = new Set(PERSONAL_REQUEST_TOOL_IDS.slice(0, 3).filter((name) => !allowed || allowed.has(name)));
|
|
273
274
|
allowed.add("personal_request_result");
|
|
274
275
|
allowed.add("personal_request_connection");
|
|
276
|
+
allowed.add("task_collaboration");
|
|
275
277
|
}
|
|
276
278
|
const deliveryContext = () => {
|
|
277
279
|
if (currentConversationId() && getSessionMetadata(currentConversationId())?.sessionType === "heartbeat") throw new Error("Heartbeat notifications must be returned in the final response for policy-controlled delivery.");
|
|
@@ -612,7 +614,14 @@ var AgentToolsFactory = class AgentToolsFactory {
|
|
|
612
614
|
}
|
|
613
615
|
})] : [],
|
|
614
616
|
...optionalTools,
|
|
615
|
-
...personalExecution ? [
|
|
617
|
+
...personalExecution ? [
|
|
618
|
+
createPersonalRequestResultTool(currentConversationId),
|
|
619
|
+
createPersonalRequestConnectionTool(currentConversationId),
|
|
620
|
+
createTaskCollaborationTool({
|
|
621
|
+
...productToolDeps,
|
|
622
|
+
getCurrentConversationId: currentConversationId
|
|
623
|
+
})
|
|
624
|
+
] : []
|
|
616
625
|
];
|
|
617
626
|
if ([
|
|
618
627
|
"read_file",
|
|
@@ -43,3 +43,4 @@ export { createImageGenerateTool, resolveImageGenerationModelConfigForTool } fro
|
|
|
43
43
|
export { truncateHead, truncateTail, truncateLine, formatSize, type TruncationResult, type TruncationOptions, DEFAULT_MAX_LINES, DEFAULT_MAX_BYTES, GREP_MAX_LINE_LENGTH, } from './truncate.js';
|
|
44
44
|
export { normalizeToLF, restoreLineEndings, normalizeForFuzzyMatch, fuzzyFindText, stripBom, generateDiffString, type FuzzyMatchResult, } from './edit-diff.js';
|
|
45
45
|
export { createPersonalReadTool } from './personal-read-tool.js';
|
|
46
|
+
export { createTaskCollaborationTool } from './task-collaboration-tool.js';
|
|
@@ -46,4 +46,5 @@ import { createManagedJobTool } from "./managed-job-tool.js";
|
|
|
46
46
|
import { createImageTool } from "./image-tool.js";
|
|
47
47
|
import { createImageGenerateTool, resolveImageGenerationModelConfigForTool } from "./image-generate-tool.js";
|
|
48
48
|
import { createPersonalReadTool } from "./personal-read-tool.js";
|
|
49
|
-
|
|
49
|
+
import { createTaskCollaborationTool } from "./task-collaboration-tool.js";
|
|
50
|
+
export { BrowserRuntime, DEFAULT_DELEGATE_TOOLS, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, DEFAULT_TOOL_METADATA, DEFAULT_WEB_EXTRACT_MAX_LENGTH, DELEGATE_BLOCKED_TOOLS, GREP_MAX_LINE_LENGTH, MAX_RAW_HTML_CHARS_FOR_WEB_EXTRACT, TodoStore, ToolConcurrencyController, assertBrowserUrlAllowed, createApplyPatchTool, createAutomationTool, createBrowserAutomationTool, createClarifyTool, createCreateShareTool, createDataBatchTool, createDelegateTool, createDesktopPetTool, createExecCommandTool, createFindTool, createGrepTool, createImageGenerateTool, createImageTool, createKnowledgeGetTool, createKnowledgeReadTool, createKnowledgeSearchTool, createKnowledgeWriteTool, createListDirTool, createManagedJobTool, createMemoryMaintenanceTool, createMessageTool, createPersonalReadTool, createPublishArtifactsTool, createReadFileTool, createReadMediaTool, createSendMediaTool, createSessionRecallTool, createSessionSearchTool, createSessionStatusTool, createSkillInstallTool, createSkillManageTool, createSkillViewTool, createSkillsListTool, createSkillsMarketplaceSearchTool, createTaskCollaborationTool, createTodoTool, createToolManualTool, createUpdatePlanTool, createUserContextGetTool, createUserContextReadTool, createUserContextSearchTool, createUserContextUpdateTool, createWebExtractTool, createWebFetchTool, createWebSearchTool, createWorkflowManageTool, createWorkflowTool, createWriteFileTool, createXopcUseTool, findTool, formatSize, fuzzyFindText, generateDiffString, getToolMetadata, grepTool, isShareToolAvailable, listDirTool, normalizeForFuzzyMatch, normalizeToLF, resolveImageGenerationModelConfigForTool, resolveImageModelConfigForTool, resolveToolLockMode, restoreLineEndings, stripBom, stripHtmlBoilerplate, truncateHead, truncateLine, truncateTail, writeFileTool };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { getSqliteDatabase, init_transaction } from "../../storage/sqlite/transaction.js";
|
|
1
|
+
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../../storage/sqlite/transaction.js";
|
|
2
2
|
import { TaskRunRepository, init_task_run_repository } from "../../tasks/task-run-repository.js";
|
|
3
3
|
import { init_request_repository, personalRequestForExecution } from "../../personal-agent/request-repository.js";
|
|
4
|
+
import { assertPersonalRequestAccountAccess } from "../../personal-agent/request-access.js";
|
|
5
|
+
import { TaskCollaborationRepository } from "../../tasks/task-collaboration-repository.js";
|
|
6
|
+
import { selectionRequestHash } from "../../agent-matching/selection-repository.js";
|
|
4
7
|
import { PersonalRequestResultSchema } from "../../personal-agent/request-result.js";
|
|
5
8
|
import { Type } from "@sinclair/typebox";
|
|
6
9
|
//#region src/agent/tools/personal-request-result-tool.ts
|
|
@@ -47,8 +50,22 @@ function createPersonalRequestResultTool(conversationId) {
|
|
|
47
50
|
if (result.coverage && Date.parse(result.coverage.from) >= Date.parse(result.coverage.to)) throw new Error("Invalid coverage range");
|
|
48
51
|
if (result.coverage && request.parameters.timeRange && (Date.parse(result.coverage.from) > Date.parse(request.parameters.timeRange.from) || Date.parse(result.coverage.to) < Date.parse(request.parameters.timeRange.to))) result.coverage.partial = true;
|
|
49
52
|
const run = request.taskId ? new TaskRunRepository().getActiveRoot(request.taskId) : void 0;
|
|
50
|
-
if (!run || run.conversationId !== id) throw new Error("Task execution changed");
|
|
51
|
-
|
|
53
|
+
if (!run || run.conversationId !== id || !["running", "verifying"].includes(run.status)) throw new Error("Task execution changed");
|
|
54
|
+
assertPersonalRequestAccountAccess(request);
|
|
55
|
+
runSqliteWriteTransaction(() => {
|
|
56
|
+
const board = new TaskCollaborationRepository();
|
|
57
|
+
const direction = board.coordination(run.taskId).filter((entry) => ["main_agent", "user"].includes(entry.authorKind) && ["answer", "instruction"].includes(entry.kind)).at(-1)?.sequence ?? 0;
|
|
58
|
+
board.append({
|
|
59
|
+
taskId: run.taskId,
|
|
60
|
+
taskRunId: run.id,
|
|
61
|
+
authorKind: "worker_agent",
|
|
62
|
+
authorId: request.executorAgentId,
|
|
63
|
+
kind: "result",
|
|
64
|
+
body: result.summary,
|
|
65
|
+
idempotencyKey: `personal-request-result:${request.requestId}:${run.id}:${direction}:${selectionRequestHash(result)}`
|
|
66
|
+
});
|
|
67
|
+
getSqliteDatabase().prepare("UPDATE personal_requests SET result_json = ?, result_run_id = ?, updated_at = ? WHERE request_id = ?").run(JSON.stringify(result), run.id, Date.now(), request.requestId);
|
|
68
|
+
});
|
|
52
69
|
return {
|
|
53
70
|
content: [{
|
|
54
71
|
type: "text",
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import { getSqliteDatabase, init_transaction } from "../../storage/sqlite/transaction.js";
|
|
2
|
-
import {
|
|
1
|
+
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../../storage/sqlite/transaction.js";
|
|
2
|
+
import { init_session_instance_repository, readCurrentTranscriptId } from "../../storage/sqlite/session-instance-repository.js";
|
|
3
|
+
import { getSessionInputState, init_session_input_repository } from "../../storage/sqlite/session-input-repository.js";
|
|
4
|
+
import { getPersonalRequest, init_request_repository, listPersonalRequests, updatePersonalRequest } from "../../personal-agent/request-repository.js";
|
|
5
|
+
import { getActiveConnectionWait, init_connection_wait_repository, reviseCurrentConnectionObjective, updateConnectionWait } from "../../storage/sqlite/connection-wait-repository.js";
|
|
6
|
+
import { getSessionMetadata } from "../../storage/sqlite/session-read-repository.js";
|
|
7
|
+
import { init_session_repository } from "../../storage/sqlite/session-repository.js";
|
|
3
8
|
import { isPersonalConversation } from "../../personal-agent/repository.js";
|
|
4
9
|
import { TaskAllocationRepository } from "../../tasks/task-allocation-repository.js";
|
|
5
10
|
import { boundedPersonalResult } from "./personal-result-budget.js";
|
|
11
|
+
import { selectionRequestHash } from "../../agent-matching/selection-repository.js";
|
|
6
12
|
import { cancelPersonalTask } from "../../personal-agent/task-cancel.js";
|
|
13
|
+
import { createPersonalTaskTool } from "./personal-task-tool.js";
|
|
7
14
|
import { personalCapabilities } from "../../personal-agent/capability-service.js";
|
|
8
|
-
import { cancelPersonalRequest, personalRequestSnapshot, publishPersonalRequest, submitPersonalRequest } from "../../personal-agent/request-service.js";
|
|
15
|
+
import { assertPersonalRequestTimeRange, cancelPersonalRequest, personalRequestSnapshot, publishPersonalRequest, submitPersonalRequest } from "../../personal-agent/request-service.js";
|
|
9
16
|
import { Type } from "@sinclair/typebox";
|
|
10
17
|
//#region src/agent/tools/personal-request-tool.ts
|
|
18
|
+
init_session_input_repository();
|
|
19
|
+
init_session_repository();
|
|
20
|
+
init_session_instance_repository();
|
|
21
|
+
init_connection_wait_repository();
|
|
11
22
|
init_request_repository();
|
|
12
23
|
init_transaction();
|
|
13
24
|
const CapabilitySchema = Type.Object({
|
|
@@ -22,8 +33,20 @@ const RequestSchema = Type.Object({
|
|
|
22
33
|
"submit",
|
|
23
34
|
"get",
|
|
24
35
|
"list",
|
|
25
|
-
"cancel"
|
|
36
|
+
"cancel",
|
|
37
|
+
"answer",
|
|
38
|
+
"instruct",
|
|
39
|
+
"collaboration",
|
|
40
|
+
"entry"
|
|
26
41
|
].map((command) => Type.Literal(command))),
|
|
42
|
+
instruction: Type.Optional(Type.String({
|
|
43
|
+
minLength: 1,
|
|
44
|
+
maxLength: 8e3
|
|
45
|
+
})),
|
|
46
|
+
questionId: Type.Optional(Type.String({ minLength: 1 })),
|
|
47
|
+
entryId: Type.Optional(Type.String({ minLength: 1 })),
|
|
48
|
+
afterSequence: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
49
|
+
bodyOffset: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
27
50
|
requestId: Type.Optional(Type.String()),
|
|
28
51
|
offset: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
29
52
|
limit: Type.Optional(Type.Integer({
|
|
@@ -32,6 +55,11 @@ const RequestSchema = Type.Object({
|
|
|
32
55
|
})),
|
|
33
56
|
connectorId: Type.Optional(Type.String()),
|
|
34
57
|
accountId: Type.Optional(Type.String()),
|
|
58
|
+
description: Type.Optional(Type.String({
|
|
59
|
+
minLength: 1,
|
|
60
|
+
maxLength: 16e3,
|
|
61
|
+
description: "Complete task brief preserving all user requirements, stages, inputs, outputs and constraints. Do not replace exact specifications with a short objective or a reference to an unspecified process."
|
|
62
|
+
})),
|
|
35
63
|
objective: Type.Optional(Type.String({
|
|
36
64
|
minLength: 1,
|
|
37
65
|
maxLength: 4e3
|
|
@@ -51,12 +79,36 @@ const RequestSchema = Type.Object({
|
|
|
51
79
|
anyOf: [
|
|
52
80
|
{
|
|
53
81
|
properties: { command: { const: "submit" } },
|
|
54
|
-
required: [
|
|
82
|
+
required: [
|
|
83
|
+
"objective",
|
|
84
|
+
"connectorId",
|
|
85
|
+
"description"
|
|
86
|
+
]
|
|
55
87
|
},
|
|
56
88
|
{ properties: { command: { const: "list" } } },
|
|
57
89
|
{
|
|
58
|
-
properties: { command: { enum: [
|
|
90
|
+
properties: { command: { enum: [
|
|
91
|
+
"get",
|
|
92
|
+
"cancel",
|
|
93
|
+
"collaboration"
|
|
94
|
+
] } },
|
|
59
95
|
required: ["requestId"]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
properties: { command: { const: "entry" } },
|
|
99
|
+
required: ["requestId", "entryId"]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
properties: { command: { const: "instruct" } },
|
|
103
|
+
required: ["requestId", "instruction"]
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
properties: { command: { const: "answer" } },
|
|
107
|
+
required: [
|
|
108
|
+
"requestId",
|
|
109
|
+
"questionId",
|
|
110
|
+
"instruction"
|
|
111
|
+
]
|
|
60
112
|
}
|
|
61
113
|
]
|
|
62
114
|
});
|
|
@@ -74,6 +126,20 @@ function createPersonalRequestTools(deps) {
|
|
|
74
126
|
...value.taskId ? { allocation: new TaskAllocationRepository().summary(value.taskId) } : {}
|
|
75
127
|
};
|
|
76
128
|
};
|
|
129
|
+
const compactSnapshot = (request) => {
|
|
130
|
+
const value = snapshot(request);
|
|
131
|
+
return {
|
|
132
|
+
requestId: value.requestId,
|
|
133
|
+
taskId: value.taskId,
|
|
134
|
+
state: value.state,
|
|
135
|
+
version: value.version,
|
|
136
|
+
connectorId: value.connectorId,
|
|
137
|
+
accountId: value.accountId,
|
|
138
|
+
executorAgentId: value.executorAgentId,
|
|
139
|
+
..."allocation" in value ? { allocation: value.allocation } : {},
|
|
140
|
+
parameters: { timeRange: value.parameters.timeRange }
|
|
141
|
+
};
|
|
142
|
+
};
|
|
77
143
|
const result = (value) => ({
|
|
78
144
|
content: [{
|
|
79
145
|
type: "text",
|
|
@@ -97,14 +163,18 @@ function createPersonalRequestTools(deps) {
|
|
|
97
163
|
name: "personal_request",
|
|
98
164
|
label: "Connected app request",
|
|
99
165
|
parameters: RequestSchema,
|
|
100
|
-
description: "Submit a read-only connected-app request using the exact connectorId from personal_capability. The background Task Router chooses an executor after account authorization. Preserves the objective, displays connection or account selection in this main chat, and starts a specialist Task automatically once connected. Return quickly after submission. Never claim data was read until the Task result arrives. Resolve absolute query dates and include timeRange. If mail has no user-specified range, the host returns an explicit last-7-days default; mention that range in your confirmation. Use
|
|
166
|
+
description: "Submit a read-only connected-app request with a short objective and complete description using the exact connectorId from personal_capability. The background Task Router chooses an executor after account authorization. Preserves the objective, displays connection or account selection in this main chat, and starts a specialist Task automatically once connected. Return quickly after submission. Never claim data was read until the Task result arrives. Resolve absolute query dates and include timeRange. If mail has no user-specified range, the host returns an explicit last-7-days default; mention that range in your confirmation. get includes complete Task coordination state; collaboration/entry read the same board and full questions. answer forwards the exact questionId; instruct forwards new requirements to the existing Task. Answers and instructions cannot change the connector/account, grant access or allow writes; reconnection stays in the existing connection UI. Saved, delivered, executor-confirmed and verified are distinct states. Use get/list for status without polling; preserve idempotencyKey on uncertain retries; cancel only when the user requests it.",
|
|
101
167
|
async execute(toolCallId, input) {
|
|
102
168
|
const conversationId = conversation();
|
|
103
169
|
if (input.command === "list") {
|
|
104
170
|
const offset = input.offset ?? 0;
|
|
105
171
|
const items = listPersonalRequests(conversationId, input.limit ?? 10, offset).map((request) => {
|
|
106
|
-
const { result: _result, ...summary } = snapshot(request);
|
|
107
|
-
|
|
172
|
+
const { result: _result, parameters, ...summary } = snapshot(request);
|
|
173
|
+
const { brief: _brief, ...queryParameters } = parameters;
|
|
174
|
+
return {
|
|
175
|
+
...summary,
|
|
176
|
+
parameters: queryParameters
|
|
177
|
+
};
|
|
108
178
|
});
|
|
109
179
|
const total = getSqliteDatabase().prepare("SELECT count(*) AS count FROM personal_requests WHERE conversation_id = ?").get(conversationId).count;
|
|
110
180
|
return result(boundedPersonalResult({
|
|
@@ -120,21 +190,29 @@ function createPersonalRequestTools(deps) {
|
|
|
120
190
|
connectorId: input.connectorId,
|
|
121
191
|
accountId: input.accountId,
|
|
122
192
|
objective: input.objective.trim(),
|
|
193
|
+
description: input.description?.trim(),
|
|
123
194
|
timeRange: input.timeRange,
|
|
124
|
-
idempotencyKey: input.idempotencyKey ??
|
|
195
|
+
idempotencyKey: input.idempotencyKey ?? `personal-request-submit:${selectionRequestHash({
|
|
196
|
+
inputId: getSessionInputState(conversationId).activeInputId ?? toolCallId,
|
|
197
|
+
objective: input.objective.trim(),
|
|
198
|
+
description: input.description?.trim(),
|
|
199
|
+
connectorId: input.connectorId,
|
|
200
|
+
accountId: input.accountId,
|
|
201
|
+
timeRange: input.timeRange
|
|
202
|
+
})}`
|
|
125
203
|
});
|
|
126
204
|
publishPersonalRequest(request);
|
|
127
205
|
deps.dispatchTaskRuns?.();
|
|
128
|
-
return result(
|
|
206
|
+
return result(compactSnapshot(request));
|
|
129
207
|
}
|
|
130
208
|
const request = input.requestId ? getPersonalRequest(input.requestId) : void 0;
|
|
131
209
|
if (!request || request.conversationId !== conversationId) throw new Error("Request does not belong to this conversation");
|
|
132
210
|
if (input.command === "cancel") {
|
|
133
|
-
if (["completed", "failed"].includes(personalRequestSnapshot(request).state)) return result(
|
|
211
|
+
if (["completed", "failed"].includes(personalRequestSnapshot(request).state)) return result(compactSnapshot(request));
|
|
134
212
|
if (request.state === "cancelled") {
|
|
135
213
|
const stop = request.taskId ? await cancelPersonalTask(request.taskId, conversationId, input.idempotencyKey ?? toolCallId) : { executionStopConfirmed: true };
|
|
136
214
|
return result({
|
|
137
|
-
...
|
|
215
|
+
...compactSnapshot(request),
|
|
138
216
|
executionStopConfirmed: stop.executionStopConfirmed
|
|
139
217
|
});
|
|
140
218
|
}
|
|
@@ -142,11 +220,80 @@ function createPersonalRequestTools(deps) {
|
|
|
142
220
|
const cancelled = cancelPersonalRequest(request);
|
|
143
221
|
publishPersonalRequest(cancelled);
|
|
144
222
|
return result({
|
|
145
|
-
...cancelled,
|
|
223
|
+
...compactSnapshot(cancelled),
|
|
146
224
|
executionStopConfirmed: stop.executionStopConfirmed
|
|
147
225
|
});
|
|
148
226
|
}
|
|
149
|
-
|
|
227
|
+
const taskTool = createPersonalTaskTool({
|
|
228
|
+
...deps,
|
|
229
|
+
getCurrentAgentId: () => deps.getCurrentAgentId?.() ?? getSessionMetadata(conversationId)?.agentId
|
|
230
|
+
});
|
|
231
|
+
if (input.command === "instruct" && input.timeRange) assertPersonalRequestTimeRange(input.timeRange);
|
|
232
|
+
const instruction = input.command === "instruct" && input.timeRange ? `${input.instruction}\n\nUpdated absolute query range: ${JSON.stringify(input.timeRange)}` : input.instruction;
|
|
233
|
+
if (input.command === "answer" || input.command === "instruct") {
|
|
234
|
+
if ([
|
|
235
|
+
"completed",
|
|
236
|
+
"failed",
|
|
237
|
+
"cancelled"
|
|
238
|
+
].includes(personalRequestSnapshot(request).state)) throw new Error("Request is no longer active");
|
|
239
|
+
if (readCurrentTranscriptId(getSqliteDatabase(), conversationId) !== request.transcriptId) throw new Error("SESSION_CHANGED");
|
|
240
|
+
if (!request.taskId && input.command === "instruct" && request.state === "waiting_connection") {
|
|
241
|
+
const addition = `\n\nSupplemental requirement:\n${instruction.trim()}`;
|
|
242
|
+
if (!request.objective.endsWith(addition)) runSqliteWriteTransaction(() => {
|
|
243
|
+
if (getActiveConnectionWait(conversationId)?.id !== request.connectionWaitId) throw new Error("Connection objective changed");
|
|
244
|
+
reviseCurrentConnectionObjective(conversationId, request.objective + addition);
|
|
245
|
+
const revised = getActiveConnectionWait(conversationId);
|
|
246
|
+
updateConnectionWait({
|
|
247
|
+
...revised,
|
|
248
|
+
checkpoint: {
|
|
249
|
+
...revised.checkpoint,
|
|
250
|
+
timeRange: input.timeRange ?? request.parameters.timeRange
|
|
251
|
+
}
|
|
252
|
+
}, revised.version);
|
|
253
|
+
updatePersonalRequest(request, {
|
|
254
|
+
objective: request.objective + addition,
|
|
255
|
+
parameters: {
|
|
256
|
+
...request.parameters,
|
|
257
|
+
...input.timeRange ? { timeRange: input.timeRange } : {}
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
return result({
|
|
262
|
+
...snapshot(getPersonalRequest(request.requestId)),
|
|
263
|
+
instructionStatus: "saved",
|
|
264
|
+
guidance: "Account authorization is still required. The existing Request will create its Task with this requirement after authorization."
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (input.command !== "get" || request.taskId) {
|
|
269
|
+
if (!request.taskId) throw new Error("No Task yet; complete account authorization in the main connection UI");
|
|
270
|
+
const coordinated = await taskTool.execute(toolCallId, {
|
|
271
|
+
...input,
|
|
272
|
+
instruction,
|
|
273
|
+
taskId: request.taskId
|
|
274
|
+
});
|
|
275
|
+
if (input.command === "instruct" && input.timeRange && JSON.parse(coordinated.content[0].text).ok === true) runSqliteWriteTransaction(() => {
|
|
276
|
+
const current = getPersonalRequest(request.requestId);
|
|
277
|
+
updatePersonalRequest(current, { parameters: {
|
|
278
|
+
...current.parameters,
|
|
279
|
+
timeRange: input.timeRange
|
|
280
|
+
} });
|
|
281
|
+
const wait = getActiveConnectionWait(conversationId);
|
|
282
|
+
if (wait && wait.id === current.connectionWaitId) updateConnectionWait({
|
|
283
|
+
...wait,
|
|
284
|
+
checkpoint: {
|
|
285
|
+
...wait.checkpoint,
|
|
286
|
+
timeRange: input.timeRange
|
|
287
|
+
}
|
|
288
|
+
}, wait.version);
|
|
289
|
+
});
|
|
290
|
+
if (input.command !== "get") return coordinated;
|
|
291
|
+
return result({
|
|
292
|
+
...snapshot(request),
|
|
293
|
+
coordination: JSON.parse(coordinated.content[0].text)
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
return result(snapshot(request));
|
|
150
297
|
}
|
|
151
298
|
}];
|
|
152
299
|
}
|
|
@@ -12,7 +12,7 @@ declare const PersonalTaskModelSchema: import("@sinclair/typebox").TObject<{
|
|
|
12
12
|
taskType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
13
13
|
requestedAgentId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
14
14
|
}>>;
|
|
15
|
-
command: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"get" | "answer" | "retry_allocation" | "selection" | "list" | "cancel" | "submit" | "instruct">[]>;
|
|
15
|
+
command: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"get" | "answer" | "retry_allocation" | "selection" | "list" | "cancel" | "entry" | "submit" | "instruct" | "collaboration">[]>;
|
|
16
16
|
requestId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
17
17
|
title: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
18
18
|
taskId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
@@ -26,6 +26,10 @@ declare const PersonalTaskModelSchema: import("@sinclair/typebox").TObject<{
|
|
|
26
26
|
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
27
27
|
offset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
28
28
|
instruction: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
29
|
+
section: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<string>[]>>;
|
|
30
|
+
entryId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
31
|
+
afterSequence: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
32
|
+
bodyOffset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
29
33
|
questionId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
30
34
|
}>;
|
|
31
35
|
export interface PersonalTaskToolDeps extends XopcUseToolDeps {
|