@vellumai/assistant 0.10.7-dev.202607091111.4355283 → 0.10.7-dev.202607091507.bac9bfe
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/ARCHITECTURE.md +3 -3
- package/docs/credential-execution-service.md +9 -96
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/package.json +1 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/attachment-naming.test.ts +104 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/attachment-naming.ts +118 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/package.json +1 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/attachment-naming.test.ts +104 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/attachment-naming.ts +118 -0
- package/node_modules/@vellumai/service-contracts/package.json +1 -0
- package/node_modules/@vellumai/service-contracts/src/__tests__/attachment-naming.test.ts +104 -0
- package/node_modules/@vellumai/service-contracts/src/attachment-naming.ts +118 -0
- package/openapi.yaml +8 -8
- package/package.json +1 -1
- package/scripts/build-test-fixtures.ts +105 -0
- package/scripts/test.ts +31 -0
- package/src/__tests__/agent-loop-override-profile.test.ts +64 -1
- package/src/__tests__/agent-wake-override-profile.test.ts +20 -1
- package/src/__tests__/assistant-attachment-directive.test.ts +1 -0
- package/src/__tests__/assistant-attachments.test.ts +74 -0
- package/src/__tests__/assistant-feature-flag-guard.test.ts +3 -3
- package/src/__tests__/assistant-feature-flag-guardrails.test.ts +1 -1
- package/src/__tests__/call-site-routing-provider.test.ts +1 -0
- package/src/__tests__/channel-guardian.test.ts +29 -9
- package/src/__tests__/compaction-events.test.ts +9 -3
- package/src/__tests__/conversation-agent-loop-inference-profile.test.ts +5 -0
- package/src/__tests__/conversation-agent-loop-overflow.test.ts +18 -1
- package/src/__tests__/conversation-agent-loop.test.ts +23 -1
- package/src/__tests__/conversation-message-id-uuidv7.test.ts +80 -0
- package/src/__tests__/conversation-process-callsite.test.ts +10 -1
- package/src/__tests__/conversation-routes-slash-commands.test.ts +23 -5
- package/src/__tests__/conversation-speed-override.test.ts +13 -2
- package/src/__tests__/conversation-usage.test.ts +10 -1
- package/src/__tests__/credential-security-invariants.test.ts +0 -3
- package/src/__tests__/gateway-flag-listener.test.ts +2 -23
- package/src/__tests__/host-bash-proxy.test.ts +3 -3
- package/src/__tests__/host-shell-tool.test.ts +5 -62
- package/src/__tests__/invite-routes-http.test.ts +10 -1
- package/src/__tests__/llm-context-resolution.test.ts +10 -1
- package/src/__tests__/llm-resolver-override-or-default.test.ts +395 -0
- package/src/__tests__/llm-resolver.test.ts +10 -1
- package/src/__tests__/mtime-cache.test.ts +23 -11
- package/src/__tests__/oauth-cli.test.ts +0 -1
- package/src/__tests__/persist-user-message-set-processing-failure.test.ts +41 -0
- package/src/__tests__/plugin-effective-enabled-set.test.ts +18 -25
- package/src/__tests__/provider-commit-message-generator.test.ts +10 -1
- package/src/__tests__/provider-platform-proxy-integration.test.ts +10 -1
- package/src/__tests__/provider-registry-ollama.test.ts +10 -1
- package/src/__tests__/provider-send-message-override-profile.test.ts +12 -1
- package/src/__tests__/provider-usage-tracking.test.ts +10 -1
- package/src/__tests__/registry.test.ts +21 -12
- package/src/__tests__/require-fresh-approval.test.ts +4 -164
- package/src/__tests__/retry-openrouter-only-normalization.test.ts +10 -1
- package/src/__tests__/retry-thinking-adaptive-only.test.ts +10 -1
- package/src/__tests__/retry-thinking-tool-choice.test.ts +10 -1
- package/src/__tests__/retry-verbosity-normalization.test.ts +10 -1
- package/src/__tests__/subagent-call-site-routing.test.ts +23 -6
- package/src/__tests__/test-preload.ts +11 -9
- package/src/__tests__/tools-get-route.test.ts +5 -3
- package/src/__tests__/usage-attribution.test.ts +89 -1
- package/src/__tests__/workspace-fixtures.ts +45 -0
- package/src/__tests__/workspace-tool-loader.test.ts +5 -1
- package/src/calls/voice-session-bridge.ts +3 -1
- package/src/cli/commands/credentials.ts +0 -19
- package/src/cli/commands/keys.ts +0 -30
- package/src/cli/commands/oauth/token.ts +1 -26
- package/src/cli/commands/plugins.ts +1 -1
- package/src/cli/lib/__tests__/uninstall-plugin.test.ts +82 -21
- package/src/cli/lib/uninstall-plugin.ts +29 -2
- package/src/cli/program.ts +0 -2
- package/src/config/__tests__/default-profile-catalog.test.ts +10 -0
- package/src/config/__tests__/profile-materialization.test.ts +5 -0
- package/src/config/assistant-feature-flags.ts +1 -1
- package/src/config/bundled-skills/_shared/CLI_RETRIEVAL_PATTERN.md +9 -8
- package/src/config/feature-flag-registry.json +8 -32
- package/src/config/llm-resolver.ts +315 -1
- package/src/daemon/assistant-attachments.ts +29 -63
- package/src/daemon/conversation-agent-loop.ts +29 -3
- package/src/daemon/conversation-messaging.ts +15 -5
- package/src/daemon/conversation-surfaces.ts +3 -3
- package/src/daemon/lifecycle.ts +9 -15
- package/src/daemon/message-types/host-bash.ts +1 -1
- package/src/daemon/process-message.ts +4 -2
- package/src/home/__tests__/suggested-prompts.test.ts +4 -5
- package/src/home/suggested-prompts-cache.ts +91 -0
- package/src/home/suggested-prompts.ts +4 -77
- package/src/hooks/__tests__/hook-live-reload.test.ts +19 -25
- package/src/hooks/hook-loader.ts +72 -69
- package/src/ipc/gateway-flag-listener.ts +14 -25
- package/src/monitoring/process-memory.ts +6 -1
- package/src/oauth/connect-orchestrator.ts +1 -1
- package/src/oauth/oauth-store.ts +4 -11
- package/src/permissions/approval-policy.ts +8 -1
- package/src/permissions/confirmation-canonical-request.ts +118 -0
- package/src/permissions/prompter.ts +15 -2
- package/src/persistence/conversation-crud.ts +12 -8
- package/src/persistence/db-init.ts +30 -62
- package/src/plugin-api/types.ts +11 -2
- package/src/plugins/mtime-cache.ts +37 -29
- package/src/plugins/surface-import.ts +52 -14
- package/src/providers/__tests__/dispatch-connection-routing.test.ts +12 -1
- package/src/providers/__tests__/retry-callsite.test.ts +13 -2
- package/src/providers/__tests__/satellite-connection-routing.test.ts +12 -1
- package/src/runtime/agent-wake.ts +16 -6
- package/src/runtime/assistant-event-hub.ts +0 -105
- package/src/runtime/capabilities.ts +2 -2
- package/src/runtime/effective-capabilities.test.ts +0 -36
- package/src/runtime/effective-capabilities.ts +8 -23
- package/src/runtime/routes/__tests__/plugins-routes.test.ts +33 -34
- package/src/runtime/routes/acp-routes.ts +20 -14
- package/src/runtime/routes/conversation-routes.ts +7 -6
- package/src/runtime/routes/plugins-routes.ts +3 -3
- package/src/runtime/routes/settings-routes.ts +8 -7
- package/src/runtime/services/analyze-conversation.ts +3 -1
- package/src/security/secure-keys.ts +133 -4
- package/src/signals/user-message.ts +3 -1
- package/src/tools/AGENTS.md +0 -26
- package/src/tools/executor.ts +0 -28
- package/src/tools/host-terminal/host-shell.ts +6 -49
- package/src/tools/registry.ts +67 -76
- package/src/tools/side-effects.ts +0 -1
- package/src/tools/subagent/spawn.ts +15 -11
- package/src/tools/terminal/shell.test.ts +0 -6
- package/src/tools/terminal/shell.ts +0 -49
- package/src/tools/tool-manifest.ts +0 -43
- package/src/tools/tool-types.ts +3 -3
- package/src/tools/types.ts +15 -9
- package/src/usage/attribution.ts +42 -9
- package/src/util/process-tree.ts +25 -13
- package/src/workflows/capabilities.test.ts +0 -26
- package/src/workflows/capabilities.ts +7 -22
- package/src/__tests__/credential-execution-admin-cli.test.ts +0 -504
- package/src/__tests__/credential-execution-feature-gates.test.ts +0 -185
- package/src/__tests__/credential-execution-shell-lockdown.test.ts +0 -120
- package/src/__tests__/credential-execution-tools.test.ts +0 -289
- package/src/__tests__/db-template-cache.ts +0 -48
- package/src/__tests__/db-template-helpers.ts +0 -264
- package/src/cli/commands/credential-execution.ts +0 -362
- package/src/credential-execution/feature-gates.ts +0 -61
- package/src/tools/credential-execution/make-authenticated-request.ts +0 -198
- package/src/tools/credential-execution/manage-secure-command-tool.ts +0 -371
- package/src/tools/credential-execution/run-authenticated-command.ts +0 -261
- package/src/tools/flag-gated-tools.test.ts +0 -76
package/ARCHITECTURE.md
CHANGED
|
@@ -593,7 +593,7 @@ All guardian decisions for voice access requests flow through:
|
|
|
593
593
|
| `src/runtime/access-request-helper.ts` | Creates canonical access request and notifies guardian |
|
|
594
594
|
| `src/approvals/guardian-decision-primitive.ts` | `applyCanonicalGuardianDecision` — unified decision primitive |
|
|
595
595
|
| `src/approvals/guardian-request-resolvers.ts` | `access_request` resolver — voice direct activation, text-channel verification session |
|
|
596
|
-
| `src/runtime/trust-verdict-consumer.ts` | Gateway verdict → caller trust classification (`actorTrustContextFromVerdict`)
|
|
596
|
+
| `src/runtime/trust-verdict-consumer.ts` | Gateway verdict → caller trust classification (`actorTrustContextFromVerdict`) |
|
|
597
597
|
| `src/contacts/canonical-guardian-store.ts` | Canonical request persistence and CAS resolution |
|
|
598
598
|
|
|
599
599
|
### Speech-to-Text (STT) Boundaries
|
|
@@ -786,7 +786,7 @@ Conversation starters follow the same pattern via `GET /v1/conversation-starters
|
|
|
786
786
|
|
|
787
787
|
The assistant feature-flag resolver (`src/config/assistant-feature-flags.ts`) is the canonical module for determining whether an assistant feature flag is enabled. It loads default values from the unified registry at `meta/feature-flags/feature-flag-registry.json` (bundled copy at `src/config/feature-flag-registry.json`) and resolves the effective state for each declared assistant-scope flag. Assistant feature flags are declaration-driven assistant-scoped booleans that can gate any assistant behavior; skill availability is one consumer.
|
|
788
788
|
|
|
789
|
-
**Canonical key format:** Simple kebab-case (e.g., `contacts`, `
|
|
789
|
+
**Canonical key format:** Simple kebab-case (e.g., `contacts`, `voice-mode`).
|
|
790
790
|
|
|
791
791
|
**Resolution priority** (highest wins):
|
|
792
792
|
|
|
@@ -814,7 +814,7 @@ The assistant feature-flag resolver (`src/config/assistant-feature-flags.ts`) is
|
|
|
814
814
|
|
|
815
815
|
All six enforcement points derive the flag key via `skillFlagKey(skill)` — which returns `undefined` for ungated skills, short-circuiting the check — and then call `isAssistantFeatureFlagEnabled(flagKey, config)` for consistency.
|
|
816
816
|
|
|
817
|
-
**Migration path:** The legacy `skills.<id>.enabled` and `feature_flags.<id>.enabled` key formats are no longer supported. All code must use simple kebab-case keys (e.g., `contacts`, `
|
|
817
|
+
**Migration path:** The legacy `skills.<id>.enabled` and `feature_flags.<id>.enabled` key formats are no longer supported. All code must use simple kebab-case keys (e.g., `contacts`, `voice-mode`). Guard tests enforce canonical key usage and declaration coverage for literal key references in the unified registry.
|
|
818
818
|
|
|
819
819
|
**Key source files:**
|
|
820
820
|
|
|
@@ -34,23 +34,15 @@ For local single-user and development deployments, the assistant spawns CES as a
|
|
|
34
34
|
|
|
35
35
|
For managed multi-tenant deployments, CES runs as a sidecar container in the same pod. Communication occurs over a **bootstrap Unix socket** mounted at a well-known path in a shared `emptyDir` volume. The sidecar starts independently and the assistant connects to the socket on startup.
|
|
36
36
|
|
|
37
|
-
## CES
|
|
37
|
+
## CES RPC Operations
|
|
38
38
|
|
|
39
|
-
CES
|
|
39
|
+
CES implements three credential-execution RPC operations. Credential values are materialized only inside the CES process (`credential-executor/` package); a caller sends credential handles and receives sanitized results, never plaintext secret material.
|
|
40
40
|
|
|
41
|
-
|
|
|
42
|
-
| ---------------------------- |
|
|
43
|
-
| `run_authenticated_command` | Execute a shell command with credential environment variables injected by CES. The credential values are set in the CES process environment only — never transmitted to the
|
|
44
|
-
| `make_authenticated_request` | Execute an HTTP request with credential-bearing headers/auth injected by CES. CES performs the HTTP call and returns the response body and status to the
|
|
45
|
-
| `manage_secure_command_tool` | Register and manage secure command tool bundles in the CES toolstore. Handles bundle lifecycle (registration, unregistration) for manifest-driven credential-bearing commands.
|
|
46
|
-
|
|
47
|
-
### Tool registration
|
|
48
|
-
|
|
49
|
-
CES tools use the standard `class ... implements Tool` registration pattern. These are justified exceptions to the general preference for skills because:
|
|
50
|
-
|
|
51
|
-
- The security boundary requires that credential materialization happens in a separate process
|
|
52
|
-
- Skill scripts run inside the assistant process and cannot enforce the hard isolation invariant
|
|
53
|
-
- The tools are thin RPC stubs; the actual logic lives in the `credential-executor/` package
|
|
41
|
+
| Operation | Purpose |
|
|
42
|
+
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
43
|
+
| `run_authenticated_command` | Execute a shell command with credential environment variables injected by CES. The credential values are set in the CES process environment only — never transmitted to the caller. |
|
|
44
|
+
| `make_authenticated_request` | Execute an HTTP request with credential-bearing headers/auth injected by CES. CES performs the HTTP call and returns the response body and status to the caller. |
|
|
45
|
+
| `manage_secure_command_tool` | Register and manage secure command tool bundles in the CES toolstore. Handles bundle lifecycle (registration, unregistration) for manifest-driven credential-bearing commands. |
|
|
54
46
|
|
|
55
47
|
## Locked Decisions
|
|
56
48
|
|
|
@@ -225,47 +217,13 @@ These invariants are enforced by guard tests and code review:
|
|
|
225
217
|
|
|
226
218
|
1. **No cross-package source imports**: `assistant/` must not import from `credential-executor/` and vice versa. Communication is RPC only. Shared types flow through `packages/` only.
|
|
227
219
|
2. **No credential values in assistant process memory**: The assistant sends credential handles (not values) to CES. CES materializes and uses them internally.
|
|
228
|
-
3. **CES
|
|
220
|
+
3. **Credential-bearing execution goes through CES RPC**: operations that must materialize a credential run inside the CES process across the hard process boundary. All other credential use continues through the existing broker for local deployments.
|
|
229
221
|
4. **Grants and audit logs are CES-internal**: The assistant cannot read CES grant tables or audit logs directly. CES exposes grant status and audit summaries via RPC responses.
|
|
230
222
|
5. **No generic authenticated HTTP clients in secure commands**: `curl`, `wget`, `httpie`, interpreters, and shell trampolines are structurally denied as secure command entrypoints. This is checked at manifest validation and re-checked at execution time.
|
|
231
223
|
6. **Managed CES container runs as non-root**: The CES Docker image runs as `uid 1001` (user `ces`). The CES data volume is owned by this user.
|
|
232
224
|
7. **Single active bootstrap connection**: In managed mode, CES accepts one connection on the bootstrap socket and unlinks the socket path while that connection is live, so no second process can connect concurrently. CES is a long-lived sidecar: when the active session ends (the assistant disconnects or its container restarts), CES re-binds the socket and awaits the assistant's reconnection rather than shutting down. At most one connection is ever active; the sidecar only exits on SIGTERM/SIGINT.
|
|
233
225
|
|
|
234
|
-
##
|
|
235
|
-
|
|
236
|
-
CES is rolled out incrementally via feature flags, all defaulting to `false` (off). The flags are ordered to allow progressive enablement without user-facing disruption.
|
|
237
|
-
|
|
238
|
-
### Feature flag order
|
|
239
|
-
|
|
240
|
-
Enable flags in this order. Each flag is safe to enable independently, but later flags depend on earlier ones being on for meaningful behavior.
|
|
241
|
-
|
|
242
|
-
| Order | Flag | Gate | Safe to enable alone? |
|
|
243
|
-
| ----- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
244
|
-
| 1 | `ces-tools` | Register CES tools (`run_authenticated_command`, `make_authenticated_request`, `manage_secure_command_tool`) in the agent loop | Yes — tools register but are not invoked unless the agent discovers credentials that require CES |
|
|
245
|
-
| 2 | `ces-shell-lockdown` | Enforce shell lockdown for untrusted agents with CES-active credentials; direct shell access to credentialed services is denied | Yes — only activates when CES credentials are present |
|
|
246
|
-
| 3 | `ces-secure-install` | Route tool/command installation through CES secure bundle pipeline instead of direct shell | Yes — falls back to standard install if CES is unavailable |
|
|
247
|
-
| 4 | `ces-grant-audit` | Gate CLI execution of grant listing, grant revocation, and audit inspection commands (commands are always registered but check the flag at runtime) | Yes — read-only inspection surfaces |
|
|
248
|
-
| 5 | `ces-managed-sidecar` | Use managed sidecar transport (Unix socket) instead of local child-process transport | **No** — requires the CES sidecar container to be present in the pod template. Only enable after the sidecar image is deployed. |
|
|
249
|
-
|
|
250
|
-
### Dark-launching the managed sidecar
|
|
251
|
-
|
|
252
|
-
To dark-launch CES in managed deployments without user impact:
|
|
253
|
-
|
|
254
|
-
1. **Deploy the CES container image** via the `credential_executor_image` field in `POST /v1/internal/assistant-image-releases/`. The warm-pool manager picks it up and includes it in pod templates. The CES container starts, binds its bootstrap socket and health port (8090), but does nothing until an assistant connects.
|
|
255
|
-
|
|
256
|
-
2. **Verify sidecar health** using kubelet probes: `/healthz` (liveness, returns `{"status": "ok"}`) and `/readyz` (readiness, always returns 200; includes `rpcConnected` field for observability).
|
|
257
|
-
|
|
258
|
-
3. **Enable `ces-tools`** first on a test cohort. The assistant spawns a local CES child process and registers tools. Verify tool registration, grant creation, and audit logging work end-to-end without affecting existing workflows.
|
|
259
|
-
|
|
260
|
-
4. **Enable `ces-managed-sidecar`** on the same cohort. The assistant switches from child-process transport to the bootstrap Unix socket. CES `/readyz` always returns 200 with `{"status": "ok", "rpcConnected": <boolean>}`; check the `rpcConnected` field to verify the assistant has connected.
|
|
261
|
-
|
|
262
|
-
5. **Progressive rollout**: Widen the cohort by enabling flags on more assistants. Monitor for grant failures, materializer errors, and egress proxy issues.
|
|
263
|
-
|
|
264
|
-
### Local deployment rollout
|
|
265
|
-
|
|
266
|
-
Local deployments do not require image changes. Enabling `ces-tools` causes the assistant to spawn CES as a child process automatically. The remaining flags can be enabled in any order.
|
|
267
|
-
|
|
268
|
-
### Guarantees by deployment mode
|
|
226
|
+
## Guarantees by deployment mode
|
|
269
227
|
|
|
270
228
|
| Guarantee | Local | Managed |
|
|
271
229
|
| ------------------------------------------ | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
@@ -276,51 +234,6 @@ Local deployments do not require image changes. Enabling `ces-tools` causes the
|
|
|
276
234
|
| Secret scrubbing in HTTP responses | Defense-in-depth only | Defense-in-depth only |
|
|
277
235
|
| `host_bash` restriction | Policy-only (trust rules can deny, but the tool exists) | Policy-only (same; managed deployments should deny `host_bash` for untrusted agents) |
|
|
278
236
|
|
|
279
|
-
## Rollback
|
|
280
|
-
|
|
281
|
-
### Disabling CES entirely
|
|
282
|
-
|
|
283
|
-
Turn off all CES feature flags. The assistant stops registering CES tools and reverts to the pre-CES credential broker for all credential operations. No data migration is needed — CES grant and audit state is CES-private and does not affect the assistant's own tables.
|
|
284
|
-
|
|
285
|
-
Flag disable order:
|
|
286
|
-
|
|
287
|
-
> **Important — managed deployments**: In managed containers, the assistant image does not ship the `credential-executor` binary, so local CES transport is unavailable. Disabling `ces-managed-sidecar` while `ces-tools` is still enabled will break credentialed tool execution because the assistant cannot fall back to local discovery. Always disable `ces-tools` before `ces-managed-sidecar` in managed deployments.
|
|
288
|
-
|
|
289
|
-
**Local deployments** (reverse of enable order):
|
|
290
|
-
|
|
291
|
-
1. `ces-managed-sidecar` — assistant reverts to local child-process transport
|
|
292
|
-
2. `ces-grant-audit` — inspection surfaces disappear
|
|
293
|
-
3. `ces-secure-install` — tool installation reverts to direct shell
|
|
294
|
-
4. `ces-shell-lockdown` — shell lockdown is lifted
|
|
295
|
-
5. `ces-tools` — CES tools are unregistered from the agent loop
|
|
296
|
-
|
|
297
|
-
**Managed deployments** (`ces-tools` must be disabled before the sidecar):
|
|
298
|
-
|
|
299
|
-
1. `ces-grant-audit` — inspection surfaces disappear
|
|
300
|
-
2. `ces-secure-install` — tool installation reverts to direct shell
|
|
301
|
-
3. `ces-shell-lockdown` — shell lockdown is lifted
|
|
302
|
-
4. `ces-tools` — CES tools are unregistered; assistant reverts to the pre-CES credential broker
|
|
303
|
-
5. `ces-managed-sidecar` — sidecar transport is deactivated (safe now that no CES tools are registered)
|
|
304
|
-
|
|
305
|
-
### Removing the managed sidecar
|
|
306
|
-
|
|
307
|
-
If the CES sidecar container causes pod scheduling issues or resource pressure:
|
|
308
|
-
|
|
309
|
-
1. Disable `ces-tools` on all assistants first (prevents the assistant from attempting CES calls).
|
|
310
|
-
2. Disable `ces-managed-sidecar` on all assistants.
|
|
311
|
-
3. Remove the CES container and its volume mounts from the pod template in vembda.
|
|
312
|
-
4. CES grant/audit data on the `/ces-data` volume is orphaned and can be cleaned up at convenience.
|
|
313
|
-
|
|
314
|
-
The assistant reverts to the pre-CES credential broker once `ces-tools` is disabled.
|
|
315
|
-
|
|
316
|
-
### Partial rollback
|
|
317
|
-
|
|
318
|
-
Individual flags can be disabled independently:
|
|
319
|
-
|
|
320
|
-
- Disabling `ces-shell-lockdown` alone re-allows direct shell access to credentialed services while keeping CES tools available.
|
|
321
|
-
- Disabling `ces-grant-audit` alone removes inspection surfaces without affecting CES execution.
|
|
322
|
-
- Disabling `ces-secure-install` alone reverts tool installation to direct shell without affecting CES command execution.
|
|
323
|
-
|
|
324
237
|
## Residual Risks
|
|
325
238
|
|
|
326
239
|
Risks that are acknowledged and accepted for v1, documented here so they are explicit rather than implied.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
inferMimeType,
|
|
5
|
+
resolveAttachmentFilename,
|
|
6
|
+
} from "../attachment-naming.js";
|
|
7
|
+
|
|
8
|
+
describe("inferMimeType", () => {
|
|
9
|
+
test("maps known extensions case-insensitively", () => {
|
|
10
|
+
expect(inferMimeType("shot.PNG")).toBe("image/png");
|
|
11
|
+
expect(inferMimeType("report.pdf")).toBe("application/pdf");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("falls back to octet-stream for unknown or missing extensions", () => {
|
|
15
|
+
expect(inferMimeType("desktop")).toBe("application/octet-stream");
|
|
16
|
+
expect(inferMimeType("archive.xyz")).toBe("application/octet-stream");
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe("resolveAttachmentFilename", () => {
|
|
21
|
+
test("uses explicit filenames verbatim", () => {
|
|
22
|
+
expect(
|
|
23
|
+
resolveAttachmentFilename("custom.dat", "/tmp/shot.png", "explicit"),
|
|
24
|
+
).toBe("custom.dat");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("honors labels with recognized extensions", () => {
|
|
28
|
+
expect(
|
|
29
|
+
resolveAttachmentFilename("nice-name.png", "/tmp/shot.png", "label"),
|
|
30
|
+
).toBe("nice-name.png");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("keeps bare labels and appends the POSIX path extension", () => {
|
|
34
|
+
expect(resolveAttachmentFilename("desktop", "/tmp/shot.png", "label")).toBe(
|
|
35
|
+
"desktop.png",
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("keeps bare labels and appends the Windows path extension", () => {
|
|
40
|
+
expect(
|
|
41
|
+
resolveAttachmentFilename(
|
|
42
|
+
"desktop",
|
|
43
|
+
"C:\\Users\\user1\\Pictures\\shot.png",
|
|
44
|
+
"label",
|
|
45
|
+
),
|
|
46
|
+
).toBe("desktop.png");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("bare labels to files sharing a basename resolve to unique names", () => {
|
|
50
|
+
expect(
|
|
51
|
+
resolveAttachmentFilename("first", "/workspace/a/result.png", "label"),
|
|
52
|
+
).toBe("first.png");
|
|
53
|
+
expect(
|
|
54
|
+
resolveAttachmentFilename("second", "/workspace/b/result.png", "label"),
|
|
55
|
+
).toBe("second.png");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("does not duplicate an unknown extension the label already has", () => {
|
|
59
|
+
expect(
|
|
60
|
+
resolveAttachmentFilename(
|
|
61
|
+
"report.xlsx",
|
|
62
|
+
"/workspace/report.xlsx",
|
|
63
|
+
"label",
|
|
64
|
+
),
|
|
65
|
+
).toBe("report.xlsx");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("matches the existing extension case-insensitively", () => {
|
|
69
|
+
expect(
|
|
70
|
+
resolveAttachmentFilename("data.YAML", "/workspace/data.yaml", "label"),
|
|
71
|
+
).toBe("data.YAML");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test("still appends when the label ends differently", () => {
|
|
75
|
+
expect(
|
|
76
|
+
resolveAttachmentFilename(
|
|
77
|
+
"summary.v2",
|
|
78
|
+
"/workspace/data.parquet",
|
|
79
|
+
"label",
|
|
80
|
+
),
|
|
81
|
+
).toBe("summary.v2.parquet");
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test("falls back to the basename when the path has no extension", () => {
|
|
85
|
+
expect(resolveAttachmentFilename("label", "/tmp/rawfile", "label")).toBe(
|
|
86
|
+
"rawfile",
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("uses the basename when no preferred name is given", () => {
|
|
91
|
+
expect(
|
|
92
|
+
resolveAttachmentFilename(undefined, "C:\\temp\\report.pdf", "label"),
|
|
93
|
+
).toBe("report.pdf");
|
|
94
|
+
expect(resolveAttachmentFilename(undefined, "/tmp/report.pdf")).toBe(
|
|
95
|
+
"report.pdf",
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("ignores trailing separators", () => {
|
|
100
|
+
expect(resolveAttachmentFilename(undefined, "/tmp/dir/", "label")).toBe(
|
|
101
|
+
"dir",
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attachment filename contract shared by the daemon (which materializes
|
|
3
|
+
* `vellum://` links and `<vellum-attachment>` directives into stored
|
|
4
|
+
* attachments) and the web client (which resolves clicked links back to
|
|
5
|
+
* those attachments). Both sides must agree on the stored filename, so the
|
|
6
|
+
* naming rule lives here once.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const EXTENSION_MIME_MAP: Record<string, string> = {
|
|
10
|
+
// Images
|
|
11
|
+
png: "image/png",
|
|
12
|
+
jpg: "image/jpeg",
|
|
13
|
+
jpeg: "image/jpeg",
|
|
14
|
+
gif: "image/gif",
|
|
15
|
+
webp: "image/webp",
|
|
16
|
+
svg: "image/svg+xml",
|
|
17
|
+
ico: "image/x-icon",
|
|
18
|
+
bmp: "image/bmp",
|
|
19
|
+
heic: "image/heic",
|
|
20
|
+
heif: "image/heif",
|
|
21
|
+
|
|
22
|
+
// Documents
|
|
23
|
+
pdf: "application/pdf",
|
|
24
|
+
json: "application/json",
|
|
25
|
+
xml: "application/xml",
|
|
26
|
+
csv: "text/csv",
|
|
27
|
+
txt: "text/plain",
|
|
28
|
+
md: "text/markdown",
|
|
29
|
+
html: "text/html",
|
|
30
|
+
css: "text/css",
|
|
31
|
+
js: "text/javascript",
|
|
32
|
+
ts: "text/typescript",
|
|
33
|
+
|
|
34
|
+
// Audio
|
|
35
|
+
mp3: "audio/mpeg",
|
|
36
|
+
wav: "audio/wav",
|
|
37
|
+
ogg: "audio/ogg",
|
|
38
|
+
flac: "audio/flac",
|
|
39
|
+
aac: "audio/aac",
|
|
40
|
+
m4a: "audio/x-m4a",
|
|
41
|
+
opus: "audio/opus",
|
|
42
|
+
|
|
43
|
+
// Video
|
|
44
|
+
mp4: "video/mp4",
|
|
45
|
+
webm: "video/webm",
|
|
46
|
+
mov: "video/quicktime",
|
|
47
|
+
mpeg: "video/mpeg",
|
|
48
|
+
|
|
49
|
+
// Archives
|
|
50
|
+
zip: "application/zip",
|
|
51
|
+
gz: "application/gzip",
|
|
52
|
+
tar: "application/x-tar",
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Infer a MIME type from a filename extension.
|
|
57
|
+
* Returns `application/octet-stream` when the extension is unrecognised.
|
|
58
|
+
*/
|
|
59
|
+
export function inferMimeType(filename: string): string {
|
|
60
|
+
const dot = filename.lastIndexOf(".");
|
|
61
|
+
if (dot === -1) {
|
|
62
|
+
return "application/octet-stream";
|
|
63
|
+
}
|
|
64
|
+
const ext = filename.slice(dot + 1).toLowerCase();
|
|
65
|
+
return EXTENSION_MIME_MAP[ext] ?? "application/octet-stream";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Pick the stored attachment filename for a materialized file directive.
|
|
70
|
+
*
|
|
71
|
+
* Explicit filenames (`<vellum-attachment filename="..." />` attributes)
|
|
72
|
+
* are an authoring contract and always used verbatim. Link display text
|
|
73
|
+
* (`[label](vellum://...)`) is cosmetic: it is only honored as the filename
|
|
74
|
+
* when it carries a recognized extension. A bare label
|
|
75
|
+
* (e.g. `[desktop](vellum://.../shot.png)`) would otherwise produce an
|
|
76
|
+
* extensionless download with an `application/octet-stream` MIME type,
|
|
77
|
+
* which macOS opens as raw text. In that case the label keeps the path's
|
|
78
|
+
* extension (`desktop.png`), staying unique per link even when several
|
|
79
|
+
* links share a basename; the raw basename is the last resort.
|
|
80
|
+
*
|
|
81
|
+
* The basename fallback splits on both `/` and `\\` so it handles POSIX
|
|
82
|
+
* sandbox paths, `vellum://` URL paths, and Windows host paths alike.
|
|
83
|
+
* Splitting on both separators regardless of the runtime platform also
|
|
84
|
+
* covers Windows host paths resolved by a non-Windows daemon, which
|
|
85
|
+
* platform-selected `node:path` semantics cannot.
|
|
86
|
+
*/
|
|
87
|
+
export function resolveAttachmentFilename(
|
|
88
|
+
preferred: string | undefined,
|
|
89
|
+
resolvedPath: string,
|
|
90
|
+
filenameSource: "explicit" | "label" = "explicit",
|
|
91
|
+
): string {
|
|
92
|
+
const fallback =
|
|
93
|
+
resolvedPath.split(/[\\/]/).filter(Boolean).pop() ?? resolvedPath;
|
|
94
|
+
if (!preferred) {
|
|
95
|
+
return fallback;
|
|
96
|
+
}
|
|
97
|
+
if (filenameSource === "explicit") {
|
|
98
|
+
return preferred;
|
|
99
|
+
}
|
|
100
|
+
if (inferMimeType(preferred) !== "application/octet-stream") {
|
|
101
|
+
return preferred;
|
|
102
|
+
}
|
|
103
|
+
// Bare label: keep the label as a per-link disambiguator (two links to
|
|
104
|
+
// different files sharing a basename must not collide, because the
|
|
105
|
+
// transcript resolves clicks by filename) and append the path's
|
|
106
|
+
// extension so the stored name carries the correct type. Skip the
|
|
107
|
+
// append when the label already ends with that extension (a label like
|
|
108
|
+
// `report.xlsx` for `report.xlsx` must not become `report.xlsx.xlsx`).
|
|
109
|
+
const dot = fallback.lastIndexOf(".");
|
|
110
|
+
if (dot > 0 && dot < fallback.length - 1) {
|
|
111
|
+
const ext = fallback.slice(dot + 1);
|
|
112
|
+
if (preferred.toLowerCase().endsWith(`.${ext.toLowerCase()}`)) {
|
|
113
|
+
return preferred;
|
|
114
|
+
}
|
|
115
|
+
return `${preferred}.${ext}`;
|
|
116
|
+
}
|
|
117
|
+
return fallback;
|
|
118
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
inferMimeType,
|
|
5
|
+
resolveAttachmentFilename,
|
|
6
|
+
} from "../attachment-naming.js";
|
|
7
|
+
|
|
8
|
+
describe("inferMimeType", () => {
|
|
9
|
+
test("maps known extensions case-insensitively", () => {
|
|
10
|
+
expect(inferMimeType("shot.PNG")).toBe("image/png");
|
|
11
|
+
expect(inferMimeType("report.pdf")).toBe("application/pdf");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("falls back to octet-stream for unknown or missing extensions", () => {
|
|
15
|
+
expect(inferMimeType("desktop")).toBe("application/octet-stream");
|
|
16
|
+
expect(inferMimeType("archive.xyz")).toBe("application/octet-stream");
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe("resolveAttachmentFilename", () => {
|
|
21
|
+
test("uses explicit filenames verbatim", () => {
|
|
22
|
+
expect(
|
|
23
|
+
resolveAttachmentFilename("custom.dat", "/tmp/shot.png", "explicit"),
|
|
24
|
+
).toBe("custom.dat");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("honors labels with recognized extensions", () => {
|
|
28
|
+
expect(
|
|
29
|
+
resolveAttachmentFilename("nice-name.png", "/tmp/shot.png", "label"),
|
|
30
|
+
).toBe("nice-name.png");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("keeps bare labels and appends the POSIX path extension", () => {
|
|
34
|
+
expect(resolveAttachmentFilename("desktop", "/tmp/shot.png", "label")).toBe(
|
|
35
|
+
"desktop.png",
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("keeps bare labels and appends the Windows path extension", () => {
|
|
40
|
+
expect(
|
|
41
|
+
resolveAttachmentFilename(
|
|
42
|
+
"desktop",
|
|
43
|
+
"C:\\Users\\user1\\Pictures\\shot.png",
|
|
44
|
+
"label",
|
|
45
|
+
),
|
|
46
|
+
).toBe("desktop.png");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("bare labels to files sharing a basename resolve to unique names", () => {
|
|
50
|
+
expect(
|
|
51
|
+
resolveAttachmentFilename("first", "/workspace/a/result.png", "label"),
|
|
52
|
+
).toBe("first.png");
|
|
53
|
+
expect(
|
|
54
|
+
resolveAttachmentFilename("second", "/workspace/b/result.png", "label"),
|
|
55
|
+
).toBe("second.png");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("does not duplicate an unknown extension the label already has", () => {
|
|
59
|
+
expect(
|
|
60
|
+
resolveAttachmentFilename(
|
|
61
|
+
"report.xlsx",
|
|
62
|
+
"/workspace/report.xlsx",
|
|
63
|
+
"label",
|
|
64
|
+
),
|
|
65
|
+
).toBe("report.xlsx");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("matches the existing extension case-insensitively", () => {
|
|
69
|
+
expect(
|
|
70
|
+
resolveAttachmentFilename("data.YAML", "/workspace/data.yaml", "label"),
|
|
71
|
+
).toBe("data.YAML");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test("still appends when the label ends differently", () => {
|
|
75
|
+
expect(
|
|
76
|
+
resolveAttachmentFilename(
|
|
77
|
+
"summary.v2",
|
|
78
|
+
"/workspace/data.parquet",
|
|
79
|
+
"label",
|
|
80
|
+
),
|
|
81
|
+
).toBe("summary.v2.parquet");
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test("falls back to the basename when the path has no extension", () => {
|
|
85
|
+
expect(resolveAttachmentFilename("label", "/tmp/rawfile", "label")).toBe(
|
|
86
|
+
"rawfile",
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("uses the basename when no preferred name is given", () => {
|
|
91
|
+
expect(
|
|
92
|
+
resolveAttachmentFilename(undefined, "C:\\temp\\report.pdf", "label"),
|
|
93
|
+
).toBe("report.pdf");
|
|
94
|
+
expect(resolveAttachmentFilename(undefined, "/tmp/report.pdf")).toBe(
|
|
95
|
+
"report.pdf",
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("ignores trailing separators", () => {
|
|
100
|
+
expect(resolveAttachmentFilename(undefined, "/tmp/dir/", "label")).toBe(
|
|
101
|
+
"dir",
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attachment filename contract shared by the daemon (which materializes
|
|
3
|
+
* `vellum://` links and `<vellum-attachment>` directives into stored
|
|
4
|
+
* attachments) and the web client (which resolves clicked links back to
|
|
5
|
+
* those attachments). Both sides must agree on the stored filename, so the
|
|
6
|
+
* naming rule lives here once.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const EXTENSION_MIME_MAP: Record<string, string> = {
|
|
10
|
+
// Images
|
|
11
|
+
png: "image/png",
|
|
12
|
+
jpg: "image/jpeg",
|
|
13
|
+
jpeg: "image/jpeg",
|
|
14
|
+
gif: "image/gif",
|
|
15
|
+
webp: "image/webp",
|
|
16
|
+
svg: "image/svg+xml",
|
|
17
|
+
ico: "image/x-icon",
|
|
18
|
+
bmp: "image/bmp",
|
|
19
|
+
heic: "image/heic",
|
|
20
|
+
heif: "image/heif",
|
|
21
|
+
|
|
22
|
+
// Documents
|
|
23
|
+
pdf: "application/pdf",
|
|
24
|
+
json: "application/json",
|
|
25
|
+
xml: "application/xml",
|
|
26
|
+
csv: "text/csv",
|
|
27
|
+
txt: "text/plain",
|
|
28
|
+
md: "text/markdown",
|
|
29
|
+
html: "text/html",
|
|
30
|
+
css: "text/css",
|
|
31
|
+
js: "text/javascript",
|
|
32
|
+
ts: "text/typescript",
|
|
33
|
+
|
|
34
|
+
// Audio
|
|
35
|
+
mp3: "audio/mpeg",
|
|
36
|
+
wav: "audio/wav",
|
|
37
|
+
ogg: "audio/ogg",
|
|
38
|
+
flac: "audio/flac",
|
|
39
|
+
aac: "audio/aac",
|
|
40
|
+
m4a: "audio/x-m4a",
|
|
41
|
+
opus: "audio/opus",
|
|
42
|
+
|
|
43
|
+
// Video
|
|
44
|
+
mp4: "video/mp4",
|
|
45
|
+
webm: "video/webm",
|
|
46
|
+
mov: "video/quicktime",
|
|
47
|
+
mpeg: "video/mpeg",
|
|
48
|
+
|
|
49
|
+
// Archives
|
|
50
|
+
zip: "application/zip",
|
|
51
|
+
gz: "application/gzip",
|
|
52
|
+
tar: "application/x-tar",
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Infer a MIME type from a filename extension.
|
|
57
|
+
* Returns `application/octet-stream` when the extension is unrecognised.
|
|
58
|
+
*/
|
|
59
|
+
export function inferMimeType(filename: string): string {
|
|
60
|
+
const dot = filename.lastIndexOf(".");
|
|
61
|
+
if (dot === -1) {
|
|
62
|
+
return "application/octet-stream";
|
|
63
|
+
}
|
|
64
|
+
const ext = filename.slice(dot + 1).toLowerCase();
|
|
65
|
+
return EXTENSION_MIME_MAP[ext] ?? "application/octet-stream";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Pick the stored attachment filename for a materialized file directive.
|
|
70
|
+
*
|
|
71
|
+
* Explicit filenames (`<vellum-attachment filename="..." />` attributes)
|
|
72
|
+
* are an authoring contract and always used verbatim. Link display text
|
|
73
|
+
* (`[label](vellum://...)`) is cosmetic: it is only honored as the filename
|
|
74
|
+
* when it carries a recognized extension. A bare label
|
|
75
|
+
* (e.g. `[desktop](vellum://.../shot.png)`) would otherwise produce an
|
|
76
|
+
* extensionless download with an `application/octet-stream` MIME type,
|
|
77
|
+
* which macOS opens as raw text. In that case the label keeps the path's
|
|
78
|
+
* extension (`desktop.png`), staying unique per link even when several
|
|
79
|
+
* links share a basename; the raw basename is the last resort.
|
|
80
|
+
*
|
|
81
|
+
* The basename fallback splits on both `/` and `\\` so it handles POSIX
|
|
82
|
+
* sandbox paths, `vellum://` URL paths, and Windows host paths alike.
|
|
83
|
+
* Splitting on both separators regardless of the runtime platform also
|
|
84
|
+
* covers Windows host paths resolved by a non-Windows daemon, which
|
|
85
|
+
* platform-selected `node:path` semantics cannot.
|
|
86
|
+
*/
|
|
87
|
+
export function resolveAttachmentFilename(
|
|
88
|
+
preferred: string | undefined,
|
|
89
|
+
resolvedPath: string,
|
|
90
|
+
filenameSource: "explicit" | "label" = "explicit",
|
|
91
|
+
): string {
|
|
92
|
+
const fallback =
|
|
93
|
+
resolvedPath.split(/[\\/]/).filter(Boolean).pop() ?? resolvedPath;
|
|
94
|
+
if (!preferred) {
|
|
95
|
+
return fallback;
|
|
96
|
+
}
|
|
97
|
+
if (filenameSource === "explicit") {
|
|
98
|
+
return preferred;
|
|
99
|
+
}
|
|
100
|
+
if (inferMimeType(preferred) !== "application/octet-stream") {
|
|
101
|
+
return preferred;
|
|
102
|
+
}
|
|
103
|
+
// Bare label: keep the label as a per-link disambiguator (two links to
|
|
104
|
+
// different files sharing a basename must not collide, because the
|
|
105
|
+
// transcript resolves clicks by filename) and append the path's
|
|
106
|
+
// extension so the stored name carries the correct type. Skip the
|
|
107
|
+
// append when the label already ends with that extension (a label like
|
|
108
|
+
// `report.xlsx` for `report.xlsx` must not become `report.xlsx.xlsx`).
|
|
109
|
+
const dot = fallback.lastIndexOf(".");
|
|
110
|
+
if (dot > 0 && dot < fallback.length - 1) {
|
|
111
|
+
const ext = fallback.slice(dot + 1);
|
|
112
|
+
if (preferred.toLowerCase().endsWith(`.${ext.toLowerCase()}`)) {
|
|
113
|
+
return preferred;
|
|
114
|
+
}
|
|
115
|
+
return `${preferred}.${ext}`;
|
|
116
|
+
}
|
|
117
|
+
return fallback;
|
|
118
|
+
}
|