@xopcai/xopc 0.0.199 → 0.0.201
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/{activity-store-DYVN1hRp.js → activity-store-DOhnAQOQ.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Bt70bZjv.js → agent-avatar-dicebear-D8Cw0Mve.js} +1 -1
- package/dist/gateway/static/root/assets/agents-ANavi648.js +68 -0
- package/dist/gateway/static/root/assets/{api-B8mzbAle.js → api-E9Bk-Idp.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-B4x7JfL8.js → app-management-settings-panel-BubrReXg.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-Dwdagf-Q.js → appearance-settings-BY5Az2p4.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DkTiesxe.js → apps-page-CFh9MBxc.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-Cv0VXKLm.js → archive-plugin-BY8843mB.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CgidKrXn.js → attachment-load-DG45KScf.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-751CeNI3.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DN3CQgIq.js → binary-plugins-DGIF2ZAv.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BwkSl1F_.js → block-editor-C1Qktr1g.js} +5 -5
- package/dist/gateway/static/root/assets/browser-settings-page-CGAWs-TT.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-_ndaecsf.js → browser-workflow-inputs-D_jnndyz.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-C_I31wLm.js → browser-workflows-page-DyIRvPaq.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CghUK68J.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-Dy1jZJKs.js → capability-presets-api--tz0mGLY.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-XsTfkvUn.js +3 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-D-9qiuio.js → channel-recipient-api-CkOKF9nc.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-DV5BhAeu.js → channels-settings-DkoAZZMe.js} +1 -1
- package/dist/gateway/static/root/assets/channels-status-swr-DNDvMWpl.js +1 -0
- package/dist/gateway/static/root/assets/{connectors-api-5FEBYguL.js → connectors-api-FBOe9SWC.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-e4vekkAu.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-SEFx5rnr.js → cron-expression-Q4QaYjpI.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-D4zCUQJL.js → date-picker-Dtn7e6TW.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-DpQAxS2k.js → dependency-picker-Br6nPaM6.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-B_5G3lQl.js → desktop-pet-DzTM6aH8.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-ClEyoUJe.js → desktop-pet-settings-FDmaty3P.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-AsFWmOjG.js → directory-picker-path-field-X2e8xn8j.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-C22Y2o5l.js → extension-debug-page-Dx4MBfga.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-C61Ikawk.js → extension-page-Bf_FEDhM.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-WlWWcDFr.js → extension-settings-page-CrOgZxkf.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-ByIOMQdc.js → gateway-config-api-CZ4r-7qT.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-jB0hAhWO.js → gateway-config-swr-Cv2ywpdb.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-CzzS9A17.js → gateway-settings-DpWmVi0w.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-C-fRlHCL.js → gateway-startup-retry-undf-k5g.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-DSQZhSvT.js +1 -0
- package/dist/gateway/static/root/assets/home-page-L0uHiu0T.js +3 -0
- package/dist/gateway/static/root/assets/{index-CR233S0Q.css → index-Bp8I_eX4.css} +1 -1
- package/dist/gateway/static/root/assets/index-DRrjYYzZ.js +152 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BD_TFz0_.js → keyboard-shortcuts-settings-Bc3Quw42.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-Copi3sdP.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-BwbUeLfm.js → local-apps-page-CP9X_vtz.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-xULEcFVs.js → locale-store-CnamlR07.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DMKq6e29.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-CW2VpqtT.js → management-settings-CJmcaVje.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-B1M9KO16.js → markdown-split-AcuFp0TH.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-B_QlNdqZ.js → media-plugins-BvFgsiJL.js} +1 -1
- package/dist/gateway/static/root/assets/messages-D7kOD_o_.js +3 -0
- package/dist/gateway/static/root/assets/{notes-page-BTbD4GmH.js → notes-page-IW7IQ9nJ.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-Zb8U0anO.js +4 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CeqtArlZ.js → preview-open-alternatives-C-b34dgQ.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-DnalBZZs.js → product-open-page-CWEzLykF.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BuIbLnan.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BwUfRqNV.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-BTaXxcEi.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-cGkBEfg4.js → runtime-tools-settings-panel-DAohEZrX.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-CmsrLlxu.js → schema-form-C_OBW8A5.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-BnHoTCD3.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BTB_fxjt.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-DUWCbaMJ.js → settings-form-section-C7w2WS-A.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-Bvy5rdMY.js → settings-loading-skeleton-zwibve4m.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-cZSAwsRR.js → settings-page-B9W03dSW.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-C8Hec2Af.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-BzA2NCAH.js → share-preview-page-6e3ks2be.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-Bwc5HfLI.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-D7kunhqy.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-Bvde7_i5.js → skills-page-WgkaNzpc.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-vXSqHR7g.js → skills-page.utils-D9QT5cxj.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-9cQGOGCK.js → system-settings-panel-c1HVtv1Y.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-CjP-6WVU.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-CHQRiuCF.js → theme-store-BDyUTObE.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-7XfKULPI.js → use-autosave-D6UkH_Ga.js} +1 -1
- package/dist/gateway/static/root/assets/{user-context-page-CZ9m9aC_.js → user-context-page-D8ZhPDNF.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-DXr21v-3.js → voice-api-key-field-BOxkKbGh.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-CeG7g_DZ.js → work-discovery-overlay-Dd19yK9t.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-page-DUkdJl1e.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DSQQZP9T.js → workflow-run-setup-panel-ZA3bP65I.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-C2b5W5bw.js +5 -0
- package/dist/gateway/static/root/assets/{working-directory-picker-modal-D-IgcHPp.js → working-directory-picker-modal-BcyiDXU3.js} +1 -1
- package/dist/gateway/static/root/index.html +9 -9
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/tasks.js +51 -9
- package/dist/src/agent/context/execution-scope.js +3 -1
- package/dist/src/agent/tasks/task-judge-service.d.ts +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +3 -2
- package/dist/src/agent/tools/xopc-use-tool.js +13 -3
- package/dist/src/auth/oauth/types.d.ts +2 -0
- package/dist/src/auth/oauth/xopc-cloud.js +24 -2
- package/dist/src/automations/domain/validation.d.ts +0 -12
- package/dist/src/automations/draft/automation-draft-validator.d.ts +0 -3
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/gateway/hono/app.js +1 -1
- package/dist/src/gateway/hono/oauth-async.js +2 -0
- package/dist/src/gateway/hono/routes/agent-stream.js +2 -74
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +62 -0
- package/dist/src/gateway/hono/routes/session-input-handler.js +82 -0
- package/dist/src/gateway/hono/routes/tasks.js +161 -2
- package/dist/src/gateway/service/task-conversation-query-service.d.ts +58 -0
- package/dist/src/gateway/service/task-conversation-query-service.js +84 -0
- package/dist/src/gateway/service.d.ts +10 -0
- package/dist/src/gateway/service.js +75 -42
- package/dist/src/projects/project-agent.js +1 -1
- package/dist/src/storage/sqlite/migrations/120_task_conversation.sql +112 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/tasks/execution-context.js +8 -4
- package/dist/src/tasks/index.d.ts +2 -0
- package/dist/src/tasks/index.js +3 -1
- package/dist/src/tasks/task-application-service.js +10 -17
- package/dist/src/tasks/task-context-assembler.js +9 -4
- package/dist/src/tasks/task-context-repository.d.ts +0 -6
- package/dist/src/tasks/task-context-repository.js +0 -4
- package/dist/src/tasks/task-conversation-repository.d.ts +71 -0
- package/dist/src/tasks/task-conversation-repository.js +194 -0
- package/dist/src/tasks/task-handoff-service.d.ts +31 -0
- package/dist/src/tasks/task-handoff-service.js +143 -0
- package/dist/src/tasks/task-read-model-projector.js +1 -5
- package/dist/src/tasks/task-repository.d.ts +0 -2
- package/dist/src/tasks/task-repository.js +2 -9
- package/dist/src/tasks/task-run-coordinator.js +3 -1
- package/dist/src/workflows/service/workflow-run-service.js +4 -2
- package/package.json +2 -2
- package/dist/gateway/static/root/assets/agents-D19uNmJf.js +0 -68
- package/dist/gateway/static/root/assets/automations-page-BR6qMOVr.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CDFQWAxI.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-D41mssOq.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-BXgCyuu2.js +0 -3
- package/dist/gateway/static/root/assets/channels-status-swr-B4Rbh3bM.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-C_qkEN0T.js +0 -2
- package/dist/gateway/static/root/assets/heartbeat-settings-B4A_CXUL.js +0 -1
- package/dist/gateway/static/root/assets/home-page-FVGYYPWo.js +0 -3
- package/dist/gateway/static/root/assets/index-CGbKTCST.js +0 -152
- package/dist/gateway/static/root/assets/local-app-workbench-page-BNpkigNb.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-DXP9OQQt.js +0 -2
- package/dist/gateway/static/root/assets/messages-3qRsLZuX.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-JRiq7QDW.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-CjWA13aE.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-jsCkScbG.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CGPJTEkM.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BBHzziMd.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-2cGg8-9h.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Cf06b66-.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-xlNKydYY.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-C5Xu93c_.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-Bkno4tTe.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-CQWZD03N.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-Cs-MXFJ1.js +0 -5
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { createLogger } from "../utils/logger/index.js";
|
|
2
|
+
import { init_logger } from "../utils/logger.js";
|
|
3
|
+
import { init_agent_scope, listAgentEntries, normalizeAgentId } from "../agent/agent-scope.js";
|
|
4
|
+
import { buildSessionKey, init_session_key, sanitizeSegment } from "../routing/session-key.js";
|
|
5
|
+
import { TaskRepository } from "./task-repository.js";
|
|
6
|
+
import { TaskConversationRepository } from "./task-conversation-repository.js";
|
|
7
|
+
import { TaskRunRepository } from "./task-run-repository.js";
|
|
8
|
+
import { TaskContextRepository } from "./task-context-repository.js";
|
|
9
|
+
//#region src/tasks/task-handoff-service.ts
|
|
10
|
+
init_agent_scope();
|
|
11
|
+
init_session_key();
|
|
12
|
+
init_logger();
|
|
13
|
+
const log = createLogger("TaskHandoff");
|
|
14
|
+
var TaskHandoffService = class {
|
|
15
|
+
#inflight = /* @__PURE__ */ new Map();
|
|
16
|
+
constructor(deps) {
|
|
17
|
+
this.deps = deps;
|
|
18
|
+
}
|
|
19
|
+
handoff(input) {
|
|
20
|
+
const previous = this.#inflight.get(input.taskId);
|
|
21
|
+
const pending = (previous ? previous.catch(() => void 0) : Promise.resolve()).then(() => this.performHandoff(input));
|
|
22
|
+
this.#inflight.set(input.taskId, pending);
|
|
23
|
+
pending.finally(() => {
|
|
24
|
+
if (this.#inflight.get(input.taskId) === pending) this.#inflight.delete(input.taskId);
|
|
25
|
+
});
|
|
26
|
+
return pending;
|
|
27
|
+
}
|
|
28
|
+
async performHandoff(input) {
|
|
29
|
+
const config = this.deps.getConfig();
|
|
30
|
+
const toAgentId = normalizeAgentId(input.toAgentId);
|
|
31
|
+
if (!listAgentEntries(config).find((entry) => entry.enabled !== false && normalizeAgentId(entry.id) === toAgentId)) throw new Error(`Agent not found: ${toAgentId}`);
|
|
32
|
+
const tasks = new TaskRepository();
|
|
33
|
+
const task = tasks.require(input.taskId);
|
|
34
|
+
const conversations = new TaskConversationRepository();
|
|
35
|
+
const duplicate = conversations.findHandoffByIdempotencyKey({
|
|
36
|
+
taskId: task.id,
|
|
37
|
+
expectedTaskVersion: input.expectedVersion,
|
|
38
|
+
toAgentId,
|
|
39
|
+
idempotencyKey: input.idempotencyKey
|
|
40
|
+
});
|
|
41
|
+
if (duplicate) {
|
|
42
|
+
await this.abortPreviousSession(duplicate.fromSessionKey);
|
|
43
|
+
return {
|
|
44
|
+
task,
|
|
45
|
+
conversation: conversations.requireState(task.id),
|
|
46
|
+
snapshot: duplicate,
|
|
47
|
+
...duplicate.fromAgentId ? { fromAgentId: duplicate.fromAgentId } : {},
|
|
48
|
+
toAgentId,
|
|
49
|
+
activeSessionKey: duplicate.toSessionKey,
|
|
50
|
+
assignmentEpoch: duplicate.assignmentEpoch
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (task.version !== input.expectedVersion) throw new Error("Task changed");
|
|
54
|
+
const previousState = conversations.requireState(task.id);
|
|
55
|
+
if (previousState.currentExecutorAgentId === toAgentId) throw new Error("Executor is already active");
|
|
56
|
+
const assignmentEpoch = previousState.assignmentEpoch + 1;
|
|
57
|
+
const peerId = sanitizeSegment(`task-${task.id}-assignment-${assignmentEpoch}`);
|
|
58
|
+
const sessionKey = buildSessionKey({
|
|
59
|
+
agentId: toAgentId,
|
|
60
|
+
source: "webchat",
|
|
61
|
+
accountId: "default",
|
|
62
|
+
peerKind: "direct",
|
|
63
|
+
peerId
|
|
64
|
+
});
|
|
65
|
+
const runs = new TaskRunRepository();
|
|
66
|
+
const latestRun = runs.getLatestRoot(task.id);
|
|
67
|
+
const latestReceipt = latestRun ? runs.getReceipt(latestRun.id) : void 0;
|
|
68
|
+
const remainingCriteria = latestReceipt?.verification.checks.length ? latestReceipt.verification.checks.filter((check) => check.status !== "passed").map((check) => check.criterion) : task.contract?.acceptanceCriteria ?? [];
|
|
69
|
+
const payload = {
|
|
70
|
+
objective: task.contract?.objective ?? task.title,
|
|
71
|
+
expectedOutputs: task.contract?.expectedOutputs ?? [],
|
|
72
|
+
remainingCriteria,
|
|
73
|
+
constraints: task.contract?.constraints ?? [],
|
|
74
|
+
risks: task.contract?.risks ?? [],
|
|
75
|
+
approvalRequired: task.contract?.approvalRequired ?? [],
|
|
76
|
+
context: new TaskContextRepository().list(task.id),
|
|
77
|
+
...latestReceipt ? {
|
|
78
|
+
latestReceipt,
|
|
79
|
+
completedWork: latestReceipt.changes,
|
|
80
|
+
remainingWork: latestReceipt.remainingWork
|
|
81
|
+
} : {}
|
|
82
|
+
};
|
|
83
|
+
await this.deps.sessionIndex.saveMessages(sessionKey, [], { metadata: {
|
|
84
|
+
sourceChannel: "webchat",
|
|
85
|
+
sourceChatId: `default:direct:${peerId}`,
|
|
86
|
+
sessionType: "chat",
|
|
87
|
+
routing: {
|
|
88
|
+
agentId: toAgentId,
|
|
89
|
+
source: "webchat",
|
|
90
|
+
accountId: "default",
|
|
91
|
+
peerKind: "direct",
|
|
92
|
+
peerId
|
|
93
|
+
},
|
|
94
|
+
projectId: task.projectId,
|
|
95
|
+
customData: {
|
|
96
|
+
origin: "task",
|
|
97
|
+
triggerKind: "user",
|
|
98
|
+
assignmentEpoch
|
|
99
|
+
}
|
|
100
|
+
} });
|
|
101
|
+
let completed;
|
|
102
|
+
try {
|
|
103
|
+
completed = conversations.completeHandoff({
|
|
104
|
+
taskId: task.id,
|
|
105
|
+
expectedTaskVersion: input.expectedVersion,
|
|
106
|
+
toSessionKey: sessionKey,
|
|
107
|
+
toAgentId,
|
|
108
|
+
idempotencyKey: input.idempotencyKey,
|
|
109
|
+
payload
|
|
110
|
+
});
|
|
111
|
+
} catch (error) {
|
|
112
|
+
await this.deps.sessionIndex.delete(sessionKey);
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
const oldSessionKey = completed.snapshot.fromSessionKey;
|
|
116
|
+
await this.abortPreviousSession(oldSessionKey);
|
|
117
|
+
return {
|
|
118
|
+
task: tasks.require(task.id),
|
|
119
|
+
conversation: completed.state,
|
|
120
|
+
snapshot: completed.snapshot,
|
|
121
|
+
...completed.snapshot.fromAgentId ? { fromAgentId: completed.snapshot.fromAgentId } : {},
|
|
122
|
+
toAgentId,
|
|
123
|
+
activeSessionKey: sessionKey,
|
|
124
|
+
assignmentEpoch: completed.state.assignmentEpoch
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
async abortPreviousSession(sessionKey) {
|
|
128
|
+
if (!sessionKey) return;
|
|
129
|
+
const activeRunId = this.deps.getActiveRunId(sessionKey);
|
|
130
|
+
if (!activeRunId) return;
|
|
131
|
+
try {
|
|
132
|
+
await this.deps.abortRun(activeRunId);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
log.warn({
|
|
135
|
+
err: error,
|
|
136
|
+
sessionKey,
|
|
137
|
+
runId: activeRunId
|
|
138
|
+
}, "Previous task executor did not stop cleanly");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
//#endregion
|
|
143
|
+
export { TaskHandoffService };
|
|
@@ -76,11 +76,7 @@ var TaskReadModelProjector = class {
|
|
|
76
76
|
}
|
|
77
77
|
allowedCommands(task, activeRunStatus, hasWaits) {
|
|
78
78
|
if (task.phase === "closed") return ["reopen"];
|
|
79
|
-
const commands = [
|
|
80
|
-
"revise_contract",
|
|
81
|
-
"delegate",
|
|
82
|
-
"close"
|
|
83
|
-
];
|
|
79
|
+
const commands = ["revise_contract", "close"];
|
|
84
80
|
if (!activeRunStatus && !hasWaits) commands.unshift("move");
|
|
85
81
|
if (hasWaits) commands.unshift("resolve_wait");
|
|
86
82
|
else if (activeRunStatus === "running" || activeRunStatus === "verifying") commands.unshift("add_wait");
|
|
@@ -34,7 +34,6 @@ export declare class TaskRepository {
|
|
|
34
34
|
get(id: string): TaskAggregate | undefined;
|
|
35
35
|
require(id: string): TaskAggregate;
|
|
36
36
|
getByIdempotencyKey(key: string): TaskAggregate | undefined;
|
|
37
|
-
getBySession(sessionKey: string): TaskAggregate | undefined;
|
|
38
37
|
list(input?: {
|
|
39
38
|
phase?: TaskPhase;
|
|
40
39
|
projectId?: string;
|
|
@@ -53,7 +52,6 @@ export declare class TaskRepository {
|
|
|
53
52
|
priority?: TaskPriority;
|
|
54
53
|
dueAt?: number | null;
|
|
55
54
|
ownerId?: string | null;
|
|
56
|
-
delegateAgentId?: string | null;
|
|
57
55
|
now?: number;
|
|
58
56
|
}): TaskAggregate | undefined;
|
|
59
57
|
setLifecycle(input: {
|
|
@@ -93,13 +93,6 @@ var TaskRepository = class {
|
|
|
93
93
|
const row = getSqliteDatabase().prepare("SELECT * FROM tasks WHERE creation_idempotency_key = ?").get(key);
|
|
94
94
|
return row ? taskFromRow(row, this.getContract(row.task_id, row.latest_contract_version)) : void 0;
|
|
95
95
|
}
|
|
96
|
-
getBySession(sessionKey) {
|
|
97
|
-
const row = getSqliteDatabase().prepare(`SELECT tasks.* FROM tasks
|
|
98
|
-
JOIN task_sessions ON task_sessions.task_id = tasks.task_id
|
|
99
|
-
WHERE task_sessions.session_key = ?
|
|
100
|
-
ORDER BY task_sessions.created_at DESC LIMIT 1`).get(sessionKey);
|
|
101
|
-
return row ? taskFromRow(row, this.getContract(row.task_id, row.latest_contract_version)) : void 0;
|
|
102
|
-
}
|
|
103
96
|
list(input = {}) {
|
|
104
97
|
const clauses = [];
|
|
105
98
|
const params = [];
|
|
@@ -134,9 +127,9 @@ var TaskRepository = class {
|
|
|
134
127
|
if (!title) throw new Error("Task title is required");
|
|
135
128
|
const now = Math.max(patch.now ?? Date.now(), current.updatedAt + 1);
|
|
136
129
|
return getSqliteDatabase().prepare(`UPDATE tasks SET title = ?, body = ?, project_id = ?, milestone_id = ?,
|
|
137
|
-
parent_task_id = ?, priority = ?, due_at = ?, owner_id = ?,
|
|
130
|
+
parent_task_id = ?, priority = ?, due_at = ?, owner_id = ?,
|
|
138
131
|
version = version + 1, updated_at = ?
|
|
139
|
-
WHERE task_id = ? AND version = ?`).run(title, patch.body === void 0 ? current.body ?? null : patch.body?.trim() || null, patch.projectId === void 0 ? current.projectId ?? null : patch.projectId, patch.milestoneId === void 0 ? current.milestoneId ?? null : patch.milestoneId, patch.parentTaskId === void 0 ? current.parentTaskId ?? null : patch.parentTaskId, patch.priority ?? current.priority, patch.dueAt === void 0 ? current.dueAt ?? null : patch.dueAt, patch.ownerId === void 0 ? current.ownerId ?? null : patch.ownerId,
|
|
132
|
+
WHERE task_id = ? AND version = ?`).run(title, patch.body === void 0 ? current.body ?? null : patch.body?.trim() || null, patch.projectId === void 0 ? current.projectId ?? null : patch.projectId, patch.milestoneId === void 0 ? current.milestoneId ?? null : patch.milestoneId, patch.parentTaskId === void 0 ? current.parentTaskId ?? null : patch.parentTaskId, patch.priority ?? current.priority, patch.dueAt === void 0 ? current.dueAt ?? null : patch.dueAt, patch.ownerId === void 0 ? current.ownerId ?? null : patch.ownerId, now, taskId, patch.expectedVersion).changes === 0 ? void 0 : this.get(taskId);
|
|
140
133
|
}
|
|
141
134
|
setLifecycle(input) {
|
|
142
135
|
if (input.phase === "closed" !== Boolean(input.resolution)) throw new Error("Closed tasks require a resolution and open tasks cannot have one");
|
|
@@ -19,11 +19,13 @@ var TaskRunCoordinator = class TaskRunCoordinator {
|
|
|
19
19
|
let run = runs.get(input.runId);
|
|
20
20
|
if (!run) {
|
|
21
21
|
if (runs.getActiveRoot(task.id)) return void 0;
|
|
22
|
+
const agentId = task.delegateAgentId ?? input.context.agentId;
|
|
23
|
+
if (!agentId) return void 0;
|
|
22
24
|
run = runs.create({
|
|
23
25
|
id: input.runId,
|
|
24
26
|
taskId: task.id,
|
|
25
27
|
executorKind: "agent",
|
|
26
|
-
executorRef: { agentId
|
|
28
|
+
executorRef: { agentId },
|
|
27
29
|
trigger: { kind: input.context.triggerKind },
|
|
28
30
|
correlationId: input.runId,
|
|
29
31
|
idempotencyKey: input.runId,
|
|
@@ -2,6 +2,7 @@ import { getDefaultAgentId, init_resolve_route } from "../../routing/resolve-rou
|
|
|
2
2
|
import { extractProfileAgentId, resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
3
3
|
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
4
4
|
import { TaskRepository } from "../../tasks/task-repository.js";
|
|
5
|
+
import { TaskConversationRepository } from "../../tasks/task-conversation-repository.js";
|
|
5
6
|
import { TaskRunRepository } from "../../tasks/task-run-repository.js";
|
|
6
7
|
import { getProjectWorkspacePathForSession } from "../../projects/workspace.js";
|
|
7
8
|
import { publishAutomationProductEvent } from "../../automations/product-events.js";
|
|
@@ -161,10 +162,11 @@ var WorkflowRunService = class {
|
|
|
161
162
|
},
|
|
162
163
|
sessionKey
|
|
163
164
|
})) throw new Error("TaskRun changed before workflow execution started");
|
|
164
|
-
|
|
165
|
+
new TaskConversationRepository().activateExecutionSession({
|
|
165
166
|
taskId: task.id,
|
|
166
167
|
sessionKey,
|
|
167
|
-
|
|
168
|
+
agentId: params.agentId,
|
|
169
|
+
runId: linkedTaskRun.id
|
|
168
170
|
});
|
|
169
171
|
}
|
|
170
172
|
const source = normalizeWorkflowRunSourceForSession(params.source, sessionKey, params.parentSessionKey);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xopcai/xopc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.201",
|
|
4
4
|
"description": "Local-first AI system that remembers context, coordinates AI, and sustains long-term progress.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -162,8 +162,8 @@
|
|
|
162
162
|
"vitepress": "^1.6.4",
|
|
163
163
|
"vitest": "4.1.5",
|
|
164
164
|
"vue": "^3.5.35",
|
|
165
|
-
"@xopcai/endpoint-tools-protocol": "0.0.0",
|
|
166
165
|
"@xopcai/gateway-contract": "0.0.0",
|
|
166
|
+
"@xopcai/endpoint-tools-protocol": "0.0.0",
|
|
167
167
|
"@xopcai/realtime-protocol": "0.0.0",
|
|
168
168
|
"@xopcai/realtime-client": "0.0.0"
|
|
169
169
|
},
|