@ai-setting/roy-agent-core 1.7.51 → 1.7.53
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/config/config-component.d.ts +346 -0
- package/dist/config/config-parser.d.ts +45 -0
- package/dist/config/env-key.d.ts +97 -0
- package/dist/config/env-source.d.ts +113 -0
- package/dist/config/file-source.d.ts +90 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/protocol-resolver.d.ts +94 -0
- package/dist/env/agent/agent-component.d.ts +646 -0
- package/dist/env/agent/agent-config-registration.d.ts +18 -0
- package/dist/env/agent/agent-registry.d.ts +500 -0
- package/dist/env/agent/index.d.ts +9 -0
- package/dist/env/agent/summary-agent.d.ts +44 -0
- package/dist/env/agent/types.d.ts +503 -0
- package/dist/env/commands/commands-component.d.ts +97 -0
- package/dist/env/commands/commands-config-registration.d.ts +19 -0
- package/dist/env/commands/index.d.ts +7 -0
- package/dist/env/commands/parser.d.ts +18 -0
- package/dist/env/commands/types.d.ts +133 -0
- package/dist/env/component.d.ts +186 -0
- package/dist/env/constants.d.ts +112 -0
- package/dist/env/context/env-context.d.ts +420 -0
- package/dist/env/context/env-event.d.ts +144 -0
- package/dist/env/context/index.d.ts +13 -0
- package/dist/env/debug/debug-component.d.ts +160 -0
- package/dist/env/debug/formatters/index.d.ts +8 -0
- package/dist/env/debug/formatters/repl-formatter.d.ts +80 -0
- package/dist/env/debug/formatters/trace-formatter.d.ts +43 -0
- package/dist/env/debug/formatters/tree-formatter.d.ts +72 -0
- package/dist/env/debug/index.d.ts +15 -0
- package/dist/env/debug/index.js +1 -1
- package/dist/env/debug/parser/regex-parser.d.ts +49 -0
- package/dist/env/debug/parser/span-builder.d.ts +79 -0
- package/dist/env/debug/reader/log-reader.d.ts +55 -0
- package/dist/env/debug/reader/span-db-reader.d.ts +70 -0
- package/dist/env/debug/types.d.ts +145 -0
- package/dist/env/environment.d.ts +185 -0
- package/dist/env/errors.d.ts +120 -0
- package/dist/env/event-source/bounty-cli-handler.d.ts +42 -0
- package/dist/env/event-source/bounty-im-handler.d.ts +232 -0
- package/dist/env/event-source/event-source-component.d.ts +177 -0
- package/dist/env/event-source/event-source-config-registration.d.ts +18 -0
- package/dist/env/event-source/event-source-handlers.d.ts +486 -0
- package/dist/env/event-source/event-store.d.ts +110 -0
- package/dist/env/event-source/idempotency-key.d.ts +19 -0
- package/dist/env/event-source/index.d.ts +15 -0
- package/dist/env/event-source/index.js +4 -4
- package/dist/env/event-source/timer-handler.d.ts +74 -0
- package/dist/env/event-source/types.d.ts +803 -0
- package/dist/env/hook/global-hook-manager.d.ts +73 -0
- package/dist/env/hook/hook-manager.d.ts +139 -0
- package/dist/env/hook/index.d.ts +9 -0
- package/dist/env/hook/types.d.ts +107 -0
- package/dist/env/index.d.ts +24 -0
- package/dist/env/index.js +6 -6
- package/dist/env/interface.d.ts +156 -0
- package/dist/env/lark-mention-utils.d.ts +59 -0
- package/dist/env/llm/adapter-ai-sdk.d.ts +10 -0
- package/dist/env/llm/adapter-pi-ai.d.ts +39 -0
- package/dist/env/llm/adapter.d.ts +80 -0
- package/dist/env/llm/factory.d.ts +13 -0
- package/dist/env/llm/hooks.d.ts +150 -0
- package/dist/env/llm/index.d.ts +16 -0
- package/dist/env/llm/invoke.d.ts +264 -0
- package/dist/env/llm/llm-cache.d.ts +38 -0
- package/dist/env/llm/llm.d.ts +238 -0
- package/dist/env/llm/opencode-session.d.ts +79 -0
- package/dist/env/llm/provider.d.ts +40 -0
- package/dist/env/llm/tool-args-parser.d.ts +77 -0
- package/dist/env/llm/tool-schema.d.ts +54 -0
- package/dist/env/llm/transform.d.ts +57 -0
- package/dist/env/llm/types.d.ts +818 -0
- package/dist/env/log-trace/decorator.d.ts +88 -0
- package/dist/env/log-trace/index.d.ts +14 -0
- package/dist/env/log-trace/log-trace-component.d.ts +268 -0
- package/dist/env/log-trace/log-trace-config-registration.d.ts +25 -0
- package/dist/env/log-trace/logger.d.ts +83 -0
- package/dist/env/log-trace/opentelemetry/cli-propagation.d.ts +105 -0
- package/dist/env/log-trace/opentelemetry/mod.d.ts +24 -0
- package/dist/env/log-trace/opentelemetry/propagation-env.d.ts +81 -0
- package/dist/env/log-trace/opentelemetry/propagation.d.ts +79 -0
- package/dist/env/log-trace/opentelemetry/tracer-provider.d.ts +157 -0
- package/dist/env/log-trace/span-storage.d.ts +37 -0
- package/dist/env/log-trace/trace-context.d.ts +28 -0
- package/dist/env/log-trace/types.d.ts +127 -0
- package/dist/env/mcp/command-resolver.d.ts +12 -0
- package/dist/env/mcp/config.d.ts +103 -0
- package/dist/env/mcp/index.d.ts +13 -0
- package/dist/env/mcp/loader.d.ts +78 -0
- package/dist/env/mcp/mcp-component.d.ts +54 -0
- package/dist/env/mcp/mcp-config-registration.d.ts +19 -0
- package/dist/env/mcp/npm-prefix/index.d.ts +17 -0
- package/dist/env/mcp/scanner.d.ts +38 -0
- package/dist/env/mcp/tool/adapter.d.ts +32 -0
- package/dist/env/mcp/tool/index.d.ts +4 -0
- package/dist/env/mcp/types.d.ts +131 -0
- package/dist/env/memory/built-in/index.d.ts +41 -0
- package/dist/env/memory/built-in/recall-memory.d.ts +29 -0
- package/dist/env/memory/built-in/record-memory.d.ts +44 -0
- package/dist/env/memory/index.d.ts +10 -0
- package/dist/env/memory/memory-component.d.ts +114 -0
- package/dist/env/memory/memory-config-registration.d.ts +18 -0
- package/dist/env/memory/memory-config.d.ts +18 -0
- package/dist/env/memory/plugin/index.d.ts +16 -0
- package/dist/env/memory/plugin/memory-agent.d.ts +126 -0
- package/dist/env/memory/plugin/memory-manager.d.ts +71 -0
- package/dist/env/memory/plugin/memory-plugin.d.ts +103 -0
- package/dist/env/memory/plugin/recall-memory.d.ts +16 -0
- package/dist/env/memory/plugin/types.d.ts +75 -0
- package/dist/env/memory/tools/memory-agent-tools.d.ts +109 -0
- package/dist/env/memory/types.d.ts +80 -0
- package/dist/env/paths.d.ts +46 -0
- package/dist/env/plugin/bounty-cli-notification-channel.d.ts +60 -0
- package/dist/env/plugin/event-bus-notification-channel.d.ts +50 -0
- package/dist/env/plugin/index.d.ts +13 -0
- package/dist/env/plugin/lark-cli-notification-channel.d.ts +61 -0
- package/dist/env/plugin/notification-channel.d.ts +143 -0
- package/dist/env/plugin/plugin-component.d.ts +232 -0
- package/dist/env/plugin/types.d.ts +146 -0
- package/dist/env/prompt/index.d.ts +7 -0
- package/dist/env/prompt/prompt-component.d.ts +194 -0
- package/dist/env/prompt/prompt-config-registration.d.ts +18 -0
- package/dist/env/prompt/prompt-store.d.ts +26 -0
- package/dist/env/prompt/prompts-index.d.ts +146 -0
- package/dist/env/prompt/renderer.d.ts +21 -0
- package/dist/env/prompt/types.d.ts +176 -0
- package/dist/env/session/hooks.d.ts +14 -0
- package/dist/env/session/index.d.ts +19 -0
- package/dist/env/session/search-query-parser.d.ts +41 -0
- package/dist/env/session/session-component.d.ts +464 -0
- package/dist/env/session/session-config-registration.d.ts +18 -0
- package/dist/env/session/session-id.d.ts +26 -0
- package/dist/env/session/session-message-converter.d.ts +142 -0
- package/dist/env/session/session-store.d.ts +188 -0
- package/dist/env/session/storage/index.d.ts +5 -0
- package/dist/env/session/storage/memory.d.ts +119 -0
- package/dist/env/session/storage/sqlite.d.ts +108 -0
- package/dist/env/session/types.d.ts +705 -0
- package/dist/env/session-tree-stopper.d.ts +79 -0
- package/dist/env/skill/config.d.ts +13 -0
- package/dist/env/skill/index.d.ts +6 -0
- package/dist/env/skill/parser.d.ts +9 -0
- package/dist/env/skill/scanner.d.ts +25 -0
- package/dist/env/skill/skill-component.d.ts +89 -0
- package/dist/env/skill/skill-config-registration.d.ts +18 -0
- package/dist/env/skill/tool/index.d.ts +1 -0
- package/dist/env/skill/tool/skill-tool.d.ts +15 -0
- package/dist/env/skill/types.d.ts +61 -0
- package/dist/env/task/backend/index.d.ts +24 -0
- package/dist/env/task/backend/index.js +704 -0
- package/dist/env/task/backend/roy-sidecar-task-port.d.ts +148 -0
- package/dist/env/task/backend/sqlite-task-port.d.ts +28 -0
- package/dist/env/task/backend/task-store-backend.d.ts +107 -0
- package/dist/env/task/backend/types.d.ts +293 -0
- package/dist/env/task/delegate/bg-task-id-storage.d.ts +9 -0
- package/dist/env/task/delegate/delegate-tool.d.ts +681 -0
- package/dist/env/task/delegate/index.d.ts +8 -0
- package/dist/env/task/delegate/process-registry.d.ts +58 -0
- package/dist/env/task/delegate/stop-tool.d.ts +12 -0
- package/dist/env/task/delegate/subagent-resolver.d.ts +25 -0
- package/dist/env/task/events/index.d.ts +7 -0
- package/dist/env/task/events/task-event-payloads.d.ts +101 -0
- package/dist/env/task/events/task-event-types.d.ts +23 -0
- package/dist/env/task/hooks/contexts.d.ts +191 -0
- package/dist/env/task/hooks/index.d.ts +7 -0
- package/dist/env/task/hooks/task-hook-points.d.ts +42 -0
- package/dist/env/task/index.d.ts +7 -0
- package/dist/env/task/plugins/auto-task-plugin.d.ts +38 -0
- package/dist/env/task/plugins/card-chat-routing.d.ts +135 -0
- package/dist/env/task/plugins/fake-user-message-helper.d.ts +90 -0
- package/dist/env/task/plugins/index.d.ts +8 -0
- package/dist/env/task/plugins/index.js +2 -2
- package/dist/env/task/plugins/lark-card-action-handler.d.ts +166 -0
- package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +651 -0
- package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +248 -0
- package/dist/env/task/plugins/max-iteration-reminder-plugin.d.ts +112 -0
- package/dist/env/task/plugins/per-task-group-chat-plugin.d.ts +561 -0
- package/dist/env/task/plugins/task-tag-plugin.d.ts +70 -0
- package/dist/env/task/plugins/workflow-extractor-agent.d.ts +43 -0
- package/dist/env/task/registry-hook-installer.d.ts +43 -0
- package/dist/env/task/storage/index.d.ts +5 -0
- package/dist/env/task/storage/migrations/001_add_project_path_context.d.ts +14 -0
- package/dist/env/task/storage/migrations/002_add_task_type.d.ts +14 -0
- package/dist/env/task/storage/migrations/003_add_process_description.d.ts +20 -0
- package/dist/env/task/storage/migrations/004_rename_action_to_milestone.d.ts +37 -0
- package/dist/env/task/storage/migrations/005_convert_blob_description_to_text.d.ts +51 -0
- package/dist/env/task/storage/sqlite-task-store.d.ts +241 -0
- package/dist/env/task/tag-service.d.ts +138 -0
- package/dist/env/task/task-child-context.d.ts +70 -0
- package/dist/env/task/task-component.d.ts +270 -0
- package/dist/env/task/task-config-registration.d.ts +19 -0
- package/dist/env/task/task-creation-registry.d.ts +181 -0
- package/dist/env/task/task-reuse-context.d.ts +52 -0
- package/dist/env/task/task-reuse-registry.d.ts +31 -0
- package/dist/env/task/tools/batch-archive-tool.d.ts +9 -0
- package/dist/env/task/tools/batch-delete-tool.d.ts +9 -0
- package/dist/env/task/tools/complete-tool.d.ts +12 -0
- package/dist/env/task/tools/create-tool.d.ts +6 -0
- package/dist/env/task/tools/delete-tool.d.ts +6 -0
- package/dist/env/task/tools/get-tool.d.ts +6 -0
- package/dist/env/task/tools/index.d.ts +13 -0
- package/dist/env/task/tools/list-tool.d.ts +6 -0
- package/dist/env/task/tools/operation/create-tool.d.ts +12 -0
- package/dist/env/task/tools/operation/delete-tool.d.ts +6 -0
- package/dist/env/task/tools/operation/get-tool.d.ts +6 -0
- package/dist/env/task/tools/operation/index.d.ts +8 -0
- package/dist/env/task/tools/operation/list-tool.d.ts +6 -0
- package/dist/env/task/tools/operation/operation-types.d.ts +225 -0
- package/dist/env/task/tools/operation/update-tool.d.ts +6 -0
- package/dist/env/task/tools/search-tool.d.ts +9 -0
- package/dist/env/task/tools/task-tree-tool.d.ts +65 -0
- package/dist/env/task/tools/task-types.d.ts +255 -0
- package/dist/env/task/tools/update-tool.d.ts +6 -0
- package/dist/env/task/types.d.ts +290 -0
- package/dist/env/tool/built-in/bash-effect.d.ts +36 -0
- package/dist/env/tool/built-in/bash.d.ts +16 -0
- package/dist/env/tool/built-in/echo.d.ts +7 -0
- package/dist/env/tool/built-in/edit-file.d.ts +6 -0
- package/dist/env/tool/built-in/glob.d.ts +6 -0
- package/dist/env/tool/built-in/grep.d.ts +6 -0
- package/dist/env/tool/built-in/index.d.ts +39 -0
- package/dist/env/tool/built-in/query-background-process-tool.d.ts +113 -0
- package/dist/env/tool/built-in/read-file.d.ts +5 -0
- package/dist/env/tool/built-in/understand-image.d.ts +59 -0
- package/dist/env/tool/built-in/write-file.d.ts +5 -0
- package/dist/env/tool/index.d.ts +16 -0
- package/dist/env/tool/registry.d.ts +61 -0
- package/dist/env/tool/tool-component.d.ts +242 -0
- package/dist/env/tool/tool-config-registration.d.ts +18 -0
- package/dist/env/tool/types.d.ts +274 -0
- package/dist/env/tool/validator.d.ts +14 -0
- package/dist/env/types.d.ts +184 -0
- package/dist/env/workflow/decorators/decorator-node.d.ts +76 -0
- package/dist/env/workflow/decorators/edge.d.ts +42 -0
- package/dist/env/workflow/decorators/index.d.ts +13 -0
- package/dist/env/workflow/decorators/node-as.d.ts +40 -0
- package/dist/env/workflow/decorators/workflow.d.ts +30 -0
- package/dist/env/workflow/engine/dag-manager.d.ts +176 -0
- package/dist/env/workflow/engine/engine.d.ts +375 -0
- package/dist/env/workflow/engine/event-bus.d.ts +54 -0
- package/dist/env/workflow/engine/executor.d.ts +122 -0
- package/dist/env/workflow/engine/index.d.ts +15 -0
- package/dist/env/workflow/engine/node-registry.d.ts +159 -0
- package/dist/env/workflow/engine/scheduler.d.ts +164 -0
- package/dist/env/workflow/extractor/workflow-converter.d.ts +55 -0
- package/dist/env/workflow/fixtures.d.ts +401 -0
- package/dist/env/workflow/hooks/index.d.ts +4 -0
- package/dist/env/workflow/hooks/workflow-hook-points.d.ts +161 -0
- package/dist/env/workflow/index.d.ts +30 -0
- package/dist/env/workflow/index.js +1 -1
- package/dist/env/workflow/metadata/keys.d.ts +6 -0
- package/dist/env/workflow/nodes/agent-component-adapter.d.ts +175 -0
- package/dist/env/workflow/nodes/agent-node.d.ts +206 -0
- package/dist/env/workflow/nodes/ask-user-node.d.ts +66 -0
- package/dist/env/workflow/nodes/condition-node.d.ts +39 -0
- package/dist/env/workflow/nodes/index.d.ts +8 -0
- package/dist/env/workflow/nodes/merge-node.d.ts +40 -0
- package/dist/env/workflow/nodes/python-call-node.d.ts +95 -0
- package/dist/env/workflow/nodes/skill-node.d.ts +29 -0
- package/dist/env/workflow/nodes/tool-node.d.ts +58 -0
- package/dist/env/workflow/nodes/workflow-node.d.ts +118 -0
- package/dist/env/workflow/plugins/index.d.ts +6 -0
- package/dist/env/workflow/plugins/index.js +2 -2
- package/dist/env/workflow/plugins/lark-cli-workflow-notify-plugin.d.ts +107 -0
- package/dist/env/workflow/plugins/workflow-json-output-plugin.d.ts +166 -0
- package/dist/env/workflow/runtime/runtime-cancellation-scope.d.ts +121 -0
- package/dist/env/workflow/service/index.d.ts +9 -0
- package/dist/env/workflow/service/registry.d.ts +37 -0
- package/dist/env/workflow/service/workflow-service.d.ts +422 -0
- package/dist/env/workflow/storage/index.d.ts +11 -0
- package/dist/env/workflow/storage/mock-repositories.d.ts +106 -0
- package/dist/env/workflow/storage/safe-json.d.ts +62 -0
- package/dist/env/workflow/storage/sqlite.d.ts +57 -0
- package/dist/env/workflow/storage/tag-repo.d.ts +65 -0
- package/dist/env/workflow/storage/workflow-repo.d.ts +161 -0
- package/dist/env/workflow/tools/ask-user-tool.d.ts +35 -0
- package/dist/env/workflow/tools/index.d.ts +16 -0
- package/dist/env/workflow/tools/run-workflow.d.ts +130 -0
- package/dist/env/workflow/tools/submit-json-output-tool.d.ts +38 -0
- package/dist/env/workflow/tools/workflow-add-tool.d.ts +47 -0
- package/dist/env/workflow/tools/workflow-get-tool.d.ts +29 -0
- package/dist/env/workflow/tools/workflow-list-tool.d.ts +55 -0
- package/dist/env/workflow/tools/workflow-run-status-tool.d.ts +26 -0
- package/dist/env/workflow/tools/workflow-run-stop-tool.d.ts +29 -0
- package/dist/env/workflow/tools/workflow-search-tool.d.ts +33 -0
- package/dist/env/workflow/tools/workflow-tag-list-tool.d.ts +59 -0
- package/dist/env/workflow/tools/workflow-validate-tool.d.ts +60 -0
- package/dist/env/workflow/types/context.d.ts +17 -0
- package/dist/env/workflow/types/decorators-types.d.ts +182 -0
- package/dist/env/workflow/types/edge.d.ts +33 -0
- package/dist/env/workflow/types/event.d.ts +869 -0
- package/dist/env/workflow/types/index.d.ts +16 -0
- package/dist/env/workflow/types/run.d.ts +235 -0
- package/dist/env/workflow/types/workflow-error.d.ts +79 -0
- package/dist/env/workflow/types/workflow-hil.d.ts +57 -0
- package/dist/env/workflow/types/workflow-message.d.ts +193 -0
- package/dist/env/workflow/types/workflow-session.d.ts +17 -0
- package/dist/env/workflow/types/workflow.d.ts +654 -0
- package/dist/env/workflow/types_compat.d.ts +10 -0
- package/dist/env/workflow/utils/agent-session-metadata.d.ts +35 -0
- package/dist/env/workflow/utils/build-agent-node-output.d.ts +11 -0
- package/dist/env/workflow/utils/create-workflow.d.ts +35 -0
- package/dist/env/workflow/utils/dependency-prescan.d.ts +67 -0
- package/dist/env/workflow/utils/execution-state.d.ts +46 -0
- package/dist/env/workflow/utils/extract-agent-json-output.d.ts +6 -0
- package/dist/env/workflow/utils/index.d.ts +14 -0
- package/dist/env/workflow/utils/json-schema-to-zod.d.ts +23 -0
- package/dist/env/workflow/utils/node-id-utils.d.ts +20 -0
- package/dist/env/workflow/utils/node-output-contracts.d.ts +137 -0
- package/dist/env/workflow/utils/node-registry-helper.d.ts +36 -0
- package/dist/env/workflow/utils/output-schema-hint.d.ts +7 -0
- package/dist/env/workflow/utils/parse-agent-output-config.d.ts +9 -0
- package/dist/env/workflow/utils/recovery-validator.d.ts +30 -0
- package/dist/env/workflow/utils/sensitive-redact.d.ts +37 -0
- package/dist/env/workflow/utils/session-parser.d.ts +23 -0
- package/dist/env/workflow/utils/session-recovery.d.ts +122 -0
- package/dist/env/workflow/utils/template-contract-validator.d.ts +87 -0
- package/dist/env/workflow/utils/template-resolver.d.ts +285 -0
- package/dist/env/workflow/utils/validate-workflow-definition.d.ts +57 -0
- package/dist/env/workflow/utils/validation-rules.d.ts +103 -0
- package/dist/env/workflow/utils/workflow-message-metadata.d.ts +20 -0
- package/dist/env/workflow/utils/workflow-sanitize.d.ts +51 -0
- package/dist/env/workflow/workflow-component.d.ts +138 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.js +7 -7
- package/dist/shared/@ai-setting/{roy-agent-core-9faekt5n.js → roy-agent-core-4sx6sdb2.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-wxsgay02.js → roy-agent-core-brwzs8wf.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-kyasfzeh.js → roy-agent-core-hch2geta.js} +45 -14
- package/dist/shared/@ai-setting/{roy-agent-core-zd077w51.js → roy-agent-core-j8e92gj8.js} +43 -1
- package/dist/shared/@ai-setting/{roy-agent-core-wwytg8rv.js → roy-agent-core-ph5qbqcx.js} +566 -78
- package/dist/util/process/process-tree-killer.d.ts +67 -0
- package/dist/utils/id.d.ts +11 -0
- package/dist/utils/loose-json.d.ts +30 -0
- package/dist/utils/media.d.ts +70 -0
- package/dist/utils/temp-file-manager/index.d.ts +99 -0
- package/package.json +4 -2
- /package/dist/shared/@ai-setting/{roy-agent-core-s214vmmd.js → roy-agent-core-4vpk40ss.js} +0 -0
- /package/dist/shared/@ai-setting/{roy-agent-core-0cfaqnz9.js → roy-agent-core-k25gv86p.js} +0 -0
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview LarkCardPatchNotifier - 单卡片 patch 不刷屏通知器(Task #4230 重写)
|
|
3
|
+
*
|
|
4
|
+
* 封装"单卡片 patch"逻辑:每个 task 在飞书群里只有**一张**交互式卡片,
|
|
5
|
+
* 状态变化时只 patch 这张卡片的内容(不刷屏),并且把卡片**置顶**(pin),
|
|
6
|
+
* 让用户随时能看到任务进展。
|
|
7
|
+
*
|
|
8
|
+
* ## 设计要点
|
|
9
|
+
*
|
|
10
|
+
* 1. **生命周期**:startTask → updateTask* → finishTask
|
|
11
|
+
* - startTask: `im +messages-send` 发初始卡片 → 拿 messageId → `im pins create` 置顶
|
|
12
|
+
* - updateTask: `im messages patch` 改同一卡片内容(进度/当前步骤/里程碑/过程时间线)
|
|
13
|
+
* - finishTask: `im messages patch` 终态 + `im pins delete` 取消置顶
|
|
14
|
+
*
|
|
15
|
+
* 2. **卡片样式(用户验收过的 live card 样式)**
|
|
16
|
+
* - header.title 📊 Task 实时更新(<标题>)
|
|
17
|
+
* - header.subtitle spinner: '<emoji>' | <状态短语>
|
|
18
|
+
* - 实时进度(进度条 / 进行中)
|
|
19
|
+
* - 当前步骤
|
|
20
|
+
* - 🎯 里程碑时间线
|
|
21
|
+
* - 🔧 过程时间线
|
|
22
|
+
* - footer:🔄 更新次数 | 🔄 Spinner | 🟣 状态
|
|
23
|
+
*
|
|
24
|
+
* 3. **lark-cli 参数契约(Task #4230 修复,2026-10-15 用 tongzhuli profile 实测)**
|
|
25
|
+
* - `im +messages-send`:`--msg-type interactive --content <card JSON>` ✅
|
|
26
|
+
* (+shortcut 的 --content 直接吃 card JSON;旧的 `{"content":...}` 双重包裹会 230099)
|
|
27
|
+
* - `im messages patch`:**只能**用 `--data '{"content":"<card JSON 字符串>"}'`
|
|
28
|
+
* ❌ 不能传 `--content`(unknown flag → 秒失败 → 卡片永远停在初始态)
|
|
29
|
+
* - `im pins create`:**只能**用 `--data '{"message_id":"om_xxx"}'`
|
|
30
|
+
* ❌ 不能传 `--chat-id/--message-id`(unknown flag → pin 永远失败)
|
|
31
|
+
* - `im pins delete`:`--message-id om_xxx --yes`(high-risk-write,必须 --yes)
|
|
32
|
+
*
|
|
33
|
+
* 4. **状态自持(不刷屏 + 持续滚动)**
|
|
34
|
+
* - 同一 messageId 的里程碑/过程时间线由 notifier 自己累积(append + 去重)
|
|
35
|
+
* - 每次 update 递增更新次数并轮换 spinner emoji("持续滚动"观感)
|
|
36
|
+
* - caller 只需要传"本次新增了什么",不需要自己维护全量历史
|
|
37
|
+
*
|
|
38
|
+
* 5. **并发串行化**:同一 messageId 的 patch 走 mutex,避免飞书端并发覆盖
|
|
39
|
+
*
|
|
40
|
+
* 6. **错误处理**
|
|
41
|
+
* - 发卡/pat 失败 → 抛错(caller 决定是否 graceful degrade)
|
|
42
|
+
* - pin/unpin 失败 → 非致命(warn + span 属性标记),卡片仍可见
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const notifier = new LarkCardPatchNotifier();
|
|
47
|
+
* const { messageId, pinned } = await notifier.startTask({
|
|
48
|
+
* chatId: "oc_xxx", profile: "tongzhuli", taskId: 4221, taskTitle: "调研",
|
|
49
|
+
* });
|
|
50
|
+
* await notifier.updateTask({
|
|
51
|
+
* messageId, status: "running", taskId: 4221, taskTitle: "调研",
|
|
52
|
+
* currentStep: "扫描 GitHub Issues",
|
|
53
|
+
* milestones: [{ title: "调研启动", timestamp: new Date().toISOString() }],
|
|
54
|
+
* });
|
|
55
|
+
* await notifier.finishTask({ messageId, status: "completed" });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
/**
|
|
59
|
+
* 卡片状态。
|
|
60
|
+
*
|
|
61
|
+
* ★ Part 2(workflow 通知):新增 `"stopped"`(灰)—— task 只会用前三种,
|
|
62
|
+
* 但同一套卡片骨架要给 workflow run 复用,而 workflow 有 stopped 终态。
|
|
63
|
+
*/
|
|
64
|
+
export type CardStatus = "running" | "completed" | "failed" | "stopped";
|
|
65
|
+
/** workflow 卡片状态(与 CardStatus 同集合;语义别名,便于阅读) */
|
|
66
|
+
export type WorkflowCardStatus = CardStatus;
|
|
67
|
+
/** 里程碑(关键节点):时间 + 标题 + 描述 */
|
|
68
|
+
export interface Milestone {
|
|
69
|
+
/** 里程碑标题(如 "调研启动"),会被拼进 "🟢 <title>" */
|
|
70
|
+
title: string;
|
|
71
|
+
/** ISO 8601 时间戳;缺省时渲染 "—" */
|
|
72
|
+
timestamp?: string;
|
|
73
|
+
/** 补充说明(渲染成 " → <description>") */
|
|
74
|
+
description?: string;
|
|
75
|
+
}
|
|
76
|
+
/** 过程步骤(中间步骤):时间段 + 描述 */
|
|
77
|
+
export interface ProcessStep {
|
|
78
|
+
/** 步骤标题(如 "扫描 GitHub Issues") */
|
|
79
|
+
title: string;
|
|
80
|
+
/** ISO 8601 起始时间;缺省时不渲染时间行 */
|
|
81
|
+
timestamp?: string;
|
|
82
|
+
/** ISO 8601 结束时间;缺省时渲染成 "→ 现在" */
|
|
83
|
+
endTimestamp?: string;
|
|
84
|
+
/** 补充说明(渲染成 " → <description>") */
|
|
85
|
+
description?: string;
|
|
86
|
+
/** 步骤分类(如 research / code / test),有值时追加到标题括号内 */
|
|
87
|
+
category?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* 任务元信息(卡片顶部"任务栏位"区块的数据源)
|
|
91
|
+
*
|
|
92
|
+
* ★ 用户验收要求(Task #4230 v2):
|
|
93
|
+
* 卡片第一块必须是任务栏位:任务 ID / 标题 / 描述 / 目标 / 父任务 / 优先级 / context…
|
|
94
|
+
* 且 context 要渲染成**人类可读的 markdown**(绝不出现 JSON 原文)。
|
|
95
|
+
*/
|
|
96
|
+
export interface TaskMeta {
|
|
97
|
+
/** 任务 ID(#4223) */
|
|
98
|
+
id?: number | string;
|
|
99
|
+
/** 任务标题 */
|
|
100
|
+
title?: string;
|
|
101
|
+
/** 任务描述 */
|
|
102
|
+
description?: string;
|
|
103
|
+
/** 目标与预期交付物(task.goals_and_expected_deliverables) */
|
|
104
|
+
goals?: string;
|
|
105
|
+
/** 父任务 ID(无父任务时不渲染) */
|
|
106
|
+
parentTaskId?: number;
|
|
107
|
+
/** 优先级(low/medium/high) */
|
|
108
|
+
priority?: string;
|
|
109
|
+
/** 任务类型(normal/cycle/longterm) */
|
|
110
|
+
type?: string;
|
|
111
|
+
/** 项目路径 */
|
|
112
|
+
projectPath?: string;
|
|
113
|
+
/** task.context 原始 JSON 字符串 —— 渲染时会被展开成可读 bullet,不显示 JSON */
|
|
114
|
+
context?: string;
|
|
115
|
+
/** 任务当前状态描述(task.current_status) */
|
|
116
|
+
currentStatus?: string;
|
|
117
|
+
/**
|
|
118
|
+
* ★ Task #4331:专属群 chatId(决定卡片顶部按钮 + 下方链接渲染)
|
|
119
|
+
*
|
|
120
|
+
* - undefined 或空:渲染"为这个任务建群"按钮 + 不显示链接
|
|
121
|
+
* - 有值:渲染"解散该群"按钮 + 显示飞书 applink "进入群"
|
|
122
|
+
*
|
|
123
|
+
* 通常从 task.context.larkPerTaskChatId 读出,由 LarkCliTaskNotifyHook
|
|
124
|
+
* 透传给 buildTaskCard / updateTask。
|
|
125
|
+
*/
|
|
126
|
+
perTaskChatId?: string;
|
|
127
|
+
/**
|
|
128
|
+
* ★ Task #4331:专属群名(可选,仅在渲染链接文本"进入群 XXX"时使用)
|
|
129
|
+
*
|
|
130
|
+
* 若未提供,默认显示"进入群"。
|
|
131
|
+
*/
|
|
132
|
+
perTaskChatName?: string;
|
|
133
|
+
}
|
|
134
|
+
export interface StartTaskOptions {
|
|
135
|
+
/** 飞书 chat ID (oc_xxx) */
|
|
136
|
+
chatId: string;
|
|
137
|
+
/** lark-cli profile(多 appId 场景用) */
|
|
138
|
+
profile?: string;
|
|
139
|
+
/** 任务元信息(栏位区块 + header 标题) */
|
|
140
|
+
meta: TaskMeta;
|
|
141
|
+
/** 首次渲染时的里程碑(通常一条 "Task 创建") */
|
|
142
|
+
milestones?: Milestone[];
|
|
143
|
+
}
|
|
144
|
+
export interface UpdateTaskOptions {
|
|
145
|
+
/** 飞书 message_id(startTask 返回值) */
|
|
146
|
+
messageId: string;
|
|
147
|
+
/** 飞书 chat ID(仅用于诊断/日志,patch 不依赖它) */
|
|
148
|
+
chatId?: string;
|
|
149
|
+
/** lark-cli profile */
|
|
150
|
+
profile?: string;
|
|
151
|
+
status: CardStatus;
|
|
152
|
+
/** 任务元信息(缺省时沿用 startTask 时缓存的那份) */
|
|
153
|
+
meta?: TaskMeta;
|
|
154
|
+
/**
|
|
155
|
+
* 真实进度百分比(0-100)。
|
|
156
|
+
*
|
|
157
|
+
* ★ 只在调用方**确实知道**进度时传(禁止拿耗时估算假进度)。
|
|
158
|
+
* 缺省时进度区渲染"进行中"而不是假百分比。
|
|
159
|
+
*/
|
|
160
|
+
progress?: number;
|
|
161
|
+
/** 本次新增的里程碑(会 append 到已有序列并去重) */
|
|
162
|
+
milestones?: Milestone[];
|
|
163
|
+
/** 本次新增的过程信息(会 append 到已有列表并去重) */
|
|
164
|
+
processSteps?: ProcessStep[];
|
|
165
|
+
}
|
|
166
|
+
export interface FinishTaskOptions {
|
|
167
|
+
messageId: string;
|
|
168
|
+
chatId?: string;
|
|
169
|
+
profile?: string;
|
|
170
|
+
status: Extract<CardStatus, "completed" | "failed">;
|
|
171
|
+
meta?: TaskMeta;
|
|
172
|
+
/** 终态补充说明(会作为最后一条里程碑 append) */
|
|
173
|
+
finalStep?: string;
|
|
174
|
+
progress?: number;
|
|
175
|
+
}
|
|
176
|
+
/** 改投链接卡片的入参(Task #4230 follow-up) */
|
|
177
|
+
export interface RedirectNoticeOptions {
|
|
178
|
+
/** 发到哪个群(通常是"触发群",即被判定为别 task 专属群的那个) */
|
|
179
|
+
chatId: string;
|
|
180
|
+
profile?: string;
|
|
181
|
+
/** 本 task */
|
|
182
|
+
taskId?: number | string;
|
|
183
|
+
taskTitle?: string;
|
|
184
|
+
/** 卡片实际落在哪个群 */
|
|
185
|
+
targetChatId: string;
|
|
186
|
+
/** 目标群名(渲染成可点击文本;缺省显示"专属群") */
|
|
187
|
+
targetChatName?: string;
|
|
188
|
+
/** 改投原因(诊断,写进卡片文案) */
|
|
189
|
+
reason?: string;
|
|
190
|
+
}
|
|
191
|
+
export interface StartTaskResult {
|
|
192
|
+
messageId: string;
|
|
193
|
+
/** pin 是否成功(失败不影响卡片可见性,但 trace 里可查) */
|
|
194
|
+
pinned: boolean;
|
|
195
|
+
/** pin 失败原因(诊断用) */
|
|
196
|
+
pinError?: string;
|
|
197
|
+
}
|
|
198
|
+
export interface LarkCardPatchNotifierOptions {
|
|
199
|
+
/** 启动时是否 pin(默认 true) */
|
|
200
|
+
pinOnStart?: boolean;
|
|
201
|
+
/** 结束时是否 unpin(默认 true) */
|
|
202
|
+
unpinOnFinish?: boolean;
|
|
203
|
+
}
|
|
204
|
+
export interface CardPayload {
|
|
205
|
+
schema: "2.0";
|
|
206
|
+
header: {
|
|
207
|
+
title: {
|
|
208
|
+
tag: "plain_text";
|
|
209
|
+
content: string;
|
|
210
|
+
};
|
|
211
|
+
subtitle: {
|
|
212
|
+
tag: "plain_text";
|
|
213
|
+
content: string;
|
|
214
|
+
};
|
|
215
|
+
template: string;
|
|
216
|
+
};
|
|
217
|
+
body: {
|
|
218
|
+
elements: Array<Record<string, any>>;
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* workflow 运行元信息(卡片顶部"运行栏位"区块的数据源)
|
|
223
|
+
*
|
|
224
|
+
* ★ 与 {@link TaskMeta} 对应:task 卡片顶部是"任务栏位",workflow 卡片顶部是
|
|
225
|
+
* "运行栏位"(workflow 名 / runId / workflowId / 触发输入摘要)。
|
|
226
|
+
*/
|
|
227
|
+
export interface WorkflowMeta {
|
|
228
|
+
/** run 标识(== sessionId,engine 的 workflow:*.run 载荷提供) */
|
|
229
|
+
runId: string;
|
|
230
|
+
/** workflow 名称(人可读,用于卡片标题) */
|
|
231
|
+
workflowName?: string;
|
|
232
|
+
/** workflow 定义 id(可选) */
|
|
233
|
+
workflowId?: string;
|
|
234
|
+
/** 触发输入(before.run 提供);渲染时会被 humanize,绝不输出 JSON 原文 */
|
|
235
|
+
input?: unknown;
|
|
236
|
+
}
|
|
237
|
+
export interface StartWorkflowOptions {
|
|
238
|
+
/** 飞书 chat ID (oc_xxx) */
|
|
239
|
+
chatId: string;
|
|
240
|
+
/** lark-cli profile(多 appId 场景用) */
|
|
241
|
+
profile?: string;
|
|
242
|
+
/** workflow 运行元信息(栏位区块 + header 标题) */
|
|
243
|
+
meta: WorkflowMeta;
|
|
244
|
+
/** DAG 节点总数 */
|
|
245
|
+
totalNodes?: number;
|
|
246
|
+
/** 已产出结果的节点数 */
|
|
247
|
+
completedNodes?: number;
|
|
248
|
+
/** 首次渲染时的里程碑(通常一条 "Workflow 启动") */
|
|
249
|
+
milestones?: Milestone[];
|
|
250
|
+
/** 首次渲染时的过程记录 */
|
|
251
|
+
processSteps?: ProcessStep[];
|
|
252
|
+
}
|
|
253
|
+
export interface UpdateWorkflowOptions {
|
|
254
|
+
/** 飞书 message_id(startWorkflow 返回值) */
|
|
255
|
+
messageId: string;
|
|
256
|
+
/** 飞书 chat ID(仅用于诊断/日志,patch 不依赖它) */
|
|
257
|
+
chatId?: string;
|
|
258
|
+
/** lark-cli profile */
|
|
259
|
+
profile?: string;
|
|
260
|
+
/** 运行状态(缺省沿用上一次;默认为 running) */
|
|
261
|
+
status?: WorkflowCardStatus;
|
|
262
|
+
/** workflow 运行元信息(缺省时沿用 startWorkflow 时缓存的那份) */
|
|
263
|
+
meta?: WorkflowMeta;
|
|
264
|
+
/** 当前节点 id(渲染成"当前节点") */
|
|
265
|
+
currentNode?: string;
|
|
266
|
+
/** 当前节点类型(agent / tool / ...) */
|
|
267
|
+
currentNodeType?: string;
|
|
268
|
+
/** 已产出结果的节点数(进度分子) */
|
|
269
|
+
completedNodes?: number;
|
|
270
|
+
/** DAG 节点总数(进度分母) */
|
|
271
|
+
totalNodes?: number;
|
|
272
|
+
/** 真实进度百分比(0-100)。缺省时由 completedNodes/totalNodes 推算 */
|
|
273
|
+
progress?: number;
|
|
274
|
+
/** 运行耗时(毫秒) */
|
|
275
|
+
durationMs?: number;
|
|
276
|
+
/** 失败原因 */
|
|
277
|
+
error?: string;
|
|
278
|
+
/** 本次新增的里程碑(append + 去重) */
|
|
279
|
+
milestones?: Milestone[];
|
|
280
|
+
/** 本次新增的过程信息(append + 去重) */
|
|
281
|
+
processSteps?: ProcessStep[];
|
|
282
|
+
}
|
|
283
|
+
export interface FinishWorkflowOptions {
|
|
284
|
+
messageId: string;
|
|
285
|
+
chatId?: string;
|
|
286
|
+
profile?: string;
|
|
287
|
+
/** 终态:completed / failed / stopped */
|
|
288
|
+
status: Extract<WorkflowCardStatus, "completed" | "failed" | "stopped">;
|
|
289
|
+
meta?: WorkflowMeta;
|
|
290
|
+
totalNodes?: number;
|
|
291
|
+
completedNodes?: number;
|
|
292
|
+
progress?: number;
|
|
293
|
+
durationMs?: number;
|
|
294
|
+
error?: string;
|
|
295
|
+
/** 终态补充说明(会作为最后一条里程碑 append) */
|
|
296
|
+
finalStep?: string;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* 格式化 ISO 8601 时间戳为人类可读的 HH:mm:ss(北京时间 UTC+8)
|
|
300
|
+
*
|
|
301
|
+
* cross-validation ⚠️ #5 修复:原实现直接显示 ISO 8601 字符串(如 "2026-10-15T01:42:05.000Z")
|
|
302
|
+
* 对用户不友好。改为显示 HH:mm:ss(中国用户视角,北京时间)。
|
|
303
|
+
*
|
|
304
|
+
* @param iso ISO 8601 字符串;无效输入返回原值(保持向后兼容)
|
|
305
|
+
*/
|
|
306
|
+
export declare function formatTimestampForDisplay(iso: string | undefined): string;
|
|
307
|
+
/**
|
|
308
|
+
* 把多行/带 markdown 标记的长文本压成**单行可读文本**(用于卡片里的行内栏位)
|
|
309
|
+
*
|
|
310
|
+
* 背景(实测问题):agent 写的 task.description / milestoneDescription 常含
|
|
311
|
+
* `## 标题`、`- 列表`、换行 —— 直接塞进卡片的一个 bullet 会把卡片结构撑坏
|
|
312
|
+
* (标题级别会被飞书渲染成大标题,列表项和下一行黏在一起)。
|
|
313
|
+
*
|
|
314
|
+
* 处理:标题标记去掉、列表项转 "·"、换行转 " · "、压缩空白、超长截断。
|
|
315
|
+
* 路径 / 命令 / 中文正文不受影响。
|
|
316
|
+
*/
|
|
317
|
+
export declare function sanitizeInlineText(text: string, maxLen?: number): string;
|
|
318
|
+
/** ISO 8601 时间串 → 北京时间 "YYYY-MM-DD HH:mm"(非 ISO 时原样返回) */
|
|
319
|
+
export declare function formatDateTimeForDisplay(value: string): string;
|
|
320
|
+
/**
|
|
321
|
+
* 渲染进度条(用户验收样式:▓ 填充 + ░ 空白 + 百分比)
|
|
322
|
+
*
|
|
323
|
+
* @param progress 0-100
|
|
324
|
+
*/
|
|
325
|
+
export declare function renderProgressBar(progress: number): string;
|
|
326
|
+
/**
|
|
327
|
+
* 解析任务标题显示文本(cross-validation ⚠️ #4 修复)
|
|
328
|
+
*
|
|
329
|
+
* 优先级:
|
|
330
|
+
* 1. opts.taskTitle(caller 明确提供)→ 原样使用
|
|
331
|
+
* 2. opts.taskId + opts.title → "#<taskId> <title>"
|
|
332
|
+
* 3. opts.taskId 单独 → "#<taskId>"
|
|
333
|
+
* 4. 兜底 → "Task"(绝不暴露 chatId)
|
|
334
|
+
*/
|
|
335
|
+
export declare function resolveTaskTitleForDisplay(opts: {
|
|
336
|
+
taskTitle?: string;
|
|
337
|
+
taskId?: number | string;
|
|
338
|
+
title?: string;
|
|
339
|
+
}): string;
|
|
340
|
+
/**
|
|
341
|
+
* 任务定位信息行(Task #2325 保留:项目 / worktree / 前序上下文)
|
|
342
|
+
*
|
|
343
|
+
* 旧实现把这些信息渲染在普通文本通知里;卡片化后放进卡片顶部一行,
|
|
344
|
+
* 保证"飞书里一眼看出任务归属哪个项目 / 哪个 worktree / 关联哪个前序任务"。
|
|
345
|
+
*/
|
|
346
|
+
/**
|
|
347
|
+
* 把任意值渲染成**人类可读文本**(绝不输出 JSON 原文)
|
|
348
|
+
*
|
|
349
|
+
* - string / number / boolean → 原样(超长截断)
|
|
350
|
+
* - array → 逐项 humanize 后用 "、" 连接
|
|
351
|
+
* - object → 逐字段 "key: value" 用 " · " 连接(递归一层)
|
|
352
|
+
*
|
|
353
|
+
* ★ 用户要求:卡片里不要出现 JSON。
|
|
354
|
+
*/
|
|
355
|
+
export declare function humanizeValue(value: unknown, maxLen?: number): string;
|
|
356
|
+
/**
|
|
357
|
+
* 渲染"任务栏位"区块(用户验收要求的第一块)
|
|
358
|
+
*
|
|
359
|
+
* 顺序:任务 ID → 标题 → 描述 → 目标 → 父任务 → 优先级/类型 → 状态 → context 展开
|
|
360
|
+
*
|
|
361
|
+
* ★ context 是 task.context 的 JSON 字符串,这里会被**展开成可读 bullet**
|
|
362
|
+
* (已知字段用友好标签,未知字段用原 key),绝不直接输出 JSON。
|
|
363
|
+
*/
|
|
364
|
+
export declare function renderTaskInfoLines(meta: TaskMeta): string[];
|
|
365
|
+
/**
|
|
366
|
+
* task.context(JSON 字符串) → 可读 bullet 行
|
|
367
|
+
*
|
|
368
|
+
* 坏 JSON / 非对象 → 返回空数组(渲染时安全跳过,不崩、不输出 JSON)。
|
|
369
|
+
*/
|
|
370
|
+
export declare function renderContextAsLines(context?: string): string[];
|
|
371
|
+
/**
|
|
372
|
+
* 渲染里程碑序列(可变化)
|
|
373
|
+
*
|
|
374
|
+
* 样式:`- **HH:mm:ss** <title>` + 可选缩进说明行(markdown 列表,飞书渲染稳定)
|
|
375
|
+
*/
|
|
376
|
+
export declare function renderMilestones(milestones: Milestone[]): string;
|
|
377
|
+
/**
|
|
378
|
+
* 渲染过程信息 list(可变化)
|
|
379
|
+
*
|
|
380
|
+
* 样式:`- **HH:mm:ss → 现在** <title>` + 可选缩进说明行
|
|
381
|
+
*/
|
|
382
|
+
export declare function renderProcessSteps(steps: ProcessStep[]): string;
|
|
383
|
+
/**
|
|
384
|
+
* 构造 card JSON payload(Card 2.0 schema,用户验收样式 Task #4230 v2)
|
|
385
|
+
*
|
|
386
|
+
* 布局(严格按用户指定顺序):
|
|
387
|
+
* 1. header.title = 📊 Task 实时更新;header.subtitle = spinner + 状态 + 更新次数
|
|
388
|
+
* 2. **任务栏位**:任务 ID / 标题 / 描述 / 目标 / 父任务 / 优先级·类型 / context(展开为 bullet)
|
|
389
|
+
* 3. **里程碑序列**(可变化)
|
|
390
|
+
* 4. **过程信息 list**(可变化)
|
|
391
|
+
* 5. **progress 百分比**(最后一块)
|
|
392
|
+
*
|
|
393
|
+
* ★ 所有内容都是 markdown 可渲染文本,不出现 JSON 原文。
|
|
394
|
+
*/
|
|
395
|
+
export declare function buildTaskCard(opts: {
|
|
396
|
+
status: CardStatus;
|
|
397
|
+
meta: TaskMeta;
|
|
398
|
+
milestones?: Milestone[];
|
|
399
|
+
processSteps?: ProcessStep[];
|
|
400
|
+
progress?: number;
|
|
401
|
+
updateCount?: number;
|
|
402
|
+
spinner?: string;
|
|
403
|
+
}): CardPayload;
|
|
404
|
+
/**
|
|
405
|
+
* 生成"打开飞书群"的 app link(Task #4230 follow-up 修复)
|
|
406
|
+
*
|
|
407
|
+
* ★ 踩坑记录(用户实测反馈):之前用的是
|
|
408
|
+
* `https://applink.larkoffice.com/client/chat/chatDetail?chat_id=<oc_xxx>`
|
|
409
|
+
* —— 这是 **Lark 国际版**域名 + 老路径,飞书客户端点进去打不开群。
|
|
410
|
+
*
|
|
411
|
+
* 正确格式(飞书客户端自己生成的就是这个,见 `lark-cli im +chat-list` 的
|
|
412
|
+
* `chat_app_link` 字段):
|
|
413
|
+
* `https://applink.feishu.cn/client/chat/open?openChatId=<oc_xxx>`
|
|
414
|
+
*
|
|
415
|
+
* @param chatId 飞书群 id(oc_xxx)
|
|
416
|
+
* @param base applink 基址(默认飞书;Lark 国际版租户可传 applink.larksuite.com)
|
|
417
|
+
*/
|
|
418
|
+
export declare function buildChatAppLink(chatId: string, base?: string): string;
|
|
419
|
+
/** 默认 applink 基址(飞书) */
|
|
420
|
+
export declare const DEFAULT_APP_LINK_BASE = "https://applink.feishu.cn";
|
|
421
|
+
/**
|
|
422
|
+
* 构造"卡片已改投专属群"的链接卡片(Task #4230 follow-up)
|
|
423
|
+
*
|
|
424
|
+
* 为什么是卡片而不是普通消息:
|
|
425
|
+
* - 用户明确要求「旧逻辑的普通消息通知不要」;
|
|
426
|
+
* - 改投后触发群里需要一条**可点击**的入口,否则 user 不知道进展卡片去哪了。
|
|
427
|
+
*
|
|
428
|
+
* 注意:这张卡片**不携带任务进展内容**,只是一条"去哪看"的指路牌,避免把
|
|
429
|
+
* 别的 task 的进展细节塞进不属于它的群。
|
|
430
|
+
*/
|
|
431
|
+
export declare function buildRedirectCard(opts: {
|
|
432
|
+
taskId?: number | string;
|
|
433
|
+
taskTitle?: string;
|
|
434
|
+
targetChatId: string;
|
|
435
|
+
/** 目标群名(渲染成可点击文本;缺省显示"专属群") */
|
|
436
|
+
targetChatName?: string;
|
|
437
|
+
reason?: string;
|
|
438
|
+
}): CardPayload;
|
|
439
|
+
/**
|
|
440
|
+
* 格式化耗时为人类可读文本(毫秒 → ms / s / m)
|
|
441
|
+
*
|
|
442
|
+
* 例:900 → "900ms";6500 → "6.5s";2000 → "2s";120000 → "2m"
|
|
443
|
+
*/
|
|
444
|
+
export declare function formatDurationMs(ms: number | undefined): string;
|
|
445
|
+
/**
|
|
446
|
+
* 渲染"运行栏位"区块(workflow 名 / runId / 状态 / 节点进度 / 当前节点 / 耗时 /
|
|
447
|
+
* 失败原因 / 触发输入摘要)
|
|
448
|
+
*
|
|
449
|
+
* ★ 所有内容都是 markdown 可渲染文本;触发输入经 humanizeValue 处理,绝不出现 JSON 原文。
|
|
450
|
+
*/
|
|
451
|
+
export declare function renderWorkflowInfoLines(meta: WorkflowMeta, extra: {
|
|
452
|
+
status: WorkflowCardStatus;
|
|
453
|
+
totalNodes?: number;
|
|
454
|
+
completedNodes?: number;
|
|
455
|
+
currentNode?: string;
|
|
456
|
+
currentNodeType?: string;
|
|
457
|
+
durationMs?: number;
|
|
458
|
+
error?: string;
|
|
459
|
+
}): string[];
|
|
460
|
+
/**
|
|
461
|
+
* 构造 workflow 进展卡片(Card 2.0 schema,复用 task 卡片骨架)
|
|
462
|
+
*
|
|
463
|
+
* 布局(与 task 卡片对齐):
|
|
464
|
+
* 1. header.title = 🔄 Workflow 实时更新(<workflow 名>)
|
|
465
|
+
* 2. **运行栏位**:工作流 / Run ID / Workflow ID / 状态 / 节点进度 / 当前节点 / 耗时 / 失败原因 / 触发输入
|
|
466
|
+
* 3. **🎯 里程碑序列**
|
|
467
|
+
* 4. **🔧 过程信息**
|
|
468
|
+
* 5. **📊 进度**(最后一块;completed 强制 100%)
|
|
469
|
+
*/
|
|
470
|
+
export declare function buildWorkflowCard(opts: {
|
|
471
|
+
status: WorkflowCardStatus;
|
|
472
|
+
meta: WorkflowMeta;
|
|
473
|
+
milestones?: Milestone[];
|
|
474
|
+
processSteps?: ProcessStep[];
|
|
475
|
+
progress?: number;
|
|
476
|
+
completedNodes?: number;
|
|
477
|
+
totalNodes?: number;
|
|
478
|
+
currentNode?: string;
|
|
479
|
+
currentNodeType?: string;
|
|
480
|
+
durationMs?: number;
|
|
481
|
+
error?: string;
|
|
482
|
+
updateCount?: number;
|
|
483
|
+
spinner?: string;
|
|
484
|
+
}): CardPayload;
|
|
485
|
+
/**
|
|
486
|
+
* LarkCardPatchNotifier - 封装单卡片 patch 逻辑
|
|
487
|
+
*/
|
|
488
|
+
export declare class LarkCardPatchNotifier {
|
|
489
|
+
private readonly options;
|
|
490
|
+
private readonly mutexes;
|
|
491
|
+
private readonly states;
|
|
492
|
+
/**
|
|
493
|
+
* Part 2:workflow 卡片状态(key = messageId)
|
|
494
|
+
*
|
|
495
|
+
* 与 task 的 `states` 并列:两套卡片走**同一套** mutex / send / patch / pin /
|
|
496
|
+
* unpin 基础设施,只是渲染的卡片与自持的时间线不同。
|
|
497
|
+
*/
|
|
498
|
+
private readonly workflowStates;
|
|
499
|
+
/**
|
|
500
|
+
* ★ Task #4237 修复:改投链接卡片幂等表
|
|
501
|
+
*
|
|
502
|
+
* key = `${taskId}:${targetChatId}`;同一 (task, 目标群) 只允许发一张
|
|
503
|
+
* 「任务卡片已改投专属群」卡片 —— 旧实现里两条决策路径各发一次,
|
|
504
|
+
* 触发群收到两张文案不同的改投卡片。
|
|
505
|
+
*/
|
|
506
|
+
private readonly redirectsSent;
|
|
507
|
+
constructor(options?: LarkCardPatchNotifierOptions);
|
|
508
|
+
/** 取(或创建)某 messageId 的 mutex —— 不同卡片互不阻塞 */
|
|
509
|
+
private mutexFor;
|
|
510
|
+
/**
|
|
511
|
+
* 发送初始卡片 → 拿到 messageId → pin(置顶)
|
|
512
|
+
*
|
|
513
|
+
* ★ Task #4230:pin 用 `im pins create --data '{"message_id":...}'`(旧实现传
|
|
514
|
+
* `--chat-id/--message-id` 是非法 flag,导致 pin 永远失败 → 用户"还是没有 pin")。
|
|
515
|
+
*/
|
|
516
|
+
startTask(opts: StartTaskOptions): Promise<StartTaskResult>;
|
|
517
|
+
/**
|
|
518
|
+
* 在"触发群"发一条**链接卡片**,告知任务进展卡片已改投本 task 的专属群
|
|
519
|
+
*
|
|
520
|
+
* Task #4230 follow-up:当触发群被判定为"别的 task 的专属群"时,卡片不会
|
|
521
|
+
* 再落在触发群(避免跨任务污染),但 user 需要知道去哪里看 → 这里补一张
|
|
522
|
+
* 不含任务进展内容的指路卡片。
|
|
523
|
+
*
|
|
524
|
+
* 失败非致命(触发群里发不出去不影响主流程)。
|
|
525
|
+
*/
|
|
526
|
+
sendRedirectNotice(opts: RedirectNoticeOptions): Promise<boolean>;
|
|
527
|
+
/**
|
|
528
|
+
* Patch 同一卡片(状态/进度/当前步骤 + 累积里程碑与过程时间线)
|
|
529
|
+
*
|
|
530
|
+
* ★ Task #4230:patch 用 `im messages patch --data '{"content":"<card JSON>"}'`
|
|
531
|
+
* (旧实现传 `--content` 是非法 flag → 秒失败 → 卡片永远停在初始态)。
|
|
532
|
+
*/
|
|
533
|
+
updateTask(opts: UpdateTaskOptions): Promise<void>;
|
|
534
|
+
/**
|
|
535
|
+
* 完成任务:patch final status(终态里程碑 → 进度 100%)+ unpin
|
|
536
|
+
*
|
|
537
|
+
* ★ Task #4230:unpin 需要 `--yes`(`im pins delete` 是 high-risk-write,
|
|
538
|
+
* 旧实现漏了 --yes → unpin 静默失败)。
|
|
539
|
+
*/
|
|
540
|
+
finishTask(opts: FinishTaskOptions): Promise<void>;
|
|
541
|
+
/**
|
|
542
|
+
* ★ Task #4339:只更新卡片的任务元信息(meta),**保留**已累积的
|
|
543
|
+
* 里程碑 / 过程时间线 / 进度 / 更新次数。
|
|
544
|
+
*
|
|
545
|
+
* 用途:用户在卡片顶部点「为这个任务建群 / 解散该群」后,按钮需要翻面、
|
|
546
|
+
* 群链接需要出现/隐藏,但**不能**把这张卡片的进展历史冲掉。
|
|
547
|
+
*
|
|
548
|
+
* 旧实现(handler 里裸调 `buildTaskCard` 只塞 1 条 "Task 创建" 里程碑)的
|
|
549
|
+
* 后果:用户点一下按钮,卡片就退回"初始态",之前几十次进展更新全没了。
|
|
550
|
+
*
|
|
551
|
+
* ★ 同时**会**同步更新内部 `state.meta` —— 否则下一次 `updateTask`
|
|
552
|
+
* 会用旧 meta 重建卡片,把刚显示的群链接又抹掉。
|
|
553
|
+
*
|
|
554
|
+
* @param opts.clearPerTaskChat 「解散群」时必须传 true:
|
|
555
|
+
* `mergeTaskMeta` 会跳过 undefined/"" 值,**无法**用它清除字段,
|
|
556
|
+
* 所以这里显式 delete 掉 `perTaskChatId` / `perTaskChatName`。
|
|
557
|
+
* @returns 可直接提交给飞书 patch 的卡片;返回 `undefined` 表示本 notifier
|
|
558
|
+
* 没有该 messageId 的状态(进程重启 / 卡片不是本 notifier 发的),
|
|
559
|
+
* caller 需自行 fallback 构建。
|
|
560
|
+
*/
|
|
561
|
+
updateMetaAndBuildCard(messageId: string, meta: TaskMeta, opts?: {
|
|
562
|
+
clearPerTaskChat?: boolean;
|
|
563
|
+
}): CardPayload | undefined;
|
|
564
|
+
/** 诊断:当前跟踪中的卡片数(测试/自检用) */
|
|
565
|
+
trackedCardCount(): number;
|
|
566
|
+
/** 诊断:当前跟踪中的 workflow 卡片数(测试/自检用) */
|
|
567
|
+
trackedWorkflowCardCount(): number;
|
|
568
|
+
/**
|
|
569
|
+
* 发送 workflow 初始卡片 → 拿到 messageId → pin(置顶)
|
|
570
|
+
*
|
|
571
|
+
* 与 {@link startTask} 同构:同样的 send 参数契约、同样的 pin 参数契约、
|
|
572
|
+
* 同样的"pin 失败非致命"语义。差别只在渲染的是 workflow 卡片。
|
|
573
|
+
*/
|
|
574
|
+
startWorkflow(opts: StartWorkflowOptions): Promise<StartTaskResult>;
|
|
575
|
+
/**
|
|
576
|
+
* Patch 同一张 workflow 卡片(状态/进度/当前节点 + 累积里程碑与过程时间线)
|
|
577
|
+
*
|
|
578
|
+
* 与 {@link updateTask} 同构(mutex 串行化、时间线 append+去重、spinner 轮换)。
|
|
579
|
+
*/
|
|
580
|
+
updateWorkflow(opts: UpdateWorkflowOptions): Promise<void>;
|
|
581
|
+
/**
|
|
582
|
+
* 结束 workflow:patch 终态(completed 绿 / failed 红 / stopped 灰)→ unpin → 清理跟踪
|
|
583
|
+
*
|
|
584
|
+
* 与 {@link finishTask} 同构:终态里程碑 append、completed 强制 100%、
|
|
585
|
+
* unpin 非致命、最后清理内存(避免泄漏)。
|
|
586
|
+
*/
|
|
587
|
+
finishWorkflow(opts: FinishWorkflowOptions): Promise<void>;
|
|
588
|
+
/**
|
|
589
|
+
* 构建 `im +messages-send` 的 args(卡片模式)
|
|
590
|
+
*
|
|
591
|
+
* 关键点(官方 lark-cli 文档 + 2026-10-15 tongzhuli profile 实测):
|
|
592
|
+
* - --msg-type interactive
|
|
593
|
+
* - --content 是 **card JSON 字符串**(不包裹 {"content": "..."})
|
|
594
|
+
* - post 格式才用 {"zh_cn":{"content":[[{"tag":"md","text":"..."}]]}} 包裹
|
|
595
|
+
* - interactive 卡片直接传 card JSON(header + body)
|
|
596
|
+
* - 误用 post 格式 → 飞书 API 报错 code 230099 / ext 200621 "parse card json err"
|
|
597
|
+
* - --as bot(否则用 user 身份,bot 才能在群里发卡片)
|
|
598
|
+
* - profile 注入到 args 头部
|
|
599
|
+
*/
|
|
600
|
+
buildSendCardArgs(opts: {
|
|
601
|
+
chatId: string;
|
|
602
|
+
profile?: string;
|
|
603
|
+
card: CardPayload;
|
|
604
|
+
}): string[];
|
|
605
|
+
/**
|
|
606
|
+
* 构建 `im messages patch` 的 args
|
|
607
|
+
*
|
|
608
|
+
* ★ Task #4230 修复:patch **只**接受 `--data '{"content":"<card JSON 字符串>"}'`。
|
|
609
|
+
* 传 `--content` 会报 `unknown flag "--content"`(秒失败)→ 卡片永远不更新。
|
|
610
|
+
* content 必须是 **JSON 序列化后的字符串**(second stringify)。
|
|
611
|
+
*/
|
|
612
|
+
buildPatchCardArgs(opts: {
|
|
613
|
+
messageId: string;
|
|
614
|
+
profile?: string;
|
|
615
|
+
card: CardPayload;
|
|
616
|
+
}): string[];
|
|
617
|
+
/**
|
|
618
|
+
* 构建 `im pins create` 的 args(置顶卡片)
|
|
619
|
+
*
|
|
620
|
+
* ★ Task #4230 修复:pins create **只**接受 `--data '{"message_id":"om_xxx"}'`。
|
|
621
|
+
* 旧实现传 `--chat-id/--message-id` → `unknown flag "--chat-id"` → pin 永远失败。
|
|
622
|
+
*/
|
|
623
|
+
buildPinArgs(opts: {
|
|
624
|
+
messageId: string;
|
|
625
|
+
profile?: string;
|
|
626
|
+
}): string[];
|
|
627
|
+
/**
|
|
628
|
+
* 构建 `im pins delete` 的 args(取消置顶)
|
|
629
|
+
*
|
|
630
|
+
* ★ Task #4230 修复:pins delete 是 high-risk-write,**必须**带 `--yes`,
|
|
631
|
+
* 否则 lark-cli 拒绝执行 → unpin 静默失败。
|
|
632
|
+
*/
|
|
633
|
+
buildUnpinArgs(opts: {
|
|
634
|
+
messageId: string;
|
|
635
|
+
profile?: string;
|
|
636
|
+
}): string[];
|
|
637
|
+
/**
|
|
638
|
+
* 调 lark-cli(spawn)并把 args/exit code 记进 span
|
|
639
|
+
*
|
|
640
|
+
* ★ Task #4230:加上 @TracedAs,让 `debug trace` 能直接看到
|
|
641
|
+
* send/patch/pin/unpin 每一步的真实 args + 退出码(旧版这些内部方法没有
|
|
642
|
+
* span,patch 失败只能在日志里翻,trace 树断在 lark-cli-task-notify.execute)。
|
|
643
|
+
*/
|
|
644
|
+
private runLarkCli;
|
|
645
|
+
/**
|
|
646
|
+
* 从 lark-cli +messages-send 响应里提取 message_id
|
|
647
|
+
*
|
|
648
|
+
* 响应格式:{"ok": true, "data": {"message_id": "om_xxx"}}
|
|
649
|
+
*/
|
|
650
|
+
private extractMessageId;
|
|
651
|
+
}
|