pi-harness-runtime 1.1.440 → 1.1.441
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/harness/e2e/auto-test-loop.ts +2 -0
- package/harness/e2e/browser-scrapers/base-browser-scraper.ts +2 -0
- package/harness/e2e/browser-scrapers/chrome-profile-manager.ts +2 -0
- package/harness/e2e/browser-scrapers/codex-browser-scraper.ts +2 -0
- package/harness/e2e/tools-detector.ts +2 -0
- package/harness/key-loader.ts +2 -0
- package/harness/langchain/checkpointer.ts +2 -0
- package/harness/langchain/cron-cli.ts +2 -0
- package/harness/langchain/graph.ts +2 -0
- package/harness/notification-center.ts +2 -0
- package/harness/secret-provider.ts +2 -0
- package/index.ts +2 -0
- package/package.json +7 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/agent-policy/dist/extension.d.ts.map +1 -1
- package/packages/agent-policy/dist/extension.js +2 -0
- package/packages/agent-policy/dist/extension.js.map +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/agent-policy/src/extension.ts +2 -0
- package/packages/architecture-generator/package.json +1 -1
- package/packages/auth/dist/minimax-browser-auth.d.ts.map +1 -1
- package/packages/auth/dist/minimax-browser-auth.js +23 -1
- package/packages/auth/dist/minimax-browser-auth.js.map +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/auth/src/minimax-browser-auth.ts +30 -5
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/dist/inbox.d.ts.map +1 -1
- package/packages/autonomous-runtime/dist/inbox.js +2 -0
- package/packages/autonomous-runtime/dist/inbox.js.map +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/autonomous-runtime/src/inbox.ts +2 -0
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/dist/src/clipboard.d.ts.map +1 -1
- package/packages/clipboard/dist/src/clipboard.js +2 -0
- package/packages/clipboard/dist/src/clipboard.js.map +1 -1
- package/packages/clipboard/dist/src/copy-sync.d.ts.map +1 -1
- package/packages/clipboard/dist/src/copy-sync.js +2 -0
- package/packages/clipboard/dist/src/copy-sync.js.map +1 -1
- package/packages/clipboard/dist/src/gist-relay.d.ts.map +1 -1
- package/packages/clipboard/dist/src/gist-relay.js +2 -0
- package/packages/clipboard/dist/src/gist-relay.js.map +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard/src/clipboard.ts +2 -0
- package/packages/clipboard/src/copy-sync.ts +2 -0
- package/packages/clipboard/src/gist-relay.ts +2 -0
- package/packages/clipboard-plugin/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/connection-runtime/package.json +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/contracts/dist/delegation-store.js +1 -4
- package/packages/contracts/dist/workspace-env.js +28 -1
- package/packages/contracts/package.json +1 -1
- package/packages/contracts/src/delegation-store.ts +9 -4
- package/packages/contracts/src/workspace-env.ts +29 -4
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/durable-review/package.json +1 -1
- package/packages/e2e-tester/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-sink/package.json +1 -1
- package/packages/event-store/dist/src/store.d.ts.map +1 -1
- package/packages/event-store/dist/src/store.js +2 -0
- package/packages/event-store/dist/src/store.js.map +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/event-store/src/store.ts +3 -0
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/dist/analyzer.d.ts.map +1 -1
- package/packages/generic-web-plugin/dist/analyzer.js +2 -0
- package/packages/generic-web-plugin/dist/analyzer.js.map +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/generic-web-plugin/src/analyzer.ts +3 -0
- package/packages/health-monitor/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/knowledge-graph/package.json +1 -1
- package/packages/knowledge-retrieval/dist/mcp-client.d.ts.map +1 -1
- package/packages/knowledge-retrieval/dist/mcp-client.js +0 -1
- package/packages/knowledge-retrieval/dist/mcp-client.js.map +1 -1
- package/packages/knowledge-retrieval/package.json +1 -4
- package/packages/knowledge-retrieval/src/mcp-client.ts +0 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/logging/package.json +1 -1
- package/packages/mcp-adapter/dist/server.d.ts.map +1 -1
- package/packages/mcp-adapter/dist/server.js +2 -0
- package/packages/mcp-adapter/dist/server.js.map +1 -1
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/mcp-adapter/src/server.ts +3 -0
- package/packages/memory-engine/package.json +1 -1
- package/packages/milestone-manager/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/observability/package.json +1 -1
- package/packages/okf-indexer/package.json +1 -1
- package/packages/paperclip-integration/dist/index.d.ts.map +1 -1
- package/packages/paperclip-integration/dist/index.js +2 -0
- package/packages/paperclip-integration/dist/index.js.map +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/paperclip-integration/src/index.ts +2 -0
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/permission-mode/package.json +1 -1
- package/packages/privilege-broker/dist/audit.d.ts.map +1 -1
- package/packages/privilege-broker/dist/audit.js +2 -0
- package/packages/privilege-broker/dist/audit.js.map +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/privilege-broker/src/audit.ts +2 -0
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-bootstrap/package.json +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/dist/compiler.d.ts.map +1 -1
- package/packages/prompt-compiler/dist/compiler.js +2 -0
- package/packages/prompt-compiler/dist/compiler.js.map +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-compiler/src/compiler.ts +2 -0
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-mcp-client/dist/client.d.ts.map +1 -1
- package/packages/skill-mcp-client/dist/client.js +0 -1
- package/packages/skill-mcp-client/dist/client.js.map +1 -1
- package/packages/skill-mcp-client/package.json +1 -4
- package/packages/skill-mcp-client/src/client.ts +0 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skills/dist/parser.d.ts.map +1 -1
- package/packages/skills/dist/parser.js +2 -0
- package/packages/skills/dist/parser.js.map +1 -1
- package/packages/skills/dist/skill-versioning.d.ts.map +1 -1
- package/packages/skills/dist/skill-versioning.js +2 -0
- package/packages/skills/dist/skill-versioning.js.map +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/skills/src/parser.ts +3 -0
- package/packages/skills/src/skill-versioning.ts +2 -0
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/tencentdb-memory/package.json +1 -1
- package/packages/tencentdb-sync/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/tooling-preference/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/two-phase-review/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/voice-api/package.json +1 -1
- package/packages/webmcp-tester/dist/index.js +0 -2
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/webmcp-tester/src/index.ts +0 -3
- package/packages/wiki/package.json +1 -1
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/packages/write-review/dist/trigger.d.ts.map +1 -1
- package/packages/write-review/dist/trigger.js +1 -2
- package/packages/write-review/dist/trigger.js.map +1 -1
- package/packages/write-review/package.json +1 -1
- package/packages/write-review/src/trigger.ts +1 -2
- package/scripts/lib/runtime-imports.ts +189 -3
- package/scripts/telegram-webhook-server.ts +2 -0
- package/scripts/verify-package-contents.ts +148 -1
- package/harness/e2e/tools-detector.test.ts +0 -155
- package/harness/glm-quota-countdown.test.ts +0 -323
- package/harness/langchain/agents.test.ts +0 -39
- package/harness/langchain/checkpointer.test.ts +0 -243
- package/harness/langchain/daemon.test.ts +0 -459
- package/harness/langchain/model-router.test.ts +0 -191
- package/harness/langchain/ping-pong-middleware.test.ts +0 -69
- package/harness/langchain/scoreboard.test.ts +0 -267
- package/harness/langchain/status-line.test.ts +0 -106
- package/harness/langchain/surge.test.ts +0 -467
- package/harness/langchain/widget.test.ts +0 -251
- package/harness/skill-sync.test.ts +0 -57
- package/harness/ssh-detach-interceptor.test.ts +0 -263
- package/harness/ssh-hang-recovery.test.ts +0 -86
- package/packages/a2a-adapter/test/a2a.test.ts +0 -151
- package/packages/agent-policy/test/interlock.test.ts +0 -101
- package/packages/agent-policy/test/policy-retention.test.ts +0 -380
- package/packages/agent-policy/test/policy.test.ts +0 -387
- package/packages/auth/test/auth.test.ts +0 -238
- package/packages/autonomous-refactor/test/refactor.test.ts +0 -202
- package/packages/autonomous-runtime/test/types.test.ts +0 -95
- package/packages/cache-strategy/test/cache.test.ts +0 -137
- package/packages/capability-registry/test/registry.test.ts +0 -204
- package/packages/checkpoint/test/engine.test.ts +0 -265
- package/packages/cli-plugin-sdk/test/cli.test.ts +0 -45
- package/packages/code-generation/test/generator.test.ts +0 -238
- package/packages/code-review/test/engine.test.ts +0 -302
- package/packages/codex-adapter/test/provider.test.ts +0 -142
- package/packages/codex-watcher/test/watch.test.ts +0 -453
- package/packages/context-compiler/test/context-compiler.test.ts +0 -746
- package/packages/context-manager/test/context.test.ts +0 -198
- package/packages/contracts/test/delegation.test.ts +0 -350
- package/packages/contracts/test/workspace-env.test.ts +0 -802
- package/packages/cookie-sanitizer/test/infer.test.ts +0 -110
- package/packages/cookie-sanitizer/test/normalize.test.ts +0 -113
- package/packages/cookie-sanitizer/test/parse.test.ts +0 -204
- package/packages/cookie-sanitizer/test/sync.test.ts +0 -237
- package/packages/cookie-sanitizer/test/watcher.test.ts +0 -27
- package/packages/cost-optimizer/test/cost-optimizer.test.ts +0 -438
- package/packages/dependency-analyzer/test/analyzer.test.ts +0 -49
- package/packages/django-plugin/test/analyzer.test.ts +0 -195
- package/packages/doc-generator/test/docs.test.ts +0 -168
- package/packages/durable-review/test/acceptance.test.ts +0 -357
- package/packages/durable-review/test/smoke.test.ts +0 -107
- package/packages/evaluation-engine/test/engine.test.ts +0 -277
- package/packages/evaluation-runner/test/runner.test.ts +0 -168
- package/packages/event-bus/test/bus.test.ts +0 -100
- package/packages/event-store/test/store.test.ts +0 -115
- package/packages/experience-replay/test/replay.test.ts +0 -267
- package/packages/feedback-collector/test/collector.test.ts +0 -142
- package/packages/framework-detector/test/detector.test.ts +0 -75
- package/packages/framework-plugin-sdk/test/manager.test.ts +0 -320
- package/packages/frappe-plugin/test/analyzer.test.ts +0 -250
- package/packages/generic-web-plugin/test/analyzer.test.ts +0 -134
- package/packages/health-monitor/test/health.test.ts +0 -231
- package/packages/intent-analyzer/test/analyzer.test.ts +0 -72
- package/packages/intent-analyzer/test/ping-pong.test.ts +0 -96
- package/packages/jev-judge/tests/auto-continue-context.test.ts +0 -280
- package/packages/jev-judge/tests/continuation-controller.test.ts +0 -1396
- package/packages/jev-judge/tests/jev-provider-chain.test.ts +0 -536
- package/packages/jev-judge/tests/outcome-application.test.ts +0 -132
- package/packages/jev-judge/tests/question-risk.test.ts +0 -129
- package/packages/jev-judge/tests/typesafe-provider.test.ts +0 -640
- package/packages/jev-judge/tests/validation-ledger.test.ts +0 -181
- package/packages/jev-judge/tests/validation-plan.test.ts +0 -170
- package/packages/jev-judge/tests/validation-tie-breaker.test.ts +0 -88
- package/packages/laravel-plugin/test/analyzer.test.ts +0 -220
- package/packages/learning-engine/test/engine.test.ts +0 -331
- package/packages/logging/test/buffer.test.ts +0 -44
- package/packages/logging/test/classification.test.ts +0 -137
- package/packages/logging/test/config.test.ts +0 -97
- package/packages/logging/test/fanout.test.ts +0 -186
- package/packages/logging/test/identity-transport.test.ts +0 -197
- package/packages/logging/test/incidents.test.ts +0 -404
- package/packages/logging/test/ingest-schema.test.ts +0 -184
- package/packages/logging/test/integration.test.ts +0 -140
- package/packages/logging/test/log-http.test.ts +0 -246
- package/packages/logging/test/redact.test.ts +0 -109
- package/packages/logging/test/sampler.test.ts +0 -57
- package/packages/logging/test/server.test.ts +0 -444
- package/packages/logging/test/shipper.test.ts +0 -152
- package/packages/logging/test/spool.test.ts +0 -96
- package/packages/mcp-adapter/test/server.test.ts +0 -91
- package/packages/memory-engine/test/engine.test.ts +0 -456
- package/packages/model-registry/test/registry.test.ts +0 -342
- package/packages/nextjs-plugin/test/analyzer.test.ts +0 -149
- package/packages/notification/test/approval-payload.test.ts +0 -269
- package/packages/notification/test/detail-format.test.ts +0 -106
- package/packages/notification/test/notification.test.ts +0 -375
- package/packages/notification/test/pending-question-lifecycle.test.ts +0 -195
- package/packages/notification/test/pending-question.test.ts +0 -331
- package/packages/notification/test/tooling-proposal-payload.test.ts +0 -212
- package/packages/observability/test/observability.test.ts +0 -1350
- package/packages/performance-optimizer/test/optimizer.test.ts +0 -267
- package/packages/project-analyzer/test/index.test.ts +0 -1719
- package/packages/prompt-compiler/test/prompt-compiler.test.ts +0 -813
- package/packages/prompt-versioning/test/versioning.test.ts +0 -112
- package/packages/provider-adapter-sdk/test/sdk.test.ts +0 -220
- package/packages/provider-router/test/provider-router.test.ts +0 -405
- package/packages/provider-selector/test/selector.test.ts +0 -192
- package/packages/providers/test/providers.test.ts +0 -225
- package/packages/qdrant-skills/test/collection-info.test.ts +0 -165
- package/packages/qdrant-skills/test/embedder-batch.test.ts +0 -184
- package/packages/qdrant-skills/test/embedder.test.ts +0 -97
- package/packages/quota-manager/test/quota.test.ts +0 -432
- package/packages/rate-limiter/test/limiter.test.ts +0 -128
- package/packages/react-vite-plugin/test/analyzer.test.ts +0 -139
- package/packages/relay/test/client.test.ts +0 -446
- package/packages/relay/test/relay-e2e.test.ts +0 -299
- package/packages/relay/test/relay-endpoint.test.ts +0 -278
- package/packages/release-manager/test/release.test.ts +0 -215
- package/packages/requirement-compiler/test/requirement-compiler.test.ts +0 -743
- package/packages/runtime/test/runtime-api.test.ts +0 -169
- package/packages/runtime/test/runtime.test.ts +0 -297
- package/packages/scheduler/test/scheduler.test.ts +0 -125
- package/packages/session/test/manager.test.ts +0 -233
- package/packages/shared-context/test/shared-context.test.ts +0 -114
- package/packages/skill-registry/test/registry.test.ts +0 -508
- package/packages/skills/test/init-skills.test.ts +0 -114
- package/packages/skills/test/remote-skills.test.ts +0 -360
- package/packages/skills/test/remote-source.test.ts +0 -248
- package/packages/skills/test/sanitize.test.ts +0 -250
- package/packages/skills/test/vector-indexing.test.ts +0 -205
- package/packages/skills/test/vector-schema.test.ts +0 -180
- package/packages/skills/test/vector-threshold.test.ts +0 -108
- package/packages/sprint-planner/test/planner.test.ts +0 -187
- package/packages/task-compiler/test/task-compiler.test.ts +0 -628
- package/packages/test-data-generator/test/generator.test.ts +0 -265
- package/packages/test-generator/test/generator.test.ts +0 -156
- package/packages/token-estimation/test/token-estimation.test.ts +0 -207
- package/packages/token-optimizer/test/optimizer.test.ts +0 -141
- package/packages/tooling-preference/tests/changed-files.test.ts +0 -124
- package/packages/tooling-preference/tests/detect.test.ts +0 -188
- package/packages/tooling-preference/tests/proposal.test.ts +0 -107
- package/packages/tooling-preference/tests/quality-check.test.ts +0 -272
- package/packages/tooling-preference/tests/registry.test.ts +0 -51
- package/packages/tooling-preference/tests/store.test.ts +0 -99
- package/packages/trajectory/test/store.test.ts +0 -250
- package/packages/tui/test/harness-footer.test.ts +0 -559
- package/packages/tui/test/harness-header.test.ts +0 -590
- package/packages/two-phase-review/test/classify.test.ts +0 -102
- package/packages/two-phase-review/test/helpers.ts +0 -72
- package/packages/two-phase-review/test/rules.test.ts +0 -150
- package/packages/two-phase-review/test/runtime.test.ts +0 -362
- package/packages/two-phase-review/test/scope.test.ts +0 -186
- package/packages/two-phase-review/test/signals.test.ts +0 -183
- package/packages/two-phase-review/test/state.test.ts +0 -201
- package/packages/wiki/test/basic.test.ts +0 -242
- package/packages/workspace-scanner/test/scanner.test.ts +0 -43
- package/packages/worktree/test/worktree.test.ts +0 -163
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Approval payload tests.
|
|
3
|
-
*
|
|
4
|
-
* The question has to reach the user complete, and the Yes/No actions have
|
|
5
|
-
* to point at the canonical request ID - on Telegram and on LINE. A button
|
|
6
|
-
* that carries a prefixed job ID can never match the pending question, so
|
|
7
|
-
* every click is reported as stale and the approval is lost.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { describe, it, expect, beforeEach, afterEach } from "bun:test";
|
|
11
|
-
import { NotificationCenter } from "../src/notification-center.js";
|
|
12
|
-
import { PendingQuestionController } from "../src/pending-question.js";
|
|
13
|
-
import { parseCallbackData } from "../src/telegram-webhook-handler.js";
|
|
14
|
-
import type { NotificationConfig } from "../src/types.js";
|
|
15
|
-
|
|
16
|
-
const LONG_QUESTION =
|
|
17
|
-
"Want me to implement the persistence layer with the SQLite schema, the migration runner and the rollback path, and then wire it into the harness? ";
|
|
18
|
-
|
|
19
|
-
interface CapturedRequest {
|
|
20
|
-
url: string;
|
|
21
|
-
body: Record<string, any>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
let captured: CapturedRequest[] = [];
|
|
25
|
-
let originalFetch: typeof globalThis.fetch;
|
|
26
|
-
|
|
27
|
-
function createCenter(): NotificationCenter {
|
|
28
|
-
const config: NotificationConfig = {
|
|
29
|
-
channels: [
|
|
30
|
-
{
|
|
31
|
-
id: "telegram",
|
|
32
|
-
type: "telegram",
|
|
33
|
-
enabled: true,
|
|
34
|
-
config: {
|
|
35
|
-
botToken: "test-bot-token",
|
|
36
|
-
chatId: "12345",
|
|
37
|
-
enableInlineKeyboard: true,
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
id: "line",
|
|
42
|
-
type: "line",
|
|
43
|
-
enabled: true,
|
|
44
|
-
config: { channelAccessToken: "test-line-token", userId: "U-test" },
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
};
|
|
48
|
-
return new NotificationCenter(config);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function telegramRequests(): CapturedRequest[] {
|
|
52
|
-
return captured.filter((r) => r.url.includes("api.telegram.org"));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function lineRequests(): CapturedRequest[] {
|
|
56
|
-
return captured.filter((r) => r.url.includes("api.line.me"));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
beforeEach(() => {
|
|
60
|
-
captured = [];
|
|
61
|
-
originalFetch = globalThis.fetch;
|
|
62
|
-
globalThis.fetch = (async (input: any, init?: any) => {
|
|
63
|
-
const url = typeof input === "string" ? input : (input?.url ?? "");
|
|
64
|
-
let body: any = {};
|
|
65
|
-
try {
|
|
66
|
-
body = JSON.parse(init?.body ?? "{}");
|
|
67
|
-
} catch {
|
|
68
|
-
body = {};
|
|
69
|
-
}
|
|
70
|
-
captured.push({ url, body });
|
|
71
|
-
|
|
72
|
-
// The content filter asks Jev. Without a configured key the answer
|
|
73
|
-
// does not matter, and a failure keeps the test offline.
|
|
74
|
-
if (url.includes("typesafe.ai")) {
|
|
75
|
-
return new Response("unauthorized", { status: 401 });
|
|
76
|
-
}
|
|
77
|
-
return new Response(JSON.stringify({ ok: true, result: {} }), {
|
|
78
|
-
status: 200,
|
|
79
|
-
headers: { "Content-Type": "application/json" },
|
|
80
|
-
});
|
|
81
|
-
}) as typeof globalThis.fetch;
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
afterEach(() => {
|
|
85
|
-
globalThis.fetch = originalFetch;
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe("approval payload", () => {
|
|
89
|
-
it("sends the complete question to Telegram without truncating it", async () => {
|
|
90
|
-
const center = createCenter();
|
|
91
|
-
const question = LONG_QUESTION.repeat(3);
|
|
92
|
-
|
|
93
|
-
await center.notifyWithApproval("WaitingForUserInput", {
|
|
94
|
-
jobId: "q-long",
|
|
95
|
-
questionId: "q-long",
|
|
96
|
-
requirement: question,
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
const text = telegramRequests()
|
|
100
|
-
.map((r) => String(r.body.text ?? ""))
|
|
101
|
-
.join("\n");
|
|
102
|
-
|
|
103
|
-
expect(text).toContain(question.trim());
|
|
104
|
-
// The shared 50 character summary must not be used for a question.
|
|
105
|
-
expect(text).not.toContain("...");
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("sends the complete question to LINE", async () => {
|
|
109
|
-
const center = createCenter();
|
|
110
|
-
const question = LONG_QUESTION.repeat(3);
|
|
111
|
-
|
|
112
|
-
await center.notifyWithApproval("WaitingForUserInput", {
|
|
113
|
-
jobId: "q-long",
|
|
114
|
-
questionId: "q-long",
|
|
115
|
-
requirement: question,
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
const line = lineRequests()[0];
|
|
119
|
-
const messages = line?.body?.messages ?? [];
|
|
120
|
-
const textMessage = messages.find((m: any) => m.type === "text");
|
|
121
|
-
|
|
122
|
-
expect(textMessage).toBeDefined();
|
|
123
|
-
expect(String(textMessage.text)).toContain(question.trim());
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it("puts the canonical request ID into the Telegram callback data", async () => {
|
|
127
|
-
const center = createCenter();
|
|
128
|
-
|
|
129
|
-
await center.notifyWithApproval("WaitingForUserInput", {
|
|
130
|
-
jobId: "waiting-user-q-123",
|
|
131
|
-
questionId: "q-123",
|
|
132
|
-
requirement: "Want me to continue?",
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
const telegram = telegramRequests()[0];
|
|
136
|
-
const keyboard = telegram?.body?.reply_markup;
|
|
137
|
-
expect(keyboard).toBeDefined();
|
|
138
|
-
|
|
139
|
-
const approve = keyboard.inline_keyboard[0][0];
|
|
140
|
-
const reject = keyboard.inline_keyboard[0][1];
|
|
141
|
-
|
|
142
|
-
const parsedApprove = parseCallbackData(approve.callback_data);
|
|
143
|
-
const parsedReject = parseCallbackData(reject.callback_data);
|
|
144
|
-
|
|
145
|
-
expect(parsedApprove.action).toBe("approve");
|
|
146
|
-
expect(parsedReject.action).toBe("reject");
|
|
147
|
-
// The canonical ID, not the prefixed presentation job ID.
|
|
148
|
-
expect(parsedApprove.targetId).toBe("q-123");
|
|
149
|
-
expect(parsedReject.targetId).toBe("q-123");
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it("resolves the matching pending question from the real callback data", async () => {
|
|
153
|
-
const center = createCenter();
|
|
154
|
-
const controller = new PendingQuestionController();
|
|
155
|
-
const question = controller.createQuestion({
|
|
156
|
-
text: "Want me to continue?",
|
|
157
|
-
sessionId: "session-1",
|
|
158
|
-
workspacePath: "/tmp",
|
|
159
|
-
kind: "approval",
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
await center.notifyWithApproval("WaitingForUserInput", {
|
|
163
|
-
jobId: `waiting-user-${question.requestId}`,
|
|
164
|
-
questionId: question.requestId,
|
|
165
|
-
requirement: "Want me to continue?",
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
const telegram = telegramRequests()[0];
|
|
169
|
-
const callbackData = telegram.body.reply_markup.inline_keyboard[0][0]
|
|
170
|
-
.callback_data as string;
|
|
171
|
-
const parsed = parseCallbackData(callbackData);
|
|
172
|
-
|
|
173
|
-
const applied = controller.applyApproval(
|
|
174
|
-
parsed.action,
|
|
175
|
-
parsed.targetId,
|
|
176
|
-
"telegram",
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
expect(applied.applied).toBe(true);
|
|
180
|
-
expect(applied.resolution).toBe("yes");
|
|
181
|
-
expect(controller.getResolution()).toBe("yes");
|
|
182
|
-
expect(controller.getCurrentQuestion()?.resolvedBy).toBe("user");
|
|
183
|
-
expect(controller.getCurrentQuestion()?.resolvedChannel).toBe("telegram");
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it("uses the same canonical ID for the LINE postback actions", async () => {
|
|
187
|
-
const center = createCenter();
|
|
188
|
-
|
|
189
|
-
await center.notifyWithApproval("WaitingForUserInput", {
|
|
190
|
-
jobId: "waiting-user-q-123",
|
|
191
|
-
questionId: "q-123",
|
|
192
|
-
requirement: "Want me to continue?",
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
const line = lineRequests()[0];
|
|
196
|
-
const messages = line?.body?.messages ?? [];
|
|
197
|
-
const template = messages.find((m: any) => m.type === "template");
|
|
198
|
-
expect(template).toBeDefined();
|
|
199
|
-
|
|
200
|
-
const actions = template.template.actions;
|
|
201
|
-
expect(actions).toHaveLength(2);
|
|
202
|
-
expect(actions[0].type).toBe("postback");
|
|
203
|
-
expect(actions[1].type).toBe("postback");
|
|
204
|
-
|
|
205
|
-
const approve = parseCallbackData(actions[0].data);
|
|
206
|
-
const reject = parseCallbackData(actions[1].data);
|
|
207
|
-
|
|
208
|
-
expect(approve.action).toBe("approve");
|
|
209
|
-
expect(reject.action).toBe("reject");
|
|
210
|
-
expect(approve.targetId).toBe("q-123");
|
|
211
|
-
expect(reject.targetId).toBe("q-123");
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
it("routes the LINE postback into the same resolver as Telegram", async () => {
|
|
215
|
-
const center = createCenter();
|
|
216
|
-
const controller = new PendingQuestionController();
|
|
217
|
-
const question = controller.createQuestion({
|
|
218
|
-
text: "Want me to continue?",
|
|
219
|
-
sessionId: "session-1",
|
|
220
|
-
workspacePath: "/tmp",
|
|
221
|
-
kind: "approval",
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
await center.notifyWithApproval("WaitingForUserInput", {
|
|
225
|
-
jobId: `waiting-user-${question.requestId}`,
|
|
226
|
-
questionId: question.requestId,
|
|
227
|
-
requirement: "Want me to continue?",
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
const line = lineRequests()[0];
|
|
231
|
-
const messages = line?.body?.messages ?? [];
|
|
232
|
-
const template = messages.find((m: any) => m.type === "template");
|
|
233
|
-
const parsed = parseCallbackData(template.template.actions[0].data);
|
|
234
|
-
|
|
235
|
-
const applied = controller.applyApproval(
|
|
236
|
-
parsed.action,
|
|
237
|
-
parsed.targetId,
|
|
238
|
-
"line",
|
|
239
|
-
);
|
|
240
|
-
|
|
241
|
-
expect(applied.applied).toBe(true);
|
|
242
|
-
expect(controller.getResolution()).toBe("yes");
|
|
243
|
-
expect(controller.getCurrentQuestion()?.resolvedChannel).toBe("line");
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it("attaches the keyboard only to the final chunk of a long question", async () => {
|
|
247
|
-
const center = createCenter();
|
|
248
|
-
const question = `${LONG_QUESTION.repeat(30)}Want me to continue?`;
|
|
249
|
-
|
|
250
|
-
await center.notifyWithApproval("WaitingForUserInput", {
|
|
251
|
-
jobId: "q-chunked",
|
|
252
|
-
questionId: "q-chunked",
|
|
253
|
-
requirement: question,
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
const requests = telegramRequests();
|
|
257
|
-
expect(requests.length).toBeGreaterThan(1);
|
|
258
|
-
|
|
259
|
-
const withKeyboard = requests.filter((r) => r.body?.reply_markup);
|
|
260
|
-
expect(withKeyboard).toHaveLength(1);
|
|
261
|
-
// The actionable message is the last one.
|
|
262
|
-
expect(withKeyboard[0]).toBe(requests[requests.length - 1]);
|
|
263
|
-
|
|
264
|
-
// The question stays understandable across the chunks.
|
|
265
|
-
const allText = requests.map((r) => String(r.body.text ?? "")).join("");
|
|
266
|
-
expect(allText).toContain("Want me to continue?");
|
|
267
|
-
expect(allText).toContain("[Part 1/");
|
|
268
|
-
});
|
|
269
|
-
});
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Notification detail formatting.
|
|
3
|
-
*
|
|
4
|
-
* A resume trigger ("provider-overload", "post-compact") is a reason, not an
|
|
5
|
-
* error. It must never be rendered under the "Error:" footer, otherwise every
|
|
6
|
-
* scheduled resume looks like a failure in the Telegram message.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { describe, it, expect } from "bun:test";
|
|
10
|
-
import {
|
|
11
|
-
ERROR_EVENTS,
|
|
12
|
-
formatDetailLines,
|
|
13
|
-
isErrorEvent,
|
|
14
|
-
} from "../src/adapters/detail-format.js";
|
|
15
|
-
import { buildTelegramMessage } from "../src/adapters/telegram-adapter.js";
|
|
16
|
-
import type { NotificationEvent, NotificationPayload } from "../src/types.js";
|
|
17
|
-
|
|
18
|
-
function payload(
|
|
19
|
-
event: NotificationEvent,
|
|
20
|
-
details: Record<string, unknown>,
|
|
21
|
-
message = "Job will resume work on: \"Session auto-resume\"",
|
|
22
|
-
): NotificationPayload {
|
|
23
|
-
return {
|
|
24
|
-
event,
|
|
25
|
-
jobId: "job-1",
|
|
26
|
-
timestamp: "2026-10-24T00:00:00.000Z",
|
|
27
|
-
title: "Resume Scheduled",
|
|
28
|
-
message,
|
|
29
|
-
details: { jobId: "job-1", requirement: "Session auto-resume", ...details },
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
describe("detail formatter", () => {
|
|
34
|
-
it("renders a resume reason as a reason, not as an error", () => {
|
|
35
|
-
const lines = formatDetailLines({ reason: "provider-overload" }, "ResumeScheduled");
|
|
36
|
-
|
|
37
|
-
expect(lines).toEqual([{ label: "Reason", value: "provider-overload" }]);
|
|
38
|
-
expect(lines.some((line) => line.label === "Error")).toBe(false);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("renders a real error under the error label", () => {
|
|
42
|
-
const lines = formatDetailLines({ error: "NullPointerException" }, "TaskFailed");
|
|
43
|
-
|
|
44
|
-
expect(lines).toEqual([{ label: "Error", value: "NullPointerException" }]);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("keeps a legacy error of a non error event readable as a reason", () => {
|
|
48
|
-
const lines = formatDetailLines({ error: "Resumes at 12:00" }, "QuotaPaused");
|
|
49
|
-
|
|
50
|
-
expect(lines).toEqual([{ label: "Reason", value: "Resumes at 12:00" }]);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("knows which events are error events", () => {
|
|
54
|
-
expect(isErrorEvent("TaskFailed")).toBe(true);
|
|
55
|
-
expect(isErrorEvent("E2EFailed")).toBe(true);
|
|
56
|
-
expect(isErrorEvent("Error")).toBe(true);
|
|
57
|
-
expect(isErrorEvent("ResumeScheduled")).toBe(false);
|
|
58
|
-
expect(isErrorEvent("QuotaPaused")).toBe(false);
|
|
59
|
-
expect(isErrorEvent("ContextCompacted")).toBe(false);
|
|
60
|
-
expect(ERROR_EVENTS.has("ResumeScheduled")).toBe(false);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("ignores empty and non string details", () => {
|
|
64
|
-
expect(formatDetailLines({ reason: " " }, "ResumeScheduled")).toEqual([]);
|
|
65
|
-
expect(formatDetailLines({ reason: 42 }, "ResumeScheduled")).toEqual([]);
|
|
66
|
-
expect(formatDetailLines(undefined, "ResumeScheduled")).toEqual([]);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
describe("telegram message rendering", () => {
|
|
71
|
-
it("shows the resume reason without an error footer", () => {
|
|
72
|
-
const message = buildTelegramMessage(
|
|
73
|
-
payload("ResumeScheduled", { reason: "post-compact" }),
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
expect(message).toContain("Reason: post-compact");
|
|
77
|
-
expect(message).not.toContain("Error:");
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("shows the provider overload trigger without an error footer", () => {
|
|
81
|
-
const message = buildTelegramMessage(
|
|
82
|
-
payload("ResumeScheduled", { reason: "provider-overload" }),
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
expect(message).toContain("Reason: provider-overload");
|
|
86
|
-
expect(message).not.toContain("Error:");
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("still renders a real failure as an error", () => {
|
|
90
|
-
const message = buildTelegramMessage(
|
|
91
|
-
payload("TaskFailed", { error: "NullPointerException" }, "Task \"Fix login\" failed"),
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
expect(message).toContain("Error: NullPointerException");
|
|
95
|
-
expect(message).not.toContain("Reason:");
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("keeps the legacy error of a resume event out of the error footer", () => {
|
|
99
|
-
const message = buildTelegramMessage(
|
|
100
|
-
payload("ResumeScheduled", { error: "provider-overload" }),
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
expect(message).not.toContain("Error:");
|
|
104
|
-
expect(message).toContain("Reason: provider-overload");
|
|
105
|
-
});
|
|
106
|
-
});
|