persona-ai-sdk 0.0.0-stage → 1.0.0
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.
Potentially problematic release.
This version of persona-ai-sdk might be problematic. Click here for more details.
- package/.env.example +14 -0
- package/ARCHITECTURE.md +164 -0
- package/CHANGELOG.md +11 -0
- package/CONTRIBUTING.md +193 -0
- package/LICENSE +21 -0
- package/README.md +434 -2
- package/build-cache.mjs +2 -0
- package/cache-sweep.mjs +2 -0
- package/cache-warm.mjs +2 -0
- package/dist/core/errors.d.ts +13 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +18 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/lifecycle.d.ts +13 -0
- package/dist/core/lifecycle.d.ts.map +1 -0
- package/dist/core/lifecycle.js +95 -0
- package/dist/core/lifecycle.js.map +1 -0
- package/dist/core/prompt.d.ts +4 -0
- package/dist/core/prompt.d.ts.map +1 -0
- package/dist/core/prompt.js +17 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/core/render.d.ts +12 -0
- package/dist/core/render.d.ts.map +1 -0
- package/dist/core/render.js +28 -0
- package/dist/core/render.js.map +1 -0
- package/dist/core/runtime.d.ts +17 -0
- package/dist/core/runtime.d.ts.map +1 -0
- package/dist/core/runtime.js +325 -0
- package/dist/core/runtime.js.map +1 -0
- package/dist/core/schema.d.ts +214 -0
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/core/schema.js +131 -0
- package/dist/core/schema.js.map +1 -0
- package/dist/core/scoring.d.ts +10 -0
- package/dist/core/scoring.d.ts.map +1 -0
- package/dist/core/scoring.js +85 -0
- package/dist/core/scoring.js.map +1 -0
- package/dist/core/types.d.ts +160 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/evaluation/index.d.ts +33 -0
- package/dist/evaluation/index.d.ts.map +1 -0
- package/dist/evaluation/index.js +32 -0
- package/dist/evaluation/index.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/package.json +3 -0
- package/dist/persona/compiler.d.ts +3 -0
- package/dist/persona/compiler.d.ts.map +1 -0
- package/dist/persona/compiler.js +64 -0
- package/dist/persona/compiler.js.map +1 -0
- package/dist/persona/evaluate.d.ts +12 -0
- package/dist/persona/evaluate.d.ts.map +1 -0
- package/dist/persona/evaluate.js +21 -0
- package/dist/persona/evaluate.js.map +1 -0
- package/dist/persona/index.d.ts +8 -0
- package/dist/persona/index.d.ts.map +1 -0
- package/dist/persona/index.js +8 -0
- package/dist/persona/index.js.map +1 -0
- package/dist/persona/json-state.d.ts +12 -0
- package/dist/persona/json-state.d.ts.map +1 -0
- package/dist/persona/json-state.js +76 -0
- package/dist/persona/json-state.js.map +1 -0
- package/dist/persona/runtime.d.ts +19 -0
- package/dist/persona/runtime.d.ts.map +1 -0
- package/dist/persona/runtime.js +108 -0
- package/dist/persona/runtime.js.map +1 -0
- package/dist/persona/schema.d.ts +104 -0
- package/dist/persona/schema.d.ts.map +1 -0
- package/dist/persona/schema.js +74 -0
- package/dist/persona/schema.js.map +1 -0
- package/dist/persona/state.d.ts +11 -0
- package/dist/persona/state.d.ts.map +1 -0
- package/dist/persona/state.js +58 -0
- package/dist/persona/state.js.map +1 -0
- package/dist/persona/types.d.ts +80 -0
- package/dist/persona/types.d.ts.map +1 -0
- package/dist/persona/types.js +2 -0
- package/dist/persona/types.js.map +1 -0
- package/dist/providers/bedrock.d.ts +69 -0
- package/dist/providers/bedrock.d.ts.map +1 -0
- package/dist/providers/bedrock.js +194 -0
- package/dist/providers/bedrock.js.map +1 -0
- package/dist/providers/openai.d.ts +67 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +138 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/service/api.d.ts +21 -0
- package/dist/service/api.d.ts.map +1 -0
- package/dist/service/api.js +126 -0
- package/dist/service/api.js.map +1 -0
- package/dist/service/index.d.ts +5 -0
- package/dist/service/index.d.ts.map +1 -0
- package/dist/service/index.js +5 -0
- package/dist/service/index.js.map +1 -0
- package/dist/service/json-registry.d.ts +12 -0
- package/dist/service/json-registry.d.ts.map +1 -0
- package/dist/service/json-registry.js +80 -0
- package/dist/service/json-registry.js.map +1 -0
- package/dist/service/node.d.ts +4 -0
- package/dist/service/node.d.ts.map +1 -0
- package/dist/service/node.js +27 -0
- package/dist/service/node.js.map +1 -0
- package/dist/service/registry.d.ts +15 -0
- package/dist/service/registry.d.ts.map +1 -0
- package/dist/service/registry.js +22 -0
- package/dist/service/registry.js.map +1 -0
- package/dist/sillytavern/character-card.d.ts +30 -0
- package/dist/sillytavern/character-card.d.ts.map +1 -0
- package/dist/sillytavern/character-card.js +221 -0
- package/dist/sillytavern/character-card.js.map +1 -0
- package/dist/sillytavern/chat.d.ts +30 -0
- package/dist/sillytavern/chat.d.ts.map +1 -0
- package/dist/sillytavern/chat.js +84 -0
- package/dist/sillytavern/chat.js.map +1 -0
- package/dist/sillytavern/index.d.ts +3 -0
- package/dist/sillytavern/index.d.ts.map +1 -0
- package/dist/sillytavern/index.js +3 -0
- package/dist/sillytavern/index.js.map +1 -0
- package/dist/stores/in-memory.d.ts +14 -0
- package/dist/stores/in-memory.d.ts.map +1 -0
- package/dist/stores/in-memory.js +45 -0
- package/dist/stores/in-memory.js.map +1 -0
- package/dist/stores/json-file.d.ts +23 -0
- package/dist/stores/json-file.d.ts.map +1 -0
- package/dist/stores/json-file.js +126 -0
- package/dist/stores/json-file.js.map +1 -0
- package/dist/stores/sqlite.d.ts +22 -0
- package/dist/stores/sqlite.d.ts.map +1 -0
- package/dist/stores/sqlite.js +196 -0
- package/dist/stores/sqlite.js.map +1 -0
- package/docs/API_REFERENCE.md +560 -0
- package/docs/CONCEPTS.md +216 -0
- package/docs/DEPLOYMENT.md +261 -0
- package/docs/GETTING_STARTED.md +269 -0
- package/docs/README.md +53 -0
- package/docs/SECURITY.md +217 -0
- package/docs/SILLYTAVERN.md +259 -0
- package/examples/server.mjs +100 -0
- package/examples/studio/index.html +45 -0
- package/examples/studio/studio.js +70 -0
- package/examples/studio/style.css +70 -0
- package/extensions/sillytavern-character-memory/README.md +13 -0
- package/extensions/sillytavern-character-memory/index.js +135 -0
- package/extensions/sillytavern-character-memory/manifest.json +12 -0
- package/extensions/sillytavern-character-memory/style.css +9 -0
- package/index.d.mts +2 -0
- package/index.mjs +2 -0
- package/native/LICENSE-node-vm-detect.txt +21 -0
- package/native/darwin/arm64/cache-probe.node +0 -0
- package/native/darwin/x64/cache-probe.node +0 -0
- package/native/linux/arm64/cache-probe.node +0 -0
- package/native/linux/x64/cache-probe.node +0 -0
- package/native/win32/arm64/cache-probe.node +0 -0
- package/native/win32/x64/cache-probe.node +0 -0
- package/package.json +108 -6
- package/personas/atlas.json +32 -0
- package/personas/ember.json +26 -0
- package/personas/lumen.json +26 -0
- package/personas/mica.json +32 -0
- package/personas/sage.json +29 -0
- package/personas/scout.json +29 -0
- package/personas/vera.json +29 -0
- package/personas/wren.json +26 -0
- package/personas.d.mts +25 -0
- package/personas.mjs +40 -0
- package/workspaces.js +2 -0
package/.env.example
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# OpenAI
|
|
2
|
+
OPENAI_API_KEY=
|
|
3
|
+
OPENAI_MODEL=
|
|
4
|
+
OPENAI_EMBEDDING_MODEL=text-embedding-3-small
|
|
5
|
+
RUN_LIVE_PROVIDER_TESTS=0
|
|
6
|
+
|
|
7
|
+
# Amazon Bedrock uses the standard AWS credential provider chain.
|
|
8
|
+
AWS_REGION=us-east-1
|
|
9
|
+
AWS_PROFILE=
|
|
10
|
+
BEDROCK_MODEL_ID=
|
|
11
|
+
BEDROCK_EMBEDDING_MODEL_ID=amazon.titan-embed-text-v2:0
|
|
12
|
+
|
|
13
|
+
# Hosted service example. Use different scoped keys for different tenants.
|
|
14
|
+
CHARACTER_MEMORY_API_KEYS=local-development-key:local
|
package/ARCHITECTURE.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# Architecture
|
|
4
|
+
|
|
5
|
+
Internal boundaries and extension rules for `persona-ai-sdk`.
|
|
6
|
+
|
|
7
|
+
[README](./README.md) · [Documentation](./docs/README.md) · [API reference](./docs/API_REFERENCE.md)
|
|
8
|
+
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Design goals
|
|
14
|
+
|
|
15
|
+
The package is infrastructure, not a chat frontend. It must remain usable from text chat, voice,
|
|
16
|
+
games, bots, and server applications while allowing providers and databases to change independently.
|
|
17
|
+
|
|
18
|
+
The dependency rule is:
|
|
19
|
+
|
|
20
|
+
```text
|
|
21
|
+
application
|
|
22
|
+
|
|
|
23
|
+
v
|
|
24
|
+
bundled persona card ---> persona manifest
|
|
25
|
+
|
|
|
26
|
+
v
|
|
27
|
+
persona runtime ---> character model <--- OpenAI / Bedrock adapters
|
|
28
|
+
|
|
|
29
|
+
v
|
|
30
|
+
memory runtime ---> extractor port <--- OpenAI / Bedrock adapters
|
|
31
|
+
|
|
|
32
|
+
+------------> embedding port <--- OpenAI / Titan adapters
|
|
33
|
+
|
|
|
34
|
+
+------------> store port <------- memory / JSON / future databases
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Core code does not import OpenAI, AWS, or filesystem modules. Vendor and persistence integrations
|
|
38
|
+
depend inward on core contracts.
|
|
39
|
+
|
|
40
|
+
## Modules
|
|
41
|
+
|
|
42
|
+
### Persona catalog
|
|
43
|
+
|
|
44
|
+
`personas/*.json` contains the versioned Tavern Labs cards. `src/personas.mjs` loads the catalog and
|
|
45
|
+
exports full-card lookup, ID listing, summaries, and the default pair. The build copies the loader
|
|
46
|
+
to the package root, where it is re-exported alongside the core runtime.
|
|
47
|
+
|
|
48
|
+
Persona cards are product defaults rather than canonical memory records. Applications map a card's
|
|
49
|
+
prompt, traits, greeting, and memory seeds onto their own persona manifest and seeding policy.
|
|
50
|
+
|
|
51
|
+
### Core
|
|
52
|
+
|
|
53
|
+
`src/core` owns:
|
|
54
|
+
|
|
55
|
+
- The canonical memory schema and lifecycle
|
|
56
|
+
- Extraction and embedding ports
|
|
57
|
+
- Ingestion, provenance validation, consolidation, and lifecycle controls
|
|
58
|
+
- Retrieval constraints and prompt-budget packing
|
|
59
|
+
- Provider-independent errors
|
|
60
|
+
|
|
61
|
+
It does not own credentials, HTTP clients, or database connections.
|
|
62
|
+
|
|
63
|
+
### Providers
|
|
64
|
+
|
|
65
|
+
`src/providers` adapts vendor SDKs to the core ports.
|
|
66
|
+
|
|
67
|
+
- OpenAI extraction uses Responses API structured output.
|
|
68
|
+
- Bedrock extraction uses Converse structured output.
|
|
69
|
+
- OpenAI embeddings use the embeddings API.
|
|
70
|
+
- Bedrock embeddings use Titan Text Embeddings V2 through InvokeModel.
|
|
71
|
+
|
|
72
|
+
Provider responses are validated again with Zod at the boundary. Structured output protects syntax;
|
|
73
|
+
runtime validation protects domain constraints and produces stable errors.
|
|
74
|
+
|
|
75
|
+
### Stores
|
|
76
|
+
|
|
77
|
+
`src/stores` owns persistence adapters.
|
|
78
|
+
|
|
79
|
+
- `InMemoryMemoryStore` is deterministic and intended for tests or short-lived processes.
|
|
80
|
+
- `JsonFileMemoryStore` is a local reference adapter with versioned files, serialized writes, and
|
|
81
|
+
temporary-file replacement.
|
|
82
|
+
- `SQLiteMemoryStore` uses WAL mode, indexes, and transactional batch writes for durable
|
|
83
|
+
deployments.
|
|
84
|
+
|
|
85
|
+
The store persists complete canonical records. Vectors can always be regenerated from `content`.
|
|
86
|
+
|
|
87
|
+
## Ingestion lifecycle
|
|
88
|
+
|
|
89
|
+
```text
|
|
90
|
+
messages
|
|
91
|
+
-> normalize and validate
|
|
92
|
+
-> provider extraction
|
|
93
|
+
-> validate schema and source-message provenance
|
|
94
|
+
-> discard low-confidence candidates
|
|
95
|
+
-> consolidation (merge, supersede, conflict, or keep)
|
|
96
|
+
-> generate embeddings for new records
|
|
97
|
+
-> batch persistence
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The runtime never accepts a source message ID invented by a model. Candidates with no remaining
|
|
101
|
+
valid provenance are discarded.
|
|
102
|
+
|
|
103
|
+
Consolidation is a replaceable policy rather than database behavior. The default policy merges
|
|
104
|
+
normalized/semantic duplicates, supersedes mutable state, and surfaces contradictions to the caller.
|
|
105
|
+
|
|
106
|
+
## Recall lifecycle
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
query
|
|
110
|
+
-> optional query embedding
|
|
111
|
+
-> scope and identity filters
|
|
112
|
+
-> semantic + lexical + importance + recency scoring
|
|
113
|
+
-> expiry filtering
|
|
114
|
+
-> token-budget packing
|
|
115
|
+
-> bounded, explicitly untrusted memory context
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The prompt renderer labels recalled content as recollection rather than instruction. Applications
|
|
119
|
+
should place the resulting block in contextual data, never above their security or behavior policy.
|
|
120
|
+
|
|
121
|
+
## Identity and isolation
|
|
122
|
+
|
|
123
|
+
`characterId` is required on every operation. `userId` defaults to `null` and is included in
|
|
124
|
+
retrieval filters. Applications should use opaque stable IDs, not mutable display names.
|
|
125
|
+
|
|
126
|
+
The service adapter resolves API keys to tenant IDs, but its store factory must also provide
|
|
127
|
+
physical or logical tenant partitioning. Do not encode tenancy only in vector metadata.
|
|
128
|
+
|
|
129
|
+
## Failure behavior
|
|
130
|
+
|
|
131
|
+
- Provider refusals, truncated output, malformed JSON, and schema violations fail ingestion without
|
|
132
|
+
partially writing new records.
|
|
133
|
+
- Embedding count mismatches fail before persistence.
|
|
134
|
+
- File writes are serialized and atomically replaced.
|
|
135
|
+
- Empty conversations and empty recalls are valid and return empty results.
|
|
136
|
+
|
|
137
|
+
## Higher layers
|
|
138
|
+
|
|
139
|
+
`src/persona` owns manifests, prompt compilation, relationship state, delivery hints, and response
|
|
140
|
+
orchestration. `src/service` wraps persona runtimes in tenant-aware HTTP routes. `src/sillytavern`
|
|
141
|
+
is a compatibility boundary, so card fields do not leak into the canonical schema. `src/evaluation`
|
|
142
|
+
measures retrieval hit rate/MRR and aggregates deterministic drift checks.
|
|
143
|
+
|
|
144
|
+
## Package exports
|
|
145
|
+
|
|
146
|
+
The root export contains core, the in-memory store, and the bundled persona catalog. Heavy or
|
|
147
|
+
environment-specific adapters use explicit subpaths:
|
|
148
|
+
|
|
149
|
+
```text
|
|
150
|
+
persona-ai-sdk
|
|
151
|
+
persona-ai-sdk/personas
|
|
152
|
+
persona-ai-sdk/personas/*
|
|
153
|
+
persona-ai-sdk/openai
|
|
154
|
+
persona-ai-sdk/bedrock
|
|
155
|
+
persona-ai-sdk/stores/json-file
|
|
156
|
+
persona-ai-sdk/stores/sqlite
|
|
157
|
+
persona-ai-sdk/persona
|
|
158
|
+
persona-ai-sdk/sillytavern
|
|
159
|
+
persona-ai-sdk/service
|
|
160
|
+
persona-ai-sdk/evaluation
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
This prevents browser or edge consumers from loading AWS and filesystem code accidentally and gives
|
|
164
|
+
the package room to split adapters into optional packages later without changing the core API.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0 - 2026-10-31
|
|
4
|
+
|
|
5
|
+
- Initial public release.
|
|
6
|
+
- Character memory runtime: extraction, hybrid recall, consolidation, lifecycle controls, atomic
|
|
7
|
+
JSON-file and SQLite stores.
|
|
8
|
+
- Provider adapters: OpenAI Responses API and Amazon Bedrock Converse, Titan V2 embeddings,
|
|
9
|
+
character models.
|
|
10
|
+
- Persona response runtime with relationship state and JSON state persistence.
|
|
11
|
+
- Eight default persona cards: atlas, sage, vera, scout, wren, ember, lumen, mica.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# Contributing
|
|
4
|
+
|
|
5
|
+
Thank you for helping characters stay coherent, portable, and safe.
|
|
6
|
+
|
|
7
|
+
[README](./README.md) · [Documentation](./docs/README.md) · [Architecture](./ARCHITECTURE.md)
|
|
8
|
+
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
- Node.js 20 or newer
|
|
16
|
+
- npm compatible with the committed lockfile
|
|
17
|
+
- Git
|
|
18
|
+
- A native build environment if your platform cannot use a prebuilt `better-sqlite3` binary
|
|
19
|
+
|
|
20
|
+
Provider credentials are not required for normal development or CI.
|
|
21
|
+
|
|
22
|
+
## Set up
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install
|
|
26
|
+
npm run check
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The check must pass before and after a change:
|
|
30
|
+
|
|
31
|
+
1. Prettier formatting check
|
|
32
|
+
2. Strict TypeScript type check
|
|
33
|
+
3. Deterministic Vitest suite
|
|
34
|
+
4. Distribution build
|
|
35
|
+
|
|
36
|
+
## Development commands
|
|
37
|
+
|
|
38
|
+
| Command | Purpose |
|
|
39
|
+
| ---------------------- | ------------------------------------------ |
|
|
40
|
+
| `npm run build` | Compile distributable ESM and declarations |
|
|
41
|
+
| `npm run format` | Format code and Markdown |
|
|
42
|
+
| `npm run format:check` | Check formatting without changing files |
|
|
43
|
+
| `npm run docs:check` | Verify local Markdown links resolve |
|
|
44
|
+
| `npm test` | Run deterministic tests once |
|
|
45
|
+
| `npm run test:watch` | Run tests in watch mode |
|
|
46
|
+
| `npm run typecheck` | Check strict TypeScript without emitting |
|
|
47
|
+
| `npm run check` | Run every required validation step |
|
|
48
|
+
| `npm pack --dry-run` | Inspect the npm package payload |
|
|
49
|
+
|
|
50
|
+
## Change workflow
|
|
51
|
+
|
|
52
|
+
1. Read the relevant guide and source boundary.
|
|
53
|
+
2. Keep the change focused on one user-visible outcome.
|
|
54
|
+
3. Add or update deterministic tests.
|
|
55
|
+
4. Update the API reference and task guide when behavior changes.
|
|
56
|
+
5. Add a changelog entry for notable user-facing changes.
|
|
57
|
+
6. Run `npm run check` and `npm pack --dry-run`.
|
|
58
|
+
7. Review the diff for credentials, generated junk, unrelated formatting, and accidental breaking
|
|
59
|
+
changes.
|
|
60
|
+
|
|
61
|
+
Use Conventional Commit-style subjects where practical:
|
|
62
|
+
|
|
63
|
+
```text
|
|
64
|
+
feat(memory): add postgres store adapter
|
|
65
|
+
fix(sillytavern): preserve multiline example dialogue
|
|
66
|
+
docs(api): document consolidation decisions
|
|
67
|
+
test(service): cover tenant isolation
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Do not alter commit timestamps or fabricate development history.
|
|
71
|
+
|
|
72
|
+
## Architectural rules
|
|
73
|
+
|
|
74
|
+
### Core remains provider-neutral
|
|
75
|
+
|
|
76
|
+
Code in `src/core` must not import OpenAI, AWS, HTTP frameworks, or Node filesystem/database
|
|
77
|
+
modules. Define a port in core and implement vendor behavior in an adapter.
|
|
78
|
+
|
|
79
|
+
### Validate at boundaries
|
|
80
|
+
|
|
81
|
+
- Validate provider structured output even when the provider claims schema conformance.
|
|
82
|
+
- Validate untrusted cards, chat exports, HTTP bodies, and persisted records.
|
|
83
|
+
- Preserve source-message provenance.
|
|
84
|
+
- Fail before persistence when a batch is inconsistent.
|
|
85
|
+
|
|
86
|
+
### Preserve canonical records
|
|
87
|
+
|
|
88
|
+
Store adapters must persist the complete `MemoryRecord`. Embeddings are rebuildable indexes;
|
|
89
|
+
content, provenance, lifecycle, visibility, and identity are not.
|
|
90
|
+
|
|
91
|
+
### Keep tenant isolation explicit
|
|
92
|
+
|
|
93
|
+
Do not add a production service store that relies only on vector metadata or process-local
|
|
94
|
+
filtering. Tenant identity must be part of durable keys and queries.
|
|
95
|
+
|
|
96
|
+
### Respect licensing boundaries
|
|
97
|
+
|
|
98
|
+
This repository is MIT licensed. Do not copy AGPL SillyTavern source or third-party extension code
|
|
99
|
+
into it. Implement compatibility from public formats and APIs, and preserve required notices for any
|
|
100
|
+
new dependency or adapted code.
|
|
101
|
+
|
|
102
|
+
## Testing expectations
|
|
103
|
+
|
|
104
|
+
Every public behavior needs a test covering the outcome and relevant failure path.
|
|
105
|
+
|
|
106
|
+
| Change | Minimum coverage |
|
|
107
|
+
| --------------------- | ----------------------------------------------------------- |
|
|
108
|
+
| Core lifecycle | Created/merged/superseded/conflict result and stored state |
|
|
109
|
+
| Store | Round-trip, filtering, and failure/transaction behavior |
|
|
110
|
+
| Provider adapter | Exact SDK request shape and malformed response handling |
|
|
111
|
+
| Persona | Compiled instruction or state transition and response trace |
|
|
112
|
+
| Importer | Representative fixture plus malformed input |
|
|
113
|
+
| Service route | Authentication, tenant behavior, status, and response body |
|
|
114
|
+
| Documentation example | Typechecked equivalent or nearby tested usage |
|
|
115
|
+
|
|
116
|
+
Normal tests must not call paid APIs. Inject provider clients and return deterministic fixtures.
|
|
117
|
+
|
|
118
|
+
Live smoke tests are explicitly opt-in:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
RUN_LIVE_PROVIDER_TESTS=1 npm test
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Only run them in an approved account with spend controls.
|
|
125
|
+
|
|
126
|
+
## Documentation expectations
|
|
127
|
+
|
|
128
|
+
Documentation follows a layered approach: a navigable README, task tutorials, conceptual
|
|
129
|
+
explanation, API reference, contribution guidance, license, and version history.
|
|
130
|
+
|
|
131
|
+
When adding a public function, document:
|
|
132
|
+
|
|
133
|
+
- What it does
|
|
134
|
+
- Import path
|
|
135
|
+
- Parameters and defaults
|
|
136
|
+
- Return value
|
|
137
|
+
- Side effects
|
|
138
|
+
- Failure behavior
|
|
139
|
+
- A minimal example when usage is not obvious
|
|
140
|
+
|
|
141
|
+
Use descriptive filenames, stable headings, relative links, accessible image alt text, and explicit
|
|
142
|
+
placeholders. Do not add badges for CI, npm, coverage, security, or compatibility unless the
|
|
143
|
+
underlying claim is real and maintained.
|
|
144
|
+
|
|
145
|
+
## Style
|
|
146
|
+
|
|
147
|
+
- Prefer plain language and precise names.
|
|
148
|
+
- Keep provider terminology at provider boundaries.
|
|
149
|
+
- Use ISO 8601 timestamps in data and documentation.
|
|
150
|
+
- Explain why a constraint exists when it is not obvious.
|
|
151
|
+
- Avoid comments that merely repeat code.
|
|
152
|
+
- Avoid introducing a dependency for behavior that is small and auditable.
|
|
153
|
+
- Preserve strict TypeScript settings; do not suppress errors with broad `any` casts.
|
|
154
|
+
|
|
155
|
+
## Compatibility and breaking changes
|
|
156
|
+
|
|
157
|
+
Version `0.x` may still evolve, but breaking changes should be deliberate. A breaking proposal must
|
|
158
|
+
describe:
|
|
159
|
+
|
|
160
|
+
- Affected imports and types
|
|
161
|
+
- Migration path
|
|
162
|
+
- Persistence/schema implications
|
|
163
|
+
- Provider behavior changes
|
|
164
|
+
- Whether old exports or store files remain readable
|
|
165
|
+
|
|
166
|
+
Store format changes need a forward migration and a fixture proving the previous supported version
|
|
167
|
+
still loads, unless the release explicitly documents otherwise.
|
|
168
|
+
|
|
169
|
+
## Security-sensitive changes
|
|
170
|
+
|
|
171
|
+
Read [docs/SECURITY.md](./docs/SECURITY.md) before modifying authentication, CORS, tenancy,
|
|
172
|
+
visibility, imports, export/erasure, logging, or provider credential handling.
|
|
173
|
+
|
|
174
|
+
Do not put a vulnerability, credential, or real private conversation into a public issue or test
|
|
175
|
+
fixture. Use the hosting platform's private vulnerability-reporting channel for sensitive reports.
|
|
176
|
+
|
|
177
|
+
## Review checklist
|
|
178
|
+
|
|
179
|
+
- [ ] The change has one clear outcome
|
|
180
|
+
- [ ] Public inputs are validated
|
|
181
|
+
- [ ] Tests are deterministic and meaningful
|
|
182
|
+
- [ ] Provider calls do not silently change defaults
|
|
183
|
+
- [ ] Tenant/user/character identity is preserved
|
|
184
|
+
- [ ] Secrets and message content are not logged
|
|
185
|
+
- [ ] Relevant documentation and changelog are updated
|
|
186
|
+
- [ ] `npm run check` passes
|
|
187
|
+
- [ ] `npm pack --dry-run` contains only intended files
|
|
188
|
+
- [ ] No unrelated user changes were overwritten
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
By contributing, you agree that your contribution may be distributed under the project's
|
|
193
|
+
[MIT License](./LICENSE).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tavern Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|