@xopcai/xopc 0.0.118 → 0.0.119
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/README.md +2 -1
- package/README.zh-CN.md +2 -1
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-dzUrQoeZ.js → agent-avatar-dicebear-CU8J6zou.js} +1 -1
- package/dist/gateway/static/root/assets/agents-B0hkpLhP.js +2 -0
- package/dist/gateway/static/root/assets/app-management-settings-panel-B9vfYoEr.js +1 -0
- package/dist/gateway/static/root/assets/appearance-settings-ClOzIO24.js +1 -0
- package/dist/gateway/static/root/assets/{apps-page--wMEL00f.js → apps-page-DU0dz9Zo.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-Cki4SfU2.js → archive-plugin-BkVIgZzA.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-D-KnS2Do.js → attachment-load-CaCMWh1D.js} +1 -1
- package/dist/gateway/static/root/assets/automation-suggestion-card-DhGDpKP3.js +1 -0
- package/dist/gateway/static/root/assets/automations-page-CTedroVo.js +1 -0
- package/dist/gateway/static/root/assets/{binary-plugins-D2sgvJja.js → binary-plugins-B4TO_bsn.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DIq-4Gvb.js → block-editor-DJRWwWNI.js} +28 -28
- package/dist/gateway/static/root/assets/browser-settings-page-FCDwOOBK.js +8 -0
- package/dist/gateway/static/root/assets/capability-presets-api-Befi89CL.js +1 -0
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-_G8eb2vJ.js +1 -0
- package/dist/gateway/static/root/assets/channel-recipient-api-BNSuJb5f.js +1 -0
- package/dist/gateway/static/root/assets/channels-settings-C3d5JBJX.js +1 -0
- package/dist/gateway/static/root/assets/cn-BQ_8x0bT.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-yaUNvt5u.js +2 -0
- package/dist/gateway/static/root/assets/cron-expression-B3B1eqnr.js +2 -0
- package/dist/gateway/static/root/assets/dreaming-settings-DNrdg1Ve.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DYu1KaFQ.js → extension-debug-page-DYh402XV.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-B3W6QwlZ.js → extension-page-Cr_TizrN.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-D7VQ-cxE.js → extension-settings-page-BU1KoKRj.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-B7xDPu-R.js → fetch-Y7AEX4H3.js} +1 -1
- package/dist/gateway/static/root/assets/format-cron-label-arqgGlVV.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-api-BTBLSeUu.js → gateway-config-api-RbMmAOpX.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-C79wkXef.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CYj9FWCp.js → gateway-startup-retry-DiD_Tx4N.js} +1 -1
- package/dist/gateway/static/root/assets/goal-detail-page-9paXuHdo.js +1 -0
- package/dist/gateway/static/root/assets/{goals-config-api-CQQgzPr3.js → goals-config-api-DqxVi0p5.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-page-BHitvJAv.js → goals-page-CS0R-Af2.js} +2 -2
- package/dist/gateway/static/root/assets/goals-settings-CSuzZ8Ae.js +1 -0
- package/dist/gateway/static/root/assets/heartbeat-settings-DXPaYJm3.js +1 -0
- package/dist/gateway/static/root/assets/index-BoKafJIZ.js +191 -0
- package/dist/gateway/static/root/assets/index-CArhCcYn.css +1 -0
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-Dvg53qnd.js +1 -0
- package/dist/gateway/static/root/assets/{logs-page-C2Uqvae9.js → logs-page-DLXPcksQ.js} +2 -2
- package/dist/gateway/static/root/assets/{markdown-split-BwOFrJ2E.js → markdown-split-CpHxbtWJ.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Cnz6Q5G6.js → media-plugins-SFPQRSxq.js} +1 -1
- package/dist/gateway/static/root/assets/messages-CrDHEbss.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-BDF2iyRk.js +2 -0
- package/dist/gateway/static/root/assets/note-detail-page-CSb_hwig.js +2 -0
- package/dist/gateway/static/root/assets/{note-image-lightbox-B-Svpmza.js → note-image-lightbox-BUYURRgn.js} +1 -1
- package/dist/gateway/static/root/assets/notes-page-BsIBSFyZ.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-Bss4TiwP.js → preview-open-alternatives-BHz9iWYA.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CwzSovcS.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-BRNjdgKq.js → save-bar-controls-CefkOlRg.js} +1 -1
- package/dist/gateway/static/root/assets/schedule-field-CmTRoOcE.js +1 -0
- package/dist/gateway/static/root/assets/{schema-form-Dub9sy8r.js → schema-form-FMKv1vGu.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-PHmX-NmA.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BRAeKJN4.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-BeFLavGi.js → settings-collapsible-section-BouO6JTi.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-dmyaPOTG.js → settings-form-section-D-4lBl6X.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-KKrbFjy8.js +1 -0
- package/dist/gateway/static/root/assets/settings-page-layout-BJ4Gsef5.js +1 -0
- package/dist/gateway/static/root/assets/setup-status-panel-CrUjHPQo.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-C8glrdqe.js → share-preview-page-BDy2btRN.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-B18OBmH5.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-C28-2uKQ.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-Bm2ebkwl.js +2 -0
- package/dist/gateway/static/root/assets/system-settings-panel-CRngrlnZ.js +1 -0
- package/dist/gateway/static/root/assets/typed-models-lib-BltBc0b-.js +1 -0
- package/dist/gateway/static/root/assets/{use-channel-catalog-DqlWTsDb.js → use-channel-catalog-CjN-51e6.js} +1 -1
- package/dist/gateway/static/root/assets/user-profile-settings-panel-DJ1dKwZy.js +1 -0
- package/dist/gateway/static/root/assets/utils-B5M5-YvK.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-C73IVZeC.js → voice-api-key-field-CeEevm7z.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-player-store-C_ArLJPM.js → voice-player-store-B7ykUlHM.js} +1 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-C4PzUQjB.js +3 -0
- package/dist/gateway/static/root/assets/workflows-page-BL84_-Ky.js +18 -0
- package/dist/gateway/static/root/index.html +6 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +4 -5
- package/dist/src/agent/agent-manager.js +4 -8
- package/dist/src/agent/agent-manager.js.map +1 -1
- package/dist/src/agent/embedded/run-for-session.js +102 -14
- package/dist/src/agent/embedded/run-for-session.js.map +1 -1
- package/dist/src/agent/fallback/candidates.d.ts +0 -8
- package/dist/src/agent/fallback/candidates.js.map +1 -1
- package/dist/src/agent/index.js +1 -1
- package/dist/src/agent/lifecycle/handlers/compaction.d.ts +1 -3
- package/dist/src/agent/lifecycle/handlers/compaction.js +1 -16
- package/dist/src/agent/lifecycle/handlers/compaction.js.map +1 -1
- package/dist/src/agent/lifecycle/progress.d.ts +0 -1
- package/dist/src/agent/lifecycle/progress.js +1 -6
- package/dist/src/agent/lifecycle/progress.js.map +1 -1
- package/dist/src/agent/lifecycle/timeout-wrapper.d.ts +1 -2
- package/dist/src/agent/lifecycle/timeout-wrapper.js +1 -7
- package/dist/src/agent/lifecycle/timeout-wrapper.js.map +1 -1
- package/dist/src/agent/middleware/self-verify.d.ts +0 -1
- package/dist/src/agent/middleware/self-verify.js +0 -2
- package/dist/src/agent/middleware/self-verify.js.map +1 -1
- package/dist/src/agent/models/index.d.ts +1 -1
- package/dist/src/agent/models/manager.d.ts +4 -20
- package/dist/src/agent/models/manager.js +9 -126
- package/dist/src/agent/models/manager.js.map +1 -1
- package/dist/src/agent/orchestration/agent-orchestrator.d.ts +0 -4
- package/dist/src/agent/orchestration/agent-orchestrator.js +1 -9
- package/dist/src/agent/orchestration/agent-orchestrator.js.map +1 -1
- package/dist/src/agent/prompt/sections/tooling.js +2 -2
- package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.d.ts +0 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +0 -12
- package/dist/src/agent/prompt/service-prompt-builder.js.map +1 -1
- package/dist/src/agent/prompt/subagent-context.js +1 -1
- package/dist/src/agent/prompt/subagent-context.js.map +1 -1
- package/dist/src/agent/prompt/types.d.ts +1 -1
- package/dist/src/agent/service.d.ts +1 -9
- package/dist/src/agent/service.js +3 -40
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/service.types.d.ts +2 -2
- package/dist/src/agent/session/session-config-service.d.ts +11 -11
- package/dist/src/agent/session/session-config-service.js +14 -14
- package/dist/src/agent/session/session-config-service.js.map +1 -1
- package/dist/src/agent/session/session-inspector.js +3 -2
- package/dist/src/agent/session/session-inspector.js.map +1 -1
- package/dist/src/agent/starter-agents.js +12 -12
- package/dist/src/agent/starter-agents.js.map +1 -1
- package/dist/src/agent/tools/automation-tool.d.ts +14 -0
- package/dist/src/agent/tools/automation-tool.js +102 -0
- package/dist/src/agent/tools/automation-tool.js.map +1 -0
- package/dist/src/agent/tools/delegate-tool.js +1 -1
- package/dist/src/agent/tools/delegate-tool.js.map +1 -1
- package/dist/src/agent/tools/factory.d.ts +3 -3
- package/dist/src/agent/tools/factory.js +2 -2
- package/dist/src/agent/tools/factory.js.map +1 -1
- package/dist/src/agent/tools/index.d.ts +1 -1
- package/dist/src/agent/tools/index.js +2 -2
- package/dist/src/agent-manifest/resolver.d.ts +1 -0
- package/dist/src/agent-manifest/resolver.js +1 -0
- package/dist/src/agent-manifest/resolver.js.map +1 -1
- package/dist/src/agent-manifest/schema.d.ts +6 -0
- package/dist/src/agent-manifest/schema.js +12 -3
- package/dist/src/agent-manifest/schema.js.map +1 -1
- package/dist/src/ai-assist/text-assist.d.ts +1 -1
- package/dist/src/ai-assist/text-assist.js +56 -0
- package/dist/src/ai-assist/text-assist.js.map +1 -1
- package/dist/src/auth/profiles/store.js.map +1 -1
- package/dist/src/automations/api/routes.d.ts +3 -0
- package/dist/src/automations/api/routes.js +193 -0
- package/dist/src/automations/api/routes.js.map +1 -0
- package/dist/src/automations/domain/index.d.ts +3 -0
- package/dist/src/automations/domain/index.js +3 -0
- package/dist/src/automations/domain/schedule.d.ts +4 -0
- package/dist/src/automations/domain/schedule.js +37 -0
- package/dist/src/automations/domain/schedule.js.map +1 -0
- package/dist/src/automations/domain/types.d.ts +160 -0
- package/dist/src/automations/domain/validation.d.ts +370 -0
- package/dist/src/automations/domain/validation.js +149 -0
- package/dist/src/automations/domain/validation.js.map +1 -0
- package/dist/src/automations/draft/automation-draft-prompt.d.ts +26 -0
- package/dist/src/automations/draft/automation-draft-prompt.js +127 -0
- package/dist/src/automations/draft/automation-draft-prompt.js.map +1 -0
- package/dist/src/automations/draft/automation-draft-service.d.ts +12 -0
- package/dist/src/automations/draft/automation-draft-service.js +135 -0
- package/dist/src/automations/draft/automation-draft-service.js.map +1 -0
- package/dist/src/automations/draft/automation-draft-validator.d.ts +99 -0
- package/dist/src/automations/draft/automation-draft-validator.js +105 -0
- package/dist/src/automations/draft/automation-draft-validator.js.map +1 -0
- package/dist/src/automations/draft/automation-draft.types.d.ts +40 -0
- package/dist/src/automations/draft/index.d.ts +3 -0
- package/dist/src/automations/draft/index.js +3 -0
- package/dist/src/automations/index.d.ts +3 -0
- package/dist/src/automations/index.js +8 -0
- package/dist/src/automations/product-events.d.ts +5 -0
- package/dist/src/automations/product-events.js +21 -0
- package/dist/src/automations/product-events.js.map +1 -0
- package/dist/src/automations/service/action-executor.d.ts +9 -0
- package/dist/src/automations/service/action-executor.js +157 -0
- package/dist/src/automations/service/action-executor.js.map +1 -0
- package/dist/src/automations/service/automation-service.d.ts +54 -0
- package/dist/src/automations/service/automation-service.js +404 -0
- package/dist/src/automations/service/automation-service.js.map +1 -0
- package/dist/src/automations/service/index.d.ts +2 -0
- package/dist/src/automations/service/index.js +3 -0
- package/dist/src/automations/storage/automation-repository.d.ts +6 -0
- package/dist/src/automations/storage/automation-repository.js +61 -0
- package/dist/src/automations/storage/automation-repository.js.map +1 -0
- package/dist/src/automations/storage/automation-run-repository.d.ts +17 -0
- package/dist/src/automations/storage/automation-run-repository.js +130 -0
- package/dist/src/automations/storage/automation-run-repository.js.map +1 -0
- package/dist/src/automations/storage/index.d.ts +2 -0
- package/dist/src/automations/storage/index.js +3 -0
- package/dist/src/channels/plugin-types.d.ts +3 -0
- package/dist/src/chat-commands/builtins/thinking.js.map +1 -1
- package/dist/src/cli/command-catalog.js +0 -39
- package/dist/src/cli/command-catalog.js.map +1 -1
- package/dist/src/cli/command-loaders.js +0 -1
- package/dist/src/cli/command-loaders.js.map +1 -1
- package/dist/src/cli/command-manifest.js +0 -4
- package/dist/src/cli/command-manifest.js.map +1 -1
- package/dist/src/cli/commands/agents.js +7 -6
- package/dist/src/cli/commands/agents.js.map +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/{cron-health.d.ts → migrations.d.ts} +1 -1
- package/dist/src/cli/commands/doctor/checks/migrations.js +40 -0
- package/dist/src/cli/commands/doctor/checks/migrations.js.map +1 -0
- package/dist/src/cli/commands/doctor/flow.js +2 -2
- package/dist/src/cli/commands/doctor/flow.js.map +1 -1
- package/dist/src/cli/commands/gateway/call.js +2 -2
- package/dist/src/cli/commands/gateway/call.js.map +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/gateway/run-foreground.js +4 -2
- package/dist/src/cli/commands/gateway/run-foreground.js.map +1 -1
- package/dist/src/cli/commands/init.js +26 -8
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/commands/tui.js +24 -2
- package/dist/src/cli/commands/tui.js.map +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +2 -0
- package/dist/src/cli/utils/init-workspace-core.js.map +1 -1
- package/dist/src/commands/agents.config.d.ts +9 -0
- package/dist/src/commands/agents.config.js +40 -2
- package/dist/src/commands/agents.config.js.map +1 -1
- package/dist/src/config/agent-profile.js +4 -3
- package/dist/src/config/agent-profile.js.map +1 -1
- package/dist/src/config/agent-typed-models.js.map +1 -1
- package/dist/src/config/config-surface.d.ts +3 -0
- package/dist/src/config/index.d.ts +0 -1
- package/dist/src/config/index.js +3 -3
- package/dist/src/config/index.js.map +1 -1
- package/dist/src/config/paths.d.ts +0 -9
- package/dist/src/config/paths.js +1 -14
- package/dist/src/config/paths.js.map +1 -1
- package/dist/src/config/profile.js +0 -1
- package/dist/src/config/profile.js.map +1 -1
- package/dist/src/config/rules.js +0 -5
- package/dist/src/config/rules.js.map +1 -1
- package/dist/src/config/schema.d.ts +13 -12
- package/dist/src/config/schema.js +22 -26
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/config/web-patch.d.ts +0 -12
- package/dist/src/config/web-patch.js +2 -29
- package/dist/src/config/web-patch.js.map +1 -1
- package/dist/src/extensions/api.d.ts +2 -0
- package/dist/src/extensions/api.js +10 -0
- package/dist/src/extensions/api.js.map +1 -1
- package/dist/src/extensions/extension-registry-impl.d.ts +4 -1
- package/dist/src/extensions/extension-registry-impl.js +8 -0
- package/dist/src/extensions/extension-registry-impl.js.map +1 -1
- package/dist/src/extensions/loader.d.ts +3 -3
- package/dist/src/extensions/loader.js +3 -3
- package/dist/src/extensions/loader.js.map +1 -1
- package/dist/src/extensions/sdk/testing.d.ts +2 -0
- package/dist/src/extensions/sdk/testing.js +7 -0
- package/dist/src/extensions/sdk/testing.js.map +1 -1
- package/dist/src/extensions/types/core.d.ts +10 -1
- package/dist/src/extensions/types/index.d.ts +1 -1
- package/dist/src/extensions/types/{phase4.d.ts → registration.d.ts} +2 -2
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/agent-builtin-tools.js +1 -1
- package/dist/src/gateway/agent-builtin-tools.js.map +1 -1
- package/dist/src/gateway/agents-admin.d.ts +1 -0
- package/dist/src/gateway/agents-admin.js +13 -15
- package/dist/src/gateway/agents-admin.js.map +1 -1
- package/dist/src/gateway/capability-presets-admin.d.ts +1 -0
- package/dist/src/gateway/capability-presets-admin.js +19 -10
- package/dist/src/gateway/capability-presets-admin.js.map +1 -1
- package/dist/src/gateway/dreaming-automation-reconciler.d.ts +11 -0
- package/dist/src/gateway/dreaming-automation-reconciler.js +105 -0
- package/dist/src/gateway/dreaming-automation-reconciler.js.map +1 -0
- package/dist/src/gateway/heartbeat/service.d.ts +0 -2
- package/dist/src/gateway/heartbeat/service.js +0 -7
- package/dist/src/gateway/heartbeat/service.js.map +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +5 -6
- package/dist/src/gateway/hono/lib/config-payload.js +2 -2
- package/dist/src/gateway/hono/lib/config-payload.js.map +1 -1
- package/dist/src/gateway/hono/routes/agents.js.map +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.d.ts +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +12 -6
- package/dist/src/gateway/hono/routes/config-patch/misc.js.map +1 -1
- package/dist/src/gateway/hono/routes/dreaming.js +27 -37
- package/dist/src/gateway/hono/routes/dreaming.js.map +1 -1
- package/dist/src/gateway/hono/routes/home.d.ts +2 -2
- package/dist/src/gateway/hono/routes/home.js +34 -25
- package/dist/src/gateway/hono/routes/home.js.map +1 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +10 -6
- package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
- package/dist/src/gateway/hono/routes/migrations.d.ts +3 -0
- package/dist/src/gateway/hono/routes/migrations.js +35 -0
- package/dist/src/gateway/hono/routes/migrations.js.map +1 -0
- package/dist/src/gateway/hono/routes/public-gateway.js +2 -1
- package/dist/src/gateway/hono/routes/public-gateway.js.map +1 -1
- package/dist/src/gateway/hono/routes/sessions.js +14 -0
- package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
- package/dist/src/gateway/run-loop.js +2 -0
- package/dist/src/gateway/run-loop.js.map +1 -1
- package/dist/src/gateway/security/operator-scopes.js +5 -1
- package/dist/src/gateway/security/operator-scopes.js.map +1 -1
- package/dist/src/gateway/service/config-coordinator.d.ts +4 -4
- package/dist/src/gateway/service/config-coordinator.js +14 -8
- package/dist/src/gateway/service/config-coordinator.js.map +1 -1
- package/dist/src/gateway/service/sessions-api.d.ts +2 -1
- package/dist/src/gateway/service/sessions-api.js +6 -1
- package/dist/src/gateway/service/sessions-api.js.map +1 -1
- package/dist/src/gateway/service.d.ts +7 -3
- package/dist/src/gateway/service.js +61 -27
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/goals/goal-service.js +45 -4
- package/dist/src/goals/goal-service.js.map +1 -1
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/migrations/config/default-capability-preset.d.ts +10 -0
- package/dist/src/migrations/config/default-capability-preset.js +135 -0
- package/dist/src/migrations/config/default-capability-preset.js.map +1 -0
- package/dist/src/migrations/index.d.ts +4 -0
- package/dist/src/migrations/index.js +4 -0
- package/dist/src/migrations/registry.d.ts +8 -0
- package/dist/src/migrations/registry.js +18 -0
- package/dist/src/migrations/registry.js.map +1 -0
- package/dist/src/migrations/runner.d.ts +17 -0
- package/dist/src/migrations/runner.js +191 -0
- package/dist/src/migrations/runner.js.map +1 -0
- package/dist/src/migrations/types.d.ts +34 -0
- package/dist/src/notes/service.js +24 -1
- package/dist/src/notes/service.js.map +1 -1
- package/dist/src/providers/model-registry.d.ts +0 -1
- package/dist/src/providers/model-registry.js +0 -3
- package/dist/src/providers/model-registry.js.map +1 -1
- package/dist/src/routing/resolve-tui-session-key.d.ts +3 -0
- package/dist/src/routing/resolve-tui-session-key.js +14 -3
- package/dist/src/routing/resolve-tui-session-key.js.map +1 -1
- package/dist/src/session/transcript-outline.d.ts +47 -0
- package/dist/src/session/transcript-outline.js +481 -0
- package/dist/src/session/transcript-outline.js.map +1 -0
- package/dist/src/storage/sqlite/index.d.ts +0 -2
- package/dist/src/storage/sqlite/index.js +1 -3
- package/dist/src/storage/sqlite/migrations/016_automations.sql +47 -0
- package/dist/src/storage/sqlite/migrations/017_automation_run_events.sql +14 -0
- package/dist/src/storage/sqlite/migrations/018_automation_safety.sql +1 -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.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +56 -46
- package/dist/src/tui/backends/embedded-backend.d.ts +6 -0
- package/dist/src/tui/backends/embedded-backend.js +18 -7
- package/dist/src/tui/backends/embedded-backend.js.map +1 -1
- package/dist/src/tui/backends/gateway-sse-backend.d.ts +3 -0
- package/dist/src/tui/backends/gateway-sse-backend.js +14 -0
- package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
- package/dist/src/tui/tui-backend.d.ts +4 -0
- package/dist/src/tui/tui-commands.d.ts +5 -0
- package/dist/src/tui/tui-commands.js +43 -0
- package/dist/src/tui/tui-commands.js.map +1 -1
- package/dist/src/tui/tui-transcript-tree.d.ts +1 -1
- package/dist/src/tui/tui-transcript-tree.js +17 -257
- package/dist/src/tui/tui-transcript-tree.js.map +1 -1
- package/dist/src/tui/tui-types.d.ts +2 -0
- package/dist/src/tui/tui-types.js.map +1 -1
- package/dist/src/tui/tui.js +7 -2
- package/dist/src/tui/tui.js.map +1 -1
- package/dist/src/workflows/domain/index.js +1 -1
- package/dist/src/workflows/domain/run.d.ts +7 -7
- package/dist/src/workflows/domain/run.js.map +1 -1
- package/dist/src/workflows/index.js +2 -2
- package/dist/src/workflows/service/workflow-run-service.d.ts +2 -0
- package/dist/src/workflows/service/workflow-run-service.js +31 -9
- package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
- package/dist/src/workflows/service/workflow-run-service.types.d.ts +1 -1
- package/package.json +4 -2
- package/dist/gateway/static/root/assets/agents-BCxZbkOw.js +0 -2
- package/dist/gateway/static/root/assets/app-management-settings-panel-bxYJVJpx.js +0 -1
- package/dist/gateway/static/root/assets/appearance-settings-BCIykXlI.js +0 -1
- package/dist/gateway/static/root/assets/browser-settings-page-DRhKdn81.js +0 -8
- package/dist/gateway/static/root/assets/capability-presets-api-CorhiHlg.js +0 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-qFx9Jtce.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-BAwAkqIA.js +0 -1
- package/dist/gateway/static/root/assets/cn-JdwAhgNB.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-BQLcfitM.js +0 -2
- package/dist/gateway/static/root/assets/createLucideIcon-DPHK1VkS.js +0 -1
- package/dist/gateway/static/root/assets/cron-api-qGwmL-24.js +0 -1
- package/dist/gateway/static/root/assets/cron-dreaming-jobs-nCMWCf0p.js +0 -1
- package/dist/gateway/static/root/assets/cron-page-BBWMAj8-.js +0 -3
- package/dist/gateway/static/root/assets/dreaming-settings-Dw89Obml.js +0 -1
- package/dist/gateway/static/root/assets/format-cron-label-BsotZDO5.js +0 -2
- package/dist/gateway/static/root/assets/format-interval-label-BzxafKxR.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-Cmwy58rS.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-l7mu5GWX.js +0 -1
- package/dist/gateway/static/root/assets/goals-settings-CYVY4NGp.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-config-api-DriO_CN9.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-CUQTKxg7.js +0 -1
- package/dist/gateway/static/root/assets/index-C17Tsd_b.css +0 -1
- package/dist/gateway/static/root/assets/index-Cc41r16l.js +0 -191
- package/dist/gateway/static/root/assets/interval-presets-DFPCKW_W.js +0 -1
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-CcVcqstx.js +0 -1
- package/dist/gateway/static/root/assets/messages-B1iSKjiw.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-panel-BfLfcta8.js +0 -2
- package/dist/gateway/static/root/assets/note-detail-page-BjwOQBfT.js +0 -2
- package/dist/gateway/static/root/assets/notes-page-DktdBiwB.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-rfVx96fq.js +0 -1
- package/dist/gateway/static/root/assets/schedule-field-CUCKODde.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-DbtMFuuH.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-5re5gAnP.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-D-WMyLlj.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Cl-DEJAU.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-CyPVvbLt.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CleTH1oz.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-Ck8hdXqR.js +0 -2
- package/dist/gateway/static/root/assets/system-settings-panel-DI-LN_8G.js +0 -1
- package/dist/gateway/static/root/assets/typed-models-lib-kX9duch4.js +0 -1
- package/dist/gateway/static/root/assets/user-profile-settings-panel-B-UFPMXy.js +0 -1
- package/dist/gateway/static/root/assets/utils-Dm0hKalR.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-BtFGp2y_.js +0 -18
- package/dist/src/agent/fallback/error.d.ts +0 -22
- package/dist/src/agent/fallback/error.js +0 -32
- package/dist/src/agent/fallback/error.js.map +0 -1
- package/dist/src/agent/fallback/index.d.ts +0 -5
- package/dist/src/agent/fallback/index.js +0 -9
- package/dist/src/agent/fallback/index.js.map +0 -1
- package/dist/src/agent/orchestration/run-agent-turn-with-fallbacks.d.ts +0 -29
- package/dist/src/agent/orchestration/run-agent-turn-with-fallbacks.js +0 -76
- package/dist/src/agent/orchestration/run-agent-turn-with-fallbacks.js.map +0 -1
- package/dist/src/agent/service/reconcile-dreaming-cron.d.ts +0 -6
- package/dist/src/agent/service/reconcile-dreaming-cron.js +0 -84
- package/dist/src/agent/service/reconcile-dreaming-cron.js.map +0 -1
- package/dist/src/agent/tools/cronjob-tool.d.ts +0 -29
- package/dist/src/agent/tools/cronjob-tool.js +0 -274
- package/dist/src/agent/tools/cronjob-tool.js.map +0 -1
- package/dist/src/cli/commands/cron-cli.d.ts +0 -2
- package/dist/src/cli/commands/cron-cli.js +0 -15
- package/dist/src/cli/commands/cron-cli.js.map +0 -1
- package/dist/src/cli/commands/cron.d.ts +0 -4
- package/dist/src/cli/commands/cron.js +0 -188
- package/dist/src/cli/commands/cron.js.map +0 -1
- package/dist/src/cli/commands/doctor/checks/cron-health.js +0 -35
- package/dist/src/cli/commands/doctor/checks/cron-health.js.map +0 -1
- package/dist/src/cron/execution-types.d.ts +0 -42
- package/dist/src/cron/executor.d.ts +0 -67
- package/dist/src/cron/executor.js +0 -669
- package/dist/src/cron/executor.js.map +0 -1
- package/dist/src/cron/index.d.ts +0 -7
- package/dist/src/cron/index.js +0 -7
- package/dist/src/cron/job-content.d.ts +0 -5
- package/dist/src/cron/job-content.js +0 -15
- package/dist/src/cron/job-content.js.map +0 -1
- package/dist/src/cron/run-log-store.d.ts +0 -12
- package/dist/src/cron/run-log-store.js +0 -58
- package/dist/src/cron/run-log-store.js.map +0 -1
- package/dist/src/cron/schedule.d.ts +0 -10
- package/dist/src/cron/schedule.js +0 -85
- package/dist/src/cron/schedule.js.map +0 -1
- package/dist/src/cron/service.d.ts +0 -58
- package/dist/src/cron/service.js +0 -419
- package/dist/src/cron/service.js.map +0 -1
- package/dist/src/cron/types.d.ts +0 -183
- package/dist/src/cron/validation.d.ts +0 -500
- package/dist/src/cron/validation.js +0 -192
- package/dist/src/cron/validation.js.map +0 -1
- package/dist/src/cron/workflow-run-completion.d.ts +0 -23
- package/dist/src/cron/workflow-run-completion.js +0 -72
- package/dist/src/cron/workflow-run-completion.js.map +0 -1
- package/dist/src/extensions/types/phase4.js +0 -1
- package/dist/src/gateway/hono/routes/cron.d.ts +0 -3
- package/dist/src/gateway/hono/routes/cron.js +0 -109
- package/dist/src/gateway/hono/routes/cron.js.map +0 -1
- package/dist/src/storage/sqlite/cron-job-repository.d.ts +0 -6
- package/dist/src/storage/sqlite/cron-job-repository.js +0 -70
- package/dist/src/storage/sqlite/cron-job-repository.js.map +0 -1
- package/dist/src/storage/sqlite/cron-run-repository.d.ts +0 -5
- package/dist/src/storage/sqlite/cron-run-repository.js +0 -96
- package/dist/src/storage/sqlite/cron-run-repository.js.map +0 -1
- /package/dist/src/{cron → automations/domain}/types.js +0 -0
- /package/dist/src/{config/defaults.d.ts → automations/draft/automation-draft.types.js} +0 -0
- /package/dist/src/{config/defaults.js → extensions/types/registration.js} +0 -0
- /package/dist/src/{cron/execution-types.js → migrations/types.js} +0 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CronExpressionParser } from "cron-parser";
|
|
3
|
+
//#region src/automations/domain/validation.ts
|
|
4
|
+
const nonEmptyString = z.string().trim().min(1);
|
|
5
|
+
const optionalTrimmedString = (max) => z.preprocess((value) => {
|
|
6
|
+
if (value == null) return void 0;
|
|
7
|
+
if (typeof value !== "string") return value;
|
|
8
|
+
const trimmed = value.trim();
|
|
9
|
+
return trimmed.length === 0 ? void 0 : trimmed;
|
|
10
|
+
}, z.string().min(1).max(max).optional());
|
|
11
|
+
const AutomationScheduleSchema = z.discriminatedUnion("kind", [
|
|
12
|
+
z.object({
|
|
13
|
+
kind: z.literal("once"),
|
|
14
|
+
at: nonEmptyString
|
|
15
|
+
}).strict(),
|
|
16
|
+
z.object({
|
|
17
|
+
kind: z.literal("interval"),
|
|
18
|
+
everyMs: z.number().int().min(1),
|
|
19
|
+
anchorMs: z.number().int().nonnegative().optional()
|
|
20
|
+
}).strict(),
|
|
21
|
+
z.object({
|
|
22
|
+
kind: z.literal("cron"),
|
|
23
|
+
expr: nonEmptyString.superRefine((expr, ctx) => {
|
|
24
|
+
try {
|
|
25
|
+
CronExpressionParser.parse(expr);
|
|
26
|
+
} catch {
|
|
27
|
+
ctx.addIssue({
|
|
28
|
+
code: z.ZodIssueCode.custom,
|
|
29
|
+
message: `Invalid cron expression: ${expr}`
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}),
|
|
33
|
+
tz: optionalTrimmedString(100)
|
|
34
|
+
}).strict()
|
|
35
|
+
]);
|
|
36
|
+
const AutomationTriggerSchema = z.discriminatedUnion("kind", [
|
|
37
|
+
z.object({ kind: z.literal("manual") }).strict(),
|
|
38
|
+
z.object({
|
|
39
|
+
kind: z.literal("schedule"),
|
|
40
|
+
schedule: AutomationScheduleSchema
|
|
41
|
+
}).strict(),
|
|
42
|
+
z.object({
|
|
43
|
+
kind: z.literal("webhook"),
|
|
44
|
+
secretId: optionalTrimmedString(200)
|
|
45
|
+
}).strict(),
|
|
46
|
+
z.object({
|
|
47
|
+
kind: z.literal("event"),
|
|
48
|
+
eventType: nonEmptyString.max(200),
|
|
49
|
+
source: optionalTrimmedString(200),
|
|
50
|
+
payloadMatch: z.record(z.string(), z.union([
|
|
51
|
+
z.string(),
|
|
52
|
+
z.number(),
|
|
53
|
+
z.boolean(),
|
|
54
|
+
z.null()
|
|
55
|
+
])).optional()
|
|
56
|
+
}).strict()
|
|
57
|
+
]);
|
|
58
|
+
const WorkflowRunInputEnvelopeSchema = z.object({
|
|
59
|
+
payload: z.unknown(),
|
|
60
|
+
goal: optionalTrimmedString(5e3),
|
|
61
|
+
variables: z.record(z.string(), z.unknown()).optional(),
|
|
62
|
+
context: z.record(z.string(), z.unknown()).optional()
|
|
63
|
+
}).strict();
|
|
64
|
+
const AutomationActionSchema = z.discriminatedUnion("kind", [z.object({
|
|
65
|
+
kind: z.literal("agent"),
|
|
66
|
+
agentId: optionalTrimmedString(64),
|
|
67
|
+
instruction: nonEmptyString.max(5e4),
|
|
68
|
+
workingDirectory: optionalTrimmedString(4096),
|
|
69
|
+
model: optionalTrimmedString(100),
|
|
70
|
+
timeoutSeconds: z.number().int().min(1).max(86400).optional()
|
|
71
|
+
}).strict(), z.object({
|
|
72
|
+
kind: z.literal("workflow"),
|
|
73
|
+
workflowId: nonEmptyString.max(200),
|
|
74
|
+
agentId: optionalTrimmedString(64),
|
|
75
|
+
input: z.unknown().optional(),
|
|
76
|
+
inputEnvelope: WorkflowRunInputEnvelopeSchema.optional(),
|
|
77
|
+
goal: optionalTrimmedString(5e3),
|
|
78
|
+
concurrency: z.number().int().min(1).max(50).optional(),
|
|
79
|
+
maxSubagents: z.number().int().min(1).max(100).optional(),
|
|
80
|
+
timeoutSeconds: z.number().int().min(1).max(86400).optional()
|
|
81
|
+
}).strict()]);
|
|
82
|
+
const AutomationAfterRunSchema = z.discriminatedUnion("kind", [
|
|
83
|
+
z.object({ kind: z.literal("none") }).strict(),
|
|
84
|
+
z.object({ kind: z.literal("saveToSession") }).strict(),
|
|
85
|
+
z.object({
|
|
86
|
+
kind: z.literal("webhook"),
|
|
87
|
+
url: nonEmptyString.max(2e3)
|
|
88
|
+
}).strict()
|
|
89
|
+
]);
|
|
90
|
+
const AutomationReliabilitySchema = z.object({
|
|
91
|
+
timeoutSeconds: z.number().int().min(1).max(86400).optional(),
|
|
92
|
+
retryCount: z.number().int().min(0).max(10).optional(),
|
|
93
|
+
maxConcurrentRuns: z.number().int().min(1).max(20).optional(),
|
|
94
|
+
disableAfterConsecutiveFailures: z.number().int().min(1).max(100).optional()
|
|
95
|
+
}).strict();
|
|
96
|
+
const AutomationSafetyPolicySchema = z.object({ mode: z.enum([
|
|
97
|
+
"suggest_only",
|
|
98
|
+
"ask_before_apply",
|
|
99
|
+
"auto_apply"
|
|
100
|
+
]) }).strict();
|
|
101
|
+
const AutomationStateSchema = z.object({
|
|
102
|
+
nextRunAtMs: z.number().int().nonnegative().optional(),
|
|
103
|
+
runningRunId: optionalTrimmedString(100),
|
|
104
|
+
lastRunAtMs: z.number().int().nonnegative().optional(),
|
|
105
|
+
lastRunStatus: z.enum([
|
|
106
|
+
"queued",
|
|
107
|
+
"running",
|
|
108
|
+
"succeeded",
|
|
109
|
+
"failed",
|
|
110
|
+
"cancelled",
|
|
111
|
+
"timeout"
|
|
112
|
+
]).optional(),
|
|
113
|
+
lastError: z.string().optional(),
|
|
114
|
+
consecutiveFailures: z.number().int().nonnegative().optional()
|
|
115
|
+
}).strict();
|
|
116
|
+
const AutomationSchema = z.object({
|
|
117
|
+
id: nonEmptyString.max(100),
|
|
118
|
+
name: nonEmptyString.max(200),
|
|
119
|
+
description: z.string().max(2e3).optional(),
|
|
120
|
+
enabled: z.boolean(),
|
|
121
|
+
trigger: AutomationTriggerSchema,
|
|
122
|
+
action: AutomationActionSchema,
|
|
123
|
+
safety: AutomationSafetyPolicySchema.optional(),
|
|
124
|
+
afterRun: AutomationAfterRunSchema.optional(),
|
|
125
|
+
reliability: AutomationReliabilitySchema.optional(),
|
|
126
|
+
state: AutomationStateSchema.default({}),
|
|
127
|
+
createdAtMs: z.number().int().nonnegative(),
|
|
128
|
+
updatedAtMs: z.number().int().nonnegative()
|
|
129
|
+
}).strict();
|
|
130
|
+
const CreateAutomationSchema = AutomationSchema.omit({
|
|
131
|
+
id: true,
|
|
132
|
+
enabled: true,
|
|
133
|
+
state: true,
|
|
134
|
+
createdAtMs: true,
|
|
135
|
+
updatedAtMs: true
|
|
136
|
+
}).extend({
|
|
137
|
+
id: optionalTrimmedString(100),
|
|
138
|
+
enabled: z.boolean().optional(),
|
|
139
|
+
state: AutomationStateSchema.partial().optional()
|
|
140
|
+
});
|
|
141
|
+
const UpdateAutomationSchema = AutomationSchema.omit({
|
|
142
|
+
id: true,
|
|
143
|
+
createdAtMs: true,
|
|
144
|
+
updatedAtMs: true
|
|
145
|
+
}).partial().refine((data) => Object.keys(data).length > 0, { message: "At least one field must be provided" });
|
|
146
|
+
//#endregion
|
|
147
|
+
export { AutomationActionSchema, AutomationAfterRunSchema, AutomationReliabilitySchema, AutomationSafetyPolicySchema, AutomationScheduleSchema, AutomationSchema, AutomationStateSchema, AutomationTriggerSchema, CreateAutomationSchema, UpdateAutomationSchema };
|
|
148
|
+
|
|
149
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","names":[],"sources":["../../../../src/automations/domain/validation.ts"],"sourcesContent":["import { CronExpressionParser } from 'cron-parser';\nimport { z } from 'zod';\n\nconst nonEmptyString = z.string().trim().min(1);\n\nconst optionalTrimmedString = (max: number) =>\n z.preprocess((value) => {\n if (value == null) return undefined;\n if (typeof value !== 'string') return value;\n const trimmed = value.trim();\n return trimmed.length === 0 ? undefined : trimmed;\n }, z.string().min(1).max(max).optional());\n\nexport const AutomationScheduleSchema = z.discriminatedUnion('kind', [\n z.object({\n kind: z.literal('once'),\n at: nonEmptyString,\n }).strict(),\n z.object({\n kind: z.literal('interval'),\n everyMs: z.number().int().min(1),\n anchorMs: z.number().int().nonnegative().optional(),\n }).strict(),\n z.object({\n kind: z.literal('cron'),\n expr: nonEmptyString.superRefine((expr, ctx) => {\n try {\n CronExpressionParser.parse(expr);\n } catch {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `Invalid cron expression: ${expr}`,\n });\n }\n }),\n tz: optionalTrimmedString(100),\n }).strict(),\n]);\n\nexport const AutomationTriggerSchema = z.discriminatedUnion('kind', [\n z.object({ kind: z.literal('manual') }).strict(),\n z.object({\n kind: z.literal('schedule'),\n schedule: AutomationScheduleSchema,\n }).strict(),\n z.object({\n kind: z.literal('webhook'),\n secretId: optionalTrimmedString(200),\n }).strict(),\n z.object({\n kind: z.literal('event'),\n eventType: nonEmptyString.max(200),\n source: optionalTrimmedString(200),\n payloadMatch: z.record(\n z.string(),\n z.union([z.string(), z.number(), z.boolean(), z.null()]),\n ).optional(),\n }).strict(),\n]);\n\nconst WorkflowRunInputEnvelopeSchema = z.object({\n payload: z.unknown(),\n goal: optionalTrimmedString(5000),\n variables: z.record(z.string(), z.unknown()).optional(),\n context: z.record(z.string(), z.unknown()).optional(),\n}).strict();\n\nexport const AutomationActionSchema = z.discriminatedUnion('kind', [\n z.object({\n kind: z.literal('agent'),\n agentId: optionalTrimmedString(64),\n instruction: nonEmptyString.max(50000),\n workingDirectory: optionalTrimmedString(4096),\n model: optionalTrimmedString(100),\n timeoutSeconds: z.number().int().min(1).max(86400).optional(),\n }).strict(),\n z.object({\n kind: z.literal('workflow'),\n workflowId: nonEmptyString.max(200),\n agentId: optionalTrimmedString(64),\n input: z.unknown().optional(),\n inputEnvelope: WorkflowRunInputEnvelopeSchema.optional(),\n goal: optionalTrimmedString(5000),\n concurrency: z.number().int().min(1).max(50).optional(),\n maxSubagents: z.number().int().min(1).max(100).optional(),\n timeoutSeconds: z.number().int().min(1).max(86400).optional(),\n }).strict(),\n]);\n\nexport const AutomationAfterRunSchema = z.discriminatedUnion('kind', [\n z.object({ kind: z.literal('none') }).strict(),\n z.object({ kind: z.literal('saveToSession') }).strict(),\n z.object({\n kind: z.literal('webhook'),\n url: nonEmptyString.max(2000),\n }).strict(),\n]);\n\nexport const AutomationReliabilitySchema = z.object({\n timeoutSeconds: z.number().int().min(1).max(86400).optional(),\n retryCount: z.number().int().min(0).max(10).optional(),\n maxConcurrentRuns: z.number().int().min(1).max(20).optional(),\n disableAfterConsecutiveFailures: z.number().int().min(1).max(100).optional(),\n}).strict();\n\nexport const AutomationSafetyPolicySchema = z.object({\n mode: z.enum(['suggest_only', 'ask_before_apply', 'auto_apply']),\n}).strict();\n\nexport const AutomationStateSchema = z.object({\n nextRunAtMs: z.number().int().nonnegative().optional(),\n runningRunId: optionalTrimmedString(100),\n lastRunAtMs: z.number().int().nonnegative().optional(),\n lastRunStatus: z.enum(['queued', 'running', 'succeeded', 'failed', 'cancelled', 'timeout']).optional(),\n lastError: z.string().optional(),\n consecutiveFailures: z.number().int().nonnegative().optional(),\n}).strict();\n\nexport const AutomationSchema = z.object({\n id: nonEmptyString.max(100),\n name: nonEmptyString.max(200),\n description: z.string().max(2000).optional(),\n enabled: z.boolean(),\n trigger: AutomationTriggerSchema,\n action: AutomationActionSchema,\n safety: AutomationSafetyPolicySchema.optional(),\n afterRun: AutomationAfterRunSchema.optional(),\n reliability: AutomationReliabilitySchema.optional(),\n state: AutomationStateSchema.default({}),\n createdAtMs: z.number().int().nonnegative(),\n updatedAtMs: z.number().int().nonnegative(),\n}).strict();\n\nexport const CreateAutomationSchema = AutomationSchema.omit({\n id: true,\n enabled: true,\n state: true,\n createdAtMs: true,\n updatedAtMs: true,\n}).extend({\n id: optionalTrimmedString(100),\n enabled: z.boolean().optional(),\n state: AutomationStateSchema.partial().optional(),\n});\n\nexport const UpdateAutomationSchema = AutomationSchema.omit({\n id: true,\n createdAtMs: true,\n updatedAtMs: true,\n}).partial().refine(\n (data) => Object.keys(data).length > 0,\n { message: 'At least one field must be provided' },\n);\n\nexport type CreateAutomationInput = z.infer<typeof CreateAutomationSchema>;\nexport type UpdateAutomationInput = z.infer<typeof UpdateAutomationSchema>;\n"],"mappings":"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"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface AutomationDraftRepairIssue {
|
|
2
|
+
source: 'parse' | 'validation';
|
|
3
|
+
severity: 'error';
|
|
4
|
+
message: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function buildAutomationDraftPrompt(params: {
|
|
7
|
+
prompt: string;
|
|
8
|
+
language?: 'en' | 'zh';
|
|
9
|
+
}): string;
|
|
10
|
+
export declare function buildAutomationDraftRepairPrompt(params: {
|
|
11
|
+
prompt: string;
|
|
12
|
+
language?: 'en' | 'zh';
|
|
13
|
+
previousOutput: string;
|
|
14
|
+
issues: AutomationDraftRepairIssue[];
|
|
15
|
+
}): string;
|
|
16
|
+
export declare function buildAutomationRunRepairPrompt(params: {
|
|
17
|
+
language?: 'en' | 'zh';
|
|
18
|
+
automation: unknown;
|
|
19
|
+
run: unknown;
|
|
20
|
+
events: unknown[];
|
|
21
|
+
}): string;
|
|
22
|
+
export declare function buildAutomationRunRepairRetryPrompt(params: {
|
|
23
|
+
language?: 'en' | 'zh';
|
|
24
|
+
previousOutput: string;
|
|
25
|
+
issues: AutomationDraftRepairIssue[];
|
|
26
|
+
}): string;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
//#region src/automations/draft/automation-draft-prompt.ts
|
|
2
|
+
function buildAutomationDraftPrompt(params) {
|
|
3
|
+
return `You generate xopc automation drafts. Return ONLY a JSON object, no markdown.
|
|
4
|
+
|
|
5
|
+
JSON shape:
|
|
6
|
+
{
|
|
7
|
+
"automation": {
|
|
8
|
+
"name": "Short human name",
|
|
9
|
+
"description": "What this automation does",
|
|
10
|
+
"trigger": { "kind": "manual" },
|
|
11
|
+
"action": { "kind": "agent", "instruction": "clear instruction for the agent" },
|
|
12
|
+
"safety": { "mode": "suggest_only" },
|
|
13
|
+
"afterRun": { "kind": "none" },
|
|
14
|
+
"reliability": { "timeoutSeconds": 300, "disableAfterConsecutiveFailures": 3 }
|
|
15
|
+
},
|
|
16
|
+
"explanation": "Short explanation",
|
|
17
|
+
"assumptions": ["..."],
|
|
18
|
+
"risks": ["..."]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Allowed triggers:
|
|
22
|
+
- Manual: { "kind": "manual" }
|
|
23
|
+
- Schedule interval: { "kind": "schedule", "schedule": { "kind": "interval", "everyMs": 3600000 } }
|
|
24
|
+
- Schedule cron: { "kind": "schedule", "schedule": { "kind": "cron", "expr": "0 9 * * *" } }
|
|
25
|
+
- Webhook: { "kind": "webhook", "secretId": "optional-short-id" }
|
|
26
|
+
- Product event: { "kind": "event", "eventType": "goal.status_changed", "source": "goals", "payloadMatch": { "status": "blocked" } }
|
|
27
|
+
|
|
28
|
+
Useful product events:
|
|
29
|
+
- session.message.created
|
|
30
|
+
- session.transcript.updated
|
|
31
|
+
- note.created
|
|
32
|
+
- note.updated
|
|
33
|
+
- goal.created
|
|
34
|
+
- goal.status_changed
|
|
35
|
+
- workflow.run.completed
|
|
36
|
+
- channel.message.received
|
|
37
|
+
|
|
38
|
+
Allowed actions:
|
|
39
|
+
- Agent: { "kind": "agent", "agentId": "optional", "instruction": "what to do", "timeoutSeconds": 300 }
|
|
40
|
+
- Workflow: { "kind": "workflow", "workflowId": "known_workflow_id", "input": {}, "goal": "optional", "timeoutSeconds": 300 }
|
|
41
|
+
|
|
42
|
+
Safety modes:
|
|
43
|
+
- { "mode": "suggest_only" }: safest default, generate recommendations only.
|
|
44
|
+
- { "mode": "ask_before_apply" }: draft actions and require user confirmation before applying.
|
|
45
|
+
- { "mode": "auto_apply" }: trusted automation may act automatically.
|
|
46
|
+
|
|
47
|
+
Rules:
|
|
48
|
+
- Prefer agent actions unless the user names a specific existing workflow id.
|
|
49
|
+
- Default to safety { "mode": "suggest_only" } unless the user explicitly asks for fully automatic execution.
|
|
50
|
+
- Do not invent destructive actions. For deletion, external sending, or irreversible changes, include a risk and make the instruction ask for confirmation.
|
|
51
|
+
- Use cron for daily/weekly schedules. Use standard 5-field cron.
|
|
52
|
+
- Keep timeoutSeconds between 60 and 1800.
|
|
53
|
+
- afterRun should usually be { "kind": "none" }.
|
|
54
|
+
- Language for user-facing copy: ${params.language ?? "en"}.
|
|
55
|
+
|
|
56
|
+
User request:
|
|
57
|
+
${params.prompt.slice(0, 8e3)}
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
60
|
+
function buildAutomationDraftRepairPrompt(params) {
|
|
61
|
+
return `Repair the xopc automation draft. Return ONLY a JSON object with the same shape.
|
|
62
|
+
|
|
63
|
+
Original user request:
|
|
64
|
+
${params.prompt.slice(0, 8e3)}
|
|
65
|
+
|
|
66
|
+
Language for user-facing copy: ${params.language ?? "en"}
|
|
67
|
+
|
|
68
|
+
Previous output:
|
|
69
|
+
${params.previousOutput.slice(0, 12e3)}
|
|
70
|
+
|
|
71
|
+
Issues:
|
|
72
|
+
${params.issues.map((issue) => `- ${issue.source}: ${issue.message}`).join("\n")}
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
function buildAutomationRunRepairPrompt(params) {
|
|
76
|
+
return `You suggest safe repair patches for xopc automations. Return ONLY a JSON object, no markdown.
|
|
77
|
+
|
|
78
|
+
JSON shape:
|
|
79
|
+
{
|
|
80
|
+
"patch": {
|
|
81
|
+
"description": "optional improved description",
|
|
82
|
+
"trigger": "optional complete trigger object",
|
|
83
|
+
"action": "optional complete action object",
|
|
84
|
+
"safety": "optional complete safety object",
|
|
85
|
+
"afterRun": "optional complete afterRun object",
|
|
86
|
+
"reliability": "optional complete reliability object",
|
|
87
|
+
"enabled": true
|
|
88
|
+
},
|
|
89
|
+
"explanation": "Why this patch should fix the failed run",
|
|
90
|
+
"expectedEffect": "What changes after applying it",
|
|
91
|
+
"risks": ["..."],
|
|
92
|
+
"requiresApproval": true
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
Rules:
|
|
96
|
+
- Return a PATCH only. Do not include id, state, createdAtMs, or updatedAtMs.
|
|
97
|
+
- Keep the patch minimal. Prefer reliability/action/input fixes over broad rewrites.
|
|
98
|
+
- If the failure is unclear, propose only a safer timeout/retry/description patch and explain uncertainty.
|
|
99
|
+
- Never add destructive or external behavior. If the existing automation has risky external behavior, keep requiresApproval true.
|
|
100
|
+
- Language for user-facing copy: ${params.language ?? "en"}.
|
|
101
|
+
|
|
102
|
+
Current automation:
|
|
103
|
+
${JSON.stringify(params.automation, null, 2).slice(0, 12e3)}
|
|
104
|
+
|
|
105
|
+
Failed run:
|
|
106
|
+
${JSON.stringify(params.run, null, 2).slice(0, 8e3)}
|
|
107
|
+
|
|
108
|
+
Timeline events:
|
|
109
|
+
${JSON.stringify(params.events, null, 2).slice(0, 12e3)}
|
|
110
|
+
`;
|
|
111
|
+
}
|
|
112
|
+
function buildAutomationRunRepairRetryPrompt(params) {
|
|
113
|
+
return `Repair the automation repair patch. Return ONLY a JSON object with the same shape.
|
|
114
|
+
|
|
115
|
+
Language for user-facing copy: ${params.language ?? "en"}
|
|
116
|
+
|
|
117
|
+
Previous output:
|
|
118
|
+
${params.previousOutput.slice(0, 12e3)}
|
|
119
|
+
|
|
120
|
+
Issues:
|
|
121
|
+
${params.issues.map((issue) => `- ${issue.source}: ${issue.message}`).join("\n")}
|
|
122
|
+
`;
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { buildAutomationDraftPrompt, buildAutomationDraftRepairPrompt, buildAutomationRunRepairPrompt, buildAutomationRunRepairRetryPrompt };
|
|
126
|
+
|
|
127
|
+
//# sourceMappingURL=automation-draft-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automation-draft-prompt.js","names":[],"sources":["../../../../src/automations/draft/automation-draft-prompt.ts"],"sourcesContent":["export interface AutomationDraftRepairIssue {\n source: 'parse' | 'validation';\n severity: 'error';\n message: string;\n}\n\nexport function buildAutomationDraftPrompt(params: {\n prompt: string;\n language?: 'en' | 'zh';\n}): string {\n return `You generate xopc automation drafts. Return ONLY a JSON object, no markdown.\n\nJSON shape:\n{\n \"automation\": {\n \"name\": \"Short human name\",\n \"description\": \"What this automation does\",\n \"trigger\": { \"kind\": \"manual\" },\n \"action\": { \"kind\": \"agent\", \"instruction\": \"clear instruction for the agent\" },\n \"safety\": { \"mode\": \"suggest_only\" },\n \"afterRun\": { \"kind\": \"none\" },\n \"reliability\": { \"timeoutSeconds\": 300, \"disableAfterConsecutiveFailures\": 3 }\n },\n \"explanation\": \"Short explanation\",\n \"assumptions\": [\"...\"],\n \"risks\": [\"...\"]\n}\n\nAllowed triggers:\n- Manual: { \"kind\": \"manual\" }\n- Schedule interval: { \"kind\": \"schedule\", \"schedule\": { \"kind\": \"interval\", \"everyMs\": 3600000 } }\n- Schedule cron: { \"kind\": \"schedule\", \"schedule\": { \"kind\": \"cron\", \"expr\": \"0 9 * * *\" } }\n- Webhook: { \"kind\": \"webhook\", \"secretId\": \"optional-short-id\" }\n- Product event: { \"kind\": \"event\", \"eventType\": \"goal.status_changed\", \"source\": \"goals\", \"payloadMatch\": { \"status\": \"blocked\" } }\n\nUseful product events:\n- session.message.created\n- session.transcript.updated\n- note.created\n- note.updated\n- goal.created\n- goal.status_changed\n- workflow.run.completed\n- channel.message.received\n\nAllowed actions:\n- Agent: { \"kind\": \"agent\", \"agentId\": \"optional\", \"instruction\": \"what to do\", \"timeoutSeconds\": 300 }\n- Workflow: { \"kind\": \"workflow\", \"workflowId\": \"known_workflow_id\", \"input\": {}, \"goal\": \"optional\", \"timeoutSeconds\": 300 }\n\nSafety modes:\n- { \"mode\": \"suggest_only\" }: safest default, generate recommendations only.\n- { \"mode\": \"ask_before_apply\" }: draft actions and require user confirmation before applying.\n- { \"mode\": \"auto_apply\" }: trusted automation may act automatically.\n\nRules:\n- Prefer agent actions unless the user names a specific existing workflow id.\n- Default to safety { \"mode\": \"suggest_only\" } unless the user explicitly asks for fully automatic execution.\n- Do not invent destructive actions. For deletion, external sending, or irreversible changes, include a risk and make the instruction ask for confirmation.\n- Use cron for daily/weekly schedules. Use standard 5-field cron.\n- Keep timeoutSeconds between 60 and 1800.\n- afterRun should usually be { \"kind\": \"none\" }.\n- Language for user-facing copy: ${params.language ?? 'en'}.\n\nUser request:\n${params.prompt.slice(0, 8000)}\n`;\n}\n\nexport function buildAutomationDraftRepairPrompt(params: {\n prompt: string;\n language?: 'en' | 'zh';\n previousOutput: string;\n issues: AutomationDraftRepairIssue[];\n}): string {\n return `Repair the xopc automation draft. Return ONLY a JSON object with the same shape.\n\nOriginal user request:\n${params.prompt.slice(0, 8000)}\n\nLanguage for user-facing copy: ${params.language ?? 'en'}\n\nPrevious output:\n${params.previousOutput.slice(0, 12000)}\n\nIssues:\n${params.issues.map((issue) => `- ${issue.source}: ${issue.message}`).join('\\n')}\n`;\n}\n\nexport function buildAutomationRunRepairPrompt(params: {\n language?: 'en' | 'zh';\n automation: unknown;\n run: unknown;\n events: unknown[];\n}): string {\n return `You suggest safe repair patches for xopc automations. Return ONLY a JSON object, no markdown.\n\nJSON shape:\n{\n \"patch\": {\n \"description\": \"optional improved description\",\n \"trigger\": \"optional complete trigger object\",\n \"action\": \"optional complete action object\",\n \"safety\": \"optional complete safety object\",\n \"afterRun\": \"optional complete afterRun object\",\n \"reliability\": \"optional complete reliability object\",\n \"enabled\": true\n },\n \"explanation\": \"Why this patch should fix the failed run\",\n \"expectedEffect\": \"What changes after applying it\",\n \"risks\": [\"...\"],\n \"requiresApproval\": true\n}\n\nRules:\n- Return a PATCH only. Do not include id, state, createdAtMs, or updatedAtMs.\n- Keep the patch minimal. Prefer reliability/action/input fixes over broad rewrites.\n- If the failure is unclear, propose only a safer timeout/retry/description patch and explain uncertainty.\n- Never add destructive or external behavior. If the existing automation has risky external behavior, keep requiresApproval true.\n- Language for user-facing copy: ${params.language ?? 'en'}.\n\nCurrent automation:\n${JSON.stringify(params.automation, null, 2).slice(0, 12000)}\n\nFailed run:\n${JSON.stringify(params.run, null, 2).slice(0, 8000)}\n\nTimeline events:\n${JSON.stringify(params.events, null, 2).slice(0, 12000)}\n`;\n}\n\nexport function buildAutomationRunRepairRetryPrompt(params: {\n language?: 'en' | 'zh';\n previousOutput: string;\n issues: AutomationDraftRepairIssue[];\n}): string {\n return `Repair the automation repair patch. Return ONLY a JSON object with the same shape.\n\nLanguage for user-facing copy: ${params.language ?? 'en'}\n\nPrevious output:\n${params.previousOutput.slice(0, 12000)}\n\nIssues:\n${params.issues.map((issue) => `- ${issue.source}: ${issue.message}`).join('\\n')}\n`;\n}\n"],"mappings":";AAMA,SAAgB,2BAA2B,QAGhC;AACT,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCAmD0B,OAAO,YAAY,KAAK;;;EAGzD,OAAO,OAAO,MAAM,GAAG,IAAK,CAAC;;;AAI/B,SAAgB,iCAAiC,QAKtC;AACT,QAAO;;;EAGP,OAAO,OAAO,MAAM,GAAG,IAAK,CAAC;;iCAEE,OAAO,YAAY,KAAK;;;EAGvD,OAAO,eAAe,MAAM,GAAG,KAAM,CAAC;;;EAGtC,OAAO,OAAO,KAAK,UAAU,KAAK,MAAM,OAAO,IAAI,MAAM,UAAU,CAAC,KAAK,KAAK,CAAC;;;AAIjF,SAAgB,+BAA+B,QAKpC;AACT,QAAO;;;;;;;;;;;;;;;;;;;;;;;;mCAwB0B,OAAO,YAAY,KAAK;;;EAGzD,KAAK,UAAU,OAAO,YAAY,MAAM,EAAE,CAAC,MAAM,GAAG,KAAM,CAAC;;;EAG3D,KAAK,UAAU,OAAO,KAAK,MAAM,EAAE,CAAC,MAAM,GAAG,IAAK,CAAC;;;EAGnD,KAAK,UAAU,OAAO,QAAQ,MAAM,EAAE,CAAC,MAAM,GAAG,KAAM,CAAC;;;AAIzD,SAAgB,oCAAoC,QAIzC;AACT,QAAO;;iCAEwB,OAAO,YAAY,KAAK;;;EAGvD,OAAO,eAAe,MAAM,GAAG,KAAM,CAAC;;;EAGtC,OAAO,OAAO,KAAK,UAAU,KAAK,MAAM,OAAO,IAAI,MAAM,UAAU,CAAC,KAAK,KAAK,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Config } from '../../config/schema.js';
|
|
2
|
+
import type { AutomationDraftResponse, AutomationRepairDraftResponse, CreateAutomationDraftRequest, CreateAutomationRepairDraftRequest } from './automation-draft.types.js';
|
|
3
|
+
export interface AutomationDraftServiceOptions {
|
|
4
|
+
config: Config;
|
|
5
|
+
maxRepairAttempts?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class AutomationDraftService {
|
|
8
|
+
private readonly options;
|
|
9
|
+
constructor(options: AutomationDraftServiceOptions);
|
|
10
|
+
createDraft(request: CreateAutomationDraftRequest, signal?: AbortSignal): Promise<AutomationDraftResponse>;
|
|
11
|
+
createRepairDraft(request: CreateAutomationRepairDraftRequest, signal?: AbortSignal): Promise<AutomationRepairDraftResponse>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { createLogger } from "../../utils/logger/index.js";
|
|
2
|
+
import { init_logger } from "../../utils/logger.js";
|
|
3
|
+
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
4
|
+
import { resolveDraftModelRef } from "../../workflows/draft/workflow-draft-service.js";
|
|
5
|
+
import { buildAutomationDraftPrompt, buildAutomationDraftRepairPrompt, buildAutomationRunRepairPrompt, buildAutomationRunRepairRetryPrompt } from "./automation-draft-prompt.js";
|
|
6
|
+
import { buildAutomationDraftResponse, parseGeneratedAutomationDraft, parseGeneratedAutomationRepairDraft } from "./automation-draft-validator.js";
|
|
7
|
+
import { complete } from "@earendil-works/pi-ai";
|
|
8
|
+
//#region src/automations/draft/automation-draft-service.ts
|
|
9
|
+
init_providers();
|
|
10
|
+
init_logger();
|
|
11
|
+
const log = createLogger("AutomationDraft");
|
|
12
|
+
const DEFAULT_MAX_REPAIR_ATTEMPTS = 2;
|
|
13
|
+
var AutomationDraftService = class {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
this.options = options;
|
|
16
|
+
}
|
|
17
|
+
async createDraft(request, signal) {
|
|
18
|
+
const prompt = request.prompt.trim();
|
|
19
|
+
if (!prompt) throw new Error("prompt is required");
|
|
20
|
+
const modelRef = resolveDraftModelRef(this.options.config, request.agentId);
|
|
21
|
+
const model = resolveModel(modelRef);
|
|
22
|
+
const maxRepairAttempts = this.options.maxRepairAttempts ?? DEFAULT_MAX_REPAIR_ATTEMPTS;
|
|
23
|
+
let messageContent = buildAutomationDraftPrompt({
|
|
24
|
+
prompt,
|
|
25
|
+
language: request.language
|
|
26
|
+
});
|
|
27
|
+
let lastText = "";
|
|
28
|
+
let lastIssues = [];
|
|
29
|
+
for (let attempt = 0; attempt <= maxRepairAttempts; attempt += 1) {
|
|
30
|
+
lastText = extractText(await complete(model, { messages: [{
|
|
31
|
+
role: "user",
|
|
32
|
+
content: messageContent,
|
|
33
|
+
timestamp: Date.now()
|
|
34
|
+
}] }, {
|
|
35
|
+
maxTokens: 2048,
|
|
36
|
+
temperature: attempt === 0 ? .2 : .1,
|
|
37
|
+
signal
|
|
38
|
+
}));
|
|
39
|
+
try {
|
|
40
|
+
return buildAutomationDraftResponse(parseGeneratedAutomationDraft(lastText), attempt);
|
|
41
|
+
} catch (err) {
|
|
42
|
+
lastIssues = [{
|
|
43
|
+
source: "validation",
|
|
44
|
+
severity: "error",
|
|
45
|
+
message: err instanceof Error ? err.message : String(err)
|
|
46
|
+
}];
|
|
47
|
+
}
|
|
48
|
+
if (attempt >= maxRepairAttempts) break;
|
|
49
|
+
log.warn({
|
|
50
|
+
modelRef,
|
|
51
|
+
attempt: attempt + 1,
|
|
52
|
+
issueCount: lastIssues.length,
|
|
53
|
+
preview: lastText.slice(0, 500)
|
|
54
|
+
}, "Automation draft validation failed; asking model to repair");
|
|
55
|
+
messageContent = buildAutomationDraftRepairPrompt({
|
|
56
|
+
prompt,
|
|
57
|
+
language: request.language,
|
|
58
|
+
previousOutput: lastText,
|
|
59
|
+
issues: lastIssues
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const message = `Unable to generate a valid automation draft after ${maxRepairAttempts + 1} attempts`;
|
|
63
|
+
log.warn({
|
|
64
|
+
modelRef,
|
|
65
|
+
issues: lastIssues,
|
|
66
|
+
preview: lastText.slice(0, 500)
|
|
67
|
+
}, message);
|
|
68
|
+
throw new Error(message);
|
|
69
|
+
}
|
|
70
|
+
async createRepairDraft(request, signal) {
|
|
71
|
+
const modelRef = resolveDraftModelRef(this.options.config, request.agentId);
|
|
72
|
+
const model = resolveModel(modelRef);
|
|
73
|
+
const maxRepairAttempts = this.options.maxRepairAttempts ?? DEFAULT_MAX_REPAIR_ATTEMPTS;
|
|
74
|
+
let messageContent = buildAutomationRunRepairPrompt({
|
|
75
|
+
language: request.language,
|
|
76
|
+
automation: request.automation,
|
|
77
|
+
run: request.run,
|
|
78
|
+
events: request.events
|
|
79
|
+
});
|
|
80
|
+
let lastText = "";
|
|
81
|
+
let lastIssues = [];
|
|
82
|
+
for (let attempt = 0; attempt <= maxRepairAttempts; attempt += 1) {
|
|
83
|
+
lastText = extractText(await complete(model, { messages: [{
|
|
84
|
+
role: "user",
|
|
85
|
+
content: messageContent,
|
|
86
|
+
timestamp: Date.now()
|
|
87
|
+
}] }, {
|
|
88
|
+
maxTokens: 2048,
|
|
89
|
+
temperature: attempt === 0 ? .15 : .05,
|
|
90
|
+
signal
|
|
91
|
+
}));
|
|
92
|
+
try {
|
|
93
|
+
return parseGeneratedAutomationRepairDraft(lastText, attempt);
|
|
94
|
+
} catch (err) {
|
|
95
|
+
lastIssues = [{
|
|
96
|
+
source: "validation",
|
|
97
|
+
severity: "error",
|
|
98
|
+
message: err instanceof Error ? err.message : String(err)
|
|
99
|
+
}];
|
|
100
|
+
}
|
|
101
|
+
if (attempt >= maxRepairAttempts) break;
|
|
102
|
+
log.warn({
|
|
103
|
+
modelRef,
|
|
104
|
+
attempt: attempt + 1,
|
|
105
|
+
issueCount: lastIssues.length,
|
|
106
|
+
preview: lastText.slice(0, 500)
|
|
107
|
+
}, "Automation repair draft validation failed; asking model to repair");
|
|
108
|
+
messageContent = buildAutomationRunRepairRetryPrompt({
|
|
109
|
+
language: request.language,
|
|
110
|
+
previousOutput: lastText,
|
|
111
|
+
issues: lastIssues
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const message = `Unable to generate a valid automation repair draft after ${maxRepairAttempts + 1} attempts`;
|
|
115
|
+
log.warn({
|
|
116
|
+
modelRef,
|
|
117
|
+
issues: lastIssues,
|
|
118
|
+
preview: lastText.slice(0, 500)
|
|
119
|
+
}, message);
|
|
120
|
+
throw new Error(message);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
function extractText(result) {
|
|
124
|
+
const content = result.content;
|
|
125
|
+
if (typeof content === "string") return content;
|
|
126
|
+
if (Array.isArray(content)) return content.map((item) => {
|
|
127
|
+
if (item && typeof item === "object" && item.type === "text") return String(item.text ?? "");
|
|
128
|
+
return "";
|
|
129
|
+
}).join("");
|
|
130
|
+
return "";
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
export { AutomationDraftService };
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=automation-draft-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automation-draft-service.js","names":[],"sources":["../../../../src/automations/draft/automation-draft-service.ts"],"sourcesContent":["import { complete, type UserMessage } from '@earendil-works/pi-ai';\n\nimport type { Config } from '../../config/schema.js';\nimport { resolveModel } from '../../providers/index.js';\nimport { createLogger } from '../../utils/logger.js';\nimport { resolveDraftModelRef } from '../../workflows/draft/workflow-draft-service.js';\nimport {\n buildAutomationDraftPrompt,\n buildAutomationDraftRepairPrompt,\n buildAutomationRunRepairPrompt,\n buildAutomationRunRepairRetryPrompt,\n type AutomationDraftRepairIssue,\n} from './automation-draft-prompt.js';\nimport type {\n AutomationDraftResponse,\n AutomationRepairDraftResponse,\n CreateAutomationDraftRequest,\n CreateAutomationRepairDraftRequest,\n} from './automation-draft.types.js';\nimport {\n buildAutomationDraftResponse,\n parseGeneratedAutomationDraft,\n parseGeneratedAutomationRepairDraft,\n} from './automation-draft-validator.js';\n\nconst log = createLogger('AutomationDraft');\nconst DEFAULT_MAX_REPAIR_ATTEMPTS = 2;\n\nexport interface AutomationDraftServiceOptions {\n config: Config;\n maxRepairAttempts?: number;\n}\n\nexport class AutomationDraftService {\n constructor(private readonly options: AutomationDraftServiceOptions) {}\n\n async createDraft(request: CreateAutomationDraftRequest, signal?: AbortSignal): Promise<AutomationDraftResponse> {\n const prompt = request.prompt.trim();\n if (!prompt) throw new Error('prompt is required');\n\n const modelRef = resolveDraftModelRef(this.options.config, request.agentId);\n const model = resolveModel(modelRef);\n const maxRepairAttempts = this.options.maxRepairAttempts ?? DEFAULT_MAX_REPAIR_ATTEMPTS;\n let messageContent = buildAutomationDraftPrompt({ prompt, language: request.language });\n let lastText = '';\n let lastIssues: AutomationDraftRepairIssue[] = [];\n\n for (let attempt = 0; attempt <= maxRepairAttempts; attempt += 1) {\n const userMsg: UserMessage = {\n role: 'user',\n content: messageContent,\n timestamp: Date.now(),\n };\n const result = await complete(\n model,\n { messages: [userMsg] },\n { maxTokens: 2048, temperature: attempt === 0 ? 0.2 : 0.1, signal },\n );\n lastText = extractText(result);\n try {\n const draft = parseGeneratedAutomationDraft(lastText);\n return buildAutomationDraftResponse(draft, attempt);\n } catch (err) {\n lastIssues = [{\n source: 'validation',\n severity: 'error',\n message: err instanceof Error ? err.message : String(err),\n }];\n }\n\n if (attempt >= maxRepairAttempts) break;\n log.warn(\n { modelRef, attempt: attempt + 1, issueCount: lastIssues.length, preview: lastText.slice(0, 500) },\n 'Automation draft validation failed; asking model to repair',\n );\n messageContent = buildAutomationDraftRepairPrompt({\n prompt,\n language: request.language,\n previousOutput: lastText,\n issues: lastIssues,\n });\n }\n\n const message = `Unable to generate a valid automation draft after ${maxRepairAttempts + 1} attempts`;\n log.warn({ modelRef, issues: lastIssues, preview: lastText.slice(0, 500) }, message);\n throw new Error(message);\n }\n\n async createRepairDraft(\n request: CreateAutomationRepairDraftRequest,\n signal?: AbortSignal,\n ): Promise<AutomationRepairDraftResponse> {\n const modelRef = resolveDraftModelRef(this.options.config, request.agentId);\n const model = resolveModel(modelRef);\n const maxRepairAttempts = this.options.maxRepairAttempts ?? DEFAULT_MAX_REPAIR_ATTEMPTS;\n let messageContent = buildAutomationRunRepairPrompt({\n language: request.language,\n automation: request.automation,\n run: request.run,\n events: request.events,\n });\n let lastText = '';\n let lastIssues: AutomationDraftRepairIssue[] = [];\n\n for (let attempt = 0; attempt <= maxRepairAttempts; attempt += 1) {\n const userMsg: UserMessage = {\n role: 'user',\n content: messageContent,\n timestamp: Date.now(),\n };\n const result = await complete(\n model,\n { messages: [userMsg] },\n { maxTokens: 2048, temperature: attempt === 0 ? 0.15 : 0.05, signal },\n );\n lastText = extractText(result);\n try {\n return parseGeneratedAutomationRepairDraft(lastText, attempt);\n } catch (err) {\n lastIssues = [{\n source: 'validation',\n severity: 'error',\n message: err instanceof Error ? err.message : String(err),\n }];\n }\n\n if (attempt >= maxRepairAttempts) break;\n log.warn(\n { modelRef, attempt: attempt + 1, issueCount: lastIssues.length, preview: lastText.slice(0, 500) },\n 'Automation repair draft validation failed; asking model to repair',\n );\n messageContent = buildAutomationRunRepairRetryPrompt({\n language: request.language,\n previousOutput: lastText,\n issues: lastIssues,\n });\n }\n\n const message = `Unable to generate a valid automation repair draft after ${maxRepairAttempts + 1} attempts`;\n log.warn({ modelRef, issues: lastIssues, preview: lastText.slice(0, 500) }, message);\n throw new Error(message);\n }\n}\n\nfunction extractText(result: unknown): string {\n const content = (result as { content?: unknown }).content;\n if (typeof content === 'string') return content;\n if (Array.isArray(content)) {\n return content.map((item) => {\n if (item && typeof item === 'object' && (item as { type?: string }).type === 'text') {\n return String((item as { text?: string }).text ?? '');\n }\n return '';\n }).join('');\n }\n return '';\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { CreateAutomationInput } from '../domain/validation.js';
|
|
2
|
+
import type { AutomationRepairDraftResponse, AutomationSimulation } from './automation-draft.types.js';
|
|
3
|
+
interface GeneratedAutomationDraft {
|
|
4
|
+
automation: CreateAutomationInput;
|
|
5
|
+
explanation: string;
|
|
6
|
+
assumptions: string[];
|
|
7
|
+
risks: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare function parseGeneratedAutomationDraft(raw: string): GeneratedAutomationDraft;
|
|
10
|
+
export declare function buildAutomationDraftResponse(draft: GeneratedAutomationDraft, repairAttempts: number): {
|
|
11
|
+
draftId: `${string}-${string}-${string}-${string}-${string}`;
|
|
12
|
+
automation: {
|
|
13
|
+
name: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
trigger?: {
|
|
16
|
+
kind: "manual";
|
|
17
|
+
} | {
|
|
18
|
+
kind: "schedule";
|
|
19
|
+
schedule?: {
|
|
20
|
+
kind: "once";
|
|
21
|
+
at: string;
|
|
22
|
+
} | {
|
|
23
|
+
kind: "interval";
|
|
24
|
+
everyMs: number;
|
|
25
|
+
anchorMs?: number;
|
|
26
|
+
} | {
|
|
27
|
+
kind: "cron";
|
|
28
|
+
expr: string;
|
|
29
|
+
tz?: string;
|
|
30
|
+
};
|
|
31
|
+
} | {
|
|
32
|
+
kind: "webhook";
|
|
33
|
+
secretId?: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "event";
|
|
36
|
+
eventType: string;
|
|
37
|
+
source?: string;
|
|
38
|
+
payloadMatch?: Record<string, string | number | boolean>;
|
|
39
|
+
};
|
|
40
|
+
action?: {
|
|
41
|
+
kind: "agent";
|
|
42
|
+
instruction: string;
|
|
43
|
+
agentId?: string;
|
|
44
|
+
workingDirectory?: string;
|
|
45
|
+
model?: string;
|
|
46
|
+
timeoutSeconds?: number;
|
|
47
|
+
} | {
|
|
48
|
+
kind: "workflow";
|
|
49
|
+
workflowId: string;
|
|
50
|
+
agentId?: string;
|
|
51
|
+
input?: unknown;
|
|
52
|
+
inputEnvelope?: {
|
|
53
|
+
payload: unknown;
|
|
54
|
+
goal?: string;
|
|
55
|
+
variables?: Record<string, unknown>;
|
|
56
|
+
context?: Record<string, unknown>;
|
|
57
|
+
};
|
|
58
|
+
goal?: string;
|
|
59
|
+
concurrency?: number;
|
|
60
|
+
maxSubagents?: number;
|
|
61
|
+
timeoutSeconds?: number;
|
|
62
|
+
};
|
|
63
|
+
safety?: {
|
|
64
|
+
mode: "suggest_only" | "ask_before_apply" | "auto_apply";
|
|
65
|
+
};
|
|
66
|
+
afterRun?: {
|
|
67
|
+
kind: "none";
|
|
68
|
+
} | {
|
|
69
|
+
kind: "saveToSession";
|
|
70
|
+
} | {
|
|
71
|
+
kind: "webhook";
|
|
72
|
+
url: string;
|
|
73
|
+
};
|
|
74
|
+
reliability?: {
|
|
75
|
+
timeoutSeconds?: number;
|
|
76
|
+
retryCount?: number;
|
|
77
|
+
maxConcurrentRuns?: number;
|
|
78
|
+
disableAfterConsecutiveFailures?: number;
|
|
79
|
+
};
|
|
80
|
+
id?: string;
|
|
81
|
+
enabled?: boolean;
|
|
82
|
+
state?: {
|
|
83
|
+
nextRunAtMs?: number;
|
|
84
|
+
runningRunId?: string;
|
|
85
|
+
lastRunAtMs?: number;
|
|
86
|
+
lastRunStatus?: "timeout" | "failed" | "queued" | "running" | "succeeded" | "cancelled";
|
|
87
|
+
lastError?: string;
|
|
88
|
+
consecutiveFailures?: number;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
explanation: string;
|
|
92
|
+
assumptions: string[];
|
|
93
|
+
risks: string[];
|
|
94
|
+
simulation: AutomationSimulation;
|
|
95
|
+
repairAttempts: number;
|
|
96
|
+
};
|
|
97
|
+
export declare function parseGeneratedAutomationRepairDraft(raw: string, repairAttempts: number): AutomationRepairDraftResponse;
|
|
98
|
+
export declare function simulateAutomation(input: CreateAutomationInput): AutomationSimulation;
|
|
99
|
+
export {};
|