@xopcai/xopc 0.0.160 → 0.0.162
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-hpcNv9MZ.js +1 -0
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-B_27aaZQ.js → agent-avatar-dicebear-Zf9UQEmQ.js} +1 -1
- package/dist/gateway/static/root/assets/agents-DfVkZlHc.js +2 -0
- package/dist/gateway/static/root/assets/{api-BbzB57CJ.js → api-Dnatri09.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-DfmyWcyh.js → app-management-settings-panel-BBTR9wJP.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-B2v0c-K-.js → appearance-settings-C2zpLCHD.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-BMtAa4Ra.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-DL5Lnx0C.js → archive-plugin-9eR_ODY1.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-InuP-ZjQ.js → attachment-load-DPuWYUeX.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-CahGuh7B.js → automation-suggestion-card-Dw49OJRl.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-BiSAMYTr.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-CdOTGYVu.js → binary-plugins-BdkJpDFm.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-D6ShK1S-.js → block-editor-CAi7SXYU.js} +47 -47
- package/dist/gateway/static/root/assets/browser-settings-page-DHmaEJS2.js +8 -0
- package/dist/gateway/static/root/assets/browser-workflow-inputs-Dx6wkGz1.js +1 -0
- package/dist/gateway/static/root/assets/browser-workflows-page-Skertc-A.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-B5wSgf4f.js +2 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-BzoLm52Z.js → capability-presets-api-CNFl7dM3.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-DyvFZwBj.js +2 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-DbgydMjl.js → channel-recipient-api-DYQyGDw4.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-BBKEqDZn.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-Drk110ve.js +1 -0
- package/dist/gateway/static/root/assets/check-DUBLcKHA.js +1 -0
- package/dist/gateway/static/root/assets/circle-alert-BEjgurr2.js +1 -0
- package/dist/gateway/static/root/assets/cn-JdwAhgNB.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-C3bJC9nt.js → connector-logo-Bng6kxYF.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-HpgaUDQ1.js +2 -0
- package/dist/gateway/static/root/assets/createLucideIcon-DPHK1VkS.js +1 -0
- package/dist/gateway/static/root/assets/desktop-pet-Bpf6oegd.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BrHVvbBw.js → desktop-pet-settings-BVUyefSd.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-sprite-CFd1jGLJ.js → desktop-pet-sprite-DTqXSpqf.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BPI969w-.js → directory-picker-path-field-DjSZAPz_.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-iw6QXD45.js → dreaming-settings-CAZk2AM4.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-rCHyhEr6.js → extension-debug-page-C2F6vTTd.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-C4gQsAPt.js → extension-page-AnIt4bn4.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DB_3eik7.js → extension-settings-page-CLSc6682.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-Cdt38iF2.js → gateway-config-api-DLFyZv33.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DM4BgyGw.js → gateway-settings-DnQAA-qq.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-ChRFNjj_.js → gateway-startup-retry-DbzLyJ3R.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-DrnKFC6M.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-Cw1hpJkZ.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-RvljeEm6.js → goals-config-api-REmr3QCr.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-BDGkTVma.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-DMGV4S4L.js → goals-settings-Dz0F3uRO.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-B8r5EXc5.js → heartbeat-settings-CQFY5gYs.js} +1 -1
- package/dist/gateway/static/root/assets/index-C8JkTS6d.js +199 -0
- package/dist/gateway/static/root/assets/index-hmrG55qg.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-1-LYibQ4.js → keyboard-shortcuts-settings-BnOQXU5k.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-Bdef1b7F.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-CC4vtUUI.js → local-apps-page-KsOtWOyM.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-CPbGB_6l.js → locale-store-0lpYdNDr.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-Bn_taxBV.js → logs-page-CwLPgrWh.js} +3 -3
- package/dist/gateway/static/root/assets/{markdown-split-CprEIf8A.js → markdown-split-D5GRg10r.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-BXt_Sj2O.js → media-plugins-C1ryULGs.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BwQ3WssU.js +5 -0
- package/dist/gateway/static/root/assets/{notes-page-Wf5-eyyM.js → notes-page-CIeZ1_DT.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-Cf06q19x.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-dtpK_4Fs.js → page-tabs-Caj1-E_X.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DijtEVxG.js → preview-open-alternatives-DKwEce-9.js} +1 -1
- package/dist/gateway/static/root/assets/product-delivery-BTRT9kCS.js +1 -0
- package/dist/gateway/static/root/assets/product-open-page-B90ZskkN.js +1 -0
- package/dist/gateway/static/root/assets/project-detail-page-SHTurM4t.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BcC2qUAw.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-6vGefBHv.js +1 -0
- package/dist/gateway/static/root/assets/save-bar-controls-BDYt53uQ.js +1 -0
- package/dist/gateway/static/root/assets/{schedule-field-AhJ50NoT.js → schedule-field-Bcdni4Pj.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-AuJg2CXU.js → schema-form-D7oCARF7.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-C5014a53.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-CDY3ZI1K.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-D5ganr_X.js → settings-collapsible-section-6eNF8Jey.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-Db3cKRsg.js → settings-form-section-CARTHCxH.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-D05YKT2x.js → settings-loading-skeleton-DEwYqESe.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-B6vVdHeQ.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-layout-Cv_Cu4I5.js → settings-page-layout-D3srt5Bi.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-z-rF0Hdg.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-CYkZVuse.js → share-preview-page-Ck9SxiXw.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-CHZFXE_d.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-B7p2QNXt.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-ncw3tX9P.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-C1Ng5bXh.js → system-settings-panel-DLBUQSk2.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-LMHIDR9n.js → theme-store-C1oaqeD2.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-Ch2Bdm_5.js → typed-models-lib-Divbg_C4.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-CZnaMOeL.js → use-channel-catalog-CP9a_rAf.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-iYfeSLKI.js +1 -0
- package/dist/gateway/static/root/assets/voice-api-key-field-CrwkicvT.js +1 -0
- package/dist/gateway/static/root/assets/work-discovery-page-BQWxyPg8.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-50ZzGay5.js +1 -0
- package/dist/gateway/static/root/assets/work-page-DPqEahx7.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BFk8TvTw.js → workflow-run-setup-panel-DbDPYQwB.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-C3eIC5HZ.js +11 -0
- package/dist/gateway/static/root/index.html +12 -10
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +1 -0
- package/dist/src/agent/agent-manager.js +1 -0
- package/dist/src/agent/client-error-format.js +3 -3
- package/dist/src/agent/outcomes/task-evaluation.d.ts +20 -0
- package/dist/src/agent/outcomes/task-evaluation.js +48 -0
- package/dist/src/agent/outcomes/task-verifier.d.ts +29 -0
- package/dist/src/agent/outcomes/task-verifier.js +71 -0
- package/dist/src/agent/prompt/memory/index.js +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +32 -1
- package/dist/src/agent/service.js +1 -0
- package/dist/src/agent/service.types.d.ts +1 -0
- package/dist/src/agent/tools/browser/tool/browser-use-tool.d.ts +1 -7
- package/dist/src/agent/tools/browser/tool/browser-use-tool.js +2 -73
- package/dist/src/agent/tools/browser/tool/schemas.d.ts +1 -13
- package/dist/src/agent/tools/browser/tool/schemas.js +1 -9
- package/dist/src/agent/tools/browser-recipe-tool.d.ts +12 -0
- package/dist/src/agent/tools/browser-recipe-tool.js +113 -0
- package/dist/src/agent/tools/factory.d.ts +2 -0
- package/dist/src/agent/tools/factory.js +2 -0
- package/dist/src/agent/tools/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +2 -1
- package/dist/src/automations/domain/types.d.ts +13 -0
- package/dist/src/automations/domain/validation.d.ts +44 -24
- package/dist/src/automations/domain/validation.js +27 -18
- package/dist/src/automations/draft/automation-draft-validator.d.ts +6 -1
- package/dist/src/automations/draft/automation-draft-validator.js +1 -0
- package/dist/src/automations/service/action-executor.d.ts +1 -0
- package/dist/src/automations/service/action-executor.js +22 -0
- package/dist/src/browser/index.d.ts +0 -1
- package/dist/src/browser/index.js +1 -2
- package/dist/src/browser/pipeline/runner.d.ts +9 -2
- package/dist/src/browser/pipeline/runner.js +151 -105
- package/dist/src/browser/pipeline/schema.d.ts +21 -15
- package/dist/src/browser/pipeline/schema.js +93 -99
- package/dist/src/browser/recipes/index.d.ts +3 -0
- package/dist/src/browser/recipes/index.js +3 -0
- package/dist/src/browser/recipes/repository.d.ts +13 -0
- package/dist/src/browser/recipes/repository.js +81 -0
- package/dist/src/browser/recipes/runtime-service.d.ts +6 -0
- package/dist/src/browser/recipes/runtime-service.js +30 -0
- package/dist/src/browser/recipes/service.d.ts +36 -0
- package/dist/src/browser/recipes/service.js +186 -0
- package/dist/src/browser/recipes/types.d.ts +36 -0
- package/dist/src/browser/recipes/types.js +1 -0
- package/dist/src/cli/commands/browser-cli-helpers.js +6 -12
- package/dist/src/cli/commands/browser.js +4 -3
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/config/schema.d.ts +3 -3
- package/dist/src/config/schema.js +21 -21
- package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -1
- package/dist/src/gateway/hono/routes/browser-workflows.d.ts +3 -0
- package/dist/src/gateway/hono/routes/browser-workflows.js +78 -0
- package/dist/src/gateway/hono/routes/home.js +1 -0
- package/dist/src/gateway/hono/routes/index.js +4 -0
- package/dist/src/gateway/hono/routes/interaction-state.d.ts +3 -0
- package/dist/src/gateway/hono/routes/interaction-state.js +45 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
- package/dist/src/gateway/hono/routes/memory.js +33 -4
- package/dist/src/gateway/hono/routes/task-outcomes.d.ts +3 -0
- package/dist/src/gateway/hono/routes/task-outcomes.js +109 -0
- package/dist/src/gateway/hono/routes/you.d.ts +10 -2
- package/dist/src/gateway/hono/routes/you.js +184 -28
- package/dist/src/gateway/hono/sse.d.ts +2 -0
- package/dist/src/gateway/hono/sse.js +10 -3
- package/dist/src/gateway/run-loop.js +17 -7
- package/dist/src/gateway/server.d.ts +1 -0
- package/dist/src/gateway/server.js +9 -0
- package/dist/src/gateway/service/run-gateway-agent.js +84 -0
- package/dist/src/gateway/service.d.ts +3 -0
- package/dist/src/gateway/service.js +14 -0
- package/dist/src/local-apps/preview-runtime-bridge.d.ts +1 -1
- package/dist/src/local-apps/preview-runtime-bridge.js +14 -11
- package/dist/src/proactive/insight-repository.d.ts +2 -0
- package/dist/src/proactive/insight-repository.js +5 -2
- package/dist/src/proactive/run-processor.js +22 -1
- package/dist/src/proactive/types.d.ts +2 -0
- package/dist/src/proactive/value-score.d.ts +13 -0
- package/dist/src/proactive/value-score.js +30 -0
- package/dist/src/share/share-types.js +5 -5
- package/dist/src/share/site-share-types.d.ts +1 -1
- package/dist/src/share/site-share-types.js +5 -5
- package/dist/src/storage/sqlite/index.d.ts +3 -0
- package/dist/src/storage/sqlite/index.js +4 -1
- package/dist/src/storage/sqlite/interaction-state-repository.d.ts +17 -0
- package/dist/src/storage/sqlite/interaction-state-repository.js +60 -0
- package/dist/src/storage/sqlite/memory-records-repository.js +1 -1
- package/dist/src/storage/sqlite/migrations/053_browser_recipes.sql +45 -0
- package/dist/src/storage/sqlite/migrations/054_task_outcomes.sql +24 -0
- package/dist/src/storage/sqlite/migrations/055_relationship_settings.sql +14 -0
- package/dist/src/storage/sqlite/migrations/056_task_verification.sql +6 -0
- package/dist/src/storage/sqlite/migrations/057_interaction_states.sql +11 -0
- package/dist/src/storage/sqlite/migrations/058_proactive_value.sql +3 -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/relationship-settings-repository.d.ts +17 -0
- package/dist/src/storage/sqlite/relationship-settings-repository.js +64 -0
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +46 -0
- package/dist/src/storage/sqlite/task-outcome-repository.d.ts +90 -0
- package/dist/src/storage/sqlite/task-outcome-repository.js +138 -0
- package/dist/src/user-context/interaction-state.d.ts +13 -0
- package/dist/src/user-context/interaction-state.js +69 -0
- package/dist/src/user-context/memory-use-audit.d.ts +10 -0
- package/dist/src/user-context/memory-use-audit.js +25 -0
- package/dist/src/user-context/personal-playbook.d.ts +11 -0
- package/dist/src/user-context/personal-playbook.js +41 -0
- package/dist/src/user-context/projection.d.ts +4 -0
- package/dist/src/user-context/projection.js +5 -1
- package/dist/src/user-context/relationship-continuity.d.ts +14 -0
- package/dist/src/user-context/relationship-continuity.js +51 -0
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/action-boundary-settings-panel-CY3sizqC.js +0 -1
- package/dist/gateway/static/root/assets/activity-store-3Cso_2qm.js +0 -1
- package/dist/gateway/static/root/assets/agents-B1l3iii6.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-DaNFLsp0.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-Cd0gMx6p.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-BmUYDL2Z.js +0 -8
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-CE7mrWtS.js +0 -2
- package/dist/gateway/static/root/assets/channels-settings-D1_gcAHK.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-Cqfqv59m.js +0 -1
- package/dist/gateway/static/root/assets/check-BODqo66o.js +0 -1
- package/dist/gateway/static/root/assets/circle-alert-RzVebuX2.js +0 -1
- package/dist/gateway/static/root/assets/cn-BQ_8x0bT.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-CaLBi6Na.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-wacrnJJ1.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-BQamcEmF.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-DZUQ0Lf1.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-BtxVD27C.js +0 -2
- package/dist/gateway/static/root/assets/index-CHKe7nwC.js +0 -197
- package/dist/gateway/static/root/assets/index-CXhfUIjh.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CTTfyFe3.js +0 -2
- package/dist/gateway/static/root/assets/messages-DDsiqdJS.js +0 -5
- package/dist/gateway/static/root/assets/models-hub-panel-DJReXRP9.js +0 -2
- package/dist/gateway/static/root/assets/notes-workbench-BbdjzYzs.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-BwG8SOzI.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-nUlyUtxh.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-rf7bjije.js +0 -1
- package/dist/gateway/static/root/assets/save-bar-controls-qhDisdqY.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-CSoHUe38.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-Db976IEa.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-DYfXmfTx.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-wBWOFpvw.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BAMma1-P.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-TWxFFWxM.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-Ca2RA29R.js +0 -2
- package/dist/gateway/static/root/assets/user-context-page-CTumZa0y.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-DdlMxeqO.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-CcfZhdBi.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page--wxLw1p_.js +0 -1
- package/dist/gateway/static/root/assets/work-page-DyS0XBpV.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-CVVJd4gy.js +0 -11
- package/dist/src/browser/pipeline/source.d.ts +0 -9
- package/dist/src/browser/pipeline/source.js +0 -77
|
@@ -12,7 +12,7 @@ const log = createLogger("Sqlite:Migrations");
|
|
|
12
12
|
/** Baseline schema version applied from schema.sql on first open. */
|
|
13
13
|
const XOPC_DB_BASELINE_SCHEMA_VERSION = 11;
|
|
14
14
|
/** Latest schema version this release supports (increment when adding migrations). */
|
|
15
|
-
const XOPC_DB_SCHEMA_VERSION =
|
|
15
|
+
const XOPC_DB_SCHEMA_VERSION = 58;
|
|
16
16
|
const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
17
17
|
function resolveMigrationsDir(override) {
|
|
18
18
|
if (override) return override;
|
|
@@ -46,7 +46,7 @@ function applySingleMigration(db, migration) {
|
|
|
46
46
|
* Each step runs in its own transaction and updates schema_meta on success.
|
|
47
47
|
*/
|
|
48
48
|
function applyPendingMigrations(db, options = {}) {
|
|
49
|
-
const targetVersion = options.targetVersion ??
|
|
49
|
+
const targetVersion = options.targetVersion ?? 58;
|
|
50
50
|
let currentVersion = readSchemaVersion(db);
|
|
51
51
|
if (currentVersion > targetVersion) throw new DatabaseSchemaTooNewError(currentVersion, targetVersion);
|
|
52
52
|
if (currentVersion >= targetVersion) return currentVersion;
|
|
@@ -62,7 +62,7 @@ function applyPendingMigrations(db, options = {}) {
|
|
|
62
62
|
}
|
|
63
63
|
/** Inspect schema version without mutating the database. */
|
|
64
64
|
function inspectSchemaMigrationStatus(db, options = {}) {
|
|
65
|
-
const appVersion = options.targetVersion ??
|
|
65
|
+
const appVersion = options.targetVersion ?? 58;
|
|
66
66
|
const dbVersion = readSchemaVersion(db);
|
|
67
67
|
if (dbVersion > appVersion) return {
|
|
68
68
|
dbVersion,
|
|
@@ -19,7 +19,7 @@ const log = createLogger('Sqlite:Migrations');
|
|
|
19
19
|
export const XOPC_DB_BASELINE_SCHEMA_VERSION = 11;
|
|
20
20
|
|
|
21
21
|
/** Latest schema version this release supports (increment when adding migrations). */
|
|
22
|
-
export const XOPC_DB_SCHEMA_VERSION =
|
|
22
|
+
export const XOPC_DB_SCHEMA_VERSION = 58;
|
|
23
23
|
|
|
24
24
|
const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
25
25
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type SupportMode = 'efficient' | 'coach' | 'companion' | 'auto';
|
|
2
|
+
export interface RelationshipSettings {
|
|
3
|
+
supportMode: SupportMode;
|
|
4
|
+
proactiveEnabled: boolean;
|
|
5
|
+
quietStart?: string;
|
|
6
|
+
quietEnd?: string;
|
|
7
|
+
allowedTopics: string[];
|
|
8
|
+
blockedTopics: string[];
|
|
9
|
+
updatedAt: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function getRelationshipSettings(): RelationshipSettings;
|
|
12
|
+
export declare function updateRelationshipSettings(patch: Partial<Omit<RelationshipSettings, 'updatedAt'>>): RelationshipSettings;
|
|
13
|
+
export declare function buildRelationshipPrompt(settings: RelationshipSettings): string;
|
|
14
|
+
export declare function isProactiveSupportAllowed(settings: RelationshipSettings, input: {
|
|
15
|
+
now: Date;
|
|
16
|
+
topic: string;
|
|
17
|
+
}): boolean;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
|
|
2
|
+
import { LOCAL_USER_ID } from "../../user-context/owner.js";
|
|
3
|
+
//#region src/storage/sqlite/relationship-settings-repository.ts
|
|
4
|
+
function fromRow(row) {
|
|
5
|
+
return {
|
|
6
|
+
supportMode: row.support_mode,
|
|
7
|
+
proactiveEnabled: row.proactive_enabled === 1,
|
|
8
|
+
...row.quiet_start ? { quietStart: row.quiet_start } : {},
|
|
9
|
+
...row.quiet_end ? { quietEnd: row.quiet_end } : {},
|
|
10
|
+
allowedTopics: JSON.parse(row.allowed_topics_json),
|
|
11
|
+
blockedTopics: JSON.parse(row.blocked_topics_json),
|
|
12
|
+
updatedAt: row.updated_at
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function getRelationshipSettings() {
|
|
16
|
+
return fromRow(getSqliteDatabase().prepare(`SELECT support_mode, proactive_enabled, quiet_start, quiet_end,
|
|
17
|
+
allowed_topics_json, blocked_topics_json, updated_at
|
|
18
|
+
FROM relationship_settings WHERE owner_id = ?`).get(LOCAL_USER_ID));
|
|
19
|
+
}
|
|
20
|
+
function updateRelationshipSettings(patch) {
|
|
21
|
+
const next = {
|
|
22
|
+
...getRelationshipSettings(),
|
|
23
|
+
...patch,
|
|
24
|
+
updatedAt: Date.now()
|
|
25
|
+
};
|
|
26
|
+
runSqliteWriteTransaction((db) => {
|
|
27
|
+
db.prepare(`UPDATE relationship_settings
|
|
28
|
+
SET support_mode = ?, proactive_enabled = ?, quiet_start = ?, quiet_end = ?,
|
|
29
|
+
allowed_topics_json = ?, blocked_topics_json = ?, updated_at = ?
|
|
30
|
+
WHERE owner_id = ?`).run(next.supportMode, Number(next.proactiveEnabled), next.quietStart ?? null, next.quietEnd ?? null, JSON.stringify(next.allowedTopics), JSON.stringify(next.blockedTopics), next.updatedAt, LOCAL_USER_ID);
|
|
31
|
+
});
|
|
32
|
+
return next;
|
|
33
|
+
}
|
|
34
|
+
function buildRelationshipPrompt(settings) {
|
|
35
|
+
return [
|
|
36
|
+
"## Support mode",
|
|
37
|
+
{
|
|
38
|
+
efficient: "Prioritize direct action and concise answers. Acknowledge emotion briefly only when it materially helps.",
|
|
39
|
+
coach: "Help the user clarify goals and move forward. Ask focused questions and turn reflection into practical next steps.",
|
|
40
|
+
companion: "Acknowledge the user’s experience before offering solutions. Do not rush advice; ask whether they want listening or action when unclear.",
|
|
41
|
+
auto: "Infer whether the user needs listening, validation, analysis, advice, or action. Ask one concise question when the need is ambiguous."
|
|
42
|
+
}[settings.supportMode],
|
|
43
|
+
"Never claim to have human feelings, encourage exclusivity or dependency, use guilt, or present yourself as a replacement for human relationships or professional care.",
|
|
44
|
+
"Treat inferred emotions as hypotheses, not facts. In high-risk situations, encourage timely support from trusted people or appropriate emergency/professional services."
|
|
45
|
+
].join("\n\n");
|
|
46
|
+
}
|
|
47
|
+
function isProactiveSupportAllowed(settings, input) {
|
|
48
|
+
if (!settings.proactiveEnabled) return false;
|
|
49
|
+
const topic = input.topic.trim().toLocaleLowerCase();
|
|
50
|
+
if (settings.blockedTopics.map((value) => value.toLocaleLowerCase()).includes(topic)) return false;
|
|
51
|
+
const allowed = settings.allowedTopics.map((value) => value.toLocaleLowerCase());
|
|
52
|
+
if (allowed.length > 0 && !allowed.includes(topic)) return false;
|
|
53
|
+
if (!settings.quietStart || !settings.quietEnd) return true;
|
|
54
|
+
const minutes = input.now.getHours() * 60 + input.now.getMinutes();
|
|
55
|
+
const toMinutes = (value) => {
|
|
56
|
+
const [hours, minute] = value.split(":").map(Number);
|
|
57
|
+
return hours * 60 + minute;
|
|
58
|
+
};
|
|
59
|
+
const start = toMinutes(settings.quietStart);
|
|
60
|
+
const end = toMinutes(settings.quietEnd);
|
|
61
|
+
return !(start <= end ? minutes >= start && minutes < end : minutes >= start || minutes < end);
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { buildRelationshipPrompt, getRelationshipSettings, isProactiveSupportAllowed, updateRelationshipSettings };
|
|
@@ -31,7 +31,7 @@ function ensureXopcDatabaseSchema(db) {
|
|
|
31
31
|
bootstrapFreshDatabase(db);
|
|
32
32
|
currentVersion = 11;
|
|
33
33
|
}
|
|
34
|
-
applyPendingMigrations(db, { targetVersion:
|
|
34
|
+
applyPendingMigrations(db, { targetVersion: 58 });
|
|
35
35
|
}
|
|
36
36
|
//#endregion
|
|
37
37
|
export { SCHEMA_META_SCHEMA_VERSION_KEY, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_SCHEMA_VERSION, ensureSchemaMetaTable, ensureXopcDatabaseSchema, readSchemaVersion, readSchemaVersionForTest, setSchemaVersion };
|
|
@@ -724,3 +724,49 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_memory_reference_consents_pending
|
|
|
724
724
|
|
|
725
725
|
CREATE INDEX IF NOT EXISTS idx_memory_reference_consents_resolution
|
|
726
726
|
ON memory_reference_consents(record_id, status, session_key, expires_at);
|
|
727
|
+
|
|
728
|
+
CREATE TABLE IF NOT EXISTS browser_recipes (
|
|
729
|
+
recipe_id TEXT PRIMARY KEY,
|
|
730
|
+
revision INTEGER NOT NULL,
|
|
731
|
+
name TEXT NOT NULL,
|
|
732
|
+
description TEXT,
|
|
733
|
+
status TEXT NOT NULL CHECK (status IN ('published', 'disabled')),
|
|
734
|
+
yaml_source TEXT NOT NULL,
|
|
735
|
+
risk_level TEXT NOT NULL CHECK (risk_level IN ('read_only', 'account_write', 'sensitive')),
|
|
736
|
+
domains_json TEXT NOT NULL,
|
|
737
|
+
created_at_ms INTEGER NOT NULL,
|
|
738
|
+
updated_at_ms INTEGER NOT NULL
|
|
739
|
+
);
|
|
740
|
+
|
|
741
|
+
CREATE TABLE IF NOT EXISTS browser_recipe_runs (
|
|
742
|
+
run_id TEXT PRIMARY KEY,
|
|
743
|
+
recipe_id TEXT NOT NULL,
|
|
744
|
+
recipe_revision INTEGER NOT NULL,
|
|
745
|
+
recipe_yaml TEXT NOT NULL,
|
|
746
|
+
status TEXT NOT NULL CHECK (status IN ('queued', 'running', 'succeeded', 'failed', 'cancelled')),
|
|
747
|
+
args_json TEXT NOT NULL,
|
|
748
|
+
result_json TEXT,
|
|
749
|
+
error TEXT,
|
|
750
|
+
created_at_ms INTEGER NOT NULL,
|
|
751
|
+
started_at_ms INTEGER,
|
|
752
|
+
ended_at_ms INTEGER,
|
|
753
|
+
duration_ms INTEGER,
|
|
754
|
+
FOREIGN KEY (recipe_id) REFERENCES browser_recipes(recipe_id) ON DELETE CASCADE
|
|
755
|
+
);
|
|
756
|
+
|
|
757
|
+
CREATE INDEX IF NOT EXISTS idx_browser_recipe_runs_recipe_created
|
|
758
|
+
ON browser_recipe_runs(recipe_id, created_at_ms DESC);
|
|
759
|
+
|
|
760
|
+
CREATE TABLE IF NOT EXISTS browser_recipe_run_events (
|
|
761
|
+
event_id TEXT PRIMARY KEY,
|
|
762
|
+
run_id TEXT NOT NULL,
|
|
763
|
+
seq INTEGER NOT NULL,
|
|
764
|
+
type TEXT NOT NULL,
|
|
765
|
+
data_json TEXT,
|
|
766
|
+
created_at_ms INTEGER NOT NULL,
|
|
767
|
+
UNIQUE(run_id, seq),
|
|
768
|
+
FOREIGN KEY (run_id) REFERENCES browser_recipe_runs(run_id) ON DELETE CASCADE
|
|
769
|
+
);
|
|
770
|
+
|
|
771
|
+
CREATE INDEX IF NOT EXISTS idx_browser_recipe_run_events_run_seq
|
|
772
|
+
ON browser_recipe_run_events(run_id, seq ASC);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { type TaskFailureCode, type TaskFailurePhase, type TaskRecoveryAction, type TaskVerification } from '../../agent/outcomes/task-verifier.js';
|
|
2
|
+
export type TaskOutcomeStatus = 'running' | 'succeeded' | 'failed' | 'cancelled';
|
|
3
|
+
export type TaskFeedbackOutcome = 'helpful' | 'not_helpful';
|
|
4
|
+
export interface TaskContract {
|
|
5
|
+
objective: string;
|
|
6
|
+
deliverables: string[];
|
|
7
|
+
acceptanceCriteria: string[];
|
|
8
|
+
constraints: string[];
|
|
9
|
+
approvalRequired: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface TaskEvidence {
|
|
12
|
+
kind: 'artifact' | 'test' | 'state' | 'source';
|
|
13
|
+
title: string;
|
|
14
|
+
summary: string;
|
|
15
|
+
uri?: string;
|
|
16
|
+
verifies?: string[];
|
|
17
|
+
}
|
|
18
|
+
export interface TaskOutcome {
|
|
19
|
+
runId: string;
|
|
20
|
+
sessionKey: string;
|
|
21
|
+
channel: string;
|
|
22
|
+
objective: string;
|
|
23
|
+
status: TaskOutcomeStatus;
|
|
24
|
+
summary?: string;
|
|
25
|
+
contract?: TaskContract;
|
|
26
|
+
evidence: TaskEvidence[];
|
|
27
|
+
verification: TaskVerification;
|
|
28
|
+
failure?: {
|
|
29
|
+
code: TaskFailureCode;
|
|
30
|
+
phase: TaskFailurePhase;
|
|
31
|
+
recoveryAction: TaskRecoveryAction;
|
|
32
|
+
};
|
|
33
|
+
feedback?: {
|
|
34
|
+
outcome: TaskFeedbackOutcome;
|
|
35
|
+
reason?: string;
|
|
36
|
+
needsCorrection?: boolean;
|
|
37
|
+
supportFit?: boolean;
|
|
38
|
+
};
|
|
39
|
+
startedAt: number;
|
|
40
|
+
completedAt?: number;
|
|
41
|
+
updatedAt: number;
|
|
42
|
+
}
|
|
43
|
+
export interface TaskOutcomeMetrics {
|
|
44
|
+
total: number;
|
|
45
|
+
completed: number;
|
|
46
|
+
succeeded: number;
|
|
47
|
+
verified: number;
|
|
48
|
+
helpful: number;
|
|
49
|
+
notHelpful: number;
|
|
50
|
+
completionRate: number;
|
|
51
|
+
successRate: number;
|
|
52
|
+
verificationRate: number;
|
|
53
|
+
helpfulRate: number;
|
|
54
|
+
}
|
|
55
|
+
export declare function startTaskOutcome(input: {
|
|
56
|
+
runId: string;
|
|
57
|
+
sessionKey: string;
|
|
58
|
+
channel: string;
|
|
59
|
+
objective: string;
|
|
60
|
+
now?: number;
|
|
61
|
+
}): TaskOutcome;
|
|
62
|
+
export declare function completeTaskOutcome(input: {
|
|
63
|
+
runId: string;
|
|
64
|
+
status: Exclude<TaskOutcomeStatus, 'running'>;
|
|
65
|
+
summary: string;
|
|
66
|
+
now?: number;
|
|
67
|
+
}): TaskOutcome | undefined;
|
|
68
|
+
export declare function updateTaskOutcome(input: {
|
|
69
|
+
runId: string;
|
|
70
|
+
contract?: TaskContract;
|
|
71
|
+
evidence?: TaskEvidence[];
|
|
72
|
+
summary?: string;
|
|
73
|
+
now?: number;
|
|
74
|
+
}): TaskOutcome | undefined;
|
|
75
|
+
export declare function setTaskOutcomeFeedback(input: {
|
|
76
|
+
sessionKey: string;
|
|
77
|
+
assistantTimestamp: number;
|
|
78
|
+
outcome: TaskFeedbackOutcome;
|
|
79
|
+
reason?: string;
|
|
80
|
+
needsCorrection?: boolean;
|
|
81
|
+
supportFit?: boolean;
|
|
82
|
+
now?: number;
|
|
83
|
+
}): TaskOutcome | undefined;
|
|
84
|
+
export declare function getTaskOutcome(runId: string): TaskOutcome | undefined;
|
|
85
|
+
export declare function findTaskOutcomeForAssistant(sessionKey: string, assistantTimestamp: number): TaskOutcome | undefined;
|
|
86
|
+
export declare function listTaskOutcomes(input?: {
|
|
87
|
+
sessionKey?: string;
|
|
88
|
+
limit?: number;
|
|
89
|
+
}): TaskOutcome[];
|
|
90
|
+
export declare function summarizeTaskOutcomes(): TaskOutcomeMetrics;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
|
|
2
|
+
import { diagnoseTaskFailure, verifyTaskCompletion } from "../../agent/outcomes/task-verifier.js";
|
|
3
|
+
//#region src/storage/sqlite/task-outcome-repository.ts
|
|
4
|
+
function fromRow(row) {
|
|
5
|
+
const contract = row.contract_json ? JSON.parse(row.contract_json) : void 0;
|
|
6
|
+
const evidence = JSON.parse(row.evidence_json);
|
|
7
|
+
const feedback = row.feedback_outcome ? {
|
|
8
|
+
outcome: row.feedback_outcome,
|
|
9
|
+
...row.feedback_reason ? { reason: row.feedback_reason } : {},
|
|
10
|
+
...row.needs_correction === null ? {} : { needsCorrection: row.needs_correction === 1 },
|
|
11
|
+
...row.support_fit === null ? {} : { supportFit: row.support_fit === 1 }
|
|
12
|
+
} : void 0;
|
|
13
|
+
return {
|
|
14
|
+
runId: row.run_id,
|
|
15
|
+
sessionKey: row.session_key,
|
|
16
|
+
channel: row.channel,
|
|
17
|
+
objective: row.objective,
|
|
18
|
+
status: row.status,
|
|
19
|
+
...row.summary ? { summary: row.summary } : {},
|
|
20
|
+
...contract ? { contract } : {},
|
|
21
|
+
evidence,
|
|
22
|
+
verification: {
|
|
23
|
+
...JSON.parse(row.verification_json),
|
|
24
|
+
status: row.verification_status
|
|
25
|
+
},
|
|
26
|
+
...row.failure_code && row.failure_phase && row.recovery_action ? { failure: {
|
|
27
|
+
code: row.failure_code,
|
|
28
|
+
phase: row.failure_phase,
|
|
29
|
+
recoveryAction: row.recovery_action
|
|
30
|
+
} } : {},
|
|
31
|
+
...feedback ? { feedback } : {},
|
|
32
|
+
startedAt: row.started_at,
|
|
33
|
+
...row.completed_at === null ? {} : { completedAt: row.completed_at },
|
|
34
|
+
updatedAt: row.updated_at
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const SELECT_COLUMNS = `run_id, session_key, channel, objective, status, summary,
|
|
38
|
+
contract_json, evidence_json, feedback_outcome, feedback_reason,
|
|
39
|
+
needs_correction, support_fit, started_at, completed_at, updated_at,
|
|
40
|
+
verification_status, verification_json, failure_code, failure_phase, recovery_action`;
|
|
41
|
+
function startTaskOutcome(input) {
|
|
42
|
+
const now = input.now ?? Date.now();
|
|
43
|
+
runSqliteWriteTransaction((db) => {
|
|
44
|
+
db.prepare(`INSERT INTO task_outcomes (
|
|
45
|
+
run_id, session_key, channel, objective, status, started_at, updated_at
|
|
46
|
+
) VALUES (?, ?, ?, ?, 'running', ?, ?)`).run(input.runId, input.sessionKey, input.channel, input.objective, now, now);
|
|
47
|
+
});
|
|
48
|
+
return getTaskOutcome(input.runId);
|
|
49
|
+
}
|
|
50
|
+
function completeTaskOutcome(input) {
|
|
51
|
+
const now = input.now ?? Date.now();
|
|
52
|
+
const current = getTaskOutcome(input.runId);
|
|
53
|
+
if (!current) return void 0;
|
|
54
|
+
const verification = verifyTaskCompletion({
|
|
55
|
+
status: input.status,
|
|
56
|
+
acceptanceCriteria: current.contract?.acceptanceCriteria ?? [],
|
|
57
|
+
evidence: current.evidence
|
|
58
|
+
});
|
|
59
|
+
const failure = input.status === "succeeded" ? void 0 : diagnoseTaskFailure({
|
|
60
|
+
status: input.status,
|
|
61
|
+
summary: input.summary
|
|
62
|
+
});
|
|
63
|
+
runSqliteWriteTransaction((db) => {
|
|
64
|
+
db.prepare(`UPDATE task_outcomes
|
|
65
|
+
SET status = ?, summary = ?, completed_at = ?, updated_at = ?,
|
|
66
|
+
verification_status = ?, verification_json = ?, failure_code = ?,
|
|
67
|
+
failure_phase = ?, recovery_action = ?
|
|
68
|
+
WHERE run_id = ?`).run(input.status, input.summary, now, now, verification.status, JSON.stringify({ checks: verification.checks }), failure?.code ?? null, failure?.phase ?? null, failure?.recoveryAction ?? null, input.runId);
|
|
69
|
+
});
|
|
70
|
+
return getTaskOutcome(input.runId);
|
|
71
|
+
}
|
|
72
|
+
function updateTaskOutcome(input) {
|
|
73
|
+
const current = getTaskOutcome(input.runId);
|
|
74
|
+
if (!current) return void 0;
|
|
75
|
+
const now = input.now ?? Date.now();
|
|
76
|
+
const contract = input.contract === void 0 ? current.contract : input.contract;
|
|
77
|
+
const evidence = input.evidence === void 0 ? current.evidence : input.evidence;
|
|
78
|
+
const summary = input.summary === void 0 ? current.summary : input.summary;
|
|
79
|
+
runSqliteWriteTransaction((db) => {
|
|
80
|
+
db.prepare(`UPDATE task_outcomes
|
|
81
|
+
SET contract_json = ?, evidence_json = ?, summary = ?, updated_at = ?
|
|
82
|
+
WHERE run_id = ?`).run(contract ? JSON.stringify(contract) : null, JSON.stringify(evidence), summary ?? null, now, input.runId);
|
|
83
|
+
});
|
|
84
|
+
return getTaskOutcome(input.runId);
|
|
85
|
+
}
|
|
86
|
+
function setTaskOutcomeFeedback(input) {
|
|
87
|
+
const matched = findTaskOutcomeForAssistant(input.sessionKey, input.assistantTimestamp);
|
|
88
|
+
if (!matched) return void 0;
|
|
89
|
+
const now = input.now ?? Date.now();
|
|
90
|
+
runSqliteWriteTransaction((db) => {
|
|
91
|
+
db.prepare(`UPDATE task_outcomes
|
|
92
|
+
SET feedback_outcome = ?, feedback_reason = ?, needs_correction = ?, support_fit = ?, updated_at = ?
|
|
93
|
+
WHERE run_id = ?`).run(input.outcome, input.reason ?? null, input.needsCorrection === void 0 ? null : Number(input.needsCorrection), input.supportFit === void 0 ? null : Number(input.supportFit), now, matched.runId);
|
|
94
|
+
});
|
|
95
|
+
return getTaskOutcome(matched.runId);
|
|
96
|
+
}
|
|
97
|
+
function getTaskOutcome(runId) {
|
|
98
|
+
const row = getSqliteDatabase().prepare(`SELECT ${SELECT_COLUMNS} FROM task_outcomes WHERE run_id = ?`).get(runId);
|
|
99
|
+
return row ? fromRow(row) : void 0;
|
|
100
|
+
}
|
|
101
|
+
function findTaskOutcomeForAssistant(sessionKey, assistantTimestamp) {
|
|
102
|
+
const row = getSqliteDatabase().prepare(`SELECT ${SELECT_COLUMNS}
|
|
103
|
+
FROM task_outcomes
|
|
104
|
+
WHERE session_key = ?
|
|
105
|
+
AND started_at <= ?
|
|
106
|
+
ORDER BY started_at DESC
|
|
107
|
+
LIMIT 1`).get(sessionKey, assistantTimestamp);
|
|
108
|
+
return row ? fromRow(row) : void 0;
|
|
109
|
+
}
|
|
110
|
+
function listTaskOutcomes(input = {}) {
|
|
111
|
+
const limit = Math.max(1, Math.min(100, Math.floor(input.limit ?? 50)));
|
|
112
|
+
return (input.sessionKey ? getSqliteDatabase().prepare(`SELECT ${SELECT_COLUMNS} FROM task_outcomes WHERE session_key = ? ORDER BY started_at DESC LIMIT ?`).all(input.sessionKey, limit) : getSqliteDatabase().prepare(`SELECT ${SELECT_COLUMNS} FROM task_outcomes ORDER BY started_at DESC LIMIT ?`).all(limit)).map((row) => fromRow(row));
|
|
113
|
+
}
|
|
114
|
+
function summarizeTaskOutcomes() {
|
|
115
|
+
const row = getSqliteDatabase().prepare(`SELECT
|
|
116
|
+
COUNT(*) AS total,
|
|
117
|
+
SUM(CASE WHEN status != 'running' THEN 1 ELSE 0 END) AS completed,
|
|
118
|
+
SUM(CASE WHEN status = 'succeeded' THEN 1 ELSE 0 END) AS succeeded,
|
|
119
|
+
SUM(CASE WHEN verification_status = 'passed' THEN 1 ELSE 0 END) AS verified,
|
|
120
|
+
SUM(CASE WHEN feedback_outcome = 'helpful' THEN 1 ELSE 0 END) AS helpful,
|
|
121
|
+
SUM(CASE WHEN feedback_outcome = 'not_helpful' THEN 1 ELSE 0 END) AS not_helpful
|
|
122
|
+
FROM task_outcomes`).get();
|
|
123
|
+
const rated = row.helpful + row.not_helpful;
|
|
124
|
+
return {
|
|
125
|
+
total: row.total,
|
|
126
|
+
completed: row.completed,
|
|
127
|
+
succeeded: row.succeeded,
|
|
128
|
+
verified: row.verified,
|
|
129
|
+
helpful: row.helpful,
|
|
130
|
+
notHelpful: row.not_helpful,
|
|
131
|
+
completionRate: row.total ? row.completed / row.total : 0,
|
|
132
|
+
successRate: row.completed ? row.succeeded / row.completed : 0,
|
|
133
|
+
verificationRate: row.completed ? row.verified / row.completed : 0,
|
|
134
|
+
helpfulRate: rated ? row.helpful / rated : 0
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
export { completeTaskOutcome, findTaskOutcomeForAssistant, getTaskOutcome, listTaskOutcomes, setTaskOutcomeFeedback, startTaskOutcome, summarizeTaskOutcomes, updateTaskOutcome };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type SupportNeed = 'listen' | 'clarify' | 'advise' | 'act' | 'unknown';
|
|
2
|
+
export type InteractionStateSource = 'explicit' | 'inferred';
|
|
3
|
+
export type RelationshipRepairStatus = 'none' | 'needed' | 'repaired';
|
|
4
|
+
export interface InteractionStateSignal {
|
|
5
|
+
supportNeed: SupportNeed;
|
|
6
|
+
emotionHypothesis?: string;
|
|
7
|
+
confidence: number;
|
|
8
|
+
source: InteractionStateSource;
|
|
9
|
+
repairStatus: RelationshipRepairStatus;
|
|
10
|
+
repairReason?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function inferInteractionState(message: string): InteractionStateSignal;
|
|
13
|
+
export declare function buildInteractionStatePrompt(signal: InteractionStateSignal): string;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
//#region src/user-context/interaction-state.ts
|
|
2
|
+
function inferInteractionState(message) {
|
|
3
|
+
const text = message.trim().toLocaleLowerCase();
|
|
4
|
+
if (/你.{0,6}(没|不).{0,6}(理解|懂)|别.{0,4}(建议|说教)|太(啰嗦|冷淡)|you (do not|don't) understand|stop giving (me )?advice|too verbose|too cold/.test(text)) return {
|
|
5
|
+
supportNeed: "listen",
|
|
6
|
+
confidence: .95,
|
|
7
|
+
source: "explicit",
|
|
8
|
+
repairStatus: "needed",
|
|
9
|
+
repairReason: message.trim().slice(0, 240)
|
|
10
|
+
};
|
|
11
|
+
if (/这样(好多|对了)|这次对了|谢谢.{0,6}(理解|调整)|that's better|you got it|this is better/.test(text)) return {
|
|
12
|
+
supportNeed: "unknown",
|
|
13
|
+
confidence: .9,
|
|
14
|
+
source: "explicit",
|
|
15
|
+
repairStatus: "repaired"
|
|
16
|
+
};
|
|
17
|
+
if (/不想听建议|只想.{0,4}(说|聊|倾诉)|听我说|no advice|just (listen|let me talk)/.test(text)) return {
|
|
18
|
+
supportNeed: "listen",
|
|
19
|
+
confidence: .95,
|
|
20
|
+
source: "explicit",
|
|
21
|
+
repairStatus: "none"
|
|
22
|
+
};
|
|
23
|
+
if (/帮我(梳理|理清|想清楚)|一起分析|help me (clarify|think through)|talk this through/.test(text)) return {
|
|
24
|
+
supportNeed: "clarify",
|
|
25
|
+
confidence: .9,
|
|
26
|
+
source: "explicit",
|
|
27
|
+
repairStatus: "none"
|
|
28
|
+
};
|
|
29
|
+
if (/你建议|怎么办|该怎么|给我建议|what should i do|what do you recommend|advice/.test(text)) return {
|
|
30
|
+
supportNeed: "advise",
|
|
31
|
+
confidence: .9,
|
|
32
|
+
source: "explicit",
|
|
33
|
+
repairStatus: "none"
|
|
34
|
+
};
|
|
35
|
+
if (/帮我(做|改|创建|实现|处理|发送)|请(完成|执行)|\b(build|fix|create|implement|send|run)\b/.test(text)) return {
|
|
36
|
+
supportNeed: "act",
|
|
37
|
+
confidence: .85,
|
|
38
|
+
source: "explicit",
|
|
39
|
+
repairStatus: "none"
|
|
40
|
+
};
|
|
41
|
+
const emotion = text.match(/(焦虑|难过|委屈|生气|疲惫|累|害怕|孤独|anxious|sad|angry|exhausted|afraid|lonely)/)?.[1];
|
|
42
|
+
if (emotion) return {
|
|
43
|
+
supportNeed: "listen",
|
|
44
|
+
emotionHypothesis: emotion,
|
|
45
|
+
confidence: .55,
|
|
46
|
+
source: "inferred",
|
|
47
|
+
repairStatus: "none"
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
supportNeed: "unknown",
|
|
51
|
+
confidence: .3,
|
|
52
|
+
source: "inferred",
|
|
53
|
+
repairStatus: "none"
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function buildInteractionStatePrompt(signal) {
|
|
57
|
+
const lines = ["## Current interaction state", {
|
|
58
|
+
listen: "Prioritize listening and acknowledgment. Do not rush into advice or an action list.",
|
|
59
|
+
clarify: "Help the user organize the situation with one focused question at a time.",
|
|
60
|
+
advise: "Offer a clear recommendation with concise reasoning and practical options.",
|
|
61
|
+
act: "Prioritize execution, state the intended outcome, and verify the result.",
|
|
62
|
+
unknown: "Do not assume the support needed. If it matters, ask one concise question."
|
|
63
|
+
}[signal.supportNeed]];
|
|
64
|
+
if (signal.emotionHypothesis) lines.push(`Possible current emotion: ${signal.emotionHypothesis} (confidence ${signal.confidence.toFixed(2)}). Treat this only as a hypothesis.`);
|
|
65
|
+
if (signal.repairStatus === "needed") lines.push("Relationship repair is needed: briefly acknowledge the specific mismatch, do not defend yourself, adjust immediately, and ask at most one concise question.");
|
|
66
|
+
return lines.join("\n\n");
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { buildInteractionStatePrompt, inferInteractionState };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MemoryTraceEventPayload } from '../storage/sqlite/memory-records-repository.js';
|
|
2
|
+
export declare function summarizeMemoryUseAudit(traces: MemoryTraceEventPayload[]): {
|
|
3
|
+
total: number;
|
|
4
|
+
injectTurns: number;
|
|
5
|
+
turnsUsingMemory: number;
|
|
6
|
+
selectedRecords: number;
|
|
7
|
+
helpful: number;
|
|
8
|
+
notHelpful: number;
|
|
9
|
+
skippedReasons: Record<string, number>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/user-context/memory-use-audit.ts
|
|
2
|
+
function summarizeMemoryUseAudit(traces) {
|
|
3
|
+
const injects = traces.filter((trace) => trace.phase === "inject");
|
|
4
|
+
const skippedReasons = {};
|
|
5
|
+
let selectedRecords = 0;
|
|
6
|
+
let helpful = 0;
|
|
7
|
+
let notHelpful = 0;
|
|
8
|
+
for (const trace of injects) {
|
|
9
|
+
selectedRecords += trace.selectedRecordIds.length;
|
|
10
|
+
if (trace.skippedReason) skippedReasons[trace.skippedReason] = (skippedReasons[trace.skippedReason] ?? 0) + 1;
|
|
11
|
+
if (trace.feedback?.outcome === "helpful") helpful += 1;
|
|
12
|
+
if (trace.feedback?.outcome === "not_helpful" || trace.feedback?.outcome === "irrelevant") notHelpful += 1;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
total: traces.length,
|
|
16
|
+
injectTurns: injects.length,
|
|
17
|
+
turnsUsingMemory: injects.filter((trace) => trace.selectedRecordIds.length > 0).length,
|
|
18
|
+
selectedRecords,
|
|
19
|
+
helpful,
|
|
20
|
+
notHelpful,
|
|
21
|
+
skippedReasons
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { summarizeMemoryUseAudit };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MemoryRecord } from '../agent/memory/types.js';
|
|
2
|
+
export declare const PERSONAL_PLAYBOOK_RULE_TAG = "playbook:rule";
|
|
3
|
+
export declare const PERSONAL_PLAYBOOK_DISABLED_TAG = "playbook:disabled";
|
|
4
|
+
export declare const PERSONAL_PLAYBOOK_ORDER_PREFIX = "playbook:order:";
|
|
5
|
+
export interface PersonalPlaybookContext {
|
|
6
|
+
channel?: string;
|
|
7
|
+
supportNeed?: 'listen' | 'clarify' | 'advise' | 'act' | 'unknown';
|
|
8
|
+
}
|
|
9
|
+
export declare function personalPlaybookContext(record: MemoryRecord): PersonalPlaybookContext;
|
|
10
|
+
export declare function patchPersonalPlaybookContextTags(tags: string[], patch: PersonalPlaybookContext): string[];
|
|
11
|
+
export declare function buildPersonalPlaybookPrompt(records: MemoryRecord[], context?: PersonalPlaybookContext): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/user-context/personal-playbook.ts
|
|
2
|
+
const PERSONAL_PLAYBOOK_RULE_TAG = "playbook:rule";
|
|
3
|
+
const PERSONAL_PLAYBOOK_DISABLED_TAG = "playbook:disabled";
|
|
4
|
+
const PERSONAL_PLAYBOOK_ORDER_PREFIX = "playbook:order:";
|
|
5
|
+
const PLAYBOOK_CHANNEL_PREFIX = "playbook:when:channel:";
|
|
6
|
+
const PLAYBOOK_SUPPORT_PREFIX = "playbook:when:support:";
|
|
7
|
+
function personalPlaybookContext(record) {
|
|
8
|
+
const channel = record.tags?.find((tag) => tag.startsWith(PLAYBOOK_CHANNEL_PREFIX))?.slice(22);
|
|
9
|
+
const supportNeed = record.tags?.find((tag) => tag.startsWith(PLAYBOOK_SUPPORT_PREFIX))?.slice(22);
|
|
10
|
+
return {
|
|
11
|
+
...channel ? { channel: decodeURIComponent(channel) } : {},
|
|
12
|
+
...supportNeed ? { supportNeed } : {}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function patchPersonalPlaybookContextTags(tags, patch) {
|
|
16
|
+
let next = tags;
|
|
17
|
+
if ("channel" in patch) {
|
|
18
|
+
next = next.filter((tag) => !tag.startsWith(PLAYBOOK_CHANNEL_PREFIX));
|
|
19
|
+
if (patch.channel) next.push(`${PLAYBOOK_CHANNEL_PREFIX}${encodeURIComponent(patch.channel)}`);
|
|
20
|
+
}
|
|
21
|
+
if ("supportNeed" in patch) {
|
|
22
|
+
next = next.filter((tag) => !tag.startsWith(PLAYBOOK_SUPPORT_PREFIX));
|
|
23
|
+
if (patch.supportNeed) next.push(`${PLAYBOOK_SUPPORT_PREFIX}${patch.supportNeed}`);
|
|
24
|
+
}
|
|
25
|
+
return [...new Set(next)];
|
|
26
|
+
}
|
|
27
|
+
function order(record) {
|
|
28
|
+
const tag = record.tags?.find((value) => value.startsWith(PERSONAL_PLAYBOOK_ORDER_PREFIX));
|
|
29
|
+
const parsed = tag ? Number.parseInt(tag.slice(15), 10) : NaN;
|
|
30
|
+
return Number.isFinite(parsed) ? parsed : 1e3;
|
|
31
|
+
}
|
|
32
|
+
function buildPersonalPlaybookPrompt(records, context = {}) {
|
|
33
|
+
const rules = records.filter((record) => record.status === "active").filter((record) => record.tags?.includes(PERSONAL_PLAYBOOK_RULE_TAG)).filter((record) => !record.tags?.includes(PERSONAL_PLAYBOOK_DISABLED_TAG)).filter((record) => {
|
|
34
|
+
const condition = personalPlaybookContext(record);
|
|
35
|
+
return (!condition.channel || condition.channel === context.channel) && (!condition.supportNeed || condition.supportNeed === context.supportNeed);
|
|
36
|
+
}).sort((left, right) => order(left) - order(right) || left.updatedAt.localeCompare(right.updatedAt));
|
|
37
|
+
if (!rules.length) return "";
|
|
38
|
+
return ["## Personal playbook", ...rules.map((record) => `- ${record.content}`)].join("\n");
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { PERSONAL_PLAYBOOK_DISABLED_TAG, PERSONAL_PLAYBOOK_ORDER_PREFIX, PERSONAL_PLAYBOOK_RULE_TAG, buildPersonalPlaybookPrompt, patchPersonalPlaybookContextTags, personalPlaybookContext };
|
|
@@ -22,11 +22,15 @@ export declare function projectUserContextRecord(record: MemoryRecord): {
|
|
|
22
22
|
disclosurePolicy: import("../agent/memory/types.js").MemoryDisclosurePolicy;
|
|
23
23
|
stability: import("../agent/memory/lifecycle.js").MemoryStabilityBand;
|
|
24
24
|
stabilityScore: number;
|
|
25
|
+
confidence: number;
|
|
25
26
|
reviewAt: string;
|
|
26
27
|
reviewDue: boolean;
|
|
27
28
|
evidenceCount: number;
|
|
28
29
|
sourcePath: string;
|
|
29
30
|
latestEvidenceAt: string;
|
|
31
|
+
validFrom: string;
|
|
32
|
+
validTo: string;
|
|
33
|
+
expiresAt: string;
|
|
30
34
|
};
|
|
31
35
|
export declare function isPersonalContextConnector(definition: ConnectorDefinition): boolean;
|
|
32
36
|
export declare function recordsDerivedFromPersonalContextSource(records: MemoryRecord[], sourceInstanceId: string): MemoryRecord[];
|
|
@@ -57,11 +57,15 @@ function projectUserContextRecord(record) {
|
|
|
57
57
|
disclosurePolicy: record.disclosurePolicy,
|
|
58
58
|
stability: lifecycle.band,
|
|
59
59
|
stabilityScore: lifecycle.score,
|
|
60
|
+
confidence: record.confidence,
|
|
60
61
|
reviewAt: lifecycle.reviewAt,
|
|
61
62
|
reviewDue: lifecycle.reviewDue,
|
|
62
63
|
evidenceCount: record.evidence?.length ?? 0,
|
|
63
64
|
sourcePath: record.source.path,
|
|
64
|
-
latestEvidenceAt
|
|
65
|
+
latestEvidenceAt,
|
|
66
|
+
validFrom: record.validFrom,
|
|
67
|
+
validTo: record.validTo,
|
|
68
|
+
expiresAt: record.expiresAt
|
|
65
69
|
};
|
|
66
70
|
}
|
|
67
71
|
function isPersonalContextConnector(definition) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MemoryRecord } from '../agent/memory/types.js';
|
|
2
|
+
export declare const RELATIONSHIP_FOLLOW_UP_TAG = "relationship:follow-up";
|
|
3
|
+
export interface RelationshipFollowUpRequest {
|
|
4
|
+
subject: string;
|
|
5
|
+
reviewAfter?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function extractExplicitRelationshipFollowUp(message: string, nowMs?: number): RelationshipFollowUpRequest | null;
|
|
8
|
+
export declare function recordExplicitRelationshipFollowUp(input: {
|
|
9
|
+
sessionKey: string;
|
|
10
|
+
sourceAgentId: string;
|
|
11
|
+
message: string;
|
|
12
|
+
nowMs?: number;
|
|
13
|
+
}): MemoryRecord | null;
|
|
14
|
+
export declare function buildRelationshipContinuityPrompt(records: MemoryRecord[], nowMs?: number): string;
|