* feat: independent versioning for integrations
- Add per-integration changelog pages at /changelog/integrations/<name>
- Move main changelog to changelog/index.md (URL unchanged)
- Add --integration flag to generate-changelog for LLM-based per-integration changelog generation
- Add scripts/release-integration.sh <name> <version> for cutting integration releases
- Add .github/workflows/release-integration.yml to publish on integrations/** tags
- Remove integrations from main release.sh and release.yml cycle
* fix: add agno and hermes integration docs to version-0.4 for production build
* chore: apply ruff formatting to generate_changelog.py
* feat: add 4-tab code parity across all documentation examples
Every code snippet Tabs block now has Python, Node.js, CLI, and Go variants.
Raw HTTP/curl tabs replaced with proper SDK calls.
New example files:
- Go: retain.go, recall.go, reflect.go, memory-banks.go, directives.go,
mental-models.go, documents.go, main-methods.go
- Shell: memory-banks.sh, directives.sh, mental-models.sh
- Node.js: mental-models.mjs
Extended example files with missing sections:
- recall.mjs/sh: world/experience/observation types, token-budget, all tag modes
- reflect.sh: reflect-with-params, reflect-disposition, reflect-sources, reflect-with-tags
- reflect.mjs: reflect-with-tags, fixed reflect-sources API usage
- retain.mjs/sh: retain-conversation, retain-batch, retain-files-batch
SDK/CLI additions:
- TypeScript: getMentalModelHistory method
- CLI recall: --tags, --tags-match flags
- CLI reflect: --tags, --tags-match, --include-facts flags
- CLI directive update: --is-active flag
- CLI bank set-config: --retain-mission, --retain-extraction-mode,
--observations-mission, --reflect-mission, --disposition-* flags
Build validation:
- scripts/check-code-parity.mjs validates 4-tab parity across all MDX files
- Integrated into npm run build — fails if any Tabs block is missing a variant
* fix: fix doc examples for Go, Node.js, CLI + add mental model with-id examples
- Fix Go Budget constants: BUDGET_HIGH/LOW/MID → HIGH/LOW/MID
- Fix Go documents.go: ListDocuments returns []map[string]interface{}, use map access
- Fix Go retain.go: use correct relative path for sample.pdf
- Fix Node.js createMentalModel: use positional args (name, sourceQuery) not object
- Add CLI 'history' subcommand for mental models (api.rs, main.rs, mental_model.rs)
- Rebuild TypeScript/Python clients to support id param in createMentalModel
- Add create-mental-model-with-id examples across all 4 languages and docs
* fix: move id param to end of create_mental_model signature for backwards compat
115 lines
3.9 KiB
JavaScript
115 lines
3.9 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Reflect API examples for Hindsight (Node.js)
|
|
* Run: node examples/api/reflect.mjs
|
|
*/
|
|
import { HindsightClient } from '@vectorize-io/hindsight-client';
|
|
|
|
const HINDSIGHT_URL = process.env.HINDSIGHT_API_URL || 'http://localhost:8888';
|
|
|
|
// =============================================================================
|
|
// Setup (not shown in docs)
|
|
// =============================================================================
|
|
const client = new HindsightClient({ baseUrl: HINDSIGHT_URL });
|
|
|
|
// Seed some data for reflect examples
|
|
await client.retain('my-bank', 'Alice works at Google as a software engineer');
|
|
await client.retain('my-bank', 'Alice has been working there for 5 years');
|
|
await client.retain('my-bank', 'Alice recently got promoted to senior engineer');
|
|
|
|
// =============================================================================
|
|
// Doc Examples
|
|
// =============================================================================
|
|
|
|
// [docs:reflect-basic]
|
|
await client.reflect('my-bank', 'What should I know about Alice?');
|
|
// [/docs:reflect-basic]
|
|
|
|
|
|
// [docs:reflect-with-params]
|
|
const response = await client.reflect('my-bank', 'What do you think about remote work?', {
|
|
budget: 'mid',
|
|
context: "We're considering a hybrid work policy"
|
|
});
|
|
// [/docs:reflect-with-params]
|
|
|
|
|
|
// [docs:reflect-with-context]
|
|
// Context helps the LLM understand the current situation
|
|
const contextResponse = await client.reflect('my-bank', 'What do you think about the proposal?', {
|
|
context: "We're in a budget review meeting discussing Q4 spending"
|
|
});
|
|
// [/docs:reflect-with-context]
|
|
|
|
|
|
// [docs:reflect-disposition]
|
|
// Create a bank with specific disposition
|
|
await client.createBank('cautious-advisor', {
|
|
name: 'Cautious Advisor',
|
|
background: 'I am a risk-aware financial advisor',
|
|
disposition: {
|
|
skepticism: 5,
|
|
literalism: 4,
|
|
empathy: 2
|
|
}
|
|
});
|
|
|
|
// Reflect responses will reflect this disposition
|
|
const advisorResponse = await client.reflect('cautious-advisor', 'Should I invest in crypto?');
|
|
// [/docs:reflect-disposition]
|
|
|
|
|
|
// [docs:reflect-sources]
|
|
const sourcesResponse = await client.reflect('my-bank', 'Tell me about Alice', {
|
|
includeFacts: true
|
|
});
|
|
|
|
console.log('Response:', sourcesResponse.text);
|
|
console.log('\nBased on:');
|
|
for (const fact of (sourcesResponse.based_on?.memories || [])) {
|
|
console.log(` - [${fact.type}] ${fact.text}`);
|
|
}
|
|
// [/docs:reflect-sources]
|
|
|
|
|
|
// [docs:reflect-with-tags]
|
|
// Filter reflect to only use memories tagged for a specific user
|
|
await client.reflect('my-bank', 'What feedback did the user give?', {
|
|
tags: ['user:alice'],
|
|
tagsMatch: 'any_strict'
|
|
});
|
|
// [/docs:reflect-with-tags]
|
|
|
|
|
|
// [docs:reflect-structured-output]
|
|
// Define JSON schema directly
|
|
const responseSchema = {
|
|
type: 'object',
|
|
properties: {
|
|
recommendation: { type: 'string' },
|
|
confidence: { type: 'string', enum: ['low', 'medium', 'high'] },
|
|
key_factors: { type: 'array', items: { type: 'string' } },
|
|
risks: { type: 'array', items: { type: 'string' } },
|
|
},
|
|
required: ['recommendation', 'confidence', 'key_factors'],
|
|
};
|
|
|
|
const structuredResponse = await client.reflect('my-bank', 'What do you know about Alice and her career?', {
|
|
responseSchema: responseSchema,
|
|
});
|
|
|
|
// Structured output (if returned)
|
|
if (structuredResponse.structuredOutput) {
|
|
console.log('Recommendation:', structuredResponse.structuredOutput.recommendation || 'N/A');
|
|
console.log('Key factors:', structuredResponse.structuredOutput.key_factors || []);
|
|
}
|
|
// [/docs:reflect-structured-output]
|
|
|
|
|
|
// =============================================================================
|
|
// Cleanup (not shown in docs)
|
|
// =============================================================================
|
|
await fetch(`${HINDSIGHT_URL}/v1/default/banks/my-bank`, { method: 'DELETE' });
|
|
await fetch(`${HINDSIGHT_URL}/v1/default/banks/cautious-advisor`, { method: 'DELETE' });
|
|
|
|
console.log('reflect.mjs: All examples passed');
|