@hoknie/aip 0.2.1 → 0.3.1
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/app/application.js +27 -1
- package/dist/app/application.js.map +1 -1
- package/dist/app/lifecycle.js +8 -1
- package/dist/app/lifecycle.js.map +1 -1
- package/dist/app/wiring.js +1 -0
- package/dist/app/wiring.js.map +1 -1
- package/dist/cli/main.js +1 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/feature/agents/clients/agy/guard.js +17 -5
- package/dist/feature/agents/clients/agy/guard.js.map +1 -1
- package/dist/feature/agents/clients/agy/parser.js +1 -3
- package/dist/feature/agents/clients/agy/parser.js.map +1 -1
- package/dist/feature/agents/clients/agy/permissions.js +2 -0
- package/dist/feature/agents/clients/agy/permissions.js.map +1 -1
- package/dist/feature/agents/clients/agy/runtime.js +21 -2
- package/dist/feature/agents/clients/agy/runtime.js.map +1 -1
- package/dist/feature/agents/clients/agy/transcript.js +0 -1
- package/dist/feature/agents/clients/agy/transcript.js.map +1 -1
- package/dist/feature/agents/clients/claude/parser.js +2 -6
- package/dist/feature/agents/clients/claude/parser.js.map +1 -1
- package/dist/feature/agents/clients/claude/permissions.js +7 -1
- package/dist/feature/agents/clients/claude/permissions.js.map +1 -1
- package/dist/feature/agents/clients/claude/runtime.js +13 -2
- package/dist/feature/agents/clients/claude/runtime.js.map +1 -1
- package/dist/feature/agents/clients/claude/transcript.js +0 -1
- package/dist/feature/agents/clients/claude/transcript.js.map +1 -1
- package/dist/feature/agents/clients/opencode/parser.js +1 -3
- package/dist/feature/agents/clients/opencode/parser.js.map +1 -1
- package/dist/feature/agents/clients/opencode/runtime.js +24 -3
- package/dist/feature/agents/clients/opencode/runtime.js.map +1 -1
- package/dist/feature/agents/clients/opencode/transcript.js +0 -1
- package/dist/feature/agents/clients/opencode/transcript.js.map +1 -1
- package/dist/feature/agents/clients/opencode/user-servers.js +97 -0
- package/dist/feature/agents/clients/opencode/user-servers.js.map +1 -0
- package/dist/feature/agents/services/supervisor.js +1 -2
- package/dist/feature/agents/services/supervisor.js.map +1 -1
- package/dist/feature/agents/types/index.js +1 -1
- package/dist/feature/agents/types/index.js.map +1 -1
- package/dist/feature/agents/types/message.js +17 -1
- package/dist/feature/agents/types/message.js.map +1 -1
- package/dist/feature/agents/types/overlay.js +31 -0
- package/dist/feature/agents/types/overlay.js.map +1 -0
- package/dist/feature/agents/types/permissions.js +16 -0
- package/dist/feature/agents/types/permissions.js.map +1 -1
- package/dist/feature/agents/types/{run-naming.js → run-naming/run-naming.js} +1 -1
- package/dist/feature/agents/types/run-naming/run-naming.js.map +1 -0
- package/dist/feature/agents/types/runtime.js.map +1 -1
- package/dist/feature/agents/types/transcript.js.map +1 -1
- package/dist/feature/agents/types/usage.js +0 -3
- package/dist/feature/agents/types/usage.js.map +1 -1
- package/dist/feature/attachments/repositories/attachment-storage.js +84 -0
- package/dist/feature/attachments/repositories/attachment-storage.js.map +1 -0
- package/dist/feature/attachments/repositories/attachments.js +83 -0
- package/dist/feature/attachments/repositories/attachments.js.map +1 -0
- package/dist/feature/attachments/repositories/index.js +4 -0
- package/dist/feature/attachments/repositories/index.js.map +1 -0
- package/dist/feature/attachments/repositories/s3-attachment-storage.js +46 -0
- package/dist/feature/attachments/repositories/s3-attachment-storage.js.map +1 -0
- package/dist/feature/attachments/services/attachments.js +191 -0
- package/dist/feature/attachments/services/attachments.js.map +1 -0
- package/dist/feature/attachments/services/create.js +29 -0
- package/dist/feature/attachments/services/create.js.map +1 -0
- package/dist/feature/attachments/services/index.js +3 -0
- package/dist/feature/attachments/services/index.js.map +1 -0
- package/dist/feature/attachments/services/ingest.js +77 -0
- package/dist/feature/attachments/services/ingest.js.map +1 -0
- package/dist/feature/attachments/types/attachments.js +45 -0
- package/dist/feature/attachments/types/attachments.js.map +1 -0
- package/dist/feature/attachments/types/index.js +2 -0
- package/dist/feature/attachments/types/index.js.map +1 -0
- package/dist/feature/observers/services/observers.js +2 -1
- package/dist/feature/observers/services/observers.js.map +1 -1
- package/dist/feature/observers/types/plan-repairs.js +8 -4
- package/dist/feature/observers/types/plan-repairs.js.map +1 -1
- package/dist/feature/queue/repositories/index.js +1 -0
- package/dist/feature/queue/repositories/index.js.map +1 -1
- package/dist/feature/queue/repositories/links.js +117 -0
- package/dist/feature/queue/repositories/links.js.map +1 -0
- package/dist/feature/queue/repositories/queues.js +71 -9
- package/dist/feature/queue/repositories/queues.js.map +1 -1
- package/dist/feature/queue/services/advance.js +94 -38
- package/dist/feature/queue/services/advance.js.map +1 -1
- package/dist/feature/queue/services/control.js +56 -12
- package/dist/feature/queue/services/control.js.map +1 -1
- package/dist/feature/queue/services/create.js +40 -6
- package/dist/feature/queue/services/create.js.map +1 -1
- package/dist/feature/queue/services/edit.js +114 -30
- package/dist/feature/queue/services/edit.js.map +1 -1
- package/dist/feature/queue/services/index.js +1 -0
- package/dist/feature/queue/services/index.js.map +1 -1
- package/dist/feature/queue/services/items.js +85 -66
- package/dist/feature/queue/services/items.js.map +1 -1
- package/dist/feature/queue/services/link-index.js +88 -0
- package/dist/feature/queue/services/link-index.js.map +1 -0
- package/dist/feature/queue/services/links.js +252 -0
- package/dist/feature/queue/services/links.js.map +1 -0
- package/dist/feature/queue/services/projects.js +162 -0
- package/dist/feature/queue/services/projects.js.map +1 -0
- package/dist/feature/queue/services/scope.js +97 -0
- package/dist/feature/queue/services/scope.js.map +1 -0
- package/dist/feature/queue/services/store-lines.js +130 -0
- package/dist/feature/queue/services/store-lines.js.map +1 -0
- package/dist/feature/queue/services/store.js +64 -10
- package/dist/feature/queue/services/store.js.map +1 -1
- package/dist/feature/queue/services/task-tags.js +34 -4
- package/dist/feature/queue/services/task-tags.js.map +1 -1
- package/dist/feature/queue/types/advance.js +22 -11
- package/dist/feature/queue/types/advance.js.map +1 -1
- package/dist/feature/queue/types/dependencies.js +29 -12
- package/dist/feature/queue/types/dependencies.js.map +1 -1
- package/dist/feature/queue/types/edit.js +36 -8
- package/dist/feature/queue/types/edit.js.map +1 -1
- package/dist/feature/queue/types/global/index.js +3 -0
- package/dist/feature/queue/types/global/index.js.map +1 -0
- package/dist/feature/queue/types/global/order.js +63 -0
- package/dist/feature/queue/types/global/order.js.map +1 -0
- package/dist/feature/queue/types/global/queue.js +79 -0
- package/dist/feature/queue/types/global/queue.js.map +1 -0
- package/dist/feature/queue/types/index.js +2 -0
- package/dist/feature/queue/types/index.js.map +1 -1
- package/dist/feature/queue/types/items.js.map +1 -1
- package/dist/feature/queue/types/links.js +104 -0
- package/dist/feature/queue/types/links.js.map +1 -0
- package/dist/feature/queue/types/returns.js +3 -1
- package/dist/feature/queue/types/returns.js.map +1 -1
- package/dist/feature/queue/types/settings.js.map +1 -1
- package/dist/feature/runs/machine/exits.js +2 -1
- package/dist/feature/runs/machine/exits.js.map +1 -1
- package/dist/feature/runs/machine/plan.js +68 -42
- package/dist/feature/runs/machine/plan.js.map +1 -1
- package/dist/feature/runs/machine/repair.js +14 -4
- package/dist/feature/runs/machine/repair.js.map +1 -1
- package/dist/feature/runs/machine/run-control.js +8 -2
- package/dist/feature/runs/machine/run-control.js.map +1 -1
- package/dist/feature/runs/machine/scheduler.js +9 -19
- package/dist/feature/runs/machine/scheduler.js.map +1 -1
- package/dist/feature/runs/machine/steps.js +2 -2
- package/dist/feature/runs/machine/steps.js.map +1 -1
- package/dist/feature/runs/machine/transition.js +2 -0
- package/dist/feature/runs/machine/transition.js.map +1 -1
- package/dist/feature/runs/machine/variant/index.js +2 -0
- package/dist/feature/runs/machine/variant/index.js.map +1 -0
- package/dist/feature/runs/machine/variant/set-variant.js +134 -0
- package/dist/feature/runs/machine/variant/set-variant.js.map +1 -0
- package/dist/feature/runs/ports/attachments.js +2 -0
- package/dist/feature/runs/ports/attachments.js.map +1 -0
- package/dist/feature/runs/repositories/rows.js +2 -0
- package/dist/feature/runs/repositories/rows.js.map +1 -1
- package/dist/feature/runs/repositories/runs.js +6 -3
- package/dist/feature/runs/repositories/runs.js.map +1 -1
- package/dist/feature/runs/repositories/write.js +4 -4
- package/dist/feature/runs/repositories/write.js.map +1 -1
- package/dist/feature/runs/services/create.js +12 -0
- package/dist/feature/runs/services/create.js.map +1 -1
- package/dist/feature/runs/services/effects/attempts.js +33 -5
- package/dist/feature/runs/services/effects/attempts.js.map +1 -1
- package/dist/feature/runs/services/effects/context.js.map +1 -1
- package/dist/feature/runs/services/engine.js +20 -8
- package/dist/feature/runs/services/engine.js.map +1 -1
- package/dist/feature/runs/services/index.js +1 -1
- package/dist/feature/runs/services/index.js.map +1 -1
- package/dist/feature/runs/services/progress.js +24 -18
- package/dist/feature/runs/services/progress.js.map +1 -1
- package/dist/feature/runs/services/refresh.js +21 -1
- package/dist/feature/runs/services/refresh.js.map +1 -1
- package/dist/feature/runs/services/requests.js +2 -0
- package/dist/feature/runs/services/requests.js.map +1 -1
- package/dist/feature/runs/services/states.js.map +1 -1
- package/dist/feature/runs/types/attempt.js +11 -1
- package/dist/feature/runs/types/attempt.js.map +1 -1
- package/dist/feature/runs/types/constants.js +2 -0
- package/dist/feature/runs/types/constants.js.map +1 -1
- package/dist/feature/runs/types/create.js +12 -3
- package/dist/feature/runs/types/create.js.map +1 -1
- package/dist/feature/runs/types/group.js +1 -0
- package/dist/feature/runs/types/group.js.map +1 -1
- package/dist/feature/runs/types/index.js +1 -0
- package/dist/feature/runs/types/index.js.map +1 -1
- package/dist/feature/runs/types/input.js +10 -1
- package/dist/feature/runs/types/input.js.map +1 -1
- package/dist/feature/runs/types/limits.js +22 -17
- package/dist/feature/runs/types/limits.js.map +1 -1
- package/dist/feature/runs/types/pools/pools.js +57 -0
- package/dist/feature/runs/types/pools/pools.js.map +1 -0
- package/dist/feature/runs/types/run.js +4 -3
- package/dist/feature/runs/types/run.js.map +1 -1
- package/dist/feature/runs/types/skip.js +2 -17
- package/dist/feature/runs/types/skip.js.map +1 -1
- package/dist/feature/runs/types/topology.js +32 -3
- package/dist/feature/runs/types/topology.js.map +1 -1
- package/dist/feature/stats/repositories/records.js +3 -3
- package/dist/feature/stats/repositories/records.js.map +1 -1
- package/dist/feature/stats/repositories/report.js +1 -2
- package/dist/feature/stats/repositories/report.js.map +1 -1
- package/dist/feature/stats/services/create.js +11 -0
- package/dist/feature/stats/services/create.js.map +1 -1
- package/dist/feature/stats/services/report.js +28 -8
- package/dist/feature/stats/services/report.js.map +1 -1
- package/dist/feature/stats/types/aggregate.js +9 -94
- package/dist/feature/stats/types/aggregate.js.map +1 -1
- package/dist/feature/stats/types/capture.js +0 -2
- package/dist/feature/stats/types/capture.js.map +1 -1
- package/dist/feature/stats/types/index.js +2 -0
- package/dist/feature/stats/types/index.js.map +1 -1
- package/dist/feature/stats/types/names.js +27 -0
- package/dist/feature/stats/types/names.js.map +1 -0
- package/dist/feature/stats/types/records.js.map +1 -1
- package/dist/feature/stats/types/report.js +2 -0
- package/dist/feature/stats/types/report.js.map +1 -1
- package/dist/feature/stats/types/series.js +139 -0
- package/dist/feature/stats/types/series.js.map +1 -0
- package/dist/feature/swarm-config/services/assemble.js +1 -1
- package/dist/feature/swarm-config/services/assemble.js.map +1 -1
- package/dist/feature/swarm-config/services/index.js +3 -1
- package/dist/feature/swarm-config/services/index.js.map +1 -1
- package/dist/feature/swarm-config/services/load.js +17 -1
- package/dist/feature/swarm-config/services/load.js.map +1 -1
- package/dist/feature/swarm-config/services/sections/attachments.js +64 -0
- package/dist/feature/swarm-config/services/sections/attachments.js.map +1 -0
- package/dist/feature/swarm-config/services/sections/queue.js +163 -0
- package/dist/feature/swarm-config/services/sections/queue.js.map +1 -0
- package/dist/feature/swarm-config/services/sections/runtime-sections.js +72 -0
- package/dist/feature/swarm-config/services/sections/runtime-sections.js.map +1 -0
- package/dist/feature/swarm-config/services/sections/stats.js +1 -2
- package/dist/feature/swarm-config/services/sections/stats.js.map +1 -1
- package/dist/feature/swarm-config/services/sections/variants.js +175 -0
- package/dist/feature/swarm-config/services/sections/variants.js.map +1 -0
- package/dist/feature/swarm-config/services/settings.js +31 -3
- package/dist/feature/swarm-config/services/settings.js.map +1 -1
- package/dist/feature/swarm-config/services/validate-pipelines.js +12 -2
- package/dist/feature/swarm-config/services/validate-pipelines.js.map +1 -1
- package/dist/feature/swarm-config/services/validate-settings.js +1 -21
- package/dist/feature/swarm-config/services/validate-settings.js.map +1 -1
- package/dist/feature/swarm-config/services/validate.js +28 -5
- package/dist/feature/swarm-config/services/validate.js.map +1 -1
- package/dist/feature/swarm-config/types/index.js +1 -0
- package/dist/feature/swarm-config/types/index.js.map +1 -1
- package/dist/feature/swarm-config/types/merge.js +2 -0
- package/dist/feature/swarm-config/types/merge.js.map +1 -1
- package/dist/feature/swarm-config/types/pipeline.js +2 -0
- package/dist/feature/swarm-config/types/pipeline.js.map +1 -1
- package/dist/feature/swarm-config/types/settings.js +24 -1
- package/dist/feature/swarm-config/types/settings.js.map +1 -1
- package/dist/feature/swarm-config/types/variants/apply.js +92 -0
- package/dist/feature/swarm-config/types/variants/apply.js.map +1 -0
- package/dist/feature/swarm-config/types/variants/index.js +3 -0
- package/dist/feature/swarm-config/types/variants/index.js.map +1 -0
- package/dist/feature/swarm-config/types/variants/lookup.js +85 -0
- package/dist/feature/swarm-config/types/variants/lookup.js.map +1 -0
- package/dist/feature/swarm-edit/services/editor-settings.js +25 -6
- package/dist/feature/swarm-edit/services/editor-settings.js.map +1 -1
- package/dist/feature/swarm-edit/services/plan-settings.js +26 -8
- package/dist/feature/swarm-edit/services/plan-settings.js.map +1 -1
- package/dist/feature/swarm-edit/services/references.js +25 -0
- package/dist/feature/swarm-edit/services/references.js.map +1 -1
- package/dist/feature/swarm-edit/types/editor.js.map +1 -1
- package/dist/feature/swarm-edit/types/setting-fields.js +21 -2
- package/dist/feature/swarm-edit/types/setting-fields.js.map +1 -1
- package/dist/feature/tags/services/catalog.js +11 -1
- package/dist/feature/tags/services/catalog.js.map +1 -1
- package/dist/feature/tags/types/tags.js +11 -4
- package/dist/feature/tags/types/tags.js.map +1 -1
- package/dist/platform/process/ps.js +1 -1
- package/dist/platform/process/ps.js.map +1 -1
- package/dist/platform/s3/client.js +73 -0
- package/dist/platform/s3/client.js.map +1 -0
- package/dist/platform/s3/sigv4.js +57 -0
- package/dist/platform/s3/sigv4.js.map +1 -0
- package/dist/platform/sqlite/attachments-migration.js +19 -0
- package/dist/platform/sqlite/attachments-migration.js.map +1 -0
- package/dist/platform/sqlite/links-migration.js +38 -0
- package/dist/platform/sqlite/links-migration.js.map +1 -0
- package/dist/platform/sqlite/migrations.js +2 -2
- package/dist/platform/sqlite/migrations.js.map +1 -1
- package/dist/platform/sqlite/parts.js +38 -0
- package/dist/platform/sqlite/parts.js.map +1 -0
- package/dist/presentation/cli/commands/overview/command.js +57 -0
- package/dist/presentation/cli/commands/overview/command.js.map +1 -0
- package/dist/presentation/cli/commands/overview/index.js +2 -0
- package/dist/presentation/cli/commands/overview/index.js.map +1 -0
- package/dist/presentation/cli/commands/queue-edit.js +41 -4
- package/dist/presentation/cli/commands/queue-edit.js.map +1 -1
- package/dist/presentation/cli/commands/queue.js +18 -62
- package/dist/presentation/cli/commands/queue.js.map +1 -1
- package/dist/presentation/cli/commands/run-delivery.js +17 -2
- package/dist/presentation/cli/commands/run-delivery.js.map +1 -1
- package/dist/presentation/cli/commands/run.js +16 -3
- package/dist/presentation/cli/commands/run.js.map +1 -1
- package/dist/presentation/cli/commands/stats.js +1 -1
- package/dist/presentation/cli/commands/stats.js.map +1 -1
- package/dist/presentation/cli/commands/web.js +1 -0
- package/dist/presentation/cli/commands/web.js.map +1 -1
- package/dist/presentation/cli/help.js +1 -1
- package/dist/presentation/cli/help.js.map +1 -1
- package/dist/presentation/cli/io.js.map +1 -1
- package/dist/presentation/cli/links.js +63 -0
- package/dist/presentation/cli/links.js.map +1 -0
- package/dist/presentation/cli/local/config-check.js +4 -0
- package/dist/presentation/cli/local/config-check.js.map +1 -1
- package/dist/presentation/cli/local/present-variants.js +34 -0
- package/dist/presentation/cli/local/present-variants.js.map +1 -0
- package/dist/presentation/cli/options.js +18 -0
- package/dist/presentation/cli/options.js.map +1 -1
- package/dist/presentation/cli/program.js +3 -1
- package/dist/presentation/cli/program.js.map +1 -1
- package/dist/presentation/cli/queue-add.js +101 -0
- package/dist/presentation/cli/queue-add.js.map +1 -0
- package/dist/presentation/cli/queue-print.js +25 -0
- package/dist/presentation/cli/queue-print.js.map +1 -0
- package/dist/presentation/cli/setup/run.js.map +1 -1
- package/dist/presentation/cli/watch.js +105 -8
- package/dist/presentation/cli/watch.js.map +1 -1
- package/dist/presentation/format/groups.js +4 -3
- package/dist/presentation/format/groups.js.map +1 -1
- package/dist/presentation/format/hints.js +33 -0
- package/dist/presentation/format/hints.js.map +1 -0
- package/dist/presentation/format/index.js +8 -3
- package/dist/presentation/format/index.js.map +1 -1
- package/dist/presentation/format/links.js +26 -0
- package/dist/presentation/format/links.js.map +1 -0
- package/dist/presentation/format/numbers.js +20 -0
- package/dist/presentation/format/numbers.js.map +1 -0
- package/dist/presentation/format/overview.js +210 -0
- package/dist/presentation/format/overview.js.map +1 -0
- package/dist/presentation/format/queue.js +77 -21
- package/dist/presentation/format/queue.js.map +1 -1
- package/dist/presentation/format/run-steps.js +56 -0
- package/dist/presentation/format/run-steps.js.map +1 -0
- package/dist/presentation/format/runs.js +46 -16
- package/dist/presentation/format/runs.js.map +1 -1
- package/dist/presentation/format/stats.js +4 -19
- package/dist/presentation/format/stats.js.map +1 -1
- package/dist/presentation/format/style.js +40 -2
- package/dist/presentation/format/style.js.map +1 -1
- package/dist/presentation/format/table.js +23 -11
- package/dist/presentation/format/table.js.map +1 -1
- package/dist/presentation/ipc/contract/agents.js +0 -1
- package/dist/presentation/ipc/contract/agents.js.map +1 -1
- package/dist/presentation/ipc/contract/artifacts.js +4 -0
- package/dist/presentation/ipc/contract/artifacts.js.map +1 -1
- package/dist/presentation/ipc/contract/config.js +23 -5
- package/dist/presentation/ipc/contract/config.js.map +1 -1
- package/dist/presentation/ipc/contract/envelope.js +7 -0
- package/dist/presentation/ipc/contract/envelope.js.map +1 -1
- package/dist/presentation/ipc/contract/panel.js +1 -0
- package/dist/presentation/ipc/contract/panel.js.map +1 -1
- package/dist/presentation/ipc/contract/queue.js +43 -1
- package/dist/presentation/ipc/contract/queue.js.map +1 -1
- package/dist/presentation/ipc/contract/responses/attachments.js +2 -0
- package/dist/presentation/ipc/contract/responses/attachments.js.map +1 -0
- package/dist/presentation/ipc/contract/responses/index.js +1 -0
- package/dist/presentation/ipc/contract/responses/index.js.map +1 -1
- package/dist/presentation/ipc/contract/responses/stats.js +10 -8
- package/dist/presentation/ipc/contract/responses/stats.js.map +1 -1
- package/dist/presentation/ipc/contract/runs.js +15 -0
- package/dist/presentation/ipc/contract/runs.js.map +1 -1
- package/dist/presentation/ipc/contract/stats/stats.js +1 -0
- package/dist/presentation/ipc/contract/stats/stats.js.map +1 -1
- package/dist/presentation/ipc/handlers/groups.js +9 -0
- package/dist/presentation/ipc/handlers/groups.js.map +1 -1
- package/dist/presentation/ipc/handlers/queue.js +44 -13
- package/dist/presentation/ipc/handlers/queue.js.map +1 -1
- package/dist/presentation/ipc/handlers/runs.js +6 -1
- package/dist/presentation/ipc/handlers/runs.js.map +1 -1
- package/dist/presentation/ipc/handlers/stats.js +1 -0
- package/dist/presentation/ipc/handlers/stats.js.map +1 -1
- package/dist/presentation/ipc/handlers/system.js +1 -0
- package/dist/presentation/ipc/handlers/system.js.map +1 -1
- package/dist/presentation/ipc/publisher.js +80 -3
- package/dist/presentation/ipc/publisher.js.map +1 -1
- package/dist/presentation/ipc/snapshots.js +33 -4
- package/dist/presentation/ipc/snapshots.js.map +1 -1
- package/dist/presentation/ipc/views/global-queue.js +48 -0
- package/dist/presentation/ipc/views/global-queue.js.map +1 -0
- package/dist/presentation/ipc/views/index.js +2 -1
- package/dist/presentation/ipc/views/index.js.map +1 -1
- package/dist/presentation/ipc/views/queue.js +35 -10
- package/dist/presentation/ipc/views/queue.js.map +1 -1
- package/dist/presentation/ipc/views/runs.js +11 -1
- package/dist/presentation/ipc/views/runs.js.map +1 -1
- package/dist/presentation/mcp/host-kit.js +21 -2
- package/dist/presentation/mcp/host-kit.js.map +1 -1
- package/dist/presentation/mcp/host-links.js +48 -0
- package/dist/presentation/mcp/host-links.js.map +1 -0
- package/dist/presentation/mcp/host-queue-control.js.map +1 -1
- package/dist/presentation/mcp/host-queue.js +21 -13
- package/dist/presentation/mcp/host-queue.js.map +1 -1
- package/dist/presentation/mcp/host-runs.js +17 -2
- package/dist/presentation/mcp/host-runs.js.map +1 -1
- package/dist/presentation/mcp/host.js +4 -1
- package/dist/presentation/mcp/host.js.map +1 -1
- package/dist/presentation/mcp/worker-extra.js +11 -3
- package/dist/presentation/mcp/worker-extra.js.map +1 -1
- package/dist/presentation/web/errors.js +1 -1
- package/dist/presentation/web/errors.js.map +1 -1
- package/dist/presentation/web/hub.js +9 -0
- package/dist/presentation/web/hub.js.map +1 -1
- package/dist/presentation/web/options.js +1 -0
- package/dist/presentation/web/options.js.map +1 -1
- package/dist/presentation/web/panel/daemon-panel.js +1 -0
- package/dist/presentation/web/panel/daemon-panel.js.map +1 -1
- package/dist/presentation/web/panel/system.js +1 -0
- package/dist/presentation/web/panel/system.js.map +1 -1
- package/dist/presentation/web/request.js +8 -1
- package/dist/presentation/web/request.js.map +1 -1
- package/dist/presentation/web/routes/downloads.js +38 -0
- package/dist/presentation/web/routes/downloads.js.map +1 -1
- package/dist/presentation/web/routes/queue.js +56 -10
- package/dist/presentation/web/routes/queue.js.map +1 -1
- package/dist/presentation/web/routes/runs.js +9 -0
- package/dist/presentation/web/routes/runs.js.map +1 -1
- package/dist/presentation/web/routes/settings.js +11 -1
- package/dist/presentation/web/routes/settings.js.map +1 -1
- package/dist/presentation/web/server.js +11 -2
- package/dist/presentation/web/server.js.map +1 -1
- package/dist/presentation/web/uploads.js +115 -0
- package/dist/presentation/web/uploads.js.map +1 -0
- package/dist/web/assets/FilterColumn-z60UZhkk.js +1 -0
- package/dist/web/assets/SharedPipelinesGroup-CgUJ-sUc.js +1 -0
- package/dist/web/assets/card-4euJkmfJ.js +1 -0
- package/dist/web/assets/deliveryModes-BGIYJzWQ.js +1 -0
- package/dist/web/assets/empty-OZRGgwa5.js +41 -0
- package/dist/web/assets/index-Cg7gL5P8.css +2 -0
- package/dist/web/assets/index-LD1g1Vkm.js +43 -0
- package/dist/web/assets/locales-D85Vnmev.js +1 -0
- package/dist/web/assets/pipelines-Cej37cah.js +14 -0
- package/dist/web/assets/settingFields-gm9TlqxP.js +1 -0
- package/dist/web/assets/settings-CDiTeiYL.js +6 -0
- package/dist/web/assets/specialists-BGKB5BLI.js +4 -0
- package/dist/web/assets/stats-BM-bGkGX.js +1 -0
- package/dist/web/assets/topology-BE6orrOL.js +1 -0
- package/dist/web/assets/trash-xUZ90-AG.js +1 -0
- package/dist/web/index.html +7 -7
- package/integrations/claude-code/.claude-plugin/plugin.json +1 -1
- package/integrations/claude-code/hooks/feed.ts +1 -11
- package/integrations/claude-code/hooks/pane.ts +3 -15
- package/integrations/claude-code/hooks/view.tsx +0 -1
- package/integrations/claude-code/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/feature/agents/types/run-naming.js.map +0 -1
- package/dist/web/assets/FilterColumn-BrQWIM5F.js +0 -1
- package/dist/web/assets/SharedPipelinesGroup-WFngQrqI.js +0 -1
- package/dist/web/assets/badge-B_khFsd6.js +0 -1
- package/dist/web/assets/card-COXjnc-y.js +0 -1
- package/dist/web/assets/deliveryModes-funlvXVC.js +0 -1
- package/dist/web/assets/empty-Eb-EZDPX.js +0 -41
- package/dist/web/assets/index-DEXoIe2a.js +0 -21
- package/dist/web/assets/index-DMlIe0VD.css +0 -2
- package/dist/web/assets/locales-BlBJo1PR.js +0 -1
- package/dist/web/assets/pipelines-B3cdeex_.js +0 -10
- package/dist/web/assets/queue-HMUImu0E.js +0 -16
- package/dist/web/assets/select-MHus_Unr.js +0 -1
- package/dist/web/assets/settingFields-DVg9TQK2.js +0 -1
- package/dist/web/assets/settings-CpeEsUXX.js +0 -6
- package/dist/web/assets/skeleton-CWY1nRvW.js +0 -1
- package/dist/web/assets/specialists-BkLXuqUd.js +0 -1
- package/dist/web/assets/stats-DRg_5vll.js +0 -1
- package/dist/web/assets/topology-DGTNdDHf.js +0 -1
- package/dist/web/assets/trash-CFJeuRuc.js +0 -1
- package/dist/web/assets/useListDrag-B7Wlt2u9.js +0 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { join, sep } from 'node:path';
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
|
+
/** Attachments as files: `<root>/<owner>/<attachment-id>`, URI `file:///…`. */
|
|
5
|
+
export class FileAttachmentStorage {
|
|
6
|
+
root;
|
|
7
|
+
constructor(root) {
|
|
8
|
+
this.root = root;
|
|
9
|
+
}
|
|
10
|
+
handles(uri) {
|
|
11
|
+
return uri.startsWith('file:');
|
|
12
|
+
}
|
|
13
|
+
async put(owner, key, bytes) {
|
|
14
|
+
const directory = join(this.root, owner);
|
|
15
|
+
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
16
|
+
const path = join(directory, key);
|
|
17
|
+
const temporary = `${path}.${process.pid}.tmp`;
|
|
18
|
+
writeFileSync(temporary, bytes, { mode: 0o600 });
|
|
19
|
+
renameSync(temporary, path);
|
|
20
|
+
return pathToFileURL(path).href;
|
|
21
|
+
}
|
|
22
|
+
async get(uri) {
|
|
23
|
+
const path = this.pathOf(uri);
|
|
24
|
+
if (path === null)
|
|
25
|
+
return null;
|
|
26
|
+
try {
|
|
27
|
+
return readFileSync(path);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async remove(uri) {
|
|
34
|
+
const path = this.pathOf(uri);
|
|
35
|
+
if (path !== null)
|
|
36
|
+
rmSync(path, { force: true });
|
|
37
|
+
}
|
|
38
|
+
async sweep(keep) {
|
|
39
|
+
let owners;
|
|
40
|
+
try {
|
|
41
|
+
owners = readdirSync(this.root);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
for (const owner of owners) {
|
|
47
|
+
const directory = join(this.root, owner);
|
|
48
|
+
const uris = keep.get(owner);
|
|
49
|
+
if (uris === undefined) {
|
|
50
|
+
rmSync(directory, { recursive: true, force: true });
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const kept = new Set(uris.map((uri) => this.pathOf(uri)).filter((path) => path !== null));
|
|
54
|
+
let files;
|
|
55
|
+
try {
|
|
56
|
+
files = readdirSync(directory);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
for (const file of files) {
|
|
62
|
+
if (!kept.has(join(directory, file)))
|
|
63
|
+
rmSync(join(directory, file), { force: true });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** The path inside the root for a `file:` URI; null for anything else. */
|
|
68
|
+
pathOf(uri) {
|
|
69
|
+
if (!this.handles(uri))
|
|
70
|
+
return null;
|
|
71
|
+
try {
|
|
72
|
+
const path = fileURLToPath(uri);
|
|
73
|
+
return path.startsWith(this.root + sep) ? path : null;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** Picks the storage that owns the URI; null for an unknown scheme. */
|
|
81
|
+
export function attachmentStorageFor(storages, uri) {
|
|
82
|
+
return storages.find((storage) => storage.handles(uri)) ?? null;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=attachment-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-storage.js","sourceRoot":"","sources":["../../../../src/feature/attachments/repositories/attachment-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,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I,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;oBAAE,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACvF,CAAC;QACH,CAAC;IACH,CAAC;IAED,0EAA0E;IAClE,MAAM,CAAC,GAAW;QACxB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;QACpC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;YAChC,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QACxD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAED,uEAAuE;AACvE,MAAM,UAAU,oBAAoB,CAClC,QAA6B,EAC7B,GAAW;IAEX,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
function record(row) {
|
|
2
|
+
return {
|
|
3
|
+
id: String(row.id),
|
|
4
|
+
repository: String(row.repository),
|
|
5
|
+
itemId: String(row.item_id),
|
|
6
|
+
runId: row.run_id === null || row.run_id === undefined ? null : String(row.run_id),
|
|
7
|
+
fileName: String(row.file_name),
|
|
8
|
+
size: Number(row.size),
|
|
9
|
+
mediaType: String(row.media_type),
|
|
10
|
+
uri: String(row.uri),
|
|
11
|
+
createdAt: Number(row.created_at),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export class AttachmentRepository {
|
|
15
|
+
database;
|
|
16
|
+
constructor(database) {
|
|
17
|
+
this.database = database;
|
|
18
|
+
}
|
|
19
|
+
/** Records the attachments and deletes the records `removing` names, together or not at all. */
|
|
20
|
+
add(records, removing = []) {
|
|
21
|
+
this.database.transaction(() => {
|
|
22
|
+
for (const id of removing)
|
|
23
|
+
this.database.prepare('DELETE FROM attachments WHERE id = ?').run(id);
|
|
24
|
+
for (const item of records) {
|
|
25
|
+
this.database
|
|
26
|
+
.prepare(`INSERT INTO attachments (id, repository, item_id, run_id, file_name, size, media_type, uri, created_at)
|
|
27
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
28
|
+
.run(item.id, item.repository, item.itemId, item.runId, item.fileName, item.size, item.mediaType, item.uri, item.createdAt);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/** The attachments of a queue item, in the order they were attached. */
|
|
33
|
+
ofItem(itemId) {
|
|
34
|
+
return this.database
|
|
35
|
+
.prepare('SELECT * FROM attachments WHERE item_id = ? ORDER BY created_at, rowid')
|
|
36
|
+
.all(itemId).map(record);
|
|
37
|
+
}
|
|
38
|
+
/** The attachments of a run, in the order they were attached. */
|
|
39
|
+
ofRun(runId) {
|
|
40
|
+
return this.database
|
|
41
|
+
.prepare('SELECT * FROM attachments WHERE run_id = ? ORDER BY created_at, rowid')
|
|
42
|
+
.all(runId).map(record);
|
|
43
|
+
}
|
|
44
|
+
/** The attachment by its id, whoever owns it. */
|
|
45
|
+
byId(id) {
|
|
46
|
+
const row = this.database.prepare('SELECT * FROM attachments WHERE id = ?').get(id);
|
|
47
|
+
return row ? record(row) : null;
|
|
48
|
+
}
|
|
49
|
+
/** The attachment of a run by its id. */
|
|
50
|
+
inRun(runId, id) {
|
|
51
|
+
const row = this.database
|
|
52
|
+
.prepare('SELECT * FROM attachments WHERE run_id = ? AND id = ?')
|
|
53
|
+
.get(runId, id);
|
|
54
|
+
return row ? record(row) : null;
|
|
55
|
+
}
|
|
56
|
+
/** The attachments of the item now belong to the run. */
|
|
57
|
+
bindToRun(itemId, runId) {
|
|
58
|
+
this.database
|
|
59
|
+
.prepare('UPDATE attachments SET run_id = ? WHERE item_id = ? AND run_id IS NULL')
|
|
60
|
+
.run(runId, itemId);
|
|
61
|
+
}
|
|
62
|
+
/** Deletes the records of the item that no run owns; returns them. */
|
|
63
|
+
removeOfItem(itemId, names) {
|
|
64
|
+
return this.database.transaction(() => {
|
|
65
|
+
const removed = this.ofItem(itemId).filter((item) => item.runId === null && (names === undefined || names.includes(item.fileName)));
|
|
66
|
+
for (const item of removed) {
|
|
67
|
+
this.database.prepare('DELETE FROM attachments WHERE id = ?').run(item.id);
|
|
68
|
+
}
|
|
69
|
+
return removed;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/** Deletes records by id. */
|
|
73
|
+
removeRecords(ids) {
|
|
74
|
+
this.database.transaction(() => {
|
|
75
|
+
for (const id of ids)
|
|
76
|
+
this.database.prepare('DELETE FROM attachments WHERE id = ?').run(id);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
all() {
|
|
80
|
+
return this.database.prepare('SELECT * FROM attachments').all().map(record);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=attachments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachments.js","sourceRoot":"","sources":["../../../../src/feature/attachments/repositories/attachments.ts"],"names":[],"mappings":"AAiBA,SAAS,MAAM,CAAC,GAAQ;IACtB,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC;QAClC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAC3B,KAAK,EAAE,GAAG,CAAC,MAAM,KAAK,IAAI,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,MA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YACF,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;gBAC3B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC7E,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,6BAA6B;IAC7B,aAAa,CAAC,GAAa;QACzB,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE;YAC7B,KAAK,MAAM,EAAE,IAAI,GAAG;gBAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC9F,CAAC,CAAC,CAAC;IACL,CAAC;IAED,GAAG;QACD,OAAQ,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC,GAAG,EAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACzF,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/feature/attachments/repositories/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** S3 objects are addressed by attachment id, independently of a queue item or run. */
|
|
2
|
+
export class S3AttachmentStorage {
|
|
3
|
+
settings;
|
|
4
|
+
client;
|
|
5
|
+
constructor(settings, client) {
|
|
6
|
+
this.settings = settings;
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
handles(uri) {
|
|
10
|
+
return uri.startsWith('s3:');
|
|
11
|
+
}
|
|
12
|
+
async put(_owner, id, bytes) {
|
|
13
|
+
const bucket = this.settings.bucket;
|
|
14
|
+
if (!bucket)
|
|
15
|
+
throw new Error('S3 bucket is not configured');
|
|
16
|
+
const key = `${this.settings.prefix}${id}`;
|
|
17
|
+
await this.client.put(bucket, key, bytes);
|
|
18
|
+
return `s3://${bucket}/${key.split('/').map(encodeURIComponent).join('/')}`;
|
|
19
|
+
}
|
|
20
|
+
async get(uri) {
|
|
21
|
+
const address = this.address(uri);
|
|
22
|
+
return address ? this.client.get(address.bucket, address.key) : null;
|
|
23
|
+
}
|
|
24
|
+
async remove(uri) {
|
|
25
|
+
const address = this.address(uri);
|
|
26
|
+
if (address)
|
|
27
|
+
await this.client.delete(address.bucket, address.key);
|
|
28
|
+
}
|
|
29
|
+
async sweep(_keep) {
|
|
30
|
+
// Never list a bucket: it may be shared with other installations.
|
|
31
|
+
}
|
|
32
|
+
address(uri) {
|
|
33
|
+
try {
|
|
34
|
+
// Do not use URL here: it normalizes dot segments before we can recover the original key.
|
|
35
|
+
const match = /^s3:\/\/([^/?#]+)\/(.+)$/.exec(uri);
|
|
36
|
+
if (!match || /[?#]/.test(match[2]))
|
|
37
|
+
return null;
|
|
38
|
+
const key = match[2].split('/').map(decodeURIComponent).join('/');
|
|
39
|
+
return key ? { bucket: match[1], key } : null;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=s3-attachment-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3-attachment-storage.js","sourceRoot":"","sources":["../../../../src/feature/attachments/repositories/s3-attachment-storage.ts"],"names":[],"mappings":"AAKA,uFAAuF;AACvF,MAAM,OAAO,mBAAmB;IACb,QAAQ,CAA2B;IACnC,MAAM,CAAW;IAElC,YAAY,QAAkC,EAAE,MAAgB;QAC9D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,OAAO,CAAC,GAAW;QACjB,OAAO,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,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACnD,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC;gBAAE,OAAO,IAAI,CAAC;YAClD,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACnE,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACjD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { mkdirSync, renameSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { rejected } from '../../../platform/errors/index.js';
|
|
4
|
+
import { workspaceRoot } from '../../../platform/git/index.js';
|
|
5
|
+
import { attachmentStorageFor, } from '../repositories/index.js';
|
|
6
|
+
import { newAttachmentId, newRecord, prepareSources, readPrepared } from './ingest.js';
|
|
7
|
+
function refOf(record) {
|
|
8
|
+
return {
|
|
9
|
+
id: record.id,
|
|
10
|
+
fileName: record.fileName,
|
|
11
|
+
size: record.size,
|
|
12
|
+
mediaType: record.mediaType,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** Files attached to tasks: accepted into the storage, handed to the run, laid out for agents. */
|
|
16
|
+
export class AttachmentService {
|
|
17
|
+
dependencies;
|
|
18
|
+
constructor(dependencies) {
|
|
19
|
+
this.dependencies = dependencies;
|
|
20
|
+
}
|
|
21
|
+
/** Only the presence of daemon credentials is exposed to the panel. */
|
|
22
|
+
hasS3Credentials() {
|
|
23
|
+
return (this.dependencies.s3Credentials !== null && this.dependencies.s3Credentials !== undefined);
|
|
24
|
+
}
|
|
25
|
+
/** The attachments of a queue item, in the order they were attached. */
|
|
26
|
+
listOf(itemId) {
|
|
27
|
+
return this.dependencies.attachments.ofItem(itemId).map(refOf);
|
|
28
|
+
}
|
|
29
|
+
/** The attachments a run was created with. */
|
|
30
|
+
listOfRun(runId) {
|
|
31
|
+
return this.dependencies.attachments.ofRun(runId).map(refOf);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Accepts files for a queue item; with `detach` also drops attachments of the item by name.
|
|
35
|
+
* Everything is checked before anything is written, and a failure leaves nothing behind.
|
|
36
|
+
* Returns the new attachments.
|
|
37
|
+
*/
|
|
38
|
+
async ingest(params) {
|
|
39
|
+
const { attachments, now } = this.dependencies;
|
|
40
|
+
const own = attachments.ofItem(params.itemId).filter((record) => record.runId === null);
|
|
41
|
+
const dropped = params.detach ?? [];
|
|
42
|
+
for (const name of dropped) {
|
|
43
|
+
if (!own.some((record) => record.fileName === name)) {
|
|
44
|
+
throw rejected(`the task has no attachment \`${name}\``);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const kept = own.filter((record) => !dropped.includes(record.fileName));
|
|
48
|
+
const prepared = prepareSources(params.sources, kept.map((record) => record.fileName));
|
|
49
|
+
const written = [];
|
|
50
|
+
const records = [];
|
|
51
|
+
let replaced = [];
|
|
52
|
+
try {
|
|
53
|
+
const storage = prepared.length ? this.defaultStorage() : null;
|
|
54
|
+
for (const file of prepared) {
|
|
55
|
+
const bytes = await readPrepared(file);
|
|
56
|
+
const id = newAttachmentId();
|
|
57
|
+
const uri = await storage.put(params.itemId, id, bytes);
|
|
58
|
+
written.push({ uri, storage: storage });
|
|
59
|
+
records.push(newRecord(file, bytes, {
|
|
60
|
+
repository: params.repository,
|
|
61
|
+
itemId: params.itemId,
|
|
62
|
+
uri,
|
|
63
|
+
id,
|
|
64
|
+
now: now(),
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
const removing = own.filter((record) => dropped.includes(record.fileName));
|
|
68
|
+
attachments.add(records, removing.map((record) => record.id));
|
|
69
|
+
replaced = removing;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
for (const item of written) {
|
|
73
|
+
await item.storage
|
|
74
|
+
.remove(item.uri)
|
|
75
|
+
.catch((failure) => this.logStorageError(failure));
|
|
76
|
+
}
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
await this.removeBytes(replaced);
|
|
80
|
+
return records.map(refOf);
|
|
81
|
+
}
|
|
82
|
+
/** Drops attachments of a queue item by name and deletes their bytes. */
|
|
83
|
+
async detach(itemId, names) {
|
|
84
|
+
const removed = this.dependencies.attachments.removeOfItem(itemId, names);
|
|
85
|
+
await this.removeBytes(removed);
|
|
86
|
+
}
|
|
87
|
+
/** The item became a run: its attachments belong to the run now; no bytes are copied. */
|
|
88
|
+
bindToRun(itemId, runId) {
|
|
89
|
+
this.dependencies.attachments.bindToRun(itemId, runId);
|
|
90
|
+
}
|
|
91
|
+
/** The item left the queue without becoming a run: its attachments are deleted. */
|
|
92
|
+
async removeOwner(itemId) {
|
|
93
|
+
await this.removeBytes(this.dependencies.attachments.removeOfItem(itemId));
|
|
94
|
+
}
|
|
95
|
+
/** The file and its bytes; rejected when the run has no such attachment or the bytes are gone. */
|
|
96
|
+
async content(runId, id) {
|
|
97
|
+
const record = this.dependencies.attachments.inRun(runId, id);
|
|
98
|
+
if (!record)
|
|
99
|
+
throw rejected(`unknown attachment \`${id}\``);
|
|
100
|
+
const bytes = await this.bytesOf(record);
|
|
101
|
+
if (bytes === null)
|
|
102
|
+
throw rejected(`attachment \`${record.fileName}\` is not available`);
|
|
103
|
+
return { ...refOf(record), bytes };
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Lays the attachments of the run out as files in `<workspace>/logs/<run>/_attachments/`, outside
|
|
107
|
+
* every worktree, and returns the folder; null for a run without attachments. Every call writes
|
|
108
|
+
* each file from the storage again, so a changed copy never survives.
|
|
109
|
+
*/
|
|
110
|
+
async materialize(run) {
|
|
111
|
+
if (run.attachments.length === 0)
|
|
112
|
+
return null;
|
|
113
|
+
const directory = join(workspaceRoot(run.repository, run.config.workspaceDir), 'logs', run.id, '_attachments');
|
|
114
|
+
mkdirSync(directory, { recursive: true });
|
|
115
|
+
for (const ref of run.attachments) {
|
|
116
|
+
const record = this.dependencies.attachments.byId(ref.id);
|
|
117
|
+
const bytes = record ? await this.bytesOf(record) : null;
|
|
118
|
+
if (bytes === null)
|
|
119
|
+
throw new Error(`attachment ${ref.fileName} is not available`);
|
|
120
|
+
const path = join(directory, ref.fileName);
|
|
121
|
+
const temporary = `${path}.${process.pid}.tmp`;
|
|
122
|
+
writeFileSync(temporary, bytes, { mode: 0o600 });
|
|
123
|
+
renameSync(temporary, path);
|
|
124
|
+
}
|
|
125
|
+
return directory;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Deletes the records without a queue item or a run, then the stored files no record names.
|
|
129
|
+
* Links of a scheme no storage knows are left alone.
|
|
130
|
+
*/
|
|
131
|
+
async sweep(live) {
|
|
132
|
+
const { attachments } = this.dependencies;
|
|
133
|
+
const orphans = attachments
|
|
134
|
+
.all()
|
|
135
|
+
.filter((record) => record.runId === null ? !live.items.has(record.itemId) : !live.hasRun(record.runId));
|
|
136
|
+
await this.removeBytes(orphans);
|
|
137
|
+
attachments.removeRecords(orphans.map((record) => record.id));
|
|
138
|
+
const keep = new Map();
|
|
139
|
+
for (const record of attachments.all()) {
|
|
140
|
+
keep.set(record.itemId, [...(keep.get(record.itemId) ?? []), record.uri]);
|
|
141
|
+
}
|
|
142
|
+
for (const storage of this.storages()) {
|
|
143
|
+
await storage.sweep(keep).catch((error) => this.logStorageError(error));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
defaultStorage() {
|
|
147
|
+
const settings = this.dependencies.attachmentSettings?.();
|
|
148
|
+
if (typeof settings === 'string')
|
|
149
|
+
throw rejected(settings);
|
|
150
|
+
if (settings?.storage === 's3') {
|
|
151
|
+
if (!this.dependencies.s3Credentials) {
|
|
152
|
+
throw rejected('no S3 credentials in the daemon environment');
|
|
153
|
+
}
|
|
154
|
+
if (!this.dependencies.s3Storage)
|
|
155
|
+
throw new Error('S3 attachment storage is not wired');
|
|
156
|
+
return this.dependencies.s3Storage(settings.s3);
|
|
157
|
+
}
|
|
158
|
+
const storage = this.dependencies.storages[0];
|
|
159
|
+
if (!storage)
|
|
160
|
+
throw new Error('no attachment storage');
|
|
161
|
+
return storage;
|
|
162
|
+
}
|
|
163
|
+
async bytesOf(record) {
|
|
164
|
+
const storage = attachmentStorageFor(this.storages(), record.uri);
|
|
165
|
+
try {
|
|
166
|
+
return storage ? await storage.get(record.uri) : null;
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
this.logStorageError(error);
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
async removeBytes(records) {
|
|
174
|
+
for (const record of records) {
|
|
175
|
+
const storage = attachmentStorageFor(this.storages(), record.uri);
|
|
176
|
+
if (storage)
|
|
177
|
+
await storage.remove(record.uri).catch((error) => this.logStorageError(error));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
storages() {
|
|
181
|
+
const settings = this.dependencies.attachmentSettings?.();
|
|
182
|
+
const credentials = this.dependencies.s3Credentials;
|
|
183
|
+
return typeof settings !== 'string' && settings && credentials && this.dependencies.s3Storage
|
|
184
|
+
? [...this.dependencies.storages, this.dependencies.s3Storage(settings.s3)]
|
|
185
|
+
: this.dependencies.storages;
|
|
186
|
+
}
|
|
187
|
+
logStorageError(error) {
|
|
188
|
+
this.dependencies.log?.(`attachment storage: ${error instanceof Error ? error.message : String(error)}`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=attachments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachments.js","sourceRoot":"","sources":["../../../../src/feature/attachments/services/attachments.ts"],"names":[],"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,QAAQ,KAAK,QAAQ,IAAI,QAAQ,IAAI,WAAW,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS;YAC3F,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YAC3E,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;IACjC,CAAC;IAEO,eAAe,CAAC,KAAc;QACpC,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,CACrB,uBAAuB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAChF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { S3Client } from '../../../platform/s3/client.js';
|
|
3
|
+
import { AttachmentRepository, FileAttachmentStorage, S3AttachmentStorage, } from '../repositories/index.js';
|
|
4
|
+
import { AttachmentService } from './attachments.js';
|
|
5
|
+
export function createAttachmentsServices(dependencies) {
|
|
6
|
+
return {
|
|
7
|
+
attachments: new AttachmentService({
|
|
8
|
+
attachments: new AttachmentRepository(dependencies.database),
|
|
9
|
+
storages: [new FileAttachmentStorage(join(dependencies.stateDirectory, 'attachments'))],
|
|
10
|
+
now: dependencies.now,
|
|
11
|
+
...(dependencies.config
|
|
12
|
+
? { attachmentSettings: () => dependencies.config.attachmentSettings() }
|
|
13
|
+
: {}),
|
|
14
|
+
s3Credentials: dependencies.s3Credentials ?? null,
|
|
15
|
+
...(dependencies.s3Credentials
|
|
16
|
+
? {
|
|
17
|
+
s3Storage: (settings) => new S3AttachmentStorage(settings, new S3Client({
|
|
18
|
+
region: settings.region,
|
|
19
|
+
endpoint: settings.endpoint,
|
|
20
|
+
pathStyle: settings.pathStyle,
|
|
21
|
+
credentials: dependencies.s3Credentials,
|
|
22
|
+
})),
|
|
23
|
+
}
|
|
24
|
+
: {}),
|
|
25
|
+
log: dependencies.log ?? (() => undefined),
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/feature/attachments/services/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,QAAQ,EAAsB,MAAM,gCAAgC,CAAC;AAE9E,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAMrD,MAAM,UAAU,yBAAyB,CAAC,YAQzC;IACC,OAAO;QACL,WAAW,EAAE,IAAI,iBAAiB,CAAC;YACjC,WAAW,EAAE,IAAI,oBAAoB,CAAC,YAAY,CAAC,QAAQ,CAAC;YAC5D,QAAQ,EAAE,CAAC,IAAI,qBAAqB,CAAC,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC;YACvF,GAAG,EAAE,YAAY,CAAC,GAAG;YACrB,GAAG,CAAC,YAAY,CAAC,MAAM;gBACrB,CAAC,CAAC,EAAE,kBAAkB,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,MAAO,CAAC,kBAAkB,EAAE,EAAE;gBACzE,CAAC,CAAC,EAAE,CAAC;YACP,aAAa,EAAE,YAAY,CAAC,aAAa,IAAI,IAAI;YACjD,GAAG,CAAC,YAAY,CAAC,aAAa;gBAC5B,CAAC,CAAC;oBACE,SAAS,EAAE,CAAC,QAAQ,EAAE,EAAE,CACtB,IAAI,mBAAmB,CACrB,QAAQ,EACR,IAAI,QAAQ,CAAC;wBACX,MAAM,EAAE,QAAQ,CAAC,MAAM;wBACvB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;wBAC3B,SAAS,EAAE,QAAQ,CAAC,SAAS;wBAC7B,WAAW,EAAE,YAAY,CAAC,aAAc;qBACzC,CAAC,CACH;iBACJ;gBACH,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,EAAE,YAAY,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;SAC3C,CAAC;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/feature/attachments/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA0B,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAA4B,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { statSync } from 'node:fs';
|
|
3
|
+
import { readFile } from 'node:fs/promises';
|
|
4
|
+
import { basename, isAbsolute } from 'node:path';
|
|
5
|
+
import { rejected } from '../../../platform/errors/index.js';
|
|
6
|
+
import { ATTACHMENT_MAX_BYTES, ATTACHMENTS_PER_TASK, attachmentMediaType, attachmentNameProblem, formatAttachmentSize, } from '../types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Checks every source before anything is written: absolute path, a regular file, the size, the
|
|
9
|
+
* name, no repeated names and the number of attachments the task ends with.
|
|
10
|
+
*/
|
|
11
|
+
export function prepareSources(sources, keptNames) {
|
|
12
|
+
const names = new Set(keptNames);
|
|
13
|
+
const prepared = [];
|
|
14
|
+
for (const source of sources) {
|
|
15
|
+
if (!isAbsolute(source.path)) {
|
|
16
|
+
throw rejected(`attachment path must be absolute: \`${source.path}\``);
|
|
17
|
+
}
|
|
18
|
+
let size;
|
|
19
|
+
try {
|
|
20
|
+
const stat = statSync(source.path);
|
|
21
|
+
if (!stat.isFile())
|
|
22
|
+
throw rejected(`attachment is not a regular file: \`${source.path}\``);
|
|
23
|
+
size = stat.size;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
if (error.kind !== undefined)
|
|
27
|
+
throw error;
|
|
28
|
+
throw rejected(`attachment file is not readable: \`${source.path}\``);
|
|
29
|
+
}
|
|
30
|
+
const fileName = source.name ?? basename(source.path);
|
|
31
|
+
const problem = attachmentNameProblem(fileName);
|
|
32
|
+
if (problem !== null)
|
|
33
|
+
throw rejected(problem);
|
|
34
|
+
if (size > ATTACHMENT_MAX_BYTES) {
|
|
35
|
+
throw rejected(`attachment \`${fileName}\` is ${formatAttachmentSize(size)}; the limit is ${formatAttachmentSize(ATTACHMENT_MAX_BYTES)}`);
|
|
36
|
+
}
|
|
37
|
+
if (names.has(fileName))
|
|
38
|
+
throw rejected(`attachment name \`${fileName}\` is repeated`);
|
|
39
|
+
names.add(fileName);
|
|
40
|
+
prepared.push({ fileName, size, mediaType: attachmentMediaType(fileName), path: source.path });
|
|
41
|
+
}
|
|
42
|
+
if (names.size > ATTACHMENTS_PER_TASK) {
|
|
43
|
+
throw rejected(`a task may have at most ${ATTACHMENTS_PER_TASK} attachments`);
|
|
44
|
+
}
|
|
45
|
+
return prepared;
|
|
46
|
+
}
|
|
47
|
+
/** The bytes of a prepared file; a file that grew past the limit meanwhile is refused. */
|
|
48
|
+
export async function readPrepared(file) {
|
|
49
|
+
let bytes;
|
|
50
|
+
try {
|
|
51
|
+
bytes = await readFile(file.path);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
throw rejected(`attachment file is not readable: \`${file.path}\``);
|
|
55
|
+
}
|
|
56
|
+
if (bytes.length > ATTACHMENT_MAX_BYTES) {
|
|
57
|
+
throw rejected(`attachment \`${file.fileName}\` is larger than the limit`);
|
|
58
|
+
}
|
|
59
|
+
return bytes;
|
|
60
|
+
}
|
|
61
|
+
export function newRecord(file, bytes, context) {
|
|
62
|
+
return {
|
|
63
|
+
id: context.id,
|
|
64
|
+
repository: context.repository,
|
|
65
|
+
itemId: context.itemId,
|
|
66
|
+
runId: null,
|
|
67
|
+
fileName: file.fileName,
|
|
68
|
+
size: bytes.length,
|
|
69
|
+
mediaType: file.mediaType,
|
|
70
|
+
uri: context.uri,
|
|
71
|
+
createdAt: context.now,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export function newAttachmentId() {
|
|
75
|
+
return randomUUID();
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=ingest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ingest.js","sourceRoot":"","sources":["../../../../src/feature/attachments/services/ingest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,GAErB,MAAM,mBAAmB,CAAC;AAU3B;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,OAA2B,EAC3B,SAAmB;IAEnB,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,QAAQ,GAAyB,EAAE,CAAC;IAC1C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7B,MAAM,QAAQ,CAAC,uCAAuC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC;QACzE,CAAC;QACD,IAAI,IAAY,CAAC;QACjB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,C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O,QAAQ,CAAC;AAClB,CAAC;AAED,0FAA0F;AAC1F,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAwB;IACzD,IAAI,KAAa,CAAC;IAClB,IAAI,CAAC;QACH,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,QAAQ,CAAC,sCAAsC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,oBAAoB,EAAE,CAAC;QACxC,MAAM,QAAQ,CAAC,gBAAgB,IAAI,CAAC,QAAQ,6BAA6B,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,SAAS,CACvB,IAAwB,EACxB,KAAa,EACb,OAAqF;IAErF,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,IAAI,EAAE,KAAK,CAAC,MAAM;QAClB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,SAAS,EAAE,OAAO,CAAC,GAAG;KACvB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,UAAU,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** The most attachments a task may have. */
|
|
2
|
+
export const ATTACHMENTS_PER_TASK = 10;
|
|
3
|
+
/** The largest attachment: 20 MiB. */
|
|
4
|
+
export const ATTACHMENT_MAX_BYTES = 20 * 1024 * 1024;
|
|
5
|
+
const MEDIA_TYPES = {
|
|
6
|
+
png: 'image/png',
|
|
7
|
+
jpg: 'image/jpeg',
|
|
8
|
+
jpeg: 'image/jpeg',
|
|
9
|
+
gif: 'image/gif',
|
|
10
|
+
webp: 'image/webp',
|
|
11
|
+
svg: 'image/svg+xml',
|
|
12
|
+
pdf: 'application/pdf',
|
|
13
|
+
md: 'text/markdown',
|
|
14
|
+
txt: 'text/plain',
|
|
15
|
+
log: 'text/plain',
|
|
16
|
+
json: 'application/json',
|
|
17
|
+
csv: 'text/csv',
|
|
18
|
+
html: 'text/html',
|
|
19
|
+
zip: 'application/zip',
|
|
20
|
+
};
|
|
21
|
+
/** Why a name cannot be the name of an attachment; null when it can. */
|
|
22
|
+
export function attachmentNameProblem(name) {
|
|
23
|
+
if (name === '' || name === '.' || name === '..')
|
|
24
|
+
return `invalid attachment name \`${name}\``;
|
|
25
|
+
// eslint-disable-next-line no-control-regex
|
|
26
|
+
if (/[/\\\u0000-\u001f\u007f]/.test(name))
|
|
27
|
+
return `invalid attachment name \`${name}\``;
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
/** The content type by the extension of the file name; unknown ones are `application/octet-stream`. */
|
|
31
|
+
export function attachmentMediaType(fileName) {
|
|
32
|
+
const dot = fileName.lastIndexOf('.');
|
|
33
|
+
if (dot < 0)
|
|
34
|
+
return 'application/octet-stream';
|
|
35
|
+
return MEDIA_TYPES[fileName.slice(dot + 1).toLowerCase()] ?? 'application/octet-stream';
|
|
36
|
+
}
|
|
37
|
+
/** `512 B`, `2.0 KB`, `1.5 MB`. */
|
|
38
|
+
export function formatAttachmentSize(bytes) {
|
|
39
|
+
if (bytes < 1024)
|
|
40
|
+
return `${bytes} B`;
|
|
41
|
+
if (bytes < 1024 * 1024)
|
|
42
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
43
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=attachments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachments.js","sourceRoot":"","sources":["../../../../src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