@xopcai/xopc 0.0.161 → 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-o7GRljfD.js → activity-store-hpcNv9MZ.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-9R3szLMc.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-jSTqFMq9.js → api-Dnatri09.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-D81cyE76.js → app-management-settings-panel-BBTR9wJP.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-Ct6bZQCV.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-CfD7AZKn.js → archive-plugin-9eR_ODY1.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CP_Gaxt3.js → attachment-load-DPuWYUeX.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-BGKM_NDZ.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-IPr2EVnS.js → binary-plugins-BdkJpDFm.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-B6aHEGA6.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-CCX9-LjU.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-MmLMLDWf.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/{connector-logo-BbjzIs87.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/desktop-pet-Bpf6oegd.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DQLqGLc0.js → desktop-pet-settings-BVUyefSd.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-ClsiXhmz.js → directory-picker-path-field-DjSZAPz_.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-CjMPPdzg.js → dreaming-settings-CAZk2AM4.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-57eizjhB.js → extension-debug-page-C2F6vTTd.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CsbSb3u1.js → extension-page-AnIt4bn4.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DKA9-lyP.js → extension-settings-page-CLSc6682.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-DIPJuzBZ.js → gateway-config-api-DLFyZv33.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-CDLqAQY7.js → gateway-settings-DnQAA-qq.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DrfSJtvT.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-lGC10UkU.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-BWq0pdrA.js → goals-settings-Dz0F3uRO.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-D4o8BJVv.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-6T2QYehS.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-DCjg2K9f.js → local-apps-page-KsOtWOyM.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-Dar-xqQr.js → locale-store-0lpYdNDr.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-CyYCBqym.js → logs-page-CwLPgrWh.js} +3 -3
- package/dist/gateway/static/root/assets/{markdown-split-rt1XO43g.js → markdown-split-D5GRg10r.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Bwo8CJuh.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-Dp-pkX7d.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-CzZ4iKOb.js → page-tabs-Caj1-E_X.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-3E_Qa-58.js → preview-open-alternatives-DKwEce-9.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-B2T48Sbt.js → product-open-page-B90ZskkN.js} +1 -1
- 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-TkqUL3wm.js → schedule-field-Bcdni4Pj.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-DC-iU5IG.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-Dpqth3oA.js → settings-collapsible-section-6eNF8Jey.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-CNqF6IwY.js → settings-form-section-CARTHCxH.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DkvwitK_.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-DWvNgISx.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-DGpSPW-n.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-8TxxSbUw.js → system-settings-panel-DLBUQSk2.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-B5FzMWOx.js → theme-store-C1oaqeD2.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-DEGtSA5h.js → typed-models-lib-Divbg_C4.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-BDU6FneG.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-Cwi8Pz7n.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 +7 -7
- 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/agent-profile.js +1 -1
- package/dist/src/config/schema.d.ts +3 -3
- package/dist/src/config/schema.js +21 -21
- package/dist/src/gateway/agents-admin.js +1 -1
- 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/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/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-BIVBUiNT.js +0 -1
- package/dist/gateway/static/root/assets/agents-_qbUaYbs.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-0sPqD0FK.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-BxWBuBsE.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-C499b9AH.js +0 -8
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Dva9SiPK.js +0 -2
- package/dist/gateway/static/root/assets/channels-settings-DNAU7u9o.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-CIOH7tgn.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-TwiBp8vY.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-CYH5ZSXy.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-Q3B0E-0s.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-C5VAK04G.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-BJb-5IYw.js +0 -2
- package/dist/gateway/static/root/assets/index-CkUHH170.css +0 -1
- package/dist/gateway/static/root/assets/index-vq_cJZJC.js +0 -199
- package/dist/gateway/static/root/assets/local-app-workbench-page-euH17Kvb.js +0 -2
- package/dist/gateway/static/root/assets/messages-CxySDn9d.js +0 -5
- package/dist/gateway/static/root/assets/models-hub-panel-DObxxjc9.js +0 -2
- package/dist/gateway/static/root/assets/notes-workbench-CCb4RXcZ.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-BvEcriRC.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-B_e79MRJ.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-DGcqnYfR.js +0 -1
- package/dist/gateway/static/root/assets/save-bar-controls-CkeKasGm.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-DQZhrDJ8.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BkdeN99Y.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-qPG7I2zd.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-lwRAh9aw.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BGj9IVUr.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-B2UBAs5U.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-DdjzFZ8I.js +0 -2
- package/dist/gateway/static/root/assets/user-context-page-BTTZpAGV.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-DuDQd-WU.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-BUVkVCsW.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-DeEPPu4n.js +0 -1
- package/dist/gateway/static/root/assets/work-page-DQNUyTUq.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-BIy4wrzO.js +0 -11
- package/dist/src/browser/pipeline/source.d.ts +0 -9
- package/dist/src/browser/pipeline/source.js +0 -77
|
@@ -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;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { listMemoryRecords, upsertMemoryRecord } from "../storage/sqlite/memory-records-repository.js";
|
|
2
|
+
import "../storage/sqlite/index.js";
|
|
3
|
+
//#region src/user-context/relationship-continuity.ts
|
|
4
|
+
const RELATIONSHIP_FOLLOW_UP_TAG = "relationship:follow-up";
|
|
5
|
+
function extractExplicitRelationshipFollowUp(message, nowMs = Date.now()) {
|
|
6
|
+
const text = message.trim();
|
|
7
|
+
const subject = (text.match(/(?:请|记得)?(?:明天|下周|之后|到时候)?(?:提醒我|问问我|跟进一下|跟进)(?:关于)?[::,,\s]*(.+)/) ?? text.match(/(?:remember to )?(?:follow up with me|check in with me|ask me)(?: about)?[,:\s]+(.+)/i))?.[1]?.trim();
|
|
8
|
+
if (!subject || subject.length > 240) return null;
|
|
9
|
+
const delayMs = /明天|tomorrow/i.test(text) ? 1440 * 60 * 1e3 : /下周|next week/i.test(text) ? 10080 * 60 * 1e3 : 0;
|
|
10
|
+
return {
|
|
11
|
+
subject,
|
|
12
|
+
...delayMs ? { reviewAfter: new Date(nowMs + delayMs).toISOString() } : {}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function recordExplicitRelationshipFollowUp(input) {
|
|
16
|
+
const request = extractExplicitRelationshipFollowUp(input.message, input.nowMs);
|
|
17
|
+
if (!request) return null;
|
|
18
|
+
const existing = listMemoryRecords({
|
|
19
|
+
kind: "commitment",
|
|
20
|
+
status: "active",
|
|
21
|
+
limit: 200
|
|
22
|
+
}).find((record) => record.tags?.includes("relationship:follow-up") && record.content === request.subject);
|
|
23
|
+
if (existing) return existing;
|
|
24
|
+
return upsertMemoryRecord({
|
|
25
|
+
providerId: "builtin",
|
|
26
|
+
kind: "commitment",
|
|
27
|
+
sourceAgentId: input.sourceAgentId,
|
|
28
|
+
sessionKey: input.sessionKey,
|
|
29
|
+
content: request.subject,
|
|
30
|
+
source: { provider: "builtin" },
|
|
31
|
+
tags: [RELATIONSHIP_FOLLOW_UP_TAG],
|
|
32
|
+
status: "active",
|
|
33
|
+
explicitness: "explicit",
|
|
34
|
+
durability: "recurring",
|
|
35
|
+
importance: .8,
|
|
36
|
+
disclosurePolicy: "referenceable",
|
|
37
|
+
...request.reviewAfter ? { reviewAfter: request.reviewAfter } : {},
|
|
38
|
+
nowMs: input.nowMs
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function buildRelationshipContinuityPrompt(records, nowMs = Date.now()) {
|
|
42
|
+
const due = records.filter((record) => record.status === "active").filter((record) => record.tags?.includes(RELATIONSHIP_FOLLOW_UP_TAG)).filter((record) => !record.reviewAfter || Date.parse(record.reviewAfter) <= nowMs).slice(0, 3);
|
|
43
|
+
if (!due.length) return "";
|
|
44
|
+
return [
|
|
45
|
+
"## Relationship continuity",
|
|
46
|
+
"The user explicitly asked for these follow-ups. Check in naturally when relevant; do not pretend to know an outcome.",
|
|
47
|
+
...due.map((record) => `- ${record.content}`)
|
|
48
|
+
].join("\n");
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { RELATIONSHIP_FOLLOW_UP_TAG, buildRelationshipContinuityPrompt, extractExplicitRelationshipFollowUp, recordExplicitRelationshipFollowUp };
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-JdwAhgNB.js";import{t as i}from"./messages-CxySDn9d.js";import{n as a}from"./locale-store-Dar-xqQr.js";import{i as o}from"./vendor-swr-BIWyz7Rc.js";import{Jn as s,Ko as c,Qt as l,nc as u,un as d}from"./index-vq_cJZJC.js";import{n as f,r as p}from"./settings-page-layout-DWvNgISx.js";import{t as m}from"./settings-loading-skeleton-DkvwitK_.js";import{n as h,t as g}from"./settings-form-section-CNqF6IwY.js";var _=e(t(),1),v=n();function y(){let e=i(a(e=>e.language)),t=e.you,n=e.actionBoundarySettings,{data:y,error:b,isLoading:x,mutate:S}=o(`/api/you`,l),[C,w]=(0,_.useState)(!1),[T,E]=(0,_.useState)(null);async function D(e){if(!(C||e===y?.trust.defaultActionLevel)){w(!0);try{let r=await d(e);await S(e=>e&&{...e,trust:r},{revalidate:!1}),c({type:`success`,title:n.title,message:t.saved})}catch{c({type:`error`,title:n.title,message:t.saveError})}finally{w(!1),E(null)}}}return(0,v.jsxs)(p,{gap:`gap-6`,children:[(0,v.jsx)(f,{title:n.title,subtitle:n.subtitle}),(0,v.jsxs)(g,{children:[(0,v.jsx)(h,{icon:u,title:t.trustTitle,subtitle:t.trustHint}),x?(0,v.jsx)(m,{rows:4}):b||!y?(0,v.jsx)(`p`,{className:`rounded-xl border border-danger/25 bg-danger-soft p-4 text-sm text-danger`,children:n.loadError}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:y.trust.levels.map(e=>{let n=e===y.trust.defaultActionLevel;return(0,v.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:C,onClick:()=>{if(e===`auto`){E(e);return}D(e)},className:r(`rounded-xl border p-4 text-left transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-70`,n?`border-accent/35 bg-accent-soft/35`:`border-edge-subtle bg-surface-panel hover:border-accent/25 hover:bg-surface-hover`),children:[(0,v.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:t.trustLevels[e]}),(0,v.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.trustLevelHints[e]}),n?(0,v.jsx)(`span`,{className:`mt-3 inline-block rounded-full bg-accent-soft px-2 py-0.5 text-[11px] text-accent-fg`,children:t.defaultTrust}):null]},e)})}),(0,v.jsx)(`p`,{className:`mt-4 text-xs leading-5 text-fg-subtle`,children:t.autoOptInPromise})]})]}),(0,v.jsx)(s,{open:T===`auto`,title:t.autoConfirmTitle,description:t.autoConfirmBody,confirmLabel:t.autoConfirmAction,cancelLabel:t.cancel,onConfirm:()=>void D(`auto`),onCancel:()=>E(null)})]})}export{y as ActionBoundarySettingsPanel};
|