pi-crew 0.9.55 → 0.9.57
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/AGENTS.md +1 -1
- package/CHANGELOG.md +58 -0
- package/README.md +53 -5
- package/dist/index.mjs +5666 -4370
- package/docs/README.md +54 -0
- package/package.json +12 -13
- package/skills/real-test-pi-crew/SKILL.md +93 -3
- package/src/agents/discover-agents.ts +68 -10
- package/src/benchmark/feedback-loop.ts +1 -1
- package/src/config/config.ts +2 -1
- package/src/config/types.ts +12 -0
- package/src/extension/action-suggestions.ts +16 -63
- package/src/extension/async-notifier.ts +3 -3
- package/src/extension/command-completions.ts +2 -2
- package/src/extension/crew-cleanup.ts +3 -3
- package/src/extension/crew-vibes/footer.ts +4 -2
- package/src/extension/cross-extension-rpc.ts +10 -5
- package/src/extension/knowledge-injection.ts +57 -10
- package/src/extension/register.ts +2 -2
- package/src/extension/registration/artifact-cleanup.ts +41 -3
- package/src/extension/registration/commands.ts +4 -4
- package/src/extension/registration/context-builder.ts +10 -10
- package/src/extension/registration/crash-recovery-cache.ts +3 -3
- package/src/extension/registration/foreground-run-controller.ts +1 -1
- package/src/extension/registration/lazy-configurers.ts +2 -2
- package/src/extension/registration/lifecycle-handlers.ts +12 -12
- package/src/extension/registration/lifecycle.ts +2 -2
- package/src/extension/registration/observability.ts +2 -2
- package/src/extension/registration/registration-types.ts +3 -3
- package/src/extension/registration/runtime-cleanup.ts +1 -1
- package/src/extension/registration/subagent-helpers.ts +2 -2
- package/src/extension/registration/subagent-manager-setup.ts +2 -2
- package/src/extension/registration/subagent-tools.ts +21 -16
- package/src/extension/registration/team-tool.ts +109 -17
- package/src/extension/registration/viewers.ts +3 -4
- package/src/extension/registration/wire-cross-extension.ts +7 -7
- package/src/extension/rpc-hmac.ts +3 -2
- package/src/extension/run-bundle-schema.ts +13 -4
- package/src/extension/run-export.ts +2 -2
- package/src/extension/run-index.ts +2 -3
- package/src/extension/run-maintenance.ts +57 -1
- package/src/extension/team-manager-command.ts +3 -1
- package/src/extension/team-tool/anchor.ts +8 -2
- package/src/extension/team-tool/api.ts +117 -39
- package/src/extension/team-tool/cancel.ts +23 -8
- package/src/extension/team-tool/chain-executor.ts +1 -1
- package/src/extension/team-tool/dispatch/automate.ts +17 -2
- package/src/extension/team-tool/dispatch/control.ts +17 -2
- package/src/extension/team-tool/dispatch/manage.ts +34 -2
- package/src/extension/team-tool/dispatch/run.ts +17 -2
- package/src/extension/team-tool/dispatch/status.ts +37 -5
- package/src/extension/team-tool/doctor.ts +2 -2
- package/src/extension/team-tool/explain.ts +1 -1
- package/src/extension/team-tool/goal-wrap.ts +5 -5
- package/src/extension/team-tool/goal.ts +30 -9
- package/src/extension/team-tool/handle-schedule.ts +37 -19
- package/src/extension/team-tool/inspect.ts +21 -5
- package/src/extension/team-tool/lifecycle-actions.ts +53 -10
- package/src/extension/team-tool/parallel-dispatch.ts +14 -5
- package/src/extension/team-tool/param-error.ts +138 -0
- package/src/extension/team-tool/respond.ts +20 -6
- package/src/extension/team-tool/run.ts +27 -17
- package/src/extension/team-tool/status.ts +17 -6
- package/src/extension/team-tool.ts +26 -19
- package/src/hooks/registry.ts +1 -1
- package/src/i18n.ts +22 -0
- package/src/observability/event-bus.ts +1 -1
- package/src/prompt/prompt-runtime.ts +2 -2
- package/src/runtime/README.md +35 -0
- package/src/runtime/agent-control.ts +1 -1
- package/src/runtime/anchor-manager.ts +0 -2
- package/src/runtime/async-runner.ts +1 -1
- package/src/runtime/attention-events.ts +3 -2
- package/src/runtime/auto-summarize.ts +0 -2
- package/src/runtime/background-runner.ts +103 -30
- package/src/runtime/{crew-broker-child.ts → broker/crew-broker-child.ts} +2 -2
- package/src/runtime/{crew-broker-client.ts → broker/crew-broker-client.ts} +4 -7
- package/src/runtime/{crew-broker.ts → broker/crew-broker.ts} +13 -21
- package/src/runtime/chain-runner.ts +50 -5
- package/src/runtime/{child-pi-constants.ts → child-pi/child-pi-constants.ts} +1 -1
- package/src/runtime/{child-pi-kill.ts → child-pi/child-pi-kill.ts} +3 -3
- package/src/runtime/{child-pi-spawn.ts → child-pi/child-pi-spawn.ts} +28 -12
- package/src/runtime/{child-pi-steering.ts → child-pi/child-pi-steering.ts} +1 -1
- package/src/runtime/{child-pi-streams.ts → child-pi/child-pi-streams.ts} +23 -4
- package/src/runtime/{child-pi-transcript.ts → child-pi/child-pi-transcript.ts} +6 -6
- package/src/runtime/{child-pi.ts → child-pi/child-pi.ts} +47 -78
- package/src/runtime/compaction/compact-stages/bounded-tail.ts +84 -0
- package/src/runtime/{compact-stages → compaction/compact-stages}/index.ts +2 -2
- package/src/runtime/{compaction-summary.ts → compaction/compaction-summary.ts} +3 -3
- package/src/runtime/{tool-output-pruner.ts → compaction/tool-output-pruner.ts} +1 -1
- package/src/runtime/crew-agent-records.ts +48 -2
- package/src/runtime/custom-tools/irc-tool.ts +2 -2
- package/src/runtime/delivery-coordinator.ts +0 -3
- package/src/runtime/diagnostic-export.ts +5 -4
- package/src/runtime/foreground-control.ts +1 -1
- package/src/runtime/foreground-watchdog.ts +1 -1
- package/src/runtime/{adaptive-plan.ts → goal-workflow/adaptive-plan.ts} +8 -8
- package/src/runtime/{dynamic-workflow-context.ts → goal-workflow/dynamic-workflow-context.ts} +16 -16
- package/src/runtime/{dynamic-workflow-runner.ts → goal-workflow/dynamic-workflow-runner.ts} +10 -10
- package/src/runtime/{goal-achievement.ts → goal-workflow/goal-achievement.ts} +3 -3
- package/src/runtime/{goal-evaluator.ts → goal-workflow/goal-evaluator.ts} +8 -8
- package/src/runtime/{goal-loop-runner.ts → goal-workflow/goal-loop-runner.ts} +27 -25
- package/src/runtime/{goal-state-store.ts → goal-workflow/goal-state-store.ts} +8 -8
- package/src/runtime/{plan-templates.ts → goal-workflow/plan-templates.ts} +1 -1
- package/src/runtime/group-join.ts +3 -3
- package/src/runtime/handoff-manager.ts +0 -2
- package/src/runtime/{heartbeat-watcher.ts → heartbeat/heartbeat-watcher.ts} +7 -7
- package/src/runtime/iteration-hooks.ts +1 -1
- package/src/runtime/{live-agent-control.ts → live-session/live-agent-control.ts} +2 -2
- package/src/runtime/{live-agent-manager.ts → live-session/live-agent-manager.ts} +4 -4
- package/src/runtime/{live-session-runtime.ts → live-session/live-session-runtime.ts} +39 -41
- package/src/runtime/manifest-cache.ts +6 -2
- package/src/runtime/{model-fallback.ts → model/model-fallback.ts} +1 -1
- package/src/runtime/{pi-args.ts → model/pi-args.ts} +20 -5
- package/src/runtime/model/provider-extensions.ts +116 -0
- package/src/runtime/{runtime-policy.ts → model/runtime-policy.ts} +2 -2
- package/src/runtime/{runtime-resolver.ts → model/runtime-resolver.ts} +3 -3
- package/src/runtime/{runtime-warmup.ts → model/runtime-warmup.ts} +8 -8
- package/src/runtime/orphan-worker-registry.ts +1 -1
- package/src/runtime/{progress-tracker.ts → output/progress-tracker.ts} +1 -1
- package/src/runtime/{result-extractor.ts → output/result-extractor.ts} +4 -4
- package/src/runtime/{sidechain-output.ts → output/sidechain-output.ts} +2 -2
- package/src/runtime/{stream-preview.ts → output/stream-preview.ts} +1 -1
- package/src/runtime/{streaming-output.ts → output/streaming-output.ts} +2 -2
- package/src/runtime/{tool-progress.ts → output/tool-progress.ts} +1 -1
- package/src/runtime/parent-guard.ts +30 -10
- package/src/runtime/pipeline-runner.ts +2 -2
- package/src/runtime/policy-engine.ts +2 -2
- package/src/runtime/{cancellation.ts → process/cancellation.ts} +1 -1
- package/src/runtime/{post-exit-stdio-guard.ts → process/post-exit-stdio-guard.ts} +1 -1
- package/src/runtime/{process-lifecycle.ts → process/process-lifecycle.ts} +3 -3
- package/src/runtime/{checkpoint.ts → recovery/checkpoint.ts} +4 -4
- package/src/runtime/{crash-recovery.ts → recovery/crash-recovery.ts} +93 -21
- package/src/runtime/{overflow-recovery.ts → recovery/overflow-recovery.ts} +1 -1
- package/src/runtime/{recovery-recipes.ts → recovery/recovery-recipes.ts} +1 -1
- package/src/runtime/{retry-executor.ts → recovery/retry-executor.ts} +2 -2
- package/src/runtime/{retry-runner.ts → recovery/retry-runner.ts} +2 -8
- package/src/runtime/run-tracker.ts +1 -1
- package/src/runtime/run-worker.ts +3 -3
- package/src/runtime/{coalesce-tasks.ts → scheduling/coalesce-tasks.ts} +3 -3
- package/src/runtime/{concurrency.ts → scheduling/concurrency.ts} +9 -3
- package/src/runtime/{parallel-research.ts → scheduling/parallel-research.ts} +4 -2
- package/src/runtime/{run-coalesced-task-group.ts → scheduling/run-coalesced-task-group.ts} +95 -36
- package/src/runtime/{semaphore.ts → scheduling/semaphore.ts} +4 -1
- package/src/runtime/{task-graph-scheduler.ts → scheduling/task-graph-scheduler.ts} +1 -1
- package/src/runtime/session-resources.ts +1 -1
- package/src/runtime/settings-store.ts +1 -1
- package/src/runtime/single-agent-compose.ts +1 -0
- package/src/runtime/stale-reconciler.ts +1 -1
- package/src/runtime/subagent-manager.ts +1 -1
- package/src/runtime/supervisor-contact.ts +28 -13
- package/src/runtime/task-output-context.ts +7 -5
- package/src/runtime/task-runner/child-executor.ts +67 -31
- package/src/runtime/task-runner/live-executor.ts +8 -8
- package/src/runtime/task-runner/post-execution.ts +12 -12
- package/src/runtime/task-runner/pre-execution.ts +6 -6
- package/src/runtime/task-runner/progress.ts +1 -1
- package/src/runtime/task-runner/run-projection.ts +1 -1
- package/src/runtime/task-runner/scaffold-executor.ts +1 -1
- package/src/runtime/task-runner/state-helpers.ts +2 -2
- package/src/runtime/task-runner.ts +4 -4
- package/src/runtime/team-runner.ts +441 -175
- package/src/runtime/{completion-guard.ts → verification/completion-guard.ts} +1 -1
- package/src/runtime/{green-contract.ts → verification/green-contract.ts} +1 -1
- package/src/runtime/{post-checks.ts → verification/post-checks.ts} +4 -4
- package/src/runtime/{verification-gates.ts → verification/verification-gates.ts} +5 -5
- package/src/runtime/{verification-integrity.ts → verification/verification-integrity.ts} +1 -1
- package/src/schema/config-schema.ts +1 -0
- package/src/schema/team-tool-schema.ts +149 -185
- package/src/state/README.md +44 -0
- package/src/state/atomic-write.ts +24 -3
- package/src/state/{locks.ts → coordination/locks.ts} +118 -38
- package/src/state/{mailbox.ts → coordination/mailbox.ts} +14 -8
- package/src/state/{schedule.ts → coordination/schedule.ts} +3 -3
- package/src/state/{task-claims.ts → coordination/task-claims.ts} +1 -1
- package/src/state/decision-ledger.ts +1 -1
- package/src/state/{event-log-rotation.ts → event-log/event-log-rotation.ts} +189 -31
- package/src/state/{event-log.ts → event-log/event-log.ts} +77 -39
- package/src/state/{jsonl-writer.ts → event-log/jsonl-writer.ts} +14 -6
- package/src/state/hook-instinct-bridge.ts +2 -2
- package/src/state/{active-run-registry.ts → stores/active-run-registry.ts} +7 -7
- package/src/state/{artifact-store.ts → stores/artifact-store.ts} +62 -4
- package/src/state/{blob-store.ts → stores/blob-store.ts} +3 -3
- package/src/state/{health-store.ts → stores/health-store.ts} +3 -3
- package/src/state/{instinct-store.ts → stores/instinct-store.ts} +3 -3
- package/src/state/{observation-store.ts → stores/observation-store.ts} +2 -2
- package/src/state/{run-cache.ts → stores/run-cache.ts} +4 -4
- package/src/state/{run-graph.ts → stores/run-graph.ts} +4 -4
- package/src/state/{run-metrics.ts → stores/run-metrics.ts} +3 -3
- package/src/state/{state-store.ts → stores/state-store.ts} +254 -21
- package/src/state/types.ts +27 -3
- package/src/ui/component.ts +55 -0
- package/src/ui/crew-select-list.ts +3 -1
- package/src/ui/dashboard-panes/agents-pane.ts +1 -1
- package/src/ui/dwf-phase-display.ts +1 -1
- package/src/ui/heartbeat-aggregator.ts +1 -1
- package/src/ui/keybinding-map.ts +179 -6
- package/src/ui/layout-primitives.ts +9 -5
- package/src/ui/live-conversation-overlay.ts +1 -1
- package/src/ui/live-run-sidebar.ts +1 -1
- package/src/ui/overlay-stack.ts +148 -0
- package/src/ui/overlays/agent-picker-overlay.ts +1 -1
- package/src/ui/overlays/mailbox-compose-overlay.ts +1 -1
- package/src/ui/overlays/mailbox-detail-overlay.ts +2 -2
- package/src/ui/powerbar-publisher.ts +1 -1
- package/src/ui/render-scheduler.ts +1 -1
- package/src/ui/run-action-dispatcher.ts +3 -3
- package/src/ui/run-dashboard.ts +5 -33
- package/src/ui/run-event-bus.ts +3 -3
- package/src/ui/run-snapshot-cache.ts +37 -18
- package/src/ui/settings-overlay.ts +13 -21
- package/src/ui/snapshot-types.ts +1 -1
- package/src/ui/status-colors.ts +0 -2
- package/src/ui/terminal-status.ts +1 -1
- package/src/ui/theme-adapter.ts +33 -13
- package/src/ui/tool-renderers/index.ts +8 -0
- package/src/ui/transcript-viewer.ts +37 -13
- package/src/ui/widget/index.ts +32 -9
- package/src/ui/widget/widget-formatters.ts +62 -4
- package/src/ui/widget/widget-model.ts +2 -2
- package/src/ui/widget/widget-renderer.ts +1 -1
- package/src/utils/conflict-detect.ts +58 -5
- package/src/utils/ndjson.ts +2 -2
- package/src/utils/redaction.ts +39 -0
- package/src/utils/socket-path.ts +1 -1
- package/src/workflows/workflow-config.ts +1 -1
- package/src/worktree/cleanup.ts +1 -1
- package/src/worktree/worktree-manager.ts +111 -47
- package/workflows/chain.workflow.md +2 -2
- package/dist/build-meta.json +0 -16807
- package/index.bundle.ts +0 -25
- package/scripts/bench-check.mjs +0 -96
- package/scripts/bench-cold-start.mjs +0 -216
- package/scripts/build-bundle.mjs +0 -92
- package/scripts/check-all-skills.ts +0 -294
- package/scripts/check-bundle-size.mjs +0 -38
- package/scripts/check-bundle-staleness.mjs +0 -97
- package/scripts/check-conflict-markers.mjs +0 -91
- package/scripts/check-lazy-imports.mjs +0 -28
- package/scripts/dev-runner.mjs +0 -106
- package/scripts/profile-startup.mjs +0 -125
- package/scripts/release-smoke.mjs +0 -74
- package/scripts/run-bench.mjs +0 -47
- package/scripts/run-real-chain.ts +0 -41
- package/scripts/test-issue-29-crash.ts +0 -111
- package/scripts/test-issue-29-e2e.ts +0 -183
- package/scripts/test-issue-29-real-runtime.ts +0 -330
- package/scripts/test-issue-29-real-tasks.ts +0 -387
- package/scripts/test-issue-29-team-tool.ts +0 -105
- package/scripts/test-runner.mjs +0 -84
- package/scripts/verify-flicker-fix.ts +0 -109
- package/scripts/verify-skill.ts +0 -550
- package/scripts/watch-bundle.mjs +0 -259
- package/scripts/watchdog-harness.ts +0 -119
- package/src/adapters/claude-adapter.ts +0 -23
- package/src/adapters/codex-adapter.ts +0 -21
- package/src/adapters/cursor-adapter.ts +0 -17
- package/src/adapters/export-util.ts +0 -143
- package/src/adapters/index.ts +0 -15
- package/src/adapters/registry.ts +0 -18
- package/src/adapters/types.ts +0 -23
- package/src/runtime/code-summary.ts +0 -292
- package/src/runtime/cross-extension-rpc.ts +0 -143
- package/src/runtime/hidden-handoff.ts +0 -407
- package/src/runtime/prose-compressor.ts +0 -162
- package/src/subagents/async-entry.ts +0 -1
- package/src/subagents/index.ts +0 -3
- package/src/subagents/live/control.ts +0 -1
- package/src/subagents/live/manager.ts +0 -1
- package/src/subagents/live/realtime.ts +0 -1
- package/src/subagents/live/session-runtime.ts +0 -1
- package/src/subagents/manager.ts +0 -1
- package/src/subagents/spawn.ts +0 -1
- package/test-integration-check.ts +0 -118
- /package/src/runtime/{broker-issuer.ts → broker/broker-issuer.ts} +0 -0
- /package/src/runtime/{crew-broker-tokens.ts → broker/crew-broker-tokens.ts} +0 -0
- /package/src/runtime/{child-pi-pool.ts → child-pi/child-pi-pool.ts} +0 -0
- /package/src/runtime/{compact-pipeline.ts → compaction/compact-pipeline.ts} +0 -0
- /package/src/runtime/{compact-stages → compaction/compact-stages}/ansi-strip-stage.ts +0 -0
- /package/src/runtime/{compact-stages → compaction/compact-stages}/blank-collapse-stage.ts +0 -0
- /package/src/runtime/{compact-stages → compaction/compact-stages}/deduplicate-stage.ts +0 -0
- /package/src/runtime/{compact-stages → compaction/compact-stages}/head-snap-stage.ts +0 -0
- /package/src/runtime/{compact-stages → compaction/compact-stages}/tail-capture-stage.ts +0 -0
- /package/src/runtime/{compact-stages → compaction/compact-stages}/truncation-stage.ts +0 -0
- /package/src/runtime/{important-line-classifier.ts → compaction/important-line-classifier.ts} +0 -0
- /package/src/runtime/{heartbeat-gradient.ts → heartbeat/heartbeat-gradient.ts} +0 -0
- /package/src/runtime/{worker-heartbeat.ts → heartbeat/worker-heartbeat.ts} +0 -0
- /package/src/runtime/{worker-startup.ts → heartbeat/worker-startup.ts} +0 -0
- /package/src/runtime/{intercom-bridge.ts → live-session/intercom-bridge.ts} +0 -0
- /package/src/runtime/{live-control-realtime.ts → live-session/live-control-realtime.ts} +0 -0
- /package/src/runtime/{live-extension-bridge.ts → live-session/live-extension-bridge.ts} +0 -0
- /package/src/runtime/{live-irc.ts → live-session/live-irc.ts} +0 -0
- /package/src/runtime/{live-session-health.ts → live-session/live-session-health.ts} +0 -0
- /package/src/runtime/{model-resolver.ts → model/model-resolver.ts} +0 -0
- /package/src/runtime/{model-scope.ts → model/model-scope.ts} +0 -0
- /package/src/runtime/{output-validator.ts → output/output-validator.ts} +0 -0
- /package/src/runtime/{pi-json-output.ts → output/pi-json-output.ts} +0 -0
- /package/src/runtime/{progress-event-coalescer.ts → output/progress-event-coalescer.ts} +0 -0
- /package/src/runtime/{cancellation-token.ts → process/cancellation-token.ts} +0 -0
- /package/src/runtime/{zombie-scanner.ts → process/zombie-scanner.ts} +0 -0
- /package/src/runtime/{crash-classification.ts → recovery/crash-classification.ts} +0 -0
- /package/src/runtime/{batch-barrier.ts → scheduling/batch-barrier.ts} +0 -0
- /package/src/runtime/{global-worker-cap.ts → scheduling/global-worker-cap.ts} +0 -0
- /package/src/runtime/{parallel-utils.ts → scheduling/parallel-utils.ts} +0 -0
- /package/src/runtime/{scheduler.ts → scheduling/scheduler.ts} +0 -0
- /package/src/runtime/{task-graph.ts → scheduling/task-graph.ts} +0 -0
- /package/src/runtime/{verification-worktree.ts → verification/verification-worktree.ts} +0 -0
- /package/src/state/{event-reconstructor.ts → event-log/event-reconstructor.ts} +0 -0
- /package/src/state/{worker-atomic-writer.ts → event-log/worker-atomic-writer.ts} +0 -0
|
@@ -1,407 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HiddenHandoffService - Sends hidden boomerang-handoff messages to parent agents.
|
|
3
|
-
*
|
|
4
|
-
* Based on pi-boomerang's triggerHiddenOrchestratorHandoff() pattern:
|
|
5
|
-
* - Sends customType: "boomerang-handoff" messages
|
|
6
|
-
* - Full handoff details in hidden message to parent
|
|
7
|
-
* - Orchestrator immediately reads summary
|
|
8
|
-
*
|
|
9
|
-
* @see docs/pi-boomerang-integration-plan.md
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { logInternalError } from "../utils/internal-error.ts";
|
|
13
|
-
import type { HandoffSummary } from "./handoff-manager.ts";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Type of hidden handoff message.
|
|
17
|
-
*/
|
|
18
|
-
export type HiddenHandoffType = "boomerang-handoff" | "task-complete" | "context-ready";
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Hidden handoff message sent to parent agent.
|
|
22
|
-
*/
|
|
23
|
-
export interface HiddenHandoff {
|
|
24
|
-
type: HiddenHandoffType;
|
|
25
|
-
hidden: true;
|
|
26
|
-
content: HandoffContent;
|
|
27
|
-
metadata: HiddenHandoffMetadata;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Metadata for hidden handoff message.
|
|
32
|
-
*/
|
|
33
|
-
export interface HiddenHandoffMetadata {
|
|
34
|
-
taskId: string;
|
|
35
|
-
runId: string;
|
|
36
|
-
timestamp: number;
|
|
37
|
-
priority: HandoffPriority;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Priority level for hidden handoffs.
|
|
42
|
-
*/
|
|
43
|
-
export type HandoffPriority = "low" | "normal" | "high";
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Content of a hidden handoff message.
|
|
47
|
-
*/
|
|
48
|
-
export interface HandoffContent {
|
|
49
|
-
summary: string;
|
|
50
|
-
files: {
|
|
51
|
-
created: string[];
|
|
52
|
-
modified: string[];
|
|
53
|
-
deleted: string[];
|
|
54
|
-
};
|
|
55
|
-
decisions: {
|
|
56
|
-
rationale: string;
|
|
57
|
-
outcome: string;
|
|
58
|
-
}[];
|
|
59
|
-
nextSteps: string[];
|
|
60
|
-
metrics: {
|
|
61
|
-
tokens: number;
|
|
62
|
-
duration: number;
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Options for HiddenHandoffService.
|
|
68
|
-
*/
|
|
69
|
-
export interface HiddenHandoffServiceOptions {
|
|
70
|
-
/** Custom mailbox service for sending messages */
|
|
71
|
-
mailbox?: HiddenHandoffMailbox;
|
|
72
|
-
/** Event emitter for handoff events */
|
|
73
|
-
eventEmitter?: HiddenHandoffEventEmitter;
|
|
74
|
-
/** Get parent agent ID callback */
|
|
75
|
-
getParentAgentId?: () => string;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Mailbox interface for sending hidden handoffs.
|
|
80
|
-
*/
|
|
81
|
-
export interface HiddenHandoffMailbox {
|
|
82
|
-
send(recipient: string, message: HiddenHandoff): void;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Event emitter for hidden handoff events.
|
|
87
|
-
*/
|
|
88
|
-
export interface HiddenHandoffEventEmitter {
|
|
89
|
-
emit(event: string, data: unknown): void;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Event data for hidden handoff sent event.
|
|
94
|
-
*/
|
|
95
|
-
export interface HiddenHandoffSentEventData {
|
|
96
|
-
summary: HandoffSummary;
|
|
97
|
-
recipient: string;
|
|
98
|
-
priority: HandoffPriority;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* HiddenHandoffService sends hidden boomerang-handoff messages to parent agents.
|
|
103
|
-
* This enables agents to communicate progress and context without explicit user-visible output.
|
|
104
|
-
*/
|
|
105
|
-
export class HiddenHandoffService {
|
|
106
|
-
private mailbox: HiddenHandoffMailbox | null = null;
|
|
107
|
-
private eventEmitter: HiddenHandoffEventEmitter | null = null;
|
|
108
|
-
private getParentAgentIdFn: (() => string) | null = null;
|
|
109
|
-
private enabled = true;
|
|
110
|
-
// C7: Track rate limiting per recipient
|
|
111
|
-
private sendTimestamps = new Map<string, number[]>();
|
|
112
|
-
private readonly RATE_LIMIT_WINDOW_MS = 60000; // 1 minute
|
|
113
|
-
private readonly RATE_LIMIT_MAX_SENDS = 10; // Max handoffs per window
|
|
114
|
-
|
|
115
|
-
constructor(options: HiddenHandoffServiceOptions = {}) {
|
|
116
|
-
if (options.mailbox) {
|
|
117
|
-
this.mailbox = options.mailbox;
|
|
118
|
-
}
|
|
119
|
-
if (options.eventEmitter) {
|
|
120
|
-
this.eventEmitter = options.eventEmitter;
|
|
121
|
-
}
|
|
122
|
-
if (options.getParentAgentId) {
|
|
123
|
-
this.getParentAgentIdFn = options.getParentAgentId;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Check if hidden handoff service is enabled.
|
|
129
|
-
*/
|
|
130
|
-
isEnabled(): boolean {
|
|
131
|
-
return this.enabled;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Enable or disable hidden handoff service.
|
|
136
|
-
*/
|
|
137
|
-
setEnabled(enabled: boolean): void {
|
|
138
|
-
this.enabled = enabled;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Set the mailbox service for sending messages.
|
|
143
|
-
*/
|
|
144
|
-
setMailbox(mailbox: HiddenHandoffMailbox): void {
|
|
145
|
-
this.mailbox = mailbox;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Set the event emitter for events.
|
|
150
|
-
*/
|
|
151
|
-
setEventEmitter(eventEmitter: HiddenHandoffEventEmitter): void {
|
|
152
|
-
this.eventEmitter = eventEmitter;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Set the function to get parent agent ID.
|
|
157
|
-
*/
|
|
158
|
-
setGetParentAgentId(fn: () => string): void {
|
|
159
|
-
this.getParentAgentIdFn = fn;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Send a hidden handoff to the parent agent or specified recipient.
|
|
164
|
-
*
|
|
165
|
-
* @param summary - The handoff summary to send
|
|
166
|
-
* @param options - Send options
|
|
167
|
-
*/
|
|
168
|
-
sendHandoff(summary: HandoffSummary, options: SendHandoffOptions = {}): void {
|
|
169
|
-
if (!this.enabled) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const priority = options.priority ?? this.inferPriority(summary);
|
|
174
|
-
const content = this.buildContent(summary);
|
|
175
|
-
const recipient = options.to ?? this.getParentAgentId();
|
|
176
|
-
|
|
177
|
-
if (!recipient) {
|
|
178
|
-
// No parent to send to, but we still emit the event
|
|
179
|
-
this.eventEmitter?.emit("handoff:sent_no_recipient", {
|
|
180
|
-
summary,
|
|
181
|
-
priority,
|
|
182
|
-
});
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// C7: Validate recipient is a reasonable agent ID
|
|
187
|
-
if (!this.isValidRecipient(recipient)) {
|
|
188
|
-
this.eventEmitter?.emit("handoff:invalid_recipient", {
|
|
189
|
-
recipient,
|
|
190
|
-
summary,
|
|
191
|
-
});
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// C7: Check rate limit
|
|
196
|
-
if (this.isRateLimited(recipient)) {
|
|
197
|
-
this.eventEmitter?.emit("handoff:rate_limited", {
|
|
198
|
-
recipient,
|
|
199
|
-
summary,
|
|
200
|
-
});
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const message: HiddenHandoff = {
|
|
205
|
-
type: options.customType ?? "boomerang-handoff",
|
|
206
|
-
hidden: true,
|
|
207
|
-
content,
|
|
208
|
-
metadata: {
|
|
209
|
-
taskId: summary.taskId,
|
|
210
|
-
runId: summary.runId,
|
|
211
|
-
timestamp: Date.now(),
|
|
212
|
-
priority,
|
|
213
|
-
},
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
if (this.mailbox) {
|
|
217
|
-
this.mailbox.send(recipient, message);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// C7: Record send for rate limiting
|
|
221
|
-
this.recordSend(recipient);
|
|
222
|
-
|
|
223
|
-
this.eventEmitter?.emit("handoff:sent", {
|
|
224
|
-
summary,
|
|
225
|
-
recipient,
|
|
226
|
-
priority,
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Send a hidden handoff immediately (fire and forget).
|
|
232
|
-
*/
|
|
233
|
-
sendHandoffAsync(summary: HandoffSummary, options?: SendHandoffOptions): void {
|
|
234
|
-
// Fire and forget - no await
|
|
235
|
-
try {
|
|
236
|
-
this.sendHandoff(summary, options);
|
|
237
|
-
} catch (error) {
|
|
238
|
-
// Log but don't throw
|
|
239
|
-
logInternalError("hidden-handoff.async", error, `taskId=${summary.taskId} runId=${summary.runId}`);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Infer priority based on summary outcome.
|
|
245
|
-
*/
|
|
246
|
-
private inferPriority(summary: HandoffSummary): HandoffPriority {
|
|
247
|
-
if (summary.outcome === "failure") {
|
|
248
|
-
return "high";
|
|
249
|
-
}
|
|
250
|
-
if (summary.blockers.length > 0) {
|
|
251
|
-
return "normal";
|
|
252
|
-
}
|
|
253
|
-
if (summary.metrics.tokensUsed > 10000) {
|
|
254
|
-
return "normal";
|
|
255
|
-
}
|
|
256
|
-
return "low";
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Build handoff content from summary.
|
|
261
|
-
*/
|
|
262
|
-
private buildContent(summary: HandoffSummary): HandoffContent {
|
|
263
|
-
return {
|
|
264
|
-
summary: this.buildSummaryText(summary),
|
|
265
|
-
files: {
|
|
266
|
-
created: summary.filesCreated,
|
|
267
|
-
modified: summary.filesModified,
|
|
268
|
-
deleted: summary.filesDeleted,
|
|
269
|
-
},
|
|
270
|
-
decisions: summary.decisions.map((d) => ({
|
|
271
|
-
rationale: d.rationale,
|
|
272
|
-
outcome: d.outcome,
|
|
273
|
-
})),
|
|
274
|
-
nextSteps: summary.nextSteps,
|
|
275
|
-
metrics: {
|
|
276
|
-
tokens: summary.metrics.tokensUsed,
|
|
277
|
-
duration: summary.metrics.duration,
|
|
278
|
-
},
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Build summary text from summary.
|
|
284
|
-
*/
|
|
285
|
-
private buildSummaryText(summary: HandoffSummary): string {
|
|
286
|
-
const parts: string[] = [`Completed: ${summary.task}`, `Outcome: ${summary.outcome}`];
|
|
287
|
-
|
|
288
|
-
if (summary.filesCreated.length > 0) {
|
|
289
|
-
parts.push(`Files created: ${summary.filesCreated.join(", ")}`);
|
|
290
|
-
}
|
|
291
|
-
if (summary.filesModified.length > 0) {
|
|
292
|
-
parts.push(`Files modified: ${summary.filesModified.join(", ")}`);
|
|
293
|
-
}
|
|
294
|
-
if (summary.decisions.length > 0) {
|
|
295
|
-
parts.push(`Decisions: ${summary.decisions.length}`);
|
|
296
|
-
}
|
|
297
|
-
if (summary.blockers.length > 0) {
|
|
298
|
-
parts.push(`Blockers: ${summary.blockers.join("; ")}`);
|
|
299
|
-
}
|
|
300
|
-
if (summary.nextSteps.length > 0) {
|
|
301
|
-
parts.push(`Next steps: ${summary.nextSteps.join("; ")}`);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
parts.push(`Tokens: ${summary.metrics.tokensUsed}`, `Duration: ${Math.round(summary.metrics.duration / 1000)}s`);
|
|
305
|
-
|
|
306
|
-
return parts.join("\n");
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Get parent agent ID from callback or context.
|
|
311
|
-
*/
|
|
312
|
-
private getParentAgentId(): string | undefined {
|
|
313
|
-
if (this.getParentAgentIdFn) {
|
|
314
|
-
return this.getParentAgentIdFn();
|
|
315
|
-
}
|
|
316
|
-
// Fallback: try to get from global context
|
|
317
|
-
const ctx = (globalThis as Record<string, unknown>).__piCrewContext;
|
|
318
|
-
if (ctx && typeof ctx === "object") {
|
|
319
|
-
return (ctx as Record<string, unknown>).parentAgentId as string | undefined;
|
|
320
|
-
}
|
|
321
|
-
return undefined;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* C7: Validate recipient is a reasonable agent ID.
|
|
326
|
-
*/
|
|
327
|
-
private isValidRecipient(recipient: string): boolean {
|
|
328
|
-
if (!recipient || typeof recipient !== "string") {
|
|
329
|
-
return false;
|
|
330
|
-
}
|
|
331
|
-
// Reasonable length for an agent ID
|
|
332
|
-
if (recipient.length < 1 || recipient.length > 256) {
|
|
333
|
-
return false;
|
|
334
|
-
}
|
|
335
|
-
// Only allow alphanumeric, hyphen, underscore, colon, and period
|
|
336
|
-
// This prevents injection in mailbox routing
|
|
337
|
-
if (!/^[a-zA-Z0-9_:.-]+$/.test(recipient)) {
|
|
338
|
-
return false;
|
|
339
|
-
}
|
|
340
|
-
return true;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* C7: Check if recipient is rate limited.
|
|
345
|
-
* Also cleans up empty recipient entries to prevent unbounded Map growth.
|
|
346
|
-
*/
|
|
347
|
-
private isRateLimited(recipient: string): boolean {
|
|
348
|
-
const now = Date.now();
|
|
349
|
-
const timestamps = this.sendTimestamps.get(recipient) ?? [];
|
|
350
|
-
|
|
351
|
-
// Filter out old timestamps outside the window
|
|
352
|
-
const recentTimestamps = timestamps.filter((t) => now - t < this.RATE_LIMIT_WINDOW_MS);
|
|
353
|
-
|
|
354
|
-
// HIGH-11: If no recent timestamps, remove the empty key to prevent unbounded growth
|
|
355
|
-
if (recentTimestamps.length === 0) {
|
|
356
|
-
this.sendTimestamps.delete(recipient);
|
|
357
|
-
} else {
|
|
358
|
-
this.sendTimestamps.set(recipient, recentTimestamps);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
return recentTimestamps.length >= this.RATE_LIMIT_MAX_SENDS;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* C7: Record a send for rate limiting.
|
|
366
|
-
*/
|
|
367
|
-
private recordSend(recipient: string): void {
|
|
368
|
-
const now = Date.now();
|
|
369
|
-
const timestamps = this.sendTimestamps.get(recipient) ?? [];
|
|
370
|
-
timestamps.push(now);
|
|
371
|
-
|
|
372
|
-
// MEDIUM-14: Use RATE_LIMIT_WINDOW_MS consistently for both filter and record
|
|
373
|
-
const recentTimestamps = timestamps.filter((t) => now - t < this.RATE_LIMIT_WINDOW_MS);
|
|
374
|
-
|
|
375
|
-
this.sendTimestamps.set(recipient, recentTimestamps);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Dispose of resources.
|
|
380
|
-
* Call this when the service is no longer needed.
|
|
381
|
-
*/
|
|
382
|
-
dispose(): void {
|
|
383
|
-
this.mailbox = null;
|
|
384
|
-
this.eventEmitter = null;
|
|
385
|
-
this.getParentAgentIdFn = null;
|
|
386
|
-
this.sendTimestamps.clear();
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Options for sending hidden handoffs.
|
|
392
|
-
*/
|
|
393
|
-
export interface SendHandoffOptions {
|
|
394
|
-
/** Recipient agent ID (defaults to parent) */
|
|
395
|
-
to?: string;
|
|
396
|
-
/** Priority level */
|
|
397
|
-
priority?: HandoffPriority;
|
|
398
|
-
/** Custom handoff type */
|
|
399
|
-
customType?: HiddenHandoffType;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Create a HiddenHandoffService with default options.
|
|
404
|
-
*/
|
|
405
|
-
export function createHiddenHandoffService(options?: HiddenHandoffServiceOptions): HiddenHandoffService {
|
|
406
|
-
return new HiddenHandoffService(options);
|
|
407
|
-
}
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure TypeScript prose compression module.
|
|
3
|
-
*
|
|
4
|
-
* Inspired by caveman's compress.js — reduces tool descriptions and other
|
|
5
|
-
* prose by removing filler words, pleasantries, hedging, and articles while
|
|
6
|
-
* preserving code, URLs, paths, identifiers, and other protected segments
|
|
7
|
-
* byte-for-byte.
|
|
8
|
-
*
|
|
9
|
-
* No external dependencies. No `any` types. Regex-only pattern matching.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
// Protected segment patterns (order matters — earlier patterns take priority)
|
|
14
|
-
// ---------------------------------------------------------------------------
|
|
15
|
-
|
|
16
|
-
const PROTECTED_PATTERNS: readonly RegExp[] = [
|
|
17
|
-
/```[\s\S]*?```/g, // fenced code blocks
|
|
18
|
-
/`[^`\n]+`/g, // inline code
|
|
19
|
-
/\bhttps?:\/\/\S+/gi, // URLs
|
|
20
|
-
/\b[\w.-]*[/\\][\w./\\-]+/g, // paths with / or \
|
|
21
|
-
/\b[A-Z][A-Z0-9]*(?:_[A-Z][A-Z0-9]*)+\b/g, // CONSTANT_CASE
|
|
22
|
-
/\b\w+(?:\.\w+)+\(\)/g, // dotted.method() calls
|
|
23
|
-
/[A-Za-z_][A-Za-z0-9_]*\s*\([^)]*\)/g, // function calls: name(args)
|
|
24
|
-
/\b\d+\.\d+\.\d+\b/g, // version numbers x.y.z
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
// ---------------------------------------------------------------------------
|
|
28
|
-
// Compression patterns (applied to unprotected prose only)
|
|
29
|
-
// ---------------------------------------------------------------------------
|
|
30
|
-
|
|
31
|
-
const FILLERS = /\b(?:just|really|basically|actually|simply|quite|very|essentially|literally)\b/gi;
|
|
32
|
-
|
|
33
|
-
const PLEASANTRIES = /\b(?:please|kindly|thank you|thanks|sure|certainly|of course|happy to)\b[,.]?\s*/gi;
|
|
34
|
-
|
|
35
|
-
const HEDGES = /\b(?:perhaps|maybe|might|could potentially|would like to|i think|in my opinion)\b\s*/gi;
|
|
36
|
-
|
|
37
|
-
const LEADERS = /^(?:i'?\s*ll|i will|i can|you can|we will|we can|let me|let'?\s*s)\s+/gim;
|
|
38
|
-
|
|
39
|
-
const ARTICLES = /\b(?:a|an|the)\s+(?=[a-z])/gi;
|
|
40
|
-
|
|
41
|
-
// ---------------------------------------------------------------------------
|
|
42
|
-
// Sentinel helpers
|
|
43
|
-
// ---------------------------------------------------------------------------
|
|
44
|
-
|
|
45
|
-
const SENTINEL_OPEN = "\x00";
|
|
46
|
-
const SENTINEL_CLOSE = "\x00";
|
|
47
|
-
const SENTINEL_RE = /\x00(\d+)\x00/g;
|
|
48
|
-
|
|
49
|
-
interface SegmentStore {
|
|
50
|
-
segments: string[];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function extractProtected(text: string, store: SegmentStore): string {
|
|
54
|
-
let working = text;
|
|
55
|
-
for (const re of PROTECTED_PATTERNS) {
|
|
56
|
-
// Reset lastIndex for reused RegExp objects
|
|
57
|
-
re.lastIndex = 0;
|
|
58
|
-
working = working.replace(re, (match: string): string => {
|
|
59
|
-
const index = store.segments.length;
|
|
60
|
-
store.segments.push(match);
|
|
61
|
-
return `${SENTINEL_OPEN}${index}${SENTINEL_CLOSE}`;
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
return working;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function restoreProtected(text: string, store: SegmentStore): string {
|
|
68
|
-
return text.replace(SENTINEL_RE, (_match: string, indexStr: string): string => {
|
|
69
|
-
const index = Number(indexStr);
|
|
70
|
-
return store.segments[index] ?? "";
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// ---------------------------------------------------------------------------
|
|
75
|
-
// Core prose compression
|
|
76
|
-
// ---------------------------------------------------------------------------
|
|
77
|
-
|
|
78
|
-
function compressProseText(text: string): string {
|
|
79
|
-
let s = text;
|
|
80
|
-
|
|
81
|
-
// Remove leading "I'll / I will / you can / ..." sentence openers
|
|
82
|
-
s = s.replace(LEADERS, "");
|
|
83
|
-
|
|
84
|
-
// Remove pleasantries
|
|
85
|
-
s = s.replace(PLEASANTRIES, "");
|
|
86
|
-
|
|
87
|
-
// Remove hedging phrases
|
|
88
|
-
s = s.replace(HEDGES, "");
|
|
89
|
-
|
|
90
|
-
// Remove filler adverbs
|
|
91
|
-
s = s.replace(FILLERS, "");
|
|
92
|
-
|
|
93
|
-
// Remove articles before lowercase words
|
|
94
|
-
s = s.replace(ARTICLES, "");
|
|
95
|
-
|
|
96
|
-
// Collapse whitespace introduced by removals
|
|
97
|
-
s = s.replace(/[ \t]{2,}/g, " ");
|
|
98
|
-
|
|
99
|
-
// Fix punctuation spacing (e.g. "word ," → "word,")
|
|
100
|
-
s = s.replace(/\s+([,.;:!?])/g, "$1");
|
|
101
|
-
|
|
102
|
-
// Collapse excessive newlines
|
|
103
|
-
s = s.replace(/\n{3,}/g, "\n\n");
|
|
104
|
-
|
|
105
|
-
// Re-capitalize first letter of each sentence after removals
|
|
106
|
-
s = s.replace(/(^|[.!?]\s+)([a-z])/g, (_match: string, pre: string, ch: string): string => {
|
|
107
|
-
return pre + ch.toUpperCase();
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
return s.trim();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// ---------------------------------------------------------------------------
|
|
114
|
-
// Public API
|
|
115
|
-
// ---------------------------------------------------------------------------
|
|
116
|
-
|
|
117
|
-
export interface CompressResult {
|
|
118
|
-
compressed: string;
|
|
119
|
-
originalLength: number;
|
|
120
|
-
compressedLength: number;
|
|
121
|
-
savingsPercent: number;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Compress prose text by removing filler, pleasantries, hedging, and articles
|
|
126
|
-
* while preserving code blocks, URLs, paths, identifiers, and other protected
|
|
127
|
-
* segments byte-for-byte.
|
|
128
|
-
*/
|
|
129
|
-
export function compressProse(text: string): CompressResult {
|
|
130
|
-
if (typeof text !== "string" || text.length === 0) {
|
|
131
|
-
return {
|
|
132
|
-
compressed: "",
|
|
133
|
-
originalLength: 0,
|
|
134
|
-
compressedLength: 0,
|
|
135
|
-
savingsPercent: 0,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const store: SegmentStore = { segments: [] };
|
|
140
|
-
const extracted = extractProtected(text, store);
|
|
141
|
-
const compressed = compressProseText(extracted);
|
|
142
|
-
const restored = restoreProtected(compressed, store);
|
|
143
|
-
|
|
144
|
-
const originalLength = text.length;
|
|
145
|
-
const compressedLength = restored.length;
|
|
146
|
-
const savingsPercent = originalLength > 0 ? Math.round(((originalLength - compressedLength) / originalLength) * 100 * 100) / 100 : 0;
|
|
147
|
-
|
|
148
|
-
return {
|
|
149
|
-
compressed: restored,
|
|
150
|
-
originalLength,
|
|
151
|
-
compressedLength,
|
|
152
|
-
savingsPercent,
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Convenience wrapper — returns just the compressed string for tool
|
|
158
|
-
* descriptions and other single-field use cases.
|
|
159
|
-
*/
|
|
160
|
-
export function compressToolDescription(description: string): string {
|
|
161
|
-
return compressProse(description).compressed;
|
|
162
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../runtime/async-runner.ts";
|
package/src/subagents/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../runtime/live-agent-control.ts";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../runtime/live-agent-manager.ts";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../runtime/live-control-realtime.ts";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../runtime/live-session-runtime.ts";
|
package/src/subagents/manager.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../runtime/subagent-manager.ts";
|
package/src/subagents/spawn.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../runtime/child-pi.ts";
|