@vellumai/assistant 0.5.3 → 0.5.5
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/Dockerfile +18 -27
- package/docs/architecture/memory.md +105 -0
- package/node_modules/@vellumai/ces-contracts/src/index.ts +1 -0
- package/node_modules/@vellumai/ces-contracts/src/trust-rules.ts +42 -0
- package/package.json +1 -1
- package/src/__tests__/archive-recall.test.ts +560 -0
- package/src/__tests__/conversation-clear-safety.test.ts +259 -0
- package/src/__tests__/conversation-switch-memory-reduction.test.ts +474 -0
- package/src/__tests__/credential-security-invariants.test.ts +2 -0
- package/src/__tests__/db-schedule-syntax-migration.test.ts +3 -0
- package/src/__tests__/memory-reducer-job.test.ts +538 -0
- package/src/__tests__/memory-reducer-scheduling.test.ts +473 -0
- package/src/__tests__/memory-reducer-types.test.ts +12 -4
- package/src/__tests__/memory-reducer.test.ts +7 -1
- package/src/__tests__/memory-regressions.test.ts +24 -4
- package/src/__tests__/memory-simplified-config.test.ts +4 -4
- package/src/__tests__/openai-whisper.test.ts +93 -0
- package/src/__tests__/simplified-memory-e2e.test.ts +666 -0
- package/src/__tests__/simplified-memory-runtime.test.ts +616 -0
- package/src/__tests__/slack-messaging-token-resolution.test.ts +319 -0
- package/src/__tests__/volume-security-guard.test.ts +155 -0
- package/src/cli/commands/conversations.ts +18 -0
- package/src/config/bundled-skills/messaging/tools/shared.ts +1 -0
- package/src/config/bundled-skills/schedule/TOOLS.json +8 -0
- package/src/config/bundled-skills/transcribe/tools/transcribe-media.ts +16 -37
- package/src/config/env-registry.ts +9 -0
- package/src/config/feature-flag-registry.json +8 -0
- package/src/config/loader.ts +0 -1
- package/src/config/schemas/memory-simplified.ts +1 -1
- package/src/credential-execution/managed-catalog.ts +5 -15
- package/src/daemon/config-watcher.ts +4 -1
- package/src/daemon/conversation-memory.ts +117 -0
- package/src/daemon/conversation-runtime-assembly.ts +1 -0
- package/src/daemon/daemon-control.ts +7 -0
- package/src/daemon/handlers/conversations.ts +11 -0
- package/src/daemon/lifecycle.ts +51 -2
- package/src/daemon/providers-setup.ts +2 -1
- package/src/hooks/manager.ts +7 -0
- package/src/instrument.ts +33 -1
- package/src/memory/archive-recall.ts +516 -0
- package/src/memory/brief-time.ts +5 -4
- package/src/memory/conversation-crud.ts +210 -0
- package/src/memory/conversation-key-store.ts +33 -4
- package/src/memory/db-init.ts +4 -0
- package/src/memory/embedding-local.ts +11 -5
- package/src/memory/job-handlers/backfill-simplified-memory.ts +462 -0
- package/src/memory/job-handlers/conversation-starters.ts +24 -30
- package/src/memory/job-handlers/reduce-conversation-memory.ts +229 -0
- package/src/memory/jobs-store.ts +2 -0
- package/src/memory/jobs-worker.ts +8 -0
- package/src/memory/migrations/036-normalize-phone-identities.ts +49 -14
- package/src/memory/migrations/135-backfill-contact-interaction-stats.ts +9 -1
- package/src/memory/migrations/141-rename-verification-table.ts +8 -0
- package/src/memory/migrations/142-rename-verification-session-id-column.ts +7 -2
- package/src/memory/migrations/174-rename-thread-starters-table.ts +8 -0
- package/src/memory/migrations/188-schedule-quiet-flag.ts +13 -0
- package/src/memory/migrations/index.ts +1 -0
- package/src/memory/reducer-scheduler.ts +242 -0
- package/src/memory/reducer-types.ts +9 -2
- package/src/memory/reducer.ts +25 -11
- package/src/memory/schema/infrastructure.ts +1 -0
- package/src/messaging/provider.ts +9 -0
- package/src/messaging/providers/slack/adapter.ts +29 -2
- package/src/oauth/connection-resolver.test.ts +22 -18
- package/src/oauth/connection-resolver.ts +92 -7
- package/src/oauth/platform-connection.test.ts +78 -69
- package/src/oauth/platform-connection.ts +12 -19
- package/src/permissions/trust-client.ts +343 -0
- package/src/permissions/trust-store-interface.ts +105 -0
- package/src/permissions/trust-store.ts +523 -36
- package/src/platform/client.test.ts +148 -0
- package/src/platform/client.ts +71 -0
- package/src/providers/speech-to-text/openai-whisper.test.ts +190 -0
- package/src/providers/speech-to-text/openai-whisper.ts +68 -0
- package/src/providers/speech-to-text/resolve.ts +9 -0
- package/src/providers/speech-to-text/types.ts +17 -0
- package/src/runtime/auth/route-policy.ts +10 -1
- package/src/runtime/http-server.ts +2 -2
- package/src/runtime/routes/conversation-management-routes.ts +88 -2
- package/src/runtime/routes/guardian-bootstrap-routes.ts +19 -7
- package/src/runtime/routes/inbound-message-handler.ts +27 -3
- package/src/runtime/routes/inbound-stages/acl-enforcement.ts +16 -1
- package/src/runtime/routes/inbound-stages/transcribe-audio.test.ts +287 -0
- package/src/runtime/routes/inbound-stages/transcribe-audio.ts +122 -0
- package/src/runtime/routes/log-export-routes.ts +1 -0
- package/src/runtime/routes/secret-routes.ts +5 -1
- package/src/schedule/schedule-store.ts +7 -0
- package/src/schedule/scheduler.ts +6 -2
- package/src/security/ces-credential-client.ts +173 -0
- package/src/security/secure-keys.ts +65 -22
- package/src/signals/bash.ts +3 -0
- package/src/signals/cancel.ts +3 -0
- package/src/signals/confirm.ts +3 -0
- package/src/signals/conversation-undo.ts +3 -0
- package/src/signals/event-stream.ts +7 -0
- package/src/signals/shotgun.ts +3 -0
- package/src/signals/trust-rule.ts +3 -0
- package/src/telemetry/usage-telemetry-reporter.test.ts +23 -36
- package/src/telemetry/usage-telemetry-reporter.ts +22 -20
- package/src/tools/filesystem/edit.ts +6 -1
- package/src/tools/filesystem/read.ts +6 -1
- package/src/tools/filesystem/write.ts +6 -1
- package/src/tools/memory/handlers.ts +129 -1
- package/src/tools/schedule/create.ts +3 -0
- package/src/tools/schedule/list.ts +5 -1
- package/src/tools/schedule/update.ts +6 -0
- package/src/util/device-id.ts +70 -7
- package/src/util/logger.ts +35 -9
- package/src/util/platform.ts +29 -5
- package/src/workspace/migrations/migrate-to-workspace-volume.ts +113 -0
- package/src/workspace/migrations/registry.ts +2 -0
package/Dockerfile
CHANGED
|
@@ -47,57 +47,48 @@ RUN apt-get update && apt-get install -y \
|
|
|
47
47
|
g++ \
|
|
48
48
|
git \
|
|
49
49
|
sudo \
|
|
50
|
+
bubblewrap \
|
|
51
|
+
htop \
|
|
52
|
+
procps \
|
|
50
53
|
&& rm -rf /var/lib/apt/lists/*
|
|
51
54
|
|
|
55
|
+
## Alias bwrap to bubblewrap
|
|
56
|
+
RUN ln -sf /usr/bin/bwrap /usr/bin/bubblewrap
|
|
57
|
+
|
|
52
58
|
# Copy bun binary from builder instead of re-installing
|
|
53
59
|
COPY --from=builder /root/.bun/bin/bun /usr/local/bin/bun
|
|
54
60
|
RUN ln -sf /usr/local/bin/bun /usr/local/bin/bunx
|
|
55
61
|
|
|
62
|
+
# Install assistant CLI launcher backed by the bundled assistant package
|
|
63
|
+
RUN printf '#!/usr/bin/env sh\nexec bun run /app/assistant/src/index.ts "$@"\n' > /usr/local/bin/assistant && \
|
|
64
|
+
chmod +x /usr/local/bin/assistant
|
|
65
|
+
|
|
56
66
|
# Create non-root user that also has sudo access so it can like install stuff
|
|
57
67
|
RUN groupadd --system --gid 1001 assistant && \
|
|
58
68
|
useradd --system --uid 1001 --gid assistant --create-home --shell /bin/bash assistant && \
|
|
59
69
|
echo "assistant ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
|
60
70
|
|
|
61
|
-
# Set up
|
|
62
|
-
RUN mkdir -p /home/assistant/.vellum
|
|
63
|
-
chown -R assistant:assistant /home/assistant/.vellum
|
|
64
|
-
chmod a+rwx /data
|
|
71
|
+
# Set up assistant home directory for local state (device.json, etc.)
|
|
72
|
+
RUN mkdir -p /home/assistant/.vellum && \
|
|
73
|
+
chown -R assistant:assistant /home/assistant/.vellum
|
|
65
74
|
|
|
66
75
|
# Update PATH for assistant user
|
|
67
|
-
ENV PATH="/home/assistant/.bun/bin
|
|
76
|
+
ENV PATH="/home/assistant/.bun/bin:${PATH}"
|
|
68
77
|
|
|
69
|
-
# Configure package managers to use
|
|
70
|
-
ENV BUN_INSTALL="/
|
|
78
|
+
# Configure package managers to use assistant home
|
|
79
|
+
ENV BUN_INSTALL="/home/assistant/.bun"
|
|
71
80
|
ENV PATH="${BUN_INSTALL}/bin:${PATH}"
|
|
72
|
-
ENV PYTHONUSERBASE="/
|
|
81
|
+
ENV PYTHONUSERBASE="/home/assistant/.python"
|
|
73
82
|
ENV PATH="${PYTHONUSERBASE}/bin:${PATH}"
|
|
74
83
|
|
|
75
|
-
# Configure apt/dpkg to install future packages to /data
|
|
76
|
-
RUN mkdir -p /data/dpkg/info /data/dpkg/updates /data/dpkg/triggers && \
|
|
77
|
-
mkdir -p /data/usr/bin /data/usr/lib /data/usr/share && \
|
|
78
|
-
chown -R assistant:assistant /data/dpkg /data/usr
|
|
79
|
-
|
|
80
|
-
# Create dpkg configuration for using /data as install prefix
|
|
81
|
-
RUN echo 'Dir::State "/data/dpkg";' > /etc/apt/apt.conf.d/99data-dir && \
|
|
82
|
-
echo 'Dir::State::status "/data/dpkg/status";' >> /etc/apt/apt.conf.d/99data-dir && \
|
|
83
|
-
echo 'Dir::Cache "/data/apt/cache";' >> /etc/apt/apt.conf.d/99data-dir && \
|
|
84
|
-
echo 'DPkg::Options {"--instdir=/data/usr";"--admindir=/data/dpkg";"--force-not-root";"--force-bad-path";};' >> /etc/apt/apt.conf.d/99data-dir && \
|
|
85
|
-
mkdir -p /data/apt/cache && \
|
|
86
|
-
touch /data/dpkg/status && \
|
|
87
|
-
chown -R assistant:assistant /data/apt /data/dpkg
|
|
88
|
-
|
|
89
|
-
ENV PATH="/data/usr/bin:/data/usr/sbin:${PATH}"
|
|
90
|
-
ENV LD_LIBRARY_PATH="/data/usr/lib:/data/usr/lib/x86_64-linux-gnu:/data/usr/lib/aarch64-linux-gnu"
|
|
91
|
-
|
|
92
84
|
# Ensure the CES bootstrap socket volume is writable by the non-root CES user.
|
|
93
85
|
RUN mkdir -p /run/ces-bootstrap && chmod 777 /run/ces-bootstrap
|
|
94
86
|
|
|
95
|
-
USER
|
|
87
|
+
USER assistant
|
|
96
88
|
|
|
97
89
|
EXPOSE 3001
|
|
98
90
|
|
|
99
91
|
ENV RUNTIME_HTTP_PORT=3001
|
|
100
|
-
ENV BASE_DATA_DIR=/data
|
|
101
92
|
ENV IS_CONTAINERIZED=true
|
|
102
93
|
|
|
103
94
|
# Copy from builder
|
|
@@ -2,6 +2,111 @@
|
|
|
2
2
|
|
|
3
3
|
Assistant memory and context-injection architecture details.
|
|
4
4
|
|
|
5
|
+
## Simplified Memory System (Default)
|
|
6
|
+
|
|
7
|
+
The simplified memory system replaces the legacy item/tier/staleness model with a two-layer architecture: a **brief** (time-relevant context + open loops) plus **archive recall** (observations, chunks, episodes). It is enabled by default via `memory.simplified.enabled: true`.
|
|
8
|
+
|
|
9
|
+
### Architecture Overview
|
|
10
|
+
|
|
11
|
+
```mermaid
|
|
12
|
+
graph TB
|
|
13
|
+
subgraph "Write Path (Simplified)"
|
|
14
|
+
MSG["Incoming Message"] --> REDUCER["Memory Reducer<br/>(LLM-backed, delayed)"]
|
|
15
|
+
REDUCER --> TC["time_contexts<br/>(brief state)"]
|
|
16
|
+
REDUCER --> OL["open_loops<br/>(brief state)"]
|
|
17
|
+
REDUCER --> OBS_R["Archive Observations<br/>(reducer output)"]
|
|
18
|
+
REDUCER --> EP_R["Archive Episodes<br/>(reducer output)"]
|
|
19
|
+
|
|
20
|
+
MSG --> INDEXER["Dual-Write Indexer"]
|
|
21
|
+
INDEXER --> OBS["memory_observations"]
|
|
22
|
+
INDEXER --> CHK["memory_chunks<br/>(content-hash deduped)"]
|
|
23
|
+
|
|
24
|
+
COMPACT["Context Compaction"] --> EP["memory_episodes"]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
subgraph "Read Path (Simplified)"
|
|
28
|
+
TURN["User Turn"] --> BRIEF["Memory Brief Compiler"]
|
|
29
|
+
BRIEF --> TC
|
|
30
|
+
BRIEF --> OL
|
|
31
|
+
BRIEF --> BRIEF_OUT["<memory_brief><br/>Time contexts + Open loops"]
|
|
32
|
+
|
|
33
|
+
TURN --> RECALL_GATE["Archive Recall Gate<br/>(keyword + pattern match)"]
|
|
34
|
+
RECALL_GATE --> PREFETCH["Prefetch<br/>(episodes + observations)"]
|
|
35
|
+
RECALL_GATE --> DEEP["Deeper Recall<br/>(episodes + observations + chunks)"]
|
|
36
|
+
DEEP --> RECALL_OUT["<supporting_recall><br/>Source-linked bullets"]
|
|
37
|
+
|
|
38
|
+
BRIEF_OUT --> INJECT["Runtime Injection<br/>(prepend to user message)"]
|
|
39
|
+
RECALL_OUT --> INJECT
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
subgraph "Memory Tools (Simplified)"
|
|
43
|
+
SAVE["memory_save"] --> OBS
|
|
44
|
+
RECALL_TOOL["memory_recall"] --> RECALL_GATE
|
|
45
|
+
end
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Tables
|
|
49
|
+
|
|
50
|
+
| Table | Purpose | Write source |
|
|
51
|
+
| --------------------- | ----------------------------------------------- | ------------------------------------------------------- |
|
|
52
|
+
| `time_contexts` | Bounded temporal windows for the brief | Reducer |
|
|
53
|
+
| `open_loops` | Unresolved follow-up items for the brief | Reducer |
|
|
54
|
+
| `memory_observations` | Raw factual statements from conversation turns | Indexer dual-write, reducer, memory_save tool, backfill |
|
|
55
|
+
| `memory_chunks` | Deduplicated content units for embedding/recall | Derived from observations, content-hash deduped |
|
|
56
|
+
| `memory_episodes` | Narrative summaries of interaction spans | Compaction, reducer, backfill |
|
|
57
|
+
|
|
58
|
+
### Reducer
|
|
59
|
+
|
|
60
|
+
The memory reducer is a provider-backed (LLM) background process that analyzes unreduced conversation turns and produces structured CRUD operations for brief-state tables and archive candidates. It runs on a delay after conversation idle or switch, scheduled via the `reduce_conversation_memory` job. The reducer is side-effect-free; results are applied transactionally via `applyReducerResult`.
|
|
61
|
+
|
|
62
|
+
### Brief
|
|
63
|
+
|
|
64
|
+
The memory brief is compiled fresh on every turn from active `time_contexts` and `open_loops`. It is rendered as `<memory_brief>` XML and injected as a text block prepended to the user message. Empty sections are omitted.
|
|
65
|
+
|
|
66
|
+
### Archive Recall
|
|
67
|
+
|
|
68
|
+
Archive recall runs when the user's turn triggers a recall gate (past-reference language, analogy/debugging patterns, or strong prefetch hits). It queries episodes, observations, and chunks via keyword matching and returns up to 3 source-linked bullets in `<supporting_recall>`. No recall tag is emitted when results are empty.
|
|
69
|
+
|
|
70
|
+
### Backfill
|
|
71
|
+
|
|
72
|
+
Existing users have legacy data in `memory_segments`, `memory_summaries`, and `memory_items`. The `backfill_simplified_memory` job migrates this data into the simplified tables:
|
|
73
|
+
|
|
74
|
+
- `memory_segments` -> `memory_observations` + `memory_chunks`
|
|
75
|
+
- `memory_summaries` -> `memory_episodes`
|
|
76
|
+
- Active, high-confidence `memory_items` -> `memory_observations` + `memory_chunks`, with unambiguous items also mapped to `time_contexts` or `open_loops`
|
|
77
|
+
|
|
78
|
+
The backfill is idempotent (content-hash dedup + checkpoint tracking), processes in batches of 200, and self-enqueues continuation jobs for large datasets.
|
|
79
|
+
|
|
80
|
+
### Rollback Posture
|
|
81
|
+
|
|
82
|
+
The legacy memory system remains fully available as a short-lived rollback path:
|
|
83
|
+
|
|
84
|
+
- **Legacy tables are preserved**: `memory_segments`, `memory_items`, `memory_summaries`, and `memory_item_sources` remain in the schema and continue to receive writes from the legacy indexer/extraction pipeline.
|
|
85
|
+
- **Flag-gated**: Setting `memory.simplified.enabled: false` reverts to the legacy item/tier/staleness model for both read and write paths.
|
|
86
|
+
- **Memory tools**: `memory_save` and `memory_recall` check the flag at call time and route to the appropriate path (simplified observations or legacy items).
|
|
87
|
+
- **No data loss**: The backfill copies data without deleting legacy rows. Both systems can coexist.
|
|
88
|
+
|
|
89
|
+
### Key Files
|
|
90
|
+
|
|
91
|
+
| File | Role |
|
|
92
|
+
| ----------------------------------------------------------------- | ------------------------------------------------ |
|
|
93
|
+
| `assistant/src/config/schemas/memory-simplified.ts` | Config schema with `enabled: true` default |
|
|
94
|
+
| `assistant/src/memory/reducer.ts` | Provider-backed reducer (LLM call + parse) |
|
|
95
|
+
| `assistant/src/memory/reducer-store.ts` | Transactional result application |
|
|
96
|
+
| `assistant/src/memory/reducer-scheduler.ts` | Idle-delay and conversation-switch scheduling |
|
|
97
|
+
| `assistant/src/memory/archive-store.ts` | Observation/chunk/episode write helpers |
|
|
98
|
+
| `assistant/src/memory/archive-recall.ts` | Prefetch + deeper recall over archive tables |
|
|
99
|
+
| `assistant/src/memory/brief.ts` | Brief composer (time contexts + open loops) |
|
|
100
|
+
| `assistant/src/memory/job-handlers/backfill-simplified-memory.ts` | Legacy data migration handler |
|
|
101
|
+
| `assistant/src/tools/memory/handlers.ts` | Memory tool handlers (simplified/legacy routing) |
|
|
102
|
+
| `assistant/src/__tests__/simplified-memory-e2e.test.ts` | End-to-end test suite |
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Legacy Memory System — Daemon Data Flow
|
|
107
|
+
|
|
108
|
+
> **Note**: The legacy system below is retained as rollback support. New installations use the simplified system by default.
|
|
109
|
+
|
|
5
110
|
## Memory System — Daemon Data Flow
|
|
6
111
|
|
|
7
112
|
```mermaid
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trust rule types shared between the assistant daemon and the gateway.
|
|
3
|
+
*
|
|
4
|
+
* These are extracted from `assistant/src/permissions/types.ts` and
|
|
5
|
+
* `assistant/src/permissions/trust-store.ts` so that both packages can
|
|
6
|
+
* reference a single canonical definition.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Trust decision
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
/** The possible decisions a trust rule can make. */
|
|
14
|
+
export type TrustDecision = "allow" | "deny" | "ask";
|
|
15
|
+
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Trust rule
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
export interface TrustRule {
|
|
21
|
+
id: string;
|
|
22
|
+
tool: string;
|
|
23
|
+
pattern: string;
|
|
24
|
+
scope: string;
|
|
25
|
+
decision: TrustDecision;
|
|
26
|
+
priority: number;
|
|
27
|
+
createdAt: number;
|
|
28
|
+
executionTarget?: string;
|
|
29
|
+
allowHighRisk?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
// Trust file (on-disk shape)
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
|
|
36
|
+
/** Shape of the `trust.json` file persisted to disk. */
|
|
37
|
+
export interface TrustFileData {
|
|
38
|
+
version: number;
|
|
39
|
+
rules: TrustRule[];
|
|
40
|
+
/** Set to true when the user explicitly accepts the starter approval bundle. */
|
|
41
|
+
starterBundleAccepted?: boolean;
|
|
42
|
+
}
|