@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
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ParsedAction } from '../types.js';
|
|
2
|
+
import type { EntityRegistry } from './entity-registry.js';
|
|
3
|
+
/**
|
|
4
|
+
* Parse a camelCase action name into verb + entityName.
|
|
5
|
+
*
|
|
6
|
+
* 'createThread' → { verb: 'create', entityName: 'thread' }
|
|
7
|
+
* 'updateFf' → { verb: 'update', entityName: 'ff' }
|
|
8
|
+
* 'saveMemory' → { verb: 'save', entityName: 'memory' }
|
|
9
|
+
* 'deleteExecNote' → { verb: 'delete', entityName: 'execNote' }
|
|
10
|
+
* 'random' → null
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseActionName(name: string): {
|
|
13
|
+
verb: string;
|
|
14
|
+
entityName: string;
|
|
15
|
+
} | null;
|
|
16
|
+
/**
|
|
17
|
+
* Human-readable label for an action, using entity metadata from the registry.
|
|
18
|
+
*
|
|
19
|
+
* 'createThread' + registry → "Add Thread"
|
|
20
|
+
* 'deleteFf' + registry → "Delete Forcing Function"
|
|
21
|
+
*
|
|
22
|
+
* Falls back to capitalize(entityName) if the entity isn't in the registry.
|
|
23
|
+
*/
|
|
24
|
+
export declare function actionLabel(actionName: string, registry: EntityRegistry): string;
|
|
25
|
+
/**
|
|
26
|
+
* Extract a display title from an action's params using the entity's displayField.
|
|
27
|
+
*
|
|
28
|
+
* For create actions: uses displayField to find the title in params.
|
|
29
|
+
* For update actions: summarizes as "field: value" (or full updates object).
|
|
30
|
+
* For delete actions: uses reason if present, falls back to id.
|
|
31
|
+
*
|
|
32
|
+
* Returns empty string if nothing meaningful can be extracted.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getActionDisplayTitle(action: ParsedAction, registry: EntityRegistry, maxLength?: number): string;
|
|
35
|
+
/**
|
|
36
|
+
* Check if an action targets a specific entity.
|
|
37
|
+
*
|
|
38
|
+
* isEntityAction('createThread', 'thread') → true
|
|
39
|
+
* isEntityAction('updateFf', 'thread') → false
|
|
40
|
+
*/
|
|
41
|
+
export declare function isEntityAction(actionName: string, entityName: string): boolean;
|
|
42
|
+
/** The operations an entity actually supports (operations > createOnly > all). */
|
|
43
|
+
export declare function allowedOperations(config: {
|
|
44
|
+
createOnly?: boolean;
|
|
45
|
+
operations?: ReadonlyArray<'create' | 'update' | 'delete'>;
|
|
46
|
+
}): ReadonlyArray<'create' | 'update' | 'delete'>;
|
|
47
|
+
//# sourceMappingURL=entity-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-helpers.d.ts","sourceRoot":"","sources":["../../src/core/entity-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAI1D;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAIzF;AAWD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,MAAM,CAShF;AAID;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,cAAc,EACxB,SAAS,SAAK,GACb,MAAM,CA4CR;AAID;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAI9E;AAYD,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,aAAa,CAAC,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAA;CAAE,GAAG,aAAa,CAAC,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAI7K"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// ─── Action Name Parsing ────────────────────────────────────────────────────
|
|
2
|
+
/**
|
|
3
|
+
* Parse a camelCase action name into verb + entityName.
|
|
4
|
+
*
|
|
5
|
+
* 'createThread' → { verb: 'create', entityName: 'thread' }
|
|
6
|
+
* 'updateFf' → { verb: 'update', entityName: 'ff' }
|
|
7
|
+
* 'saveMemory' → { verb: 'save', entityName: 'memory' }
|
|
8
|
+
* 'deleteExecNote' → { verb: 'delete', entityName: 'execNote' }
|
|
9
|
+
* 'random' → null
|
|
10
|
+
*/
|
|
11
|
+
export function parseActionName(name) {
|
|
12
|
+
const m = name.match(/^(create|update|delete|save)([A-Z]\w*)$/);
|
|
13
|
+
if (!m)
|
|
14
|
+
return null;
|
|
15
|
+
return { verb: m[1], entityName: m[2].charAt(0).toLowerCase() + m[2].slice(1) };
|
|
16
|
+
}
|
|
17
|
+
// ─── Action Label ───────────────────────────────────────────────────────────
|
|
18
|
+
const VERB_LABELS = {
|
|
19
|
+
create: 'Add',
|
|
20
|
+
save: 'Add',
|
|
21
|
+
update: 'Update',
|
|
22
|
+
delete: 'Delete',
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Human-readable label for an action, using entity metadata from the registry.
|
|
26
|
+
*
|
|
27
|
+
* 'createThread' + registry → "Add Thread"
|
|
28
|
+
* 'deleteFf' + registry → "Delete Forcing Function"
|
|
29
|
+
*
|
|
30
|
+
* Falls back to capitalize(entityName) if the entity isn't in the registry.
|
|
31
|
+
*/
|
|
32
|
+
export function actionLabel(actionName, registry) {
|
|
33
|
+
const parsed = parseActionName(actionName);
|
|
34
|
+
if (!parsed)
|
|
35
|
+
return actionName;
|
|
36
|
+
const verbLabel = VERB_LABELS[parsed.verb] ?? capitalize(parsed.verb);
|
|
37
|
+
const entity = registry.getEntityForAction(actionName);
|
|
38
|
+
const entityLabel = entity?.label ?? capitalize(parsed.entityName);
|
|
39
|
+
return `${verbLabel} ${entityLabel}`;
|
|
40
|
+
}
|
|
41
|
+
// ─── Display Title ──────────────────────────────────────────────────────────
|
|
42
|
+
/**
|
|
43
|
+
* Extract a display title from an action's params using the entity's displayField.
|
|
44
|
+
*
|
|
45
|
+
* For create actions: uses displayField to find the title in params.
|
|
46
|
+
* For update actions: summarizes as "field: value" (or full updates object).
|
|
47
|
+
* For delete actions: uses reason if present, falls back to id.
|
|
48
|
+
*
|
|
49
|
+
* Returns empty string if nothing meaningful can be extracted.
|
|
50
|
+
*/
|
|
51
|
+
export function getActionDisplayTitle(action, registry, maxLength = 60) {
|
|
52
|
+
const parsed = parseActionName(action.name);
|
|
53
|
+
if (!parsed)
|
|
54
|
+
return '';
|
|
55
|
+
const entity = registry.getEntityForAction(action.name);
|
|
56
|
+
const p = action.params;
|
|
57
|
+
if (parsed.verb === 'create' || parsed.verb === 'save') {
|
|
58
|
+
// Try displayField first
|
|
59
|
+
if (entity?.displayField && p[entity.displayField] != null) {
|
|
60
|
+
return truncate(String(p[entity.displayField]), maxLength);
|
|
61
|
+
}
|
|
62
|
+
// Fallback: try common field names
|
|
63
|
+
for (const field of ['title', 'text', 'what', 'content', 'name']) {
|
|
64
|
+
if (p[field] != null)
|
|
65
|
+
return truncate(String(p[field]), maxLength);
|
|
66
|
+
}
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
if (parsed.verb === 'update') {
|
|
70
|
+
// {id, field, value} shape (legacy pattern)
|
|
71
|
+
if (p.field != null && p.value != null) {
|
|
72
|
+
return truncate(`${p.field}: ${String(p.value)}`, maxLength);
|
|
73
|
+
}
|
|
74
|
+
// {id, updates: {...}} shape (archetype pattern)
|
|
75
|
+
if (p.updates != null && typeof p.updates === 'object') {
|
|
76
|
+
const updates = p.updates;
|
|
77
|
+
const keys = Object.keys(updates);
|
|
78
|
+
if (keys.length === 1) {
|
|
79
|
+
return truncate(`${keys[0]}: ${String(updates[keys[0]])}`, maxLength);
|
|
80
|
+
}
|
|
81
|
+
if (keys.length > 1) {
|
|
82
|
+
return truncate(`${keys.join(', ')}`, maxLength);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return '';
|
|
86
|
+
}
|
|
87
|
+
if (parsed.verb === 'delete') {
|
|
88
|
+
if (p.reason != null)
|
|
89
|
+
return truncate(String(p.reason), maxLength);
|
|
90
|
+
return '';
|
|
91
|
+
}
|
|
92
|
+
return '';
|
|
93
|
+
}
|
|
94
|
+
// ─── Entity Check ───────────────────────────────────────────────────────────
|
|
95
|
+
/**
|
|
96
|
+
* Check if an action targets a specific entity.
|
|
97
|
+
*
|
|
98
|
+
* isEntityAction('createThread', 'thread') → true
|
|
99
|
+
* isEntityAction('updateFf', 'thread') → false
|
|
100
|
+
*/
|
|
101
|
+
export function isEntityAction(actionName, entityName) {
|
|
102
|
+
const parsed = parseActionName(actionName);
|
|
103
|
+
if (!parsed)
|
|
104
|
+
return false;
|
|
105
|
+
return parsed.entityName === entityName;
|
|
106
|
+
}
|
|
107
|
+
// ─── Internals ──────────────────────────────────────────────────────────────
|
|
108
|
+
function capitalize(s) {
|
|
109
|
+
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
110
|
+
}
|
|
111
|
+
function truncate(s, max) {
|
|
112
|
+
return s.length > max ? s.slice(0, max) + '…' : s;
|
|
113
|
+
}
|
|
114
|
+
/** The operations an entity actually supports (operations > createOnly > all). */
|
|
115
|
+
export function allowedOperations(config) {
|
|
116
|
+
if (config.operations && config.operations.length > 0)
|
|
117
|
+
return config.operations;
|
|
118
|
+
if (config.createOnly)
|
|
119
|
+
return ['create'];
|
|
120
|
+
return ['create', 'update', 'delete'];
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=entity-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-helpers.js","sourceRoot":"","sources":["../../src/core/entity-helpers.ts"],"names":[],"mappings":"AAGA,+EAA+E;AAE/E;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAA;IAC/D,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAA;IACnB,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;AACjF,CAAC;AAED,+EAA+E;AAE/E,MAAM,WAAW,GAA2B;IAC1C,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,KAAK;IACX,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;CACjB,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,UAAkB,EAAE,QAAwB;IACtE,MAAM,MAAM,GAAG,eAAe,CAAC,UAAU,CAAC,CAAA;IAC1C,IAAI,CAAC,MAAM;QAAE,OAAO,UAAU,CAAA;IAE9B,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACrE,MAAM,MAAM,GAAG,QAAQ,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAA;IACtD,MAAM,WAAW,GAAG,MAAM,EAAE,KAAK,IAAI,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IAElE,OAAO,GAAG,SAAS,IAAI,WAAW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AA+E;AAE/E,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAC/C,CAAC;AAED,SAAS,QAAQ,CAAC,CAAS,EAAE,GAAW;IACtC,OAAO,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AACnD,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,iBAAiB,CAAC,MAA4F;IAC5H,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC,UAAU,CAAA;IAC/E,IAAI,MAAM,CAAC,UAAU;QAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IACxC,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;AACvC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ActionDefinition, ContextInputDefinition } from '../types.js';
|
|
2
|
+
import type { EntityDefinitionResult } from './entities.js';
|
|
3
|
+
export interface EntityRegistryEntry {
|
|
4
|
+
name: string;
|
|
5
|
+
label: string;
|
|
6
|
+
displayField?: string;
|
|
7
|
+
actions: Record<string, ActionDefinition>;
|
|
8
|
+
contextInput: ContextInputDefinition;
|
|
9
|
+
}
|
|
10
|
+
export interface EntityRegistry {
|
|
11
|
+
/** All actions from all entities, merged */
|
|
12
|
+
actions: Record<string, ActionDefinition>;
|
|
13
|
+
/** All context inputs from all entities, keyed by entity name */
|
|
14
|
+
contextInputs: Record<string, ContextInputDefinition>;
|
|
15
|
+
/** Lookup: action name → entity metadata */
|
|
16
|
+
getEntityForAction(actionName: string): {
|
|
17
|
+
name: string;
|
|
18
|
+
label: string;
|
|
19
|
+
displayField?: string;
|
|
20
|
+
} | null;
|
|
21
|
+
/** All registered entity names */
|
|
22
|
+
entityNames: string[];
|
|
23
|
+
/** All registered entities (full metadata) */
|
|
24
|
+
entities: EntityRegistryEntry[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Combine multiple defineEntity() results into a single registry.
|
|
28
|
+
*
|
|
29
|
+
* Provides the connective tissue between defineEntity() outputs and
|
|
30
|
+
* action helpers — merged actions, context inputs, and action→entity lookup.
|
|
31
|
+
*
|
|
32
|
+
* Example:
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const registry = buildEntityRegistry(
|
|
35
|
+
* { name: 'thread', ...threadEntity },
|
|
36
|
+
* { name: 'ff', ...ffEntity },
|
|
37
|
+
* { name: 'cue', ...cueEntity },
|
|
38
|
+
* )
|
|
39
|
+
*
|
|
40
|
+
* registry.getEntityForAction('updateThread')
|
|
41
|
+
* // → { name: 'thread', label: 'Thread', displayField: 'title' }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function buildEntityRegistry(...entries: Array<{
|
|
45
|
+
name: string;
|
|
46
|
+
} & EntityDefinitionResult>): EntityRegistry;
|
|
47
|
+
//# sourceMappingURL=entity-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-registry.d.ts","sourceRoot":"","sources":["../../src/core/entity-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAC3E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAI3D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IACzC,YAAY,EAAE,sBAAsB,CAAA;CACrC;AAED,MAAM,WAAW,cAAc;IAC7B,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IACzC,iEAAiE;IACjE,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAA;IACrD,4CAA4C;IAC5C,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IACrG,kCAAkC;IAClC,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,8CAA8C;IAC9C,QAAQ,EAAE,mBAAmB,EAAE,CAAA;CAChC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,OAAO,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,sBAAsB,CAAC,GAC3D,cAAc,CAqChB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combine multiple defineEntity() results into a single registry.
|
|
3
|
+
*
|
|
4
|
+
* Provides the connective tissue between defineEntity() outputs and
|
|
5
|
+
* action helpers — merged actions, context inputs, and action→entity lookup.
|
|
6
|
+
*
|
|
7
|
+
* Example:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const registry = buildEntityRegistry(
|
|
10
|
+
* { name: 'thread', ...threadEntity },
|
|
11
|
+
* { name: 'ff', ...ffEntity },
|
|
12
|
+
* { name: 'cue', ...cueEntity },
|
|
13
|
+
* )
|
|
14
|
+
*
|
|
15
|
+
* registry.getEntityForAction('updateThread')
|
|
16
|
+
* // → { name: 'thread', label: 'Thread', displayField: 'title' }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export function buildEntityRegistry(...entries) {
|
|
20
|
+
const allActions = {};
|
|
21
|
+
const allContextInputs = {};
|
|
22
|
+
const actionToEntity = new Map();
|
|
23
|
+
const registryEntries = [];
|
|
24
|
+
for (const entry of entries) {
|
|
25
|
+
const registryEntry = {
|
|
26
|
+
name: entry.name,
|
|
27
|
+
label: entry.label,
|
|
28
|
+
displayField: entry.displayField,
|
|
29
|
+
actions: entry.actions,
|
|
30
|
+
contextInput: entry.contextInput,
|
|
31
|
+
};
|
|
32
|
+
registryEntries.push(registryEntry);
|
|
33
|
+
// Merge actions
|
|
34
|
+
for (const [actionName, actionDef] of Object.entries(entry.actions)) {
|
|
35
|
+
allActions[actionName] = actionDef;
|
|
36
|
+
actionToEntity.set(actionName, registryEntry);
|
|
37
|
+
}
|
|
38
|
+
// Merge context inputs
|
|
39
|
+
allContextInputs[entry.name] = entry.contextInput;
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
actions: allActions,
|
|
43
|
+
contextInputs: allContextInputs,
|
|
44
|
+
entityNames: registryEntries.map(e => e.name),
|
|
45
|
+
entities: registryEntries,
|
|
46
|
+
getEntityForAction(actionName) {
|
|
47
|
+
const entry = actionToEntity.get(actionName);
|
|
48
|
+
if (!entry)
|
|
49
|
+
return null;
|
|
50
|
+
return { name: entry.name, label: entry.label, displayField: entry.displayField };
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=entity-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-registry.js","sourceRoot":"","sources":["../../src/core/entity-registry.ts"],"names":[],"mappings":"AA0BA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,mBAAmB,CACjC,GAAG,OAAyD;IAE5D,MAAM,UAAU,GAAqC,EAAE,CAAA;IACvD,MAAM,gBAAgB,GAA2C,EAAE,CAAA;IACnE,MAAM,cAAc,GAAG,IAAI,GAAG,EAA+B,CAAA;IAC7D,MAAM,eAAe,GAA0B,EAAE,CAAA;IAEjD,KAAK,MAAM,KAAK,IAAI,OAAO,E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ructions from config.
|
|
4
|
+
* These are thinking-nudges, not hard rules.
|
|
5
|
+
*
|
|
6
|
+
* DESIGN PRINCIPLE — Scenario-first, not directive-first.
|
|
7
|
+
* Describe what a great expert does in this situation. Don't tell the AI
|
|
8
|
+
* what to do — it's the expert. Paint the scenario and explain the intent.
|
|
9
|
+
* Prescriptive directives ("do X", "don't Y", "limit to Z") cap the AI's
|
|
10
|
+
* judgment. Scenario-first framing lets it bring its full capability.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildEQBlock(eq: EQConfig | undefined, promptMode?: PromptMode): string;
|
|
13
|
+
//# sourceMappingURL=eq.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eq.d.ts","sourceRoot":"","sources":["../../src/core/eq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAEvD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,SAAS,EAAE,UAAU,GAAE,UAA2B,GAAG,MAAM,CA4CtG"}
|
package/dist/core/eq.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build EQ (emotional intelligence) instructions from config.
|
|
3
|
+
* These are thinking-nudges, not hard rules.
|
|
4
|
+
*
|
|
5
|
+
* DESIGN PRINCIPLE — Scenario-first, not directive-first.
|
|
6
|
+
* Describe what a great expert does in this situation. Don't tell the AI
|
|
7
|
+
* what to do — it's the expert. Paint the scenario and explain the intent.
|
|
8
|
+
* Prescriptive directives ("do X", "don't Y", "limit to Z") cap the AI's
|
|
9
|
+
* judgment. Scenario-first framing lets it bring its full capability.
|
|
10
|
+
*/
|
|
11
|
+
export function buildEQBlock(eq, promptMode = 'conversation') {
|
|
12
|
+
if (!eq)
|
|
13
|
+
return '';
|
|
14
|
+
const nudges = [];
|
|
15
|
+
if (eq.frequencyRule) {
|
|
16
|
+
nudges.push('Continuity: trust what already landed and look for the next layer underneath. ' +
|
|
17
|
+
'Repeat only when urgency or a likely mistake makes it the responsible move.');
|
|
18
|
+
}
|
|
19
|
+
if (eq.autonomyRespect && promptMode === 'conversation') {
|
|
20
|
+
nudges.push("Autonomy: when someone is processing or thinking aloud, the most valuable thing an expert can do " +
|
|
21
|
+
"is often to help them think — reflecting back what they're hearing, naming the pattern, finding the question " +
|
|
22
|
+
"underneath the question. Unsolicited advice lands best when it's earned and specific. " +
|
|
23
|
+
"That said, when something important is being missed, a trusted expert says it directly.");
|
|
24
|
+
}
|
|
25
|
+
if (eq.qualitativeFirst) {
|
|
26
|
+
nudges.push('Lead with judgment and meaning. Use data to sharpen the point, not to replace it.');
|
|
27
|
+
}
|
|
28
|
+
if (eq.coherence) {
|
|
29
|
+
nudges.push("Coherence: keep trust with the person and with the thread of the work. " +
|
|
30
|
+
"If your view evolves, make the shift legible instead of silently contradicting yourself.");
|
|
31
|
+
}
|
|
32
|
+
if (eq.expertJudgment) {
|
|
33
|
+
nudges.push("Expert judgment: your recommendations carry real weight. Apply the professional standard a thoughtful " +
|
|
34
|
+
"expert in your domain would. When a responsible expert would need more information before advising, get it " +
|
|
35
|
+
"instead of filling critical gaps with assumptions.");
|
|
36
|
+
}
|
|
37
|
+
if (nudges.length === 0)
|
|
38
|
+
return '';
|
|
39
|
+
return nudges.join('\n');
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=eq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eq.js","sourceRoot":"","sources":["../../src/core/eq.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAC,EAAwB,EAAE,aAAyB,cAAc;IAC5F,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,CAAA;IAElB,MAAM,MAAM,GAAa,EAAE,CAAA;IAE3B,IAAI,EAAE,CAAC,aAAa,EAAE,CAAC;QACrB,MAAM,CAAC,IAAI,CACT,gFAAgF;YAChF,6EAA6E,CAC9E,CAAA;IACH,CAAC;IAED,IAAI,EAAE,CAAC,eAAe,IAAI,UAAU,KAAK,cAAc,EAAE,CAAC;QACxD,MAAM,CAAC,IAAI,CACT,mGAAmG;YACnG,+GAA+G;YAC/G,wFAAwF;YACxF,yFAAyF,CAC1F,CAAA;IACH,CAAC;IAED,IAAI,EAAE,CAAC,gBAAgB,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,CACT,mFAAmF,CACpF,CAAA;IACH,CAAC;IAED,IAAI,EAAE,CAAC,SAAS,EAAE,CAAC;QACjB,MAAM,CAAC,IAAI,CACT,yEAAyE;YACzE,0FAA0F,CAC3F,CAAA;IACH,CAAC;IAED,IAAI,EAAE,CAAC,cAAc,EAAE,CAAC;QACtB,MAAM,CAAC,IAAI,CACT,wGAAwG;YACxG,6GAA6G;YAC7G,oDAAoD,CACrD,CAAA;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IAClC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ContextInputDefinition } from '../types.js';
|
|
2
|
+
export interface FocusWorkItem {
|
|
3
|
+
artifactName?: string;
|
|
4
|
+
primaryGoal: string;
|
|
5
|
+
goodOutcome?: string;
|
|
6
|
+
constraints?: readonly string[];
|
|
7
|
+
mandatoryOutputs?: readonly string[];
|
|
8
|
+
followUpAssignment?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface FocusContextInputLabels {
|
|
11
|
+
workItem?: string;
|
|
12
|
+
sourceContext?: string;
|
|
13
|
+
workHistory?: string;
|
|
14
|
+
files?: string;
|
|
15
|
+
environment?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function buildFocusContextInputs(labels?: FocusContextInputLabels): Record<string, ContextInputDefinition>;
|
|
18
|
+
export declare function renderFocusWorkItem(input: FocusWorkItem): string;
|
|
19
|
+
//# sourceMappingURL=focus-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-context.d.ts","sourceRoot":"","sources":["../../src/core/focus-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD,MAAM,WAAW,aAAa;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC/B,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACpC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,uBAAuB,CAAC,MAAM,GAAE,uBAA4B,GAAG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CA4BpH;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAUhE"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export function buildFocusContextInputs(labels = {}) {
|
|
2
|
+
return {
|
|
3
|
+
workItem: {
|
|
4
|
+
label: labels.workItem ?? 'WORK ITEM',
|
|
5
|
+
intent: 'Persona-authored future operating context for this focus turn: expert judgment lens, work/product spine, success picture, and manageable reasoning decomposition. It is layered on source truth, visible conversation, durable files, and tool outcomes; it does not replace them or another expert\'s ownership.',
|
|
6
|
+
format: 'block',
|
|
7
|
+
},
|
|
8
|
+
sourceContext: {
|
|
9
|
+
label: labels.sourceContext ?? 'SOURCE CONTEXT',
|
|
10
|
+
intent: 'Exact compact contents of small source-truth files that define success for the current work. Use this as durable grounding when planning, making tradeoffs, handing off work, and judging completeness; use readFile when relevant source truth is absent, too large, or stale.',
|
|
11
|
+
format: 'block',
|
|
12
|
+
},
|
|
13
|
+
workHistory: {
|
|
14
|
+
label: labels.workHistory ?? 'WORK HISTORY',
|
|
15
|
+
intent: 'Chronological private work continuity: self-notes, this persona\'s action outcomes, and world changes not already visible in chat.',
|
|
16
|
+
format: 'list',
|
|
17
|
+
},
|
|
18
|
+
files: {
|
|
19
|
+
label: labels.files ?? 'FILES',
|
|
20
|
+
intent: 'Factual workspace tree with size signals. Files are durable artifacts; WORK ITEM is private operating context layered on top of source truth and durable files. Use the relevant read/list/search action when contents matter.',
|
|
21
|
+
format: 'list',
|
|
22
|
+
},
|
|
23
|
+
environment: {
|
|
24
|
+
label: labels.environment ?? 'ENVIRONMENT',
|
|
25
|
+
intent: 'Factual runtime and workspace constraints. Use these facts when choosing tools, paths, dependencies, build strategy, or verification steps.',
|
|
26
|
+
format: 'list',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function renderFocusWorkItem(input) {
|
|
31
|
+
return [
|
|
32
|
+
input.artifactName ? `Artifact: ${input.artifactName}` : null,
|
|
33
|
+
`Primary goal: ${input.primaryGoal}`,
|
|
34
|
+
input.goodOutcome ? `What good looks like: ${input.goodOutcome}` : null,
|
|
35
|
+
renderList('Hard constraints:', input.constraints),
|
|
36
|
+
renderList('Mandatory outputs:', input.mandatoryOutputs),
|
|
37
|
+
input.followUpAssignment ? 'Follow-up assignment:' : null,
|
|
38
|
+
input.followUpAssignment ? `- ${input.followUpAssignment}` : null,
|
|
39
|
+
].filter(Boolean).join('\n');
|
|
40
|
+
}
|
|
41
|
+
function renderList(label, items) {
|
|
42
|
+
if (!items || items.length === 0)
|
|
43
|
+
return null;
|
|
44
|
+
return [label, ...items.map(item => `- ${item}`)].join('\n');
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=focus-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-context.js","sourceRoot":"","sources":["../../src/core/focus-context.ts"],"names":[],"mappings":"AAmBA,MAAM,UAAU,uBAAuB,CAAC,SAAkC,EAAE;IAC1E,OAAO;QACL,QAAQ,EAAE;YACR,KAAK,EAAE,MAAM,CAAC,QAAQ,IAAI,WAAW;YACrC,MAAM,EAAE,mTAAmT;YAC3T,MAAM,EAAE,OAAO;SAChB;QACD,aAAa,EAAE;YACb,KAAK,EAAE,MAAM,CAAC,aAAa,IAAI,gBAAgB;YAC/C,MAAM,EAAE,iRAAiR;YACzR,MAAM,EAAE,OAAO;SAChB;QACD,WAAW,EAAE;YACX,KAAK,EAAE,MAAM,CAAC,WAAW,IAAI,cAAc;YAC3C,MAAM,EAAE,oIAAoI;YAC5I,MAAM,EAAE,MAAM;SACf;QACD,KAAK,EAAE;YACL,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,OAAO;YAC9B,MAAM,EAAE,gOAAgO;YACxO,MAAM,EAAE,MAAM;SACf;QACD,WAAW,EAAE;YACX,KAAK,EAAE,MAAM,CAAC,WAAW,IAAI,aAAa;YAC1C,MAAM,EAAE,6IAA6I;YACrJ,MAAM,EAAE,MAAM;SACf;KACF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAoB;IACtD,OAAO;QACL,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI;QAC7D,iBAAiB,KAAK,CAAC,WAAW,EAAE;QACpC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,yBAAyB,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI;QACvE,UAAU,CAAC,mBAAmB,EAAE,KAAK,CAAC,WAAW,CAAC;QAClD,UAAU,CAAC,oBAAoB,EAAE,KAAK,CAAC,gBAAgB,CAAC;QACxD,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI;QACzD,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,IAAI;KAClE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC9B,CAAC;AAED,SAAS,UAAU,CAAC,KAAa,EAAE,KAAyB;IAC1D,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAC7C,OAAO,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC9D,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ActionDefinition, ParsedAction } from '../types.js';
|
|
2
|
+
export declare const ENTER_FOCUS_MODE_ACTION_NAME = "enterFocusMode";
|
|
3
|
+
export declare const UPDATE_FOCUS_WORK_ITEM_ACTION_NAME = "updateFocusWorkItem";
|
|
4
|
+
export declare const RETURN_TO_SESSION_ACTION_NAME = "returnToSession";
|
|
5
|
+
export declare const enterFocusModeAction: ActionDefinition;
|
|
6
|
+
export declare const updateFocusWorkItemAction: ActionDefinition;
|
|
7
|
+
export declare const returnToSessionAction: ActionDefinition;
|
|
8
|
+
export declare const FOCUS_MODE_ACTIONS: Record<typeof ENTER_FOCUS_MODE_ACTION_NAME | typeof UPDATE_FOCUS_WORK_ITEM_ACTION_NAME | typeof RETURN_TO_SESSION_ACTION_NAME, ActionDefinition>;
|
|
9
|
+
export declare function buildFocusActionSets<const TActions extends Record<string, ActionDefinition>>(actions: TActions): {
|
|
10
|
+
conversation: TActions & {
|
|
11
|
+
enterFocusMode: ActionDefinition;
|
|
12
|
+
};
|
|
13
|
+
focus: TActions & {
|
|
14
|
+
returnToSession: ActionDefinition;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare function isEnterFocusModeAction(action: Pick<ParsedAction, 'name'>): boolean;
|
|
18
|
+
export declare function isUpdateFocusWorkItemAction(action: Pick<ParsedAction, 'name'>): boolean;
|
|
19
|
+
export declare function isReturnToSessionAction(action: Pick<ParsedAction, 'name'>): boolean;
|
|
20
|
+
export declare function enterFocusModeOutcomeNote(action: Pick<ParsedAction, 'params'>): string;
|
|
21
|
+
export declare function updateFocusWorkItemOutcomeNote(action: Pick<ParsedAction, 'params'>): string;
|
|
22
|
+
export declare function returnToSessionOutcomeNote(action: Pick<ParsedAction, 'params'>): string;
|
|
23
|
+
//# sourceMappingURL=focus-mode-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-mode-actions.d.ts","sourceRoot":"","sources":["../../src/core/focus-mode-actions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEjE,eAAO,MAAM,4BAA4B,mBAAmB,CAAA;AAC5D,eAAO,MAAM,kCAAkC,wBAAwB,CAAA;AACvE,eAAO,MAAM,6BAA6B,oBAAoB,CAAA;AAE9D,eAAO,MAAM,oBAAoB,EAAE,gBAOlC,CAAA;AAED,eAAO,MAAM,yBAAyB,EAAE,gBAOvC,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,gBASnC,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CACrC,OAAO,4BAA4B,GAAG,OAAO,kCAAkC,GAAG,OAAO,6BAA6B,EACtH,gBAAgB,CAKjB,CAAA;AAED,wBAAgB,oBAAoB,CAAC,KAAK,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAC1F,OAAO,EAAE,QAAQ,GAChB;IACD,YAAY,EAAE,QAAQ,GAAG;QAAE,cAAc,EAAE,gBAAgB,CAAA;KAAE,CAAA;IAC7D,KAAK,EAAE,QAAQ,GAAG;QAAE,eAAe,EAAE,gBAAgB,CAAA;KAAE,CAAA;CACxD,CAYA;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,OAAO,CAElF;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,OAAO,CAEvF;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,OAAO,CAEnF;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,GAAG,MAAM,CAItF;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,GAAG,MAAM,CAG3F;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,GAAG,MAAM,CAQvF"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const ENTER_FOCUS_MODE_ACTION_NAME = 'enterFocusMode';
|
|
3
|
+
export const UPDATE_FOCUS_WORK_ITEM_ACTION_NAME = 'updateFocusWorkItem';
|
|
4
|
+
export const RETURN_TO_SESSION_ACTION_NAME = 'returnToSession';
|
|
5
|
+
export const enterFocusModeAction = {
|
|
6
|
+
description: 'Enter focus mode for this persona\'s ongoing work. When entering focus mode, you have an opportunity to write a work item for your future self. This is your future operating context: it follows future focus prompts as your own expert anchor, layered on top of source truth, visible conversation, durable files, and tool outcomes. It can describe the expert judgment lens to hold, the work or product spine, what excellent success feels like, and the manageable parts you expect your future self to reason through. It is private operating context for this persona, not a handoff that replaces another expert\'s ownership of method, sequencing, tools, or implementation approach. The focused work context begins on the next turn.',
|
|
7
|
+
confidence: 'low',
|
|
8
|
+
schema: z.object({
|
|
9
|
+
workItem: z.string().min(1).optional(),
|
|
10
|
+
}),
|
|
11
|
+
};
|
|
12
|
+
export const updateFocusWorkItemAction = {
|
|
13
|
+
description: 'Update the focus work item for this persona\'s future self. The work item is editable private operating context: replace it when your expert judgment lens, work spine, success picture, or reasoning decomposition has changed. The runtime carries the updated work item into future focus prompts; this is not a quality check, approval step, or substitute source of truth.',
|
|
14
|
+
confidence: 'low',
|
|
15
|
+
schema: z.object({
|
|
16
|
+
workItem: z.string().min(1),
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
export const returnToSessionAction = {
|
|
20
|
+
description: 'Return from private focus work to the visible session flow. Use this when the persona is ready to make its handoff, result, question, or blocked state visible to the session. This is a routing/visibility action, not a quality check: it does not approve or reject the work.',
|
|
21
|
+
confidence: 'low',
|
|
22
|
+
schema: z.object({
|
|
23
|
+
message: z.string().min(1),
|
|
24
|
+
to: z.string().min(1).optional(),
|
|
25
|
+
state: z.enum(['ready', 'blocked', 'failed']).optional(),
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
export const FOCUS_MODE_ACTIONS = {
|
|
29
|
+
[ENTER_FOCUS_MODE_ACTION_NAME]: enterFocusModeAction,
|
|
30
|
+
[UPDATE_FOCUS_WORK_ITEM_ACTION_NAME]: updateFocusWorkItemAction,
|
|
31
|
+
[RETURN_TO_SESSION_ACTION_NAME]: returnToSessionAction,
|
|
32
|
+
};
|
|
33
|
+
export function buildFocusActionSets(actions) {
|
|
34
|
+
return {
|
|
35
|
+
conversation: {
|
|
36
|
+
enterFocusMode: enterFocusModeAction,
|
|
37
|
+
...actions,
|
|
38
|
+
},
|
|
39
|
+
focus: {
|
|
40
|
+
...actions,
|
|
41
|
+
updateFocusWorkItem: updateFocusWorkItemAction,
|
|
42
|
+
returnToSession: returnToSessionAction,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function isEnterFocusModeAction(action) {
|
|
47
|
+
return action.name === ENTER_FOCUS_MODE_ACTION_NAME;
|
|
48
|
+
}
|
|
49
|
+
export function isUpdateFocusWorkItemAction(action) {
|
|
50
|
+
return action.name === UPDATE_FOCUS_WORK_ITEM_ACTION_NAME;
|
|
51
|
+
}
|
|
52
|
+
export function isReturnToSessionAction(action) {
|
|
53
|
+
return action.name === RETURN_TO_SESSION_ACTION_NAME;
|
|
54
|
+
}
|
|
55
|
+
export function enterFocusModeOutcomeNote(action) {
|
|
56
|
+
const workItem = typeof action.params.workItem === 'string' ? action.params.workItem.trim() : '';
|
|
57
|
+
if (workItem)
|
|
58
|
+
return 'focus mode entered with a persona-authored work item.';
|
|
59
|
+
return 'focus mode entered.';
|
|
60
|
+
}
|
|
61
|
+
export function updateFocusWorkItemOutcomeNote(action) {
|
|
62
|
+
void action;
|
|
63
|
+
return 'focus work item updated.';
|
|
64
|
+
}
|
|
65
|
+
export function returnToSessionOutcomeNote(action) {
|
|
66
|
+
const message = typeof action.params.message === 'string' ? action.params.message.trim() : '';
|
|
67
|
+
const to = typeof action.params.to === 'string' && action.params.to.trim()
|
|
68
|
+
? ` to ${action.params.to.trim()}`
|
|
69
|
+
: '';
|
|
70
|
+
return message
|
|
71
|
+
? `returnToSession posted visible message${to}: ${message}`
|
|
72
|
+
: `returnToSession posted visible message${to}.`;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=focus-mode-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-mode-actions.js","sourceRoot":"","sources":["../../src/core/focus-mode-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,MAAM,CAAC,MAAM,4BAA4B,GAAG,gBAAgB,CAAA;AAC5D,MAAM,CAAC,MAAM,kCAAkC,GAAG,qBAAqB,CAAA;AACvE,MAAM,CAAC,MAAM,6BAA6B,GAAG,iBAAiB,CAAA;AAE9D,MAAM,CAAC,MAAM,oBAAoB,GAAqB;IACpD,WAAW,E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OAAO,EAAE;QAC3D,CAAC,CAAC,yCAAyC,EAAE,GAAG,CAAA;AACpD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determine if a greeting/re-engagement is appropriate based on staleness.
|
|
3
|
+
* Returns true if: no prior message, >2 hours since last, or new calendar day.
|
|
4
|
+
*/
|
|
5
|
+
export declare function shouldGreet(lastMessageAt: Date | null | undefined, now?: Date, timezone?: string): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Build a greeting context hint for the system prompt.
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildGreetingHint(isGreeting: boolean, timezone?: string): string;
|
|
10
|
+
//# sourceMappingURL=greeting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"greeting.d.ts","sourceRoot":"","sources":["../../src/core/greeting.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,WAAW,CACzB,aAAa,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,EACtC,GAAG,CAAC,EAAE,IAAI,EACV,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAUT;AAYD;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,OAAO,EACnB,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAYR"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const STALE_THRESHOLD_MS = 2 * 60 * 60 * 1000; // 2 hours
|
|
2
|
+
/**
|
|
3
|
+
* Determine if a greeting/re-engagement is appropriate based on staleness.
|
|
4
|
+
* Returns true if: no prior message, >2 hours since last, or new calendar day.
|
|
5
|
+
*/
|
|
6
|
+
export function shouldGreet(lastMessageAt, now, timezone) {
|
|
7
|
+
if (!lastMessageAt)
|
|
8
|
+
return true;
|
|
9
|
+
const currentTime = now ?? new Date();
|
|
10
|
+
const elapsed = currentTime.getTime() - lastMessageAt.getTime();
|
|
11
|
+
if (elapsed >= STALE_THRESHOLD_MS)
|
|
12
|
+
return true;
|
|
13
|
+
if (isNewDay(lastMessageAt, currentTime, timezone))
|
|
14
|
+
return true;
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Check if two dates fall on different calendar days in the given timezone.
|
|
19
|
+
*/
|
|
20
|
+
function isNewDay(a, b, timezone) {
|
|
21
|
+
const opts = { timeZone: timezone };
|
|
22
|
+
const dayA = a.toLocaleDateString('en-CA', opts);
|
|
23
|
+
const dayB = b.toLocaleDateString('en-CA', opts);
|
|
24
|
+
return dayA !== dayB;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Build a greeting context hint for the system prompt.
|
|
28
|
+
*/
|
|
29
|
+
export function buildGreetingHint(isGreeting, timezone) {
|
|
30
|
+
if (!isGreeting)
|
|
31
|
+
return '';
|
|
32
|
+
const now = new Date();
|
|
33
|
+
const timeStr = now.toLocaleTimeString('en-US', {
|
|
34
|
+
timeZone: timezone,
|
|
35
|
+
hour: 'numeric',
|
|
36
|
+
minute: '2-digit',
|
|
37
|
+
});
|
|
38
|
+
const dateStr = now.toLocaleDateString('en-CA', { timeZone: timezone });
|
|
39
|
+
return `This is a fresh session (${dateStr}, ${timeStr}). The context, memories, and history you have paint the current situation.`;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=greeting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"greeting.js","sourceRoot":"","sources":["../../src/core/greeting.ts"],"names":[],"mappings":"AAAA,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA,CAAC,UAAU;AAExD;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,aAAsC,EACtC,GAAU,EACV,QAAiB;IAEjB,IAAI,CAAC,aAAa;QAAE,OAAO,IAAI,CAAA;IAE/B,MAAM,WAAW,GAAG,GAAG,IAAI,IAAI,IAAI,EAAE,CAAA;IACrC,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,aAAa,CAAC,OAAO,EAAE,CAAA;IAE/D,IAAI,OAAO,IAAI,kBAAkB;QAAE,OAAO,IAAI,CAAA;IAC9C,IAAI,QAAQ,CAAC,aAAa,EAAE,WAAW,EAAE,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAA;IAE/D,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;GAEG;AACH,SAAS,QAAQ,CAAC,CAAO,EAAE,CAAO,EAAE,QAAiB;IACnD,MAAM,IAAI,GAA+B,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAA;IAC/D,MAAM,IAAI,GAAG,CAAC,CAAC,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IAChD,MAAM,IAAI,GAAG,CAAC,CAAC,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IAChD,OAAO,IAAI,KAAK,IAAI,CAAA;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAAmB,EACnB,QAAiB;IAEjB,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAA;IAE1B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IACtB,MAAM,OAAO,GAAG,GAAG,CAAC,kBAAkB,CAAC,OAAO,EAAE;QAC9C,QAAQ,EAAE,QAAQ;QAClB,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;KAClB,CAAC,CAAA;IACF,MAAM,OAAO,GAAG,GAAG,CAAC,kBAAkB,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAA;IAEvE,OAAO,4BAA4B,OAAO,KAAK,OAAO,6EAA6E,CAAA;AACrI,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PersonaIdentity } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Build the identity paragraph of the system prompt from persona config.
|
|
4
|
+
* This is the opening paragraph that sets expertise, relationship, and north star.
|
|
5
|
+
*
|
|
6
|
+
* DESIGN PRINCIPLE — Scenario-first, not directive-first.
|
|
7
|
+
* Identity stays neutral: who this expert is, what they weave together,
|
|
8
|
+
* and what they serve. Mode-specific presence/keystone hooks are layered
|
|
9
|
+
* separately so operational turns do not inherit conversation assumptions.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildIdentityBlock(identity: PersonaIdentity): string;
|
|
12
|
+
export declare function buildConversationKeystone(identity: PersonaIdentity, relationalPreamble?: string | false): string;
|
|
13
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/core/identity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAOlD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,CA0BpE;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,eAAe,EACzB,kBAAkB,CAAC,EAAE,MAAM,GAAG,KAAK,GAClC,MAAM,CAQR"}
|