feat(telos): add @decocms/telos goal-pursuit agent core#3897
Open
pedrofrxncx wants to merge 20 commits into
Open
feat(telos): add @decocms/telos goal-pursuit agent core#3897pedrofrxncx wants to merge 20 commits into
pedrofrxncx wants to merge 20 commits into
Conversation
Standalone, domain-agnostic core for agents that pursue a fixed goal: one
Eudaimon per tenant observes a world, measures it against an immutable,
versioned UnmovedMover, and acts to close the gap.
- core.ts: UnmovedMover, GoalLedger port, Domain/Action/Deliberator ports,
EventBus, Eudaimon, wire() — depends only on zod
- InMemoryGoalLedger + inMemoryBus defaults
- ruleDeliberator (offline) and aiDeliberator ("@decocms/telos/ai", optional
`ai` peer dep, injected model)
- runnable examples (storefront + content-calendar) and unit tests
Additive and inert: nothing imports it yet; the agent loop and apps/mesh are
untouched.
Let the engine author its own SUBORDINATE goals after each cycle, anchored so it can never run away: - UnmovedMover gains `source: "authority" | "engine"`; GoalLedger gains `anchor()` (latest authority goal — the fixed parent the engine can never overwrite). `latest()` stays the current working goal. - New GoalProposer port, consulted after each pursue cycle, handed the anchor to keep proposals in its service; returns the next goal or null. - Gated by default: optional `approveGoal` hook (reject → eudaimon.goal.rejected); omit it to auto-install. Engine installs emit eudaimon.goal.proposed. - Eudaimon now takes an options object (EudaimonDeps). Additive: omit `proposer` for the classic authority-only behavior.
Three pictures of purpose, composing over the Aristotelian core: - /daimonion: the veto guardrail (apophatic — only forbids). guardedBy(d)(domain) screens every action before its side effect; forbidden actions never run and emit eudaimon.action.vetoed. Built + tested. (Distinct from the Eudaimon, the striver — the Daimonion only ever says no.) - /elenchus: goal-discovery dialectic (interface). deliver(tenant) births a GoalProposal an authority then installs; the contract the onboarding research→propose flow will implement. - /demiurge: the transcendent Form you only approach (interface only, reserved — no impl/consumer yet; participation():number replaces satisfied():boolean). Adds PursuitContext.vetoed() + eudaimon.action.vetoed; the built-in deliberators turn a guarded action's VetoError into that event.
Flat src/ → folders mirroring the package's own design:
core/ the Aristotelian engine, split by concept (mover, ledger, domain,
events, deliberator, eudaimon) behind a barrel
deliberators/ rule, ai
socratic/ daimonion (veto), elenchus
platonic/ demiurge
Also: extracted the duplicated apply→record / veto→ctx.vetoed flow out of both
deliberators into a single core applyAction(); moved VetoError into core so the
layering is one-way (core never depends on the socratic/platonic extensions).
No behavior change — 20 tests, tsc, lint, knip, example all green.
- Added `telos_goal` table to the database schema for managing organization-specific goals. - Implemented onboarding goal seeding in the `seedOnboardingGoal` function, which utilizes the new `KyselyGoalLedger` to manage goal persistence. - Introduced `researchElenchus` for goal discovery based on user email, enhancing the onboarding experience. - Updated package dependencies to include `@decocms/telos` across relevant files.
- Introduced `telos_fact` table to store tentative findings about an organization's owner during onboarding. - Added `FactStore` class for managing facts, including insertion, status updates, and retrieval. - Created `createTelosGoalRoutes` for handling API endpoints related to onboarding goals and facts. - Implemented durable capabilities for onboarding research, utilizing Firecrawl and OpenRouter to generate facts based on user email. - Integrated real-time updates for goal and fact status through SSE notifications. - Updated the home page layout to include the new `TelosGoalCard` component for displaying onboarding information.
- Simplified and clarified comments across various files, including `telos_fact`, `telos_goal`, and `fact-store`, to enhance readability and understanding of the codebase. - Removed outdated and verbose documentation, replacing it with concise descriptions of functionality and purpose. - Ensured consistency in comment style and format throughout the codebase.
…onboarding process - Introduced `onboardingLedger` function to create a Postgres GoalLedger adapter, allowing for better management of organization-specific goals. - Updated the `telos_goal` table structure and removed the previous implementation in favor of the new adapter. - Refactored API routes and capabilities to utilize the new onboarding ledger, improving the onboarding experience for organizations. - Added `kysely` as a devDependency and updated peerDependencies to include it, ensuring compatibility with the new ledger implementation. - Enhanced documentation and comments for clarity regarding the new structure and functionality.
…reamline storage integration - Deleted `110-telos-goal.ts` and `111-telos-fact.ts` migration files as telos now manages its own schema and migrations. - Updated `index.ts` to remove references to the deleted migrations. - Refactored API routes to utilize the new `onboardingFacts` and `onboardingLedger` functions from the `store` module, enhancing integration with the telos storage system. - Cleaned up the `fact-store` and `ledger` implementations, ensuring alignment with the new architecture and removing unused code.
…lities - Introduced `bootTelos` function to streamline the initialization of the telos schema, replacing previous migration calls. - Updated API routes to utilize the new `telos` module for managing onboarding facts and goals, improving integration and reducing complexity. - Removed deprecated `onboardingFacts` and `onboardingLedger` functions, consolidating functionality within the new `telos` structure. - Added new capabilities for goal pursuit, allowing for adaptive deliberation and event handling during onboarding processes. - Enhanced documentation to reflect changes in architecture and usage of the telos system.
- Introduced `initTelosDbos` to initialize the shared queue for onboarding research and goal pursuit, improving resource management. - Added new action types for user-driven onboarding actions, allowing the system to suggest actions like connecting tools and running automations. - Implemented a retry mechanism for onboarding research steps to handle transient failures, enhancing reliability during user onboarding. - Refactored the goal pursuit capability to streamline the process of pursuing goals and managing schedules, ensuring continuous engagement until goals are met. - Updated event handling to include new goal suggestion events, enriching the interaction model for user onboarding. - Enhanced documentation to reflect the new capabilities and usage patterns in the telos system.
…uit capabilities - Replaced `RESEARCH_EMAIL` with a new `researchSubject` function to dynamically resolve user email and name during onboarding and goal pursuit. - Updated API routes to utilize the new `researchSubject` function, improving the accuracy of user data in event handling. - Enhanced the `goal-pursuit` capability to streamline the scheduling and execution of goal pursuit cycles, ensuring continuous engagement until goals are met. - Introduced a safety net mechanism to re-arm pursuit loops for goals that have stalled, enhancing reliability in goal management. - Improved documentation to reflect changes in the onboarding and goal pursuit processes, ensuring clarity for future development.
- Updated the Telos goal routes to utilize the latest goal suggestion and onboarding progress, improving user experience during onboarding. - Introduced a new `OrgActivity` pub/sub mechanism to signal meaningful changes in organization state, allowing for better responsiveness in goal pursuit. - Enhanced the `onboardingProgress` function to provide detailed tool connection status, enriching the onboarding feedback loop. - Implemented debounced goal re-fitting triggered by user fact edits, ensuring goals remain relevant and aligned with user input. - Improved the TelosGoalCard component to display suggested next steps and tool connection progress, enhancing user engagement and clarity. - Refactored various components and hooks to accommodate new data structures and improve overall code organization.
- Added a new `catalog.ts` file to manage a catalog of connectable apps, including fetching from a live store and validating proposed tools against the catalog. - Enhanced the `research.ts` file to utilize the catalog for validating tools and generating prompts based on available integrations. - Updated the `target.ts` interface to include optional `appName` and `icon` properties for better integration with the catalog. - Refactored the onboarding research capabilities to ensure only supported tools are suggested, improving the onboarding experience. - Introduced a new `use-install-app` hook for streamlined app installation, enhancing user interaction with tool connections. - Improved the `TelosGoalCard` component to display tool connection status and facilitate app installation directly from the UI.
… goal pursuit - Introduced a new `thought` management system to capture and publish the agent's reasoning during research and pursuit phases, improving user engagement. - Updated the `TelosGoalCard` component to display live thoughts, providing users with real-time insights into the agent's reasoning. - Enhanced the `researchUser` function to include callbacks for thought updates, ensuring that the agent's reasoning is communicated effectively. - Implemented new SSE events for thoughts and suggestions, allowing for dynamic updates in the UI without requiring full state refetches. - Refactored various components and hooks to integrate the new thought management system, improving overall responsiveness and user experience.
- Introduced a new `telos` module to manage agent purposes, allowing agents to carry a defined telos (purpose) during operations. - Implemented `resolveAgentTelos` function to fetch and render an agent's purpose from the goal ledger, enhancing agent decision-making. - Updated the `runAgentLoop` and `buildAgentSystemPrompt` functions to incorporate telos, ensuring agents operate with a clear purpose. - Enhanced the `createTelosGoalRoutes` to trigger pursuit cycles based on user confirmations, improving responsiveness to user input. - Added new tests for telos functionality, ensuring robust integration and behavior of purpose management within the agent framework.
- Removed redundant import of `GoalLedger` in `agents.ts` and replaced it with a more relevant import from `@decocms/telos`. - Expanded the README.md to include detailed instructions on integrating telos into existing agents, outlining how to define an agent's purpose and manage its tools. - Refactored `guardTools` in `daimonion.ts` to improve type handling for tool execution, ensuring better compatibility with various tool structures.
…ocess - Introduced a new `Goal` interface to define a fixed, outcome-framed goal for organizations, ensuring clarity in onboarding objectives. - Updated the `createTelosGoalRoutes` to utilize the new goal structure, projecting relevant tools for user connections. - Removed the deprecated `catalog.ts` file and refactored related functionalities to streamline app integration processes. - Enhanced the onboarding capabilities by implementing a deterministic goal installation during user signup, improving the user experience. - Updated various functions to align with the new goal structure, ensuring consistency across the onboarding workflow.
- Removed the `goal-progression` capability as its functionality is now integrated within the enduring goal structure. - Updated the `goal-pursuit` capability to ensure continuous engagement with the goal, reflecting the enduring nature of the goal in the pursuit cycle. - Enhanced the `curriculumFor` function to clarify the onboarding steps and improve the user experience by providing more detailed instructions. - Refactored the `runPursuitCycle` function to eliminate the concept of a "reached" goal, ensuring the system continuously produces actionable steps. - Improved documentation and comments throughout the code to reflect the new goal management approach and enhance clarity for future development.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
@decocms/telos— a small, standalone, domain-agnostic core for agents that pursue a fixed goal. One agent per tenant observes a world, measures it against a goal it did not choose, and acts to close the gap until none is left.The design keeps the goal and the striving rigorously separate, so an agent can never quietly rewrite its own purpose (the names come from Aristotle's two movers — see the package README for the full intro):
UnmovedMover<T>— the goal: frozen, versioned, per-tenant target data. Behaviorless; never mutated, never acts.GoalLedger<T>— append-only succession of goal versions (installing a new version is the only way a goal changes).Eudaimon<S,T,G>— the agent: observes, measures, deliberates, acts — pursuing the current goal but never authoring it.Domain<S,T,G>— the one extension point: how to perceive a world, judge it, and act in it.Deliberator— swappable reasoning:ruleDeliberator(offline, deterministic) oraiDeliberator.What's included
core.ts—UnmovedMover, theGoalLedger/Domain/Action/Deliberatorports,EventBus,Eudaimon,wire(). Depends only onzod— never the AI SDK.InMemoryGoalLedger+inMemoryBus— swappable defaults.ruleDeliberator(offline) andaiDeliberator(exported at@decocms/telos/ai;aiis an optional peer dep, model is injected).examples/(storefront + content-calendar on the same core) and co-located unit tests.Architecture: two causes, kept apart
The agent reacts to
state.changed; a new goal arrives only viagoal.updated, which only an authority emits. The agent is never on the goal-setting path.Scope / impact
Additive and inert. Nothing in the codebase imports it yet — the existing agent loop and
apps/meshare untouched. The package is self-contained and extractable to its own repo (deps:zod; optional peer:ai).Testing
bun test packages/telos— 10 pass (frozen mover, ledger succession, pursuit, causal separation, deterministic convergence to a fixed star + re-pursuit of a raised goal).bun run --cwd packages/telos check(tsc),bun run lint,bun run knip— all green.bun run --cwd packages/telos example— converges as expected (ledger history: v1 -> v2).knip.jsoncgains one entry markingaias the intentional optional peer (mirrors the existingmesh-sdk→sonnerprecedent).Summary by cubic
Adds
@decocms/telos, a small, domain‑agnostic core for fixed‑goal agents, and wires it into Mesh with a Postgres goal ledger, durable onboarding, a recurring pursuit loop, and a live home card. On signup we install a deterministic, fixed org goal and stream research, thoughts, and suggestions; Decopilot and user agents carry a telos (charter + guard) resolved from per‑agent goals, and pursuit now runs continuously for the enduring goal.New Features
UnmovedMover(addssource),GoalLedger(addsanchor()),Eudaimon,Domain/Action,Deliberator(rule or optional@decocms/telos/ai),Telos<T>(charter/guard/measure for existing agents),applyAction,VetoError; bus addseudaimon.action.vetoedandPursuitContext.vetoed().bootTelos()migrates/builds the@decocms/telos/postgresstore and registers capabilities; shared, rate‑limited DBOS queue viainitTelosDbos(); onboarding installs a fixed Goal (buildStudioGoal()) onuser.signupand runs background research (Firecrawl + OpenRouter) to propose facts; pursuit runs immediately and on a schedule with a heartbeat and never “finishes”; user‑only actions surface asgoal.suggestionand cache per org; live thoughts stream via SSE (goal.thought) and cache per org; fact edits debounce a goal re‑fit;orgActivitypub/sub nudges pursuit.TelosGoalCardshows suggested next steps, live thoughts, per‑tool connection status, and one‑click install buttons (use-install-app);GET /api/:org/telos-goalreturns{ goal, facts, suggestion, thought, progress, status };POST /api/:org/telos-facts/:idconfirms/rejects facts; SSE notifications (telos.goal.installed,telos.facts.updated,telos.goal.suggestion,telos.goal.thought).agent:<id>); the charter is added to the system prompt and tools are guarded viaguardToolsfrom@decocms/telos/daimonion; new agents seed their telos from their instructions on create.Refactors
bootTelos(), removed legacy onboarding ledger/facts wiring, added a telos SSE pool and client hooks, and updatedknip.jsoncto ignore the optionalaipeer.appNameandicon). ImprovedguardToolstypes and cleaned telos agent imports; expandedpackages/telos/README.mdwith an integration guide. Removed the old goal‑progression capability; pursuit is continuous against the enduring goal.Written for commit b9be9c1. Summary will update on new commits.