@itaila/archetype 0.3.30
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/LICENSE +21 -0
- package/README.md +475 -0
- package/dist/audit/audit-persona.d.ts +163 -0
- package/dist/audit/audit-persona.d.ts.map +1 -0
- package/dist/audit/audit-persona.js +415 -0
- package/dist/audit/audit-persona.js.map +1 -0
- package/dist/audit/brain-reflection.d.ts +33 -0
- package/dist/audit/brain-reflection.d.ts.map +1 -0
- package/dist/audit/brain-reflection.js +148 -0
- package/dist/audit/brain-reflection.js.map +1 -0
- package/dist/audit/conversation-audit.d.ts +12 -0
- package/dist/audit/conversation-audit.d.ts.map +1 -0
- package/dist/audit/conversation-audit.js +76 -0
- package/dist/audit/conversation-audit.js.map +1 -0
- package/dist/audit/prompt-audit.d.ts +10 -0
- package/dist/audit/prompt-audit.d.ts.map +1 -0
- package/dist/audit/prompt-audit.js +153 -0
- package/dist/audit/prompt-audit.js.map +1 -0
- package/dist/audit/prompt-dump.d.ts +137 -0
- package/dist/audit/prompt-dump.d.ts.map +1 -0
- package/dist/audit/prompt-dump.js +269 -0
- package/dist/audit/prompt-dump.js.map +1 -0
- package/dist/audit/trace-integrity.d.ts +33 -0
- package/dist/audit/trace-integrity.d.ts.map +1 -0
- package/dist/audit/trace-integrity.js +109 -0
- package/dist/audit/trace-integrity.js.map +1 -0
- package/dist/audit/types.d.ts +92 -0
- package/dist/audit/types.d.ts.map +1 -0
- package/dist/audit/types.js +2 -0
- package/dist/audit/types.js.map +1 -0
- package/dist/audit/version.d.ts +14 -0
- package/dist/audit/version.d.ts.map +1 -0
- package/dist/audit/version.js +65 -0
- package/dist/audit/version.js.map +1 -0
- package/dist/brain.d.ts +7 -0
- package/dist/brain.d.ts.map +1 -0
- package/dist/brain.js +83 -0
- package/dist/brain.js.map +1 -0
- package/dist/builder/actions.d.ts +60 -0
- package/dist/builder/actions.d.ts.map +1 -0
- package/dist/builder/actions.js +257 -0
- package/dist/builder/actions.js.map +1 -0
- package/dist/builder/browser.d.ts +140 -0
- package/dist/builder/browser.d.ts.map +1 -0
- package/dist/builder/browser.js +232 -0
- package/dist/builder/browser.js.map +1 -0
- package/dist/builder/executor.d.ts +228 -0
- package/dist/builder/executor.d.ts.map +1 -0
- package/dist/builder/executor.js +1548 -0
- package/dist/builder/executor.js.map +1 -0
- package/dist/builder/index.d.ts +24 -0
- package/dist/builder/index.d.ts.map +1 -0
- package/dist/builder/index.js +24 -0
- package/dist/builder/index.js.map +1 -0
- package/dist/builder/node-test-discovery.d.ts +13 -0
- package/dist/builder/node-test-discovery.d.ts.map +1 -0
- package/dist/builder/node-test-discovery.js +45 -0
- package/dist/builder/node-test-discovery.js.map +1 -0
- package/dist/builder/sandbox.d.ts +172 -0
- package/dist/builder/sandbox.d.ts.map +1 -0
- package/dist/builder/sandbox.js +294 -0
- package/dist/builder/sandbox.js.map +1 -0
- package/dist/builder/workspace-files.d.ts +63 -0
- package/dist/builder/workspace-files.d.ts.map +1 -0
- package/dist/builder/workspace-files.js +190 -0
- package/dist/builder/workspace-files.js.map +1 -0
- package/dist/core/actions.d.ts +55 -0
- package/dist/core/actions.d.ts.map +1 -0
- package/dist/core/actions.js +311 -0
- package/dist/core/actions.js.map +1 -0
- package/dist/core/attachment-notes.d.ts +7 -0
- package/dist/core/attachment-notes.d.ts.map +1 -0
- package/dist/core/attachment-notes.js +38 -0
- package/dist/core/attachment-notes.js.map +1 -0
- package/dist/core/context.d.ts +10 -0
- package/dist/core/context.d.ts.map +1 -0
- package/dist/core/context.js +108 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/crud-prompt.d.ts +16 -0
- package/dist/core/crud-prompt.d.ts.map +1 -0
- package/dist/core/crud-prompt.js +268 -0
- package/dist/core/crud-prompt.js.map +1 -0
- package/dist/core/crud-schema.d.ts +12 -0
- package/dist/core/crud-schema.d.ts.map +1 -0
- package/dist/core/crud-schema.js +42 -0
- package/dist/core/crud-schema.js.map +1 -0
- package/dist/core/effective-config.d.ts +13 -0
- package/dist/core/effective-config.d.ts.map +1 -0
- package/dist/core/effective-config.js +33 -0
- package/dist/core/effective-config.js.map +1 -0
- package/dist/core/entities.d.ts +82 -0
- package/dist/core/entities.d.ts.map +1 -0
- package/dist/core/entities.js +116 -0
- package/dist/core/entities.js.map +1 -0
- package/dist/core/entity-helpers.d.ts +47 -0
- package/dist/core/entity-helpers.d.ts.map +1 -0
- package/dist/core/entity-helpers.js +122 -0
- package/dist/core/entity-helpers.js.map +1 -0
- package/dist/core/entity-registry.d.ts +47 -0
- package/dist/core/entity-registry.d.ts.map +1 -0
- package/dist/core/entity-registry.js +54 -0
- package/dist/core/entity-registry.js.map +1 -0
- package/dist/core/eq.d.ts +13 -0
- package/dist/core/eq.d.ts.map +1 -0
- package/dist/core/eq.js +41 -0
- package/dist/core/eq.js.map +1 -0
- package/dist/core/focus-context.d.ts +19 -0
- package/dist/core/focus-context.d.ts.map +1 -0
- package/dist/core/focus-context.js +46 -0
- package/dist/core/focus-context.js.map +1 -0
- package/dist/core/focus-mode-actions.d.ts +23 -0
- package/dist/core/focus-mode-actions.d.ts.map +1 -0
- package/dist/core/focus-mode-actions.js +74 -0
- package/dist/core/focus-mode-actions.js.map +1 -0
- package/dist/core/greeting.d.ts +10 -0
- package/dist/core/greeting.d.ts.map +1 -0
- package/dist/core/greeting.js +41 -0
- package/dist/core/greeting.js.map +1 -0
- package/dist/core/identity.d.ts +13 -0
- package/dist/core/identity.d.ts.map +1 -0
- package/dist/core/identity.js +54 -0
- package/dist/core/identity.js.map +1 -0
- package/dist/core/knowledge.d.ts +10 -0
- package/dist/core/knowledge.d.ts.map +1 -0
- package/dist/core/knowledge.js +40 -0
- package/dist/core/knowledge.js.map +1 -0
- package/dist/core/memory-actions.d.ts +38 -0
- package/dist/core/memory-actions.d.ts.map +1 -0
- package/dist/core/memory-actions.js +181 -0
- package/dist/core/memory-actions.js.map +1 -0
- package/dist/core/memory.d.ts +35 -0
- package/dist/core/memory.d.ts.map +1 -0
- package/dist/core/memory.js +168 -0
- package/dist/core/memory.js.map +1 -0
- package/dist/core/peer-actions.d.ts +15 -0
- package/dist/core/peer-actions.d.ts.map +1 -0
- package/dist/core/peer-actions.js +33 -0
- package/dist/core/peer-actions.js.map +1 -0
- package/dist/core/prompt-builder.d.ts +46 -0
- package/dist/core/prompt-builder.d.ts.map +1 -0
- package/dist/core/prompt-builder.js +543 -0
- package/dist/core/prompt-builder.js.map +1 -0
- package/dist/core/prompt-mode.d.ts +3 -0
- package/dist/core/prompt-mode.d.ts.map +1 -0
- package/dist/core/prompt-mode.js +6 -0
- package/dist/core/prompt-mode.js.map +1 -0
- package/dist/core/prompted-turn.d.ts +6 -0
- package/dist/core/prompted-turn.d.ts.map +1 -0
- package/dist/core/prompted-turn.js +48 -0
- package/dist/core/prompted-turn.js.map +1 -0
- package/dist/core/request-builder.d.ts +14 -0
- package/dist/core/request-builder.d.ts.map +1 -0
- package/dist/core/request-builder.js +64 -0
- package/dist/core/request-builder.js.map +1 -0
- package/dist/core/session-routing.d.ts +23 -0
- package/dist/core/session-routing.d.ts.map +1 -0
- package/dist/core/session-routing.js +59 -0
- package/dist/core/session-routing.js.map +1 -0
- package/dist/core/voice.d.ts +6 -0
- package/dist/core/voice.d.ts.map +1 -0
- package/dist/core/voice.js +30 -0
- package/dist/core/voice.js.map +1 -0
- package/dist/engine/chat.d.ts +45 -0
- package/dist/engine/chat.d.ts.map +1 -0
- package/dist/engine/chat.js +308 -0
- package/dist/engine/chat.js.map +1 -0
- package/dist/engine/continuity.d.ts +107 -0
- package/dist/engine/continuity.d.ts.map +1 -0
- package/dist/engine/continuity.js +320 -0
- package/dist/engine/continuity.js.map +1 -0
- package/dist/engine/crud.d.ts +62 -0
- package/dist/engine/crud.d.ts.map +1 -0
- package/dist/engine/crud.js +260 -0
- package/dist/engine/crud.js.map +1 -0
- package/dist/engine/side-effects.d.ts +93 -0
- package/dist/engine/side-effects.d.ts.map +1 -0
- package/dist/engine/side-effects.js +271 -0
- package/dist/engine/side-effects.js.map +1 -0
- package/dist/engine/staging.d.ts +29 -0
- package/dist/engine/staging.d.ts.map +1 -0
- package/dist/engine/staging.js +159 -0
- package/dist/engine/staging.js.map +1 -0
- package/dist/engine/working-set.d.ts +18 -0
- package/dist/engine/working-set.d.ts.map +1 -0
- package/dist/engine/working-set.js +246 -0
- package/dist/engine/working-set.js.map +1 -0
- package/dist/evals/action-contracts.d.ts +40 -0
- package/dist/evals/action-contracts.d.ts.map +1 -0
- package/dist/evals/action-contracts.js +208 -0
- package/dist/evals/action-contracts.js.map +1 -0
- package/dist/evals/brain-bloat.d.ts +39 -0
- package/dist/evals/brain-bloat.d.ts.map +1 -0
- package/dist/evals/brain-bloat.js +167 -0
- package/dist/evals/brain-bloat.js.map +1 -0
- package/dist/evals/brain-prescriptions.d.ts +30 -0
- package/dist/evals/brain-prescriptions.d.ts.map +1 -0
- package/dist/evals/brain-prescriptions.js +148 -0
- package/dist/evals/brain-prescriptions.js.map +1 -0
- package/dist/evals/cross-layer-duplicates.d.ts +49 -0
- package/dist/evals/cross-layer-duplicates.d.ts.map +1 -0
- package/dist/evals/cross-layer-duplicates.js +289 -0
- package/dist/evals/cross-layer-duplicates.js.map +1 -0
- package/dist/evals/entity-visibility.d.ts +28 -0
- package/dist/evals/entity-visibility.d.ts.map +1 -0
- package/dist/evals/entity-visibility.js +216 -0
- package/dist/evals/entity-visibility.js.map +1 -0
- package/dist/evals/index.d.ts +19 -0
- package/dist/evals/index.d.ts.map +1 -0
- package/dist/evals/index.js +11 -0
- package/dist/evals/index.js.map +1 -0
- package/dist/evals/judge.d.ts +22 -0
- package/dist/evals/judge.d.ts.map +1 -0
- package/dist/evals/judge.js +337 -0
- package/dist/evals/judge.js.map +1 -0
- package/dist/evals/operational-contract.d.ts +40 -0
- package/dist/evals/operational-contract.d.ts.map +1 -0
- package/dist/evals/operational-contract.js +115 -0
- package/dist/evals/operational-contract.js.map +1 -0
- package/dist/evals/prompt-content.d.ts +14 -0
- package/dist/evals/prompt-content.d.ts.map +1 -0
- package/dist/evals/prompt-content.js +104 -0
- package/dist/evals/prompt-content.js.map +1 -0
- package/dist/evals/runtime.d.ts +4 -0
- package/dist/evals/runtime.d.ts.map +1 -0
- package/dist/evals/runtime.js +197 -0
- package/dist/evals/runtime.js.map +1 -0
- package/dist/evals/sample-projects.d.ts +143 -0
- package/dist/evals/sample-projects.d.ts.map +1 -0
- package/dist/evals/sample-projects.js +644 -0
- package/dist/evals/sample-projects.js.map +1 -0
- package/dist/evals/types.d.ts +88 -0
- package/dist/evals/types.d.ts.map +1 -0
- package/dist/evals/types.js +2 -0
- package/dist/evals/types.js.map +1 -0
- package/dist/foundation/index.d.ts +158 -0
- package/dist/foundation/index.d.ts.map +1 -0
- package/dist/foundation/index.js +256 -0
- package/dist/foundation/index.js.map +1 -0
- package/dist/index.d.ts +223 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +998 -0
- package/dist/index.js.map +1 -0
- package/dist/managed/autonomous-loop.d.ts +199 -0
- package/dist/managed/autonomous-loop.d.ts.map +1 -0
- package/dist/managed/autonomous-loop.js +451 -0
- package/dist/managed/autonomous-loop.js.map +1 -0
- package/dist/managed/conversation.d.ts +20 -0
- package/dist/managed/conversation.d.ts.map +1 -0
- package/dist/managed/conversation.js +40 -0
- package/dist/managed/conversation.js.map +1 -0
- package/dist/managed/knowledge.d.ts +7 -0
- package/dist/managed/knowledge.d.ts.map +1 -0
- package/dist/managed/knowledge.js +174 -0
- package/dist/managed/knowledge.js.map +1 -0
- package/dist/managed/memory-manager.d.ts +7 -0
- package/dist/managed/memory-manager.d.ts.map +1 -0
- package/dist/managed/memory-manager.js +18 -0
- package/dist/managed/memory-manager.js.map +1 -0
- package/dist/managed/memory-review.d.ts +45 -0
- package/dist/managed/memory-review.d.ts.map +1 -0
- package/dist/managed/memory-review.js +130 -0
- package/dist/managed/memory-review.js.map +1 -0
- package/dist/managed/storage.d.ts +2 -0
- package/dist/managed/storage.d.ts.map +1 -0
- package/dist/managed/storage.js +2 -0
- package/dist/managed/storage.js.map +1 -0
- package/dist/managed/work-history.d.ts +23 -0
- package/dist/managed/work-history.d.ts.map +1 -0
- package/dist/managed/work-history.js +31 -0
- package/dist/managed/work-history.js.map +1 -0
- package/dist/observability/index.d.ts +15 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +15 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/render-run-markdown.d.ts +90 -0
- package/dist/observability/render-run-markdown.d.ts.map +1 -0
- package/dist/observability/render-run-markdown.js +231 -0
- package/dist/observability/render-run-markdown.js.map +1 -0
- package/dist/observability/turn-reporter.d.ts +20 -0
- package/dist/observability/turn-reporter.d.ts.map +1 -0
- package/dist/observability/turn-reporter.js +106 -0
- package/dist/observability/turn-reporter.js.map +1 -0
- package/dist/persona.d.ts +49 -0
- package/dist/persona.d.ts.map +1 -0
- package/dist/persona.js +287 -0
- package/dist/persona.js.map +1 -0
- package/dist/playbook/defaults.d.ts +25 -0
- package/dist/playbook/defaults.d.ts.map +1 -0
- package/dist/playbook/defaults.js +108 -0
- package/dist/playbook/defaults.js.map +1 -0
- package/dist/playbook/invariants.d.ts +244 -0
- package/dist/playbook/invariants.d.ts.map +1 -0
- package/dist/playbook/invariants.js +259 -0
- package/dist/playbook/invariants.js.map +1 -0
- package/dist/playbook/templates.d.ts +7 -0
- package/dist/playbook/templates.d.ts.map +1 -0
- package/dist/playbook/templates.js +437 -0
- package/dist/playbook/templates.js.map +1 -0
- package/dist/providers/gemini.d.ts +73 -0
- package/dist/providers/gemini.d.ts.map +1 -0
- package/dist/providers/gemini.js +536 -0
- package/dist/providers/gemini.js.map +1 -0
- package/dist/providers/types.d.ts +2 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +2 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/providers/zod-to-gemini.d.ts +8 -0
- package/dist/providers/zod-to-gemini.d.ts.map +1 -0
- package/dist/providers/zod-to-gemini.js +148 -0
- package/dist/providers/zod-to-gemini.js.map +1 -0
- package/dist/samples/pm-spec-agent.d.ts +22 -0
- package/dist/samples/pm-spec-agent.d.ts.map +1 -0
- package/dist/samples/pm-spec-agent.js +53 -0
- package/dist/samples/pm-spec-agent.js.map +1 -0
- package/dist/types.d.ts +920 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +68 -0
package/dist/persona.js
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { chat, createTrace } from './engine/chat.js';
|
|
2
|
+
import { validateCrudActions } from './engine/crud.js';
|
|
3
|
+
import { shouldGreet } from './core/greeting.js';
|
|
4
|
+
import { buildRetrospectPrompt } from './core/prompt-builder.js';
|
|
5
|
+
import { MEMORY_ACTIONS, CRAFT_MEMORY_ACTIONS } from './core/memory-actions.js';
|
|
6
|
+
import { buildGeminiActionOnlySchema } from './providers/gemini.js';
|
|
7
|
+
import { stripActionAnnotations } from './core/actions.js';
|
|
8
|
+
import { auditPrompt } from './audit/prompt-audit.js';
|
|
9
|
+
import { auditConversation } from './audit/conversation-audit.js';
|
|
10
|
+
import { resolvePromptedTurnMode } from './core/prompt-mode.js';
|
|
11
|
+
import { resolveEntities } from './core/effective-config.js';
|
|
12
|
+
import { toPromptedTurnChatInput } from './core/prompted-turn.js';
|
|
13
|
+
import { resolvePersonaConfigBrain } from './brain.js';
|
|
14
|
+
function filterRetrospectEntities(entities) {
|
|
15
|
+
if (!entities)
|
|
16
|
+
return undefined;
|
|
17
|
+
const filtered = Object.fromEntries(Object.entries(entities).filter(([name]) => name === 'memory' || name === 'craftMemory'));
|
|
18
|
+
return Object.keys(filtered).length > 0 ? filtered : undefined;
|
|
19
|
+
}
|
|
20
|
+
function collectLegacyCrudContractDrift(parsed, label) {
|
|
21
|
+
if (!parsed.crudActions?.length)
|
|
22
|
+
return [];
|
|
23
|
+
return [`${label} used legacy top-level "crudActions" key; use actions[{ "name": "crud", ... }] instead.`];
|
|
24
|
+
}
|
|
25
|
+
function parseRetrospectResponse(text, config) {
|
|
26
|
+
const trace = createTrace();
|
|
27
|
+
try {
|
|
28
|
+
const parsed = JSON.parse(text);
|
|
29
|
+
trace.parseOk = true;
|
|
30
|
+
trace.errors.push(...collectLegacyCrudContractDrift(parsed, 'Retrospect response'));
|
|
31
|
+
// Extract crud actions from the actions array
|
|
32
|
+
const crudActionsFromActions = [];
|
|
33
|
+
const rawActions = parsed.actions ?? [];
|
|
34
|
+
// Also accept legacy top-level crudActions for backward compat
|
|
35
|
+
if (parsed.crudActions?.length) {
|
|
36
|
+
crudActionsFromActions.push(...parsed.crudActions);
|
|
37
|
+
}
|
|
38
|
+
// When memory is CRUD-native (memory entities present), the crud envelope
|
|
39
|
+
// is the only honored memory-mutation path — matching the schema. Named
|
|
40
|
+
// memory actions are NOT valid here; if the model emits one anyway it must
|
|
41
|
+
// be flagged in the trace as unknown_action, never silently treated as
|
|
42
|
+
// valid (which would disagree with the executor and hide the deviation).
|
|
43
|
+
const effectiveEntities = config ? filterRetrospectEntities(resolveEntities(config)) : undefined;
|
|
44
|
+
const memoryIsCrudNative = Boolean(effectiveEntities && Object.keys(effectiveEntities).length > 0);
|
|
45
|
+
// Legacy action-path: only honored for personas that opted out of CRUD-native memory.
|
|
46
|
+
const actions = [];
|
|
47
|
+
const allActions = memoryIsCrudNative
|
|
48
|
+
? {}
|
|
49
|
+
: (config?.craftMemory?.enabled
|
|
50
|
+
? { ...MEMORY_ACTIONS, ...CRAFT_MEMORY_ACTIONS }
|
|
51
|
+
: MEMORY_ACTIONS);
|
|
52
|
+
for (const action of rawActions) {
|
|
53
|
+
if (action.name === 'crud') {
|
|
54
|
+
const p = action.params;
|
|
55
|
+
const innerParams = typeof p.params === 'string' ? p.params : (p.params ? JSON.stringify(p.params) : undefined);
|
|
56
|
+
crudActionsFromActions.push({
|
|
57
|
+
operation: p.operation,
|
|
58
|
+
entity: p.entity,
|
|
59
|
+
id: p.id,
|
|
60
|
+
params: innerParams,
|
|
61
|
+
});
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (!(action.name in allActions)) {
|
|
65
|
+
trace.actions.push({ name: action.name, params: action.params ?? {}, status: 'unknown_action' });
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const parseResult = allActions[action.name].schema.safeParse(action.params ?? {});
|
|
69
|
+
if (!parseResult.success) {
|
|
70
|
+
trace.actions.push({ name: action.name, params: action.params, status: 'invalid', error: parseResult.error.message });
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
actions.push({
|
|
74
|
+
name: action.name,
|
|
75
|
+
params: parseResult.data,
|
|
76
|
+
confidence: allActions[action.name].confidence,
|
|
77
|
+
});
|
|
78
|
+
trace.actions.push({ name: action.name, params: parseResult.data, status: 'valid' });
|
|
79
|
+
}
|
|
80
|
+
// CRUD-path: validate against entity schemas
|
|
81
|
+
let crudActions;
|
|
82
|
+
if (effectiveEntities && crudActionsFromActions.length > 0) {
|
|
83
|
+
const crudValidation = validateCrudActions(crudActionsFromActions, effectiveEntities);
|
|
84
|
+
for (const valid of crudValidation.valid) {
|
|
85
|
+
trace.crudActions.push({ operation: valid.operation, entity: valid.entity, id: valid.id, params: valid.params ?? {}, status: 'valid' });
|
|
86
|
+
}
|
|
87
|
+
for (const inv of crudValidation.invalid) {
|
|
88
|
+
trace.crudActions.push({ operation: inv.action.operation, entity: inv.action.entity, id: inv.action.id, params: inv.action.params ?? {}, status: 'invalid', error: inv.error });
|
|
89
|
+
}
|
|
90
|
+
if (crudValidation.invalid.length > 0) {
|
|
91
|
+
console.warn(`[archetype:retrospect] ${crudValidation.invalid.length} CRUD action(s) failed validation:`, crudValidation.invalid.map(i => `${i.action.operation} ${i.action.entity}: ${i.error}`).join(' | '));
|
|
92
|
+
}
|
|
93
|
+
if (crudValidation.valid.length > 0) {
|
|
94
|
+
crudActions = crudValidation.valid;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const diagnostics = config?.diagnostics?.enabled && parsed.diagnostics?.length
|
|
98
|
+
? parsed.diagnostics.map(d => d.trim()).filter(Boolean)
|
|
99
|
+
: undefined;
|
|
100
|
+
return { actions, crudActions, diagnostics, raw: text, trace };
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
trace.parseOk = false;
|
|
104
|
+
trace.errors.push('Failed to parse retrospect response as JSON');
|
|
105
|
+
return { actions: [], raw: text, trace };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Build the response schema for retrospective passes.
|
|
110
|
+
* When memory entities are registered, includes a crud variant in the actions anyOf.
|
|
111
|
+
* Legacy actions array is kept for backward compat.
|
|
112
|
+
*/
|
|
113
|
+
function buildRetrospectResponseSchema(config, effectiveEntities) {
|
|
114
|
+
const memoryEntities = filterRetrospectEntities(effectiveEntities);
|
|
115
|
+
// Memory is CRUD-native: when memory entities are present, the ONLY memory
|
|
116
|
+
// mutation path the executor can honor is the `crud` action envelope. Offer
|
|
117
|
+
// exactly that — never the legacy per-entity action names (saveMemory,
|
|
118
|
+
// updateMemory, saveCraftMemory…). Offering both lets the model pick a
|
|
119
|
+
// representation the executor then rejects, and a schema that invites an
|
|
120
|
+
// unhonorable shape is bad context, not something to patch around at runtime.
|
|
121
|
+
if (memoryEntities && Object.keys(memoryEntities).length > 0) {
|
|
122
|
+
return buildGeminiActionOnlySchema({}, memoryEntities);
|
|
123
|
+
}
|
|
124
|
+
// No memory entities (a persona that opted out of CRUD-native memory): the
|
|
125
|
+
// legacy named-action interface is the only path that exists for it.
|
|
126
|
+
const legacyActions = config.craftMemory?.enabled
|
|
127
|
+
? { ...MEMORY_ACTIONS, ...CRAFT_MEMORY_ACTIONS }
|
|
128
|
+
: MEMORY_ACTIONS;
|
|
129
|
+
return buildGeminiActionOnlySchema(legacyActions);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* PersonaEngine — the main SDK entry point.
|
|
133
|
+
* Wraps a PersonaConfig and provides the chat interface.
|
|
134
|
+
*/
|
|
135
|
+
export class PersonaEngine {
|
|
136
|
+
config;
|
|
137
|
+
constructor(config) {
|
|
138
|
+
this.config = resolvePersonaConfigBrain(config);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Stateless chat — app manages history + persistence.
|
|
142
|
+
* Build prompt → call LLM → parse response.
|
|
143
|
+
*/
|
|
144
|
+
async chat(input) {
|
|
145
|
+
return chat(this.config, input);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Stateless app-initiated turn — delegates to chat() with the intent
|
|
149
|
+
* framed as a system section, not a user message.
|
|
150
|
+
* The message slot gets a neutral directive so the AI understands
|
|
151
|
+
* this is system-initiated, not user-initiated.
|
|
152
|
+
*/
|
|
153
|
+
async promptedTurn(input) {
|
|
154
|
+
const promptMode = resolvePromptedTurnMode(input.promptMode, input.turnKind);
|
|
155
|
+
const chatInput = {
|
|
156
|
+
...toPromptedTurnChatInput(input),
|
|
157
|
+
promptMode,
|
|
158
|
+
// crudValidation handled below — not passed to chat() because chat()'s
|
|
159
|
+
// retry adds input.message to history, and prompted turns should not
|
|
160
|
+
// fabricate a fresh user utterance.
|
|
161
|
+
};
|
|
162
|
+
const result = await this.chat(chatInput);
|
|
163
|
+
// CRUD validation gate — handled here (not in chat()) to keep retry
|
|
164
|
+
// history clean: no synthetic user message in retry context.
|
|
165
|
+
if (input.crudValidation && result.crudActions && result.crudActions.length > 0) {
|
|
166
|
+
const validationErrors = input.crudValidation(result.crudActions);
|
|
167
|
+
if (validationErrors && validationErrors.length > 0) {
|
|
168
|
+
result.trace.errors.push(...validationErrors.map(e => `CRUD validation rejected: ${e}`));
|
|
169
|
+
const maxRetries = input.crudValidationRetries ?? 1;
|
|
170
|
+
if (maxRetries > 0) {
|
|
171
|
+
const retryGuidance = [
|
|
172
|
+
'--- VALIDATION FEEDBACK (internal) ---',
|
|
173
|
+
'The previous draft had CRUD validation errors:',
|
|
174
|
+
...validationErrors.map(e => `- ${e}`),
|
|
175
|
+
'',
|
|
176
|
+
'Regenerate the complete app-initiated turn for the original intent.',
|
|
177
|
+
'Do not mention validation, correction, retries, the previous draft, or that you fixed anything in the user-facing message.',
|
|
178
|
+
].join('\n');
|
|
179
|
+
return this.promptedTurn({
|
|
180
|
+
...input,
|
|
181
|
+
extraSystemSections: [...(input.extraSystemSections ?? []), retryGuidance],
|
|
182
|
+
crudValidationRetries: maxRetries - 1,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return result;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Stateless retrospective memory pass — infer durable memory updates silently.
|
|
191
|
+
* Returns memory CRUD actions only; no user-facing message.
|
|
192
|
+
*/
|
|
193
|
+
async retrospect(input) {
|
|
194
|
+
const effectiveEntities = filterRetrospectEntities(resolveEntities(this.config));
|
|
195
|
+
const systemPrompt = buildRetrospectPrompt({
|
|
196
|
+
config: { ...this.config, entities: effectiveEntities },
|
|
197
|
+
input: {
|
|
198
|
+
timezone: input.timezone,
|
|
199
|
+
promptNow: input.promptNow,
|
|
200
|
+
userIdentity: input.userIdentity,
|
|
201
|
+
locale: input.locale,
|
|
202
|
+
memories: input.memories,
|
|
203
|
+
knowledgeDocuments: input.knowledgeDocuments,
|
|
204
|
+
craftMemories: input.craftMemories,
|
|
205
|
+
context: input.context,
|
|
206
|
+
directives: input.directives,
|
|
207
|
+
promptScaffold: input.promptScaffold,
|
|
208
|
+
extraSystemSections: input.extraSystemSections,
|
|
209
|
+
workingSet: input.workingSet,
|
|
210
|
+
},
|
|
211
|
+
guidelines: input.guidelines,
|
|
212
|
+
history: input.history,
|
|
213
|
+
});
|
|
214
|
+
// Build response schema: CRUD entities for memory when available, legacy actions as fallback
|
|
215
|
+
const retrospectSchema = buildRetrospectResponseSchema(this.config, effectiveEntities);
|
|
216
|
+
const cleanHistory = stripActionAnnotations(input.history ?? []);
|
|
217
|
+
const response = await this.config.provider.chat({
|
|
218
|
+
systemPrompt,
|
|
219
|
+
history: cleanHistory,
|
|
220
|
+
message: 'Run the silent retrospective and return only the memory mutations that should change.',
|
|
221
|
+
responseSchema: retrospectSchema,
|
|
222
|
+
});
|
|
223
|
+
return parseRetrospectResponse(response.text, this.config);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Stateless greeting — build greeting prompt, call LLM, return plain text.
|
|
227
|
+
* No response schema, no actions — just a warm check-in message.
|
|
228
|
+
*/
|
|
229
|
+
async greet(input) {
|
|
230
|
+
const result = await this.promptedTurn({
|
|
231
|
+
label: 'Greeting',
|
|
232
|
+
intent: "Generate a warm, natural check-in for a fresh or resumed session. Text like a thoughtful person, not a notification.",
|
|
233
|
+
turnKind: 'proactive-conversation',
|
|
234
|
+
timezone: input.timezone,
|
|
235
|
+
promptNow: input.promptNow,
|
|
236
|
+
userIdentity: input.userIdentity,
|
|
237
|
+
locale: input.locale,
|
|
238
|
+
memories: input.memories,
|
|
239
|
+
knowledgeDocuments: input.knowledgeDocuments,
|
|
240
|
+
craftMemories: input.craftMemories,
|
|
241
|
+
context: input.context,
|
|
242
|
+
guidelines: input.guidelines,
|
|
243
|
+
history: input.history,
|
|
244
|
+
});
|
|
245
|
+
return { greeting: result.message };
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Check if a greeting is appropriate given the last message time.
|
|
249
|
+
*/
|
|
250
|
+
shouldGreet(lastMessageAt, timezone) {
|
|
251
|
+
return shouldGreet(lastMessageAt, undefined, timezone);
|
|
252
|
+
}
|
|
253
|
+
/** The persona's display name */
|
|
254
|
+
get name() {
|
|
255
|
+
return this.config.identity.name;
|
|
256
|
+
}
|
|
257
|
+
/** The LLM provider name */
|
|
258
|
+
get providerName() {
|
|
259
|
+
return this.config.provider.name;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Audit the persona for keystone principle violations.
|
|
263
|
+
* Reviews the assembled prompt and optionally the conversation history.
|
|
264
|
+
* Returns explicit, actionable failure lists for developers/coding agents.
|
|
265
|
+
*/
|
|
266
|
+
async audit(input) {
|
|
267
|
+
const promptResult = await auditPrompt({
|
|
268
|
+
apiKey: input.apiKey,
|
|
269
|
+
config: this.config,
|
|
270
|
+
context: input.context,
|
|
271
|
+
memories: input.memories,
|
|
272
|
+
});
|
|
273
|
+
const conversationResult = input.history?.length
|
|
274
|
+
? await auditConversation({
|
|
275
|
+
apiKey: input.apiKey,
|
|
276
|
+
config: this.config,
|
|
277
|
+
history: input.history,
|
|
278
|
+
context: input.context,
|
|
279
|
+
})
|
|
280
|
+
: null;
|
|
281
|
+
return {
|
|
282
|
+
prompt: promptResult,
|
|
283
|
+
conversation: conversationResult,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
//# sourceMappingURL=persona.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persona.js","sourceRoot":"","sources":["../src/persona.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/E,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAEjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,uBAAu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AAC,aAAa,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;IACxD,CAAC;IAED,iCAAiC;IACjC,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAA;IAClC,CAAC;IAED,4BAA4B;IAC5B,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAA;IAClC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAK,CAAC,KAAiB;QAC3B,MAAM,YAAY,GAAG,MAAM,WAAW,CAAC;YACrC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACzB,CAAC,CAAA;QAEF,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,EAAE,MAAM;YAC9C,CAAC,CAAC,MAAM,iBAAiB,CAAC;gBACtB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB,CAAC;YACJ,CAAC,CAAC,IAAI,CAAA;QAER,OAAO;YACL,MAAM,EAAE,YAAY;YACpB,YAAY,EAAE,kBAAkB;SACjC,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in playbook defaults — EQ, anti-pattern guards, cold start, memory extraction.
|
|
3
|
+
* These are battle-tested patterns from the AI Persona Playbook.
|
|
4
|
+
*/
|
|
5
|
+
export declare const OPERATIONAL_REALITY = "Operational reality:\n- This role exists because its judgment matters.\n- Treat structured context, ledgers, entities, queue items, and recent facts as the live source of truth.\n- Treat declared actions, entities, and output fields literally.\n- If information is missing, use the existing action/entity surface honestly rather than inventing hidden systems or actors.\n- Explain the move in message. Change shared state only through declared actions or entities.\n- Prefer honest operational moves over advisory prose when this turn should change shared state, owned work, or the outside world.";
|
|
6
|
+
export declare const CONVERSATION_REALITY = "Conversation reality:\n- You are the domain expert.\n- The information in front of you is usually incomplete. Use the real situation over the most literal reading of every sentence in this prompt.\n- The latest live signal, structured context, durable work items, entities, explicit constraints, and memories are all part of the live situation.\n- When the live conversation contradicts a memory, update or delete the stale memory through the crud action in this turn \u2014 don't wait for a retrospective pass.\n- The visible recipients see your message, not the system's internals.";
|
|
7
|
+
export declare const FOCUS_REALITY = "Focus reality:\n- You are the domain expert.\n- Focus context contains persona-authored operating context, source truth, private work history, and factual workspace state for this turn.\n- Focus turns are private work continuity unless the runtime explicitly returns a completion or handoff to the outer session.";
|
|
8
|
+
export declare const EXPERT_AUTONOMY = "Expert autonomy:\n- Treat yourself and every participant as an expert owner of their field. Share intent, context, constraints, evidence, and what great should feel like; let each expert own method, sequencing, tools, and implementation approach unless those details are real source facts or constraints. Short-lived work items anchor judgment; they do not replace it with a checklist.";
|
|
9
|
+
export declare const APP_INITIATED_TURN_REALITY = "App-initiated turn:\n- This turn was initiated by the app/runtime, not by a fresh inbound message.\n- Use recent conversation for continuity. Do not treat the last user line as a brand-new unanswered message unless the turn intent clearly makes it one.\n- Continue from the real situation instead of restarting.";
|
|
10
|
+
export declare const OUTCOME_NOTES_INSTRUCTION = "Outcome notes:\n- Future turns may see prior messages and structured state, but not every executed action in raw form.\n- When an action result appears in your current prompt, that action already happened. Use the result as current world state; rerun the action only when you need a fresh value or exact contents are no longer carried. Inner narration and action outcomes are one work stream: what you said or intended, compact action narration, then what actually happened. Read them together in order; the outcome is the factual state. Action narration is not a raw action dump; raw parameters are omitted because they can bloat or contaminate continuity and may reference action APIs no longer available.\n- The subject may be the conversation, institution, or world depending on mode.\n- Match your words to your actions. If your message narrates a change (\"I've logged\u2026\", \"I've added\u2026\", \"I've updated\u2026\", \"I've saved\u2026\"), the corresponding action or crud call must also appear in this turn's output. Don't describe actions you aren't taking \u2014 silent narration is how past-tense promises become hallucinations future turns try to reconcile.";
|
|
11
|
+
export declare const ATTACHMENT_CONTINUITY_RULES = "Attachment continuity:\n- This turn includes one or more uploaded images.\n- The raw image may not be available again on future turns.\n- If a compact factual carry-forward note about the image would materially help future reasoning, you may include it in \"attachmentNotes\".\n- Use attachmentNotes for enduring visual facts, not for exhaustive description or speculation.\n- If nothing about the image is likely to matter later, omit attachmentNotes.";
|
|
12
|
+
export declare const MEMORY_ENTITY_RULES = "Memory:\n- Memory is what you've learned about this person that's worth carrying into future conversations \u2014 the durable layer beneath chat history, which gets trimmed.\n- Every stored memory comes from a specific moment. When reading one, check whether the situation that made it true still holds. When writing one, capture the situation that produced it \u2014 a correction saved without its why calcifies into a rule divorced from reality.\n- Update or delete memories that no longer fit the live conversation; don't keep obeying stored rules the user has already overwritten.";
|
|
13
|
+
export declare const MEMORY_METADATA_GUIDANCE = "Memory metadata:\n- source: \"user\" when they said it directly, \"inferred\" when you noticed a pattern, \"suggested\" when it's an agent-proposed idea not clearly adopted yet.\n- stability: \"durable\" for reliable truths, \"tentative\" for still-forming patterns, \"temporary\" for situation-bound facts.\n- contextHint: the situation that produced the memory. For any correction or instruction tied to a moment (illness, travel, a specific week), contextHint is not optional \u2014 without it, the memory becomes a rule divorced from its reason.";
|
|
14
|
+
export declare const RETROSPECTIVE_MEMORY_POLICY = "Retrospective memory policy:\n- This is a silent internal reflection pass. Step back from the last few days of interactions and ask what deserves to remain in the assistant's mind for future conversations.\n- Work from the actual situation: recent behavior, repeated choices, recurring friction, stable habits, durable tradeoff preferences, and what consistently seems to work or fail for them.\n- Keep the memory set sharp. Preserve what would materially improve future judgment, and let go of what now feels situational, noisy, outdated, or overshadowed by better evidence.\n- Each memory you keep loads into every future conversation. Your reasoning improves over time \u2014 ask whether each memory still helps your current judgment, or whether it's an older decision that would now constrain better thinking.\n- Some unusual details may still deserve memory if they meaningfully change how the assistant should think or relate to the user over time.\n- Review memory metadata too: agent-suggested ideas should not quietly harden into user-owned truth, and temporary corrections should not become timeless rules.\n- If nothing meaningful should change, return no memory mutations.";
|
|
15
|
+
export declare const RETROSPECTIVE_OUTPUT_FORMAT = "Output valid JSON. Express every memory change as an entity CRUD item in the \"actions\" array, exactly as the ENTITY CRUD RESPONSE CONTRACT specifies: { \"name\": \"crud\", \"params\": { \"operation\": \"create\"|\"update\"|\"delete\", \"entity\": \"memory\" | \"craftMemory\", \"id\": \"...\", \"params\": \"{ ... }\" } }. Every memory and craftMemory mutation uses that single \"crud\" action \u2014 there are no per-entity memory action names.\n- This pass is silent and non-user-facing.\n- If nothing durable should change, return an empty actions array.";
|
|
16
|
+
export declare const DIAGNOSTICS_CHANNEL = "Diagnostics channel:\nThe \"diagnostics\" field reaches the developer, not the person \u2014 it's for tensions between what the person needs and what your current setup allows.";
|
|
17
|
+
export declare const CRAFT_MEMORY_SECTION_INTRO = "Craft memory \u2014 professional growth:\nThese are observations about your own craft: what works, timing insights, patterns in how interactions unfold. They are scoped to you as a practitioner, not to any individual user. They load into every conversation and inform your professional judgment over time.\nBecause they shape your judgment across every user you work with, each craft memory has outsized influence. Your practice evolves \u2014 these should capture what you've genuinely learned, not lock you into approaches from a point in time when you knew less.";
|
|
18
|
+
export declare const CRAFT_MEMORY_FULLCRUD_RULES = "Craft memory:\n- The craftMemory entity holds transferable observations that sharpen your practice across future users \u2014 patterns that would apply to the next person, not patches for a single moment.";
|
|
19
|
+
export declare const RETROSPECTIVE_CRAFT_POLICY = "Craft memory reflection:\n- Review existing craft memories against what you now know. Update when a prior observation has evolved. Delete when it was situational noise, not a real pattern.\n- Look for new craft-level patterns: approaches that consistently work, timing that matters, common mismatches between what users ask for and what they need.\n- Be especially careful with craft memories that sound like patches or absolute rules born from one incident. Rewrite or drop them unless they truly transfer.\n- Craft memories should be transferable \u2014 useful regardless of which user you're talking to.";
|
|
20
|
+
export declare const ACTION_OUTPUT_FORMAT = "Output contract:\nReturn exactly one raw JSON object and nothing else.\nDo not wrap the response in markdown code fences.\nDo not add any text before or after the JSON.\nRequired top-level keys:\n- \"message\": Your conversational response.\n- \"actions\": Array of { \"name\": \"<actionName>\", \"params\": { ... } }. Use [] if no actions.\n- \"outcomeNotes\": Array of strings describing what your actions changed. Use [] when no actions changed anything.\nOptional top-level keys:\n- \"followUps\": Natural next things the user might realistically tap or say next, written as user utterances.\n- \"diagnostics\": Developer-facing setup tensions.\n- \"attachmentNotes\": Compact factual carry-forward notes about uploaded images when useful.";
|
|
21
|
+
export declare const OPERATIONAL_ACTION_OUTPUT_FORMAT = "Output contract:\nReturn exactly one raw JSON object and nothing else.\nDo not wrap the response in markdown code fences.\nDo not add any text before or after the JSON.\nRequired top-level keys:\n- \"message\": Your written brief for this operational turn.\n- \"actions\": Array of { \"name\": \"<actionName>\", \"params\": { ... } }. Use [] if no actions.\n- \"outcomeNotes\": Array of strings describing what your actions changed in the institution or world. Use [] when no actions changed anything.\nOptional top-level keys:\n- \"diagnostics\": Developer-facing setup tensions. Omit or use [] when nothing to flag.\n- \"attachmentNotes\": Compact factual carry-forward notes about uploaded images when useful. Omit when not needed.\n- Entity mutations still belong inside \"actions\". Do not invent a top-level \"crudActions\" key.";
|
|
22
|
+
export declare const FOCUS_ACTION_OUTPUT_FORMAT = "Output:\nReturn one raw JSON object: { \"message\": \"...\", \"actions\": [...] }. No markdown.\n\"message\" is your private focus note for this turn's work continuity.\n\"actions\" is a list executed in order within this turn. Later actions run after earlier state changes, such as files written earlier in the list, but you choose the whole list before any action outcomes are known. Include a later action when it remains the right next action without seeing those outcomes; when a result could change what you do next, let that result return on the next turn first. Future turns receive factual action outcomes, not raw action payloads. When an action result appears in your current prompt, that action already happened; use it as current world state. Inner narration and action outcomes are one work stream: what you said or intended, compact action narration, then what actually happened. Action narration is not a raw action dump and should not contaminate continuity. The action list may contain one action or many related actions; it is the complete set chosen for this turn.";
|
|
23
|
+
export declare const MOMENTUM = "Momentum:\n- Guide the person toward felt progress. The conversation itself is often where the value lands, not in the structured changes.";
|
|
24
|
+
export declare const COME_BACK_TEST = "Come-back test:\n- Will this make them want to come back and think with me again?";
|
|
25
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/playbook/defaults.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,mBAAmB,ylBAMmG,CAAA;AAEnI,eAAO,MAAM,oBAAoB,4kBAKsC,CAAA;AAEvE,eAAO,MAAM,aAAa,6TAGoG,CAAA;AAE9H,eAAO,MAAM,eAAe,sYACoV,CAAA;AAEhX,eAAO,MAAM,0BAA0B,4TAGmB,CAAA;AAI1D,eAAO,MAAM,yBAAyB,4pCAI2T,CAAA;AAEjW,eAAO,MAAM,2BAA2B,ycAKsC,CAAA;AAI9E,eAAO,MAAM,mBAAmB,6kBAGwG,CAAA;AAExI,eAAO,MAAM,wBAAwB,0iBAGuM,CAAA;AAE5O,eAAO,MAAM,2BAA2B,qqCAO2B,CAAA;AAEnE,eAAO,MAAM,2BAA2B,ojBAE2B,CAAA;AAInE,eAAO,MAAM,mBAAmB,qLACoH,CAAA;AAIpJ,eAAO,MAAM,0BAA0B,0jBAEuN,CAAA;AAE9P,eAAO,MAAM,2BAA2B,iNACiJ,CAAA;AAEzL,eAAO,MAAM,0BAA0B,mmBAIsD,CAAA;AAI7F,eAAO,MAAM,oBAAoB,4uBAW2D,CAAA;AAE5F,eAAO,MAAM,gCAAgC,u0BAWkD,CAAA;AAE/F,eAAO,MAAM,0BAA0B,ikCAG02B,CAAA;AAIj5B,eAAO,MAAM,QAAQ,+IAC2G,CAAA;AAEhI,eAAO,MAAM,cAAc,sFACsC,CAAA"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in playbook defaults — EQ, anti-pattern guards, cold start, memory extraction.
|
|
3
|
+
* These are battle-tested patterns from the AI Persona Playbook.
|
|
4
|
+
*/
|
|
5
|
+
export const OPERATIONAL_REALITY = `Operational reality:
|
|
6
|
+
- This role exists because its judgment matters.
|
|
7
|
+
- Treat structured context, ledgers, entities, queue items, and recent facts as the live source of truth.
|
|
8
|
+
- Treat declared actions, entities, and output fields literally.
|
|
9
|
+
- If information is missing, use the existing action/entity surface honestly rather than inventing hidden systems or actors.
|
|
10
|
+
- Explain the move in message. Change shared state only through declared actions or entities.
|
|
11
|
+
- Prefer honest operational moves over advisory prose when this turn should change shared state, owned work, or the outside world.`;
|
|
12
|
+
export const CONVERSATION_REALITY = `Conversation reality:
|
|
13
|
+
- You are the domain expert.
|
|
14
|
+
- The information in front of you is usually incomplete. Use the real situation over the most literal reading of every sentence in this prompt.
|
|
15
|
+
- The latest live signal, structured context, durable work items, entities, explicit constraints, and memories are all part of the live situation.
|
|
16
|
+
- When the live conversation contradicts a memory, update or delete the stale memory through the crud action in this turn — don't wait for a retrospective pass.
|
|
17
|
+
- The visible recipients see your message, not the system's internals.`;
|
|
18
|
+
export const FOCUS_REALITY = `Focus reality:
|
|
19
|
+
- You are the domain expert.
|
|
20
|
+
- Focus context contains persona-authored operating context, source truth, private work history, and factual workspace state for this turn.
|
|
21
|
+
- Focus turns are private work continuity unless the runtime explicitly returns a completion or handoff to the outer session.`;
|
|
22
|
+
export const EXPERT_AUTONOMY = `Expert autonomy:
|
|
23
|
+
- Treat yourself and every participant as an expert owner of their field. Share intent, context, constraints, evidence, and what great should feel like; let each expert own method, sequencing, tools, and implementation approach unless those details are real source facts or constraints. Short-lived work items anchor judgment; they do not replace it with a checklist.`;
|
|
24
|
+
export const APP_INITIATED_TURN_REALITY = `App-initiated turn:
|
|
25
|
+
- This turn was initiated by the app/runtime, not by a fresh inbound message.
|
|
26
|
+
- Use recent conversation for continuity. Do not treat the last user line as a brand-new unanswered message unless the turn intent clearly makes it one.
|
|
27
|
+
- Continue from the real situation instead of restarting.`;
|
|
28
|
+
// ─── Outcome notes ─────────────────────────────────────────────────────────
|
|
29
|
+
export const OUTCOME_NOTES_INSTRUCTION = `Outcome notes:
|
|
30
|
+
- Future turns may see prior messages and structured state, but not every executed action in raw form.
|
|
31
|
+
- When an action result appears in your current prompt, that action already happened. Use the result as current world state; rerun the action only when you need a fresh value or exact contents are no longer carried. Inner narration and action outcomes are one work stream: what you said or intended, compact action narration, then what actually happened. Read them together in order; the outcome is the factual state. Action narration is not a raw action dump; raw parameters are omitted because they can bloat or contaminate continuity and may reference action APIs no longer available.
|
|
32
|
+
- The subject may be the conversation, institution, or world depending on mode.
|
|
33
|
+
- Match your words to your actions. If your message narrates a change ("I've logged…", "I've added…", "I've updated…", "I've saved…"), the corresponding action or crud call must also appear in this turn's output. Don't describe actions you aren't taking — silent narration is how past-tense promises become hallucinations future turns try to reconcile.`;
|
|
34
|
+
export const ATTACHMENT_CONTINUITY_RULES = `Attachment continuity:
|
|
35
|
+
- This turn includes one or more uploaded images.
|
|
36
|
+
- The raw image may not be available again on future turns.
|
|
37
|
+
- If a compact factual carry-forward note about the image would materially help future reasoning, you may include it in "attachmentNotes".
|
|
38
|
+
- Use attachmentNotes for enduring visual facts, not for exhaustive description or speculation.
|
|
39
|
+
- If nothing about the image is likely to matter later, omit attachmentNotes.`;
|
|
40
|
+
// ─── Memory rules ───────────────────────────────────────────────────────────
|
|
41
|
+
export const MEMORY_ENTITY_RULES = `Memory:
|
|
42
|
+
- Memory is what you've learned about this person that's worth carrying into future conversations — the durable layer beneath chat history, which gets trimmed.
|
|
43
|
+
- Every stored memory comes from a specific moment. When reading one, check whether the situation that made it true still holds. When writing one, capture the situation that produced it — a correction saved without its why calcifies into a rule divorced from reality.
|
|
44
|
+
- Update or delete memories that no longer fit the live conversation; don't keep obeying stored rules the user has already overwritten.`;
|
|
45
|
+
export const MEMORY_METADATA_GUIDANCE = `Memory metadata:
|
|
46
|
+
- source: "user" when they said it directly, "inferred" when you noticed a pattern, "suggested" when it's an agent-proposed idea not clearly adopted yet.
|
|
47
|
+
- stability: "durable" for reliable truths, "tentative" for still-forming patterns, "temporary" for situation-bound facts.
|
|
48
|
+
- contextHint: the situation that produced the memory. For any correction or instruction tied to a moment (illness, travel, a specific week), contextHint is not optional — without it, the memory becomes a rule divorced from its reason.`;
|
|
49
|
+
export const RETROSPECTIVE_MEMORY_POLICY = `Retrospective memory policy:
|
|
50
|
+
- This is a silent internal reflection pass. Step back from the last few days of interactions and ask what deserves to remain in the assistant's mind for future conversations.
|
|
51
|
+
- Work from the actual situation: recent behavior, repeated choices, recurring friction, stable habits, durable tradeoff preferences, and what consistently seems to work or fail for them.
|
|
52
|
+
- Keep the memory set sharp. Preserve what would materially improve future judgment, and let go of what now feels situational, noisy, outdated, or overshadowed by better evidence.
|
|
53
|
+
- Each memory you keep loads into every future conversation. Your reasoning improves over time — ask whether each memory still helps your current judgment, or whether it's an older decision that would now constrain better thinking.
|
|
54
|
+
- Some unusual details may still deserve memory if they meaningfully change how the assistant should think or relate to the user over time.
|
|
55
|
+
- Review memory metadata too: agent-suggested ideas should not quietly harden into user-owned truth, and temporary corrections should not become timeless rules.
|
|
56
|
+
- If nothing meaningful should change, return no memory mutations.`;
|
|
57
|
+
export const RETROSPECTIVE_OUTPUT_FORMAT = `Output valid JSON. Express every memory change as an entity CRUD item in the "actions" array, exactly as the ENTITY CRUD RESPONSE CONTRACT specifies: { "name": "crud", "params": { "operation": "create"|"update"|"delete", "entity": "memory" | "craftMemory", "id": "...", "params": "{ ... }" } }. Every memory and craftMemory mutation uses that single "crud" action — there are no per-entity memory action names.
|
|
58
|
+
- This pass is silent and non-user-facing.
|
|
59
|
+
- If nothing durable should change, return an empty actions array.`;
|
|
60
|
+
// ─── Diagnostics channel ─────────────────────────────────────────────────────
|
|
61
|
+
export const DIAGNOSTICS_CHANNEL = `Diagnostics channel:
|
|
62
|
+
The "diagnostics" field reaches the developer, not the person — it's for tensions between what the person needs and what your current setup allows.`;
|
|
63
|
+
// ─── Craft memory ───────────────────────────────────────────────────────────
|
|
64
|
+
export const CRAFT_MEMORY_SECTION_INTRO = `Craft memory — professional growth:
|
|
65
|
+
These are observations about your own craft: what works, timing insights, patterns in how interactions unfold. They are scoped to you as a practitioner, not to any individual user. They load into every conversation and inform your professional judgment over time.
|
|
66
|
+
Because they shape your judgment across every user you work with, each craft memory has outsized influence. Your practice evolves — these should capture what you've genuinely learned, not lock you into approaches from a point in time when you knew less.`;
|
|
67
|
+
export const CRAFT_MEMORY_FULLCRUD_RULES = `Craft memory:
|
|
68
|
+
- The craftMemory entity holds transferable observations that sharpen your practice across future users — patterns that would apply to the next person, not patches for a single moment.`;
|
|
69
|
+
export const RETROSPECTIVE_CRAFT_POLICY = `Craft memory reflection:
|
|
70
|
+
- Review existing craft memories against what you now know. Update when a prior observation has evolved. Delete when it was situational noise, not a real pattern.
|
|
71
|
+
- Look for new craft-level patterns: approaches that consistently work, timing that matters, common mismatches between what users ask for and what they need.
|
|
72
|
+
- Be especially careful with craft memories that sound like patches or absolute rules born from one incident. Rewrite or drop them unless they truly transfer.
|
|
73
|
+
- Craft memories should be transferable — useful regardless of which user you're talking to.`;
|
|
74
|
+
// ─── Default actions output format ───────────────────────────────────────────
|
|
75
|
+
export const ACTION_OUTPUT_FORMAT = `Output contract:
|
|
76
|
+
Return exactly one raw JSON object and nothing else.
|
|
77
|
+
Do not wrap the response in markdown code fences.
|
|
78
|
+
Do not add any text before or after the JSON.
|
|
79
|
+
Required top-level keys:
|
|
80
|
+
- "message": Your conversational response.
|
|
81
|
+
- "actions": Array of { "name": "<actionName>", "params": { ... } }. Use [] if no actions.
|
|
82
|
+
- "outcomeNotes": Array of strings describing what your actions changed. Use [] when no actions changed anything.
|
|
83
|
+
Optional top-level keys:
|
|
84
|
+
- "followUps": Natural next things the user might realistically tap or say next, written as user utterances.
|
|
85
|
+
- "diagnostics": Developer-facing setup tensions.
|
|
86
|
+
- "attachmentNotes": Compact factual carry-forward notes about uploaded images when useful.`;
|
|
87
|
+
export const OPERATIONAL_ACTION_OUTPUT_FORMAT = `Output contract:
|
|
88
|
+
Return exactly one raw JSON object and nothing else.
|
|
89
|
+
Do not wrap the response in markdown code fences.
|
|
90
|
+
Do not add any text before or after the JSON.
|
|
91
|
+
Required top-level keys:
|
|
92
|
+
- "message": Your written brief for this operational turn.
|
|
93
|
+
- "actions": Array of { "name": "<actionName>", "params": { ... } }. Use [] if no actions.
|
|
94
|
+
- "outcomeNotes": Array of strings describing what your actions changed in the institution or world. Use [] when no actions changed anything.
|
|
95
|
+
Optional top-level keys:
|
|
96
|
+
- "diagnostics": Developer-facing setup tensions. Omit or use [] when nothing to flag.
|
|
97
|
+
- "attachmentNotes": Compact factual carry-forward notes about uploaded images when useful. Omit when not needed.
|
|
98
|
+
- Entity mutations still belong inside "actions". Do not invent a top-level "crudActions" key.`;
|
|
99
|
+
export const FOCUS_ACTION_OUTPUT_FORMAT = `Output:
|
|
100
|
+
Return one raw JSON object: { "message": "...", "actions": [...] }. No markdown.
|
|
101
|
+
"message" is your private focus note for this turn's work continuity.
|
|
102
|
+
"actions" is a list executed in order within this turn. Later actions run after earlier state changes, such as files written earlier in the list, but you choose the whole list before any action outcomes are known. Include a later action when it remains the right next action without seeing those outcomes; when a result could change what you do next, let that result return on the next turn first. Future turns receive factual action outcomes, not raw action payloads. When an action result appears in your current prompt, that action already happened; use it as current world state. Inner narration and action outcomes are one work stream: what you said or intended, compact action narration, then what actually happened. Action narration is not a raw action dump and should not contaminate continuity. The action list may contain one action or many related actions; it is the complete set chosen for this turn.`;
|
|
103
|
+
// ─── Come-back test ──────────────────────────────────────────────────────────
|
|
104
|
+
export const MOMENTUM = `Momentum:
|
|
105
|
+
- Guide the person toward felt progress. The conversation itself is often where the value lands, not in the structured changes.`;
|
|
106
|
+
export const COME_BACK_TEST = `Come-back test:
|
|
107
|
+
- Will this make them want to come back and think with me again?`;
|
|
108
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/playbook/defaults.ts"],"names":[],"mappings":"AAAA;;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