feat(goal): add persisted same-session goal domain

This commit is contained in:
Tianyi Cui
2026-07-19 18:47:34 +08:00
parent 2b39ac3209
commit a525776015
46 changed files with 3033 additions and 6 deletions

View File

@@ -54,6 +54,10 @@
"text": "ctx.fs",
"link": "/zh-CN/api/harness/fs"
},
{
"text": "ctx.goals",
"link": "/zh-CN/api/harness/goals"
},
{
"text": "ctx.llm",
"link": "/zh-CN/api/harness/llm"

View File

@@ -2,7 +2,7 @@
# Harness events
Every event the harness packages declare on the cordis event bus (42 total), grouped by scope. The **mode** is the dispatch semantics (`emit` fire-and-forget, `parallel` awaited, `serial` first-bail, `waterfall` veto-chain — a waterfall listener MUST call `next()` to delegate).
Every event the harness packages declare on the cordis event bus (43 total), grouped by scope. The **mode** is the dispatch semantics (`emit` fire-and-forget, `parallel` awaited, `serial` first-bail, `waterfall` veto-chain — a waterfall listener MUST call `next()` to delegate).
## agent/*
@@ -519,6 +519,32 @@ Single-slot decision for the next FileSystem.writeText. Calling `next()` yields
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/fs/fs/src/index.ts#L53)
## goal/*
### goal/changed
**Mode:** `emit`
```ts website-api
/**
* Goal mutation accepted by one live agent. The matching context event is
* already appended or queued in that agent's active tool-batch FIFO.
* Listener failures are contained.
* Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only that agent.
* @param agent - agent whose session owns the goal.
* @param change - fresh current projection or clear tombstone.
* @mode emit
*/
'goal/changed'(this: import('@deepseek-ai/dsh-scope').Scoped<Agent>, agent: Agent, change: GoalChanged): void
```
Goal mutation accepted by one live agent. The matching context event is already appended or queued in that agent's active tool-batch FIFO. Listener failures are contained. Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only that agent.
- `agent` — agent whose session owns the goal.
- `change` — fresh current projection or clear tombstone.
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/goal/goal/src/types.ts#L166)
## llm/*
### llm/stream

View File

@@ -0,0 +1,241 @@
<!-- Generated by scripts/gen-website-api.ts — do not edit by hand. Run `pnpm run gen-website-api` to regenerate. -->
# ctx.goals
`GoalService` — provided by `@deepseek-ai/dsh-goal`.
Goal service (`ctx.goals`) backed exclusively by the owning session log.
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/goal/goal/src/index.ts#L97)
### ctx.goals.resolveCreate(request)
```ts website-api
/**
* Materialize deployment defaults and validate one create request.
* @param request - objective plus optional caller-selected round cap.
* @returns detached, fully resolved create specification.
*/
resolveCreate(request: CreateGoalRequest): CreateGoalSpec
```
Materialize deployment defaults and validate one create request.
- `request` — objective plus optional caller-selected round cap.
**Returns** detached, fully resolved create specification.
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/goal/goal/src/index.ts#L122)
### ctx.goals.get(agent)
```ts website-api
/**
* Read the current goal for one exact live agent.
* @param agent - owning live agent.
* @returns a fresh view or `undefined` when no goal is current.
* @throws {@link GoalError} when the agent is not the registry's live instance.
*/
get(agent: Agent): GoalView | undefined
```
Read the current goal for one exact live agent.
- `agent` — owning live agent.
**Returns** a fresh view or `undefined` when no goal is current.
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/goal/goal/src/index.ts#L135)
### ctx.goals.create(agent, request)
```ts website-api
/**
* Create and arm a goal. A completed goal may be replaced; every other
* current phase must be cleared or resumed instead.
* @param agent - owning live agent.
* @param request - objective and optional round cap.
* @returns the created live view.
*/
create(agent: Agent, request: CreateGoalRequest): GoalView
```
Create and arm a goal. A completed goal may be replaced; every other current phase must be cleared or resumed instead.
- `agent` — owning live agent.
- `request` — objective and optional round cap.
**Returns** the created live view.
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/goal/goal/src/index.ts#L149)
### ctx.goals.edit(agent, ref, request)
```ts website-api
/**
* Edit objective and/or round cap without changing phase.
* @param agent - owning live agent.
* @param ref - expected current revision.
* @param request - at least one replacement field.
* @returns the edited view.
*/
edit(agent: Agent, ref: GoalRef, request: EditGoalRequest): GoalView
```
Edit objective and/or round cap without changing phase.
- `agent` — owning live agent.
- `ref` — expected current revision.
- `request` — at least one replacement field.
**Returns** the edited view.
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/goal/goal/src/index.ts#L174)
### ctx.goals.pause(agent, ref)
```ts website-api
/**
* Pause an active goal and disarm automatic continuation.
* @param agent - owning live agent.
* @param ref - expected current revision.
* @returns the paused view.
*/
pause(agent: Agent, ref: GoalRef): GoalView
```
Pause an active goal and disarm automatic continuation.
- `agent` — owning live agent.
- `ref` — expected current revision.
**Returns** the paused view.
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/goal/goal/src/index.ts#L195)
### ctx.goals.resume(agent, ref)
```ts website-api
/**
* Resume and arm a stopped goal, or rearm an active goal after a
* session-start edge, while its round budget still has capacity.
* @param agent - owning live agent.
* @param ref - expected current revision.
* @returns the active view.
*/
resume(agent: Agent, ref: GoalRef): GoalView
```
Resume and arm a stopped goal, or rearm an active goal after a session-start edge, while its round budget still has capacity.
- `agent` — owning live agent.
- `ref` — expected current revision.
**Returns** the active view.
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/goal/goal/src/index.ts#L206)
### ctx.goals.complete(agent, ref)
```ts website-api
/**
* Mark a current non-complete goal complete and disarm it.
* @param agent - owning live agent.
* @param ref - expected current revision.
* @returns the completed view.
*/
complete(agent: Agent, ref: GoalRef): GoalView
```
Mark a current non-complete goal complete and disarm it.
- `agent` — owning live agent.
- `ref` — expected current revision.
**Returns** the completed view.
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/goal/goal/src/index.ts#L231)
### ctx.goals.block(agent, ref)
```ts website-api
/**
* Mark an active goal blocked and disarm it.
* @param agent - owning live agent.
* @param ref - expected current revision.
* @returns the blocked view.
*/
block(agent: Agent, ref: GoalRef): GoalView
```
Mark an active goal blocked and disarm it.
- `agent` — owning live agent.
- `ref` — expected current revision.
**Returns** the blocked view.
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/goal/goal/src/index.ts#L248)
### ctx.goals.markUsageLimited(agent, ref)
```ts website-api
/**
* Mark an active goal stopped by an external usage limit.
* @param agent - owning live agent.
* @param ref - expected current revision.
* @returns the usage-limited view.
*/
markUsageLimited(agent: Agent, ref: GoalRef): GoalView
```
Mark an active goal stopped by an external usage limit.
- `agent` — owning live agent.
- `ref` — expected current revision.
**Returns** the usage-limited view.
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/goal/goal/src/index.ts#L258)
### ctx.goals.markBudgetLimited(agent, ref)
```ts website-api
/**
* Mark an active goal stopped at its configured round cap.
* @param agent - owning live agent.
* @param ref - expected current revision.
* @returns the budget-limited view.
*/
markBudgetLimited(agent: Agent, ref: GoalRef): GoalView
```
Mark an active goal stopped at its configured round cap.
- `agent` — owning live agent.
- `ref` — expected current revision.
**Returns** the budget-limited view.
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/goal/goal/src/index.ts#L268)
### ctx.goals.clear(agent, ref)
```ts website-api
/**
* Clear the current goal while retaining a durable tombstone and history.
* @param agent - owning live agent.
* @param ref - expected current revision.
* @returns the tombstone ref whose revision is one past the cleared snapshot.
*/
clear(agent: Agent, ref: GoalRef): GoalRef
```
Clear the current goal while retaining a durable tombstone and history.
- `agent` — owning live agent.
- `ref` — expected current revision.
**Returns** the tombstone ref whose revision is one past the cleared snapshot.
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/goal/goal/src/index.ts#L295)