* feat(liveshare): open reader capabilities the share can serve (cherry picked from commit 3c893b488900fff776a21eebee4eb2d95b878764) * feat(liveshare): let a reader run the session's slash commands (cherry picked from commit ae02bcc0f819e55ebf066de7581d4d89994930a4) * fix(liveshare): allow a reader to list the workspace file references (cherry picked from commit fffaa864b9d790a0aab30da639d5ef50ff8f303c) * fix(liveshare): bind the job endpoints to their session resource (cherry picked from commit 357d1f6efe5b161a4ce1b616e66599c4e75a6ab1) * chore: refresh the Cordis surface catalog (cherry picked from commit 88f88b225f0fcff0a5a88f09b0f555749dd62756) * test(job-controller): read the Session resources the Remote methods declare The job roster, the follow stream, and a kill each declare the request's Session as the resource they touch, and an unowned job's follow names none. Read those declarations off the mounted Controller and pin what they answer. (cherry picked from commit fa3f92427a6bd56ad2a949dc74315505cb75533b) * feat(liveshare): offer a shareable core component to viewers The terminal controller reaches the catalog from a core profile bundle, which the catalog excludes so no application plumbing is offered. Mark such a component shareable: PluginMetadata gains the mark, and the host names the packages that carry it, so a marked core component enters the catalog and every other core component stays out. The terminal namespace leaves the exclusion list for the same reason, and the marked component carries the title its dialog row shows. (cherry picked from commit b0e9e390719aab519fd82cf39c85c60e4f77b588) * fix(liveshare): classify the terminal methods as owner-selected The nine terminal methods leave owner-only for plugin-offered: the owner picks them in the share dialog, no reader role grants one, and a share that names none still refuses every terminal call. (cherry picked from commit 718c1b45a1b01320cbe9be46ece9deca37225fe2) * docs(liveshare): state that terminals open per method Terminals are no longer unconditionally owner-only: the share dialog offers the terminal controller's methods and opens none until the owner picks them. (cherry picked from commit 505c1193571b16431731f69bd5ca1b59a1059a13) * test(liveshare): cover a viewer reaching the Session's terminals The end-to-end case mounts a real terminal controller beside the share host: the catalog offers it as a shareable core component, a share that selects nothing refuses every terminal call, and a selected terminal/create through the reader's own Peer binds the shell to the Session its agentId names. (cherry picked from commit 25955a936dc5b58ebfd8e1d24f495d62d59f7b70) * fix(workspace-files): confine non-owner reads to the session workspace A non-owner Peer now reads and watches files only inside the connected Session workspace. stat, read, readBytes (including baseFile) and changes resolve the target canonically and refuse an outside one with workspace-file/outside-workspace before reporting its kind. Owner and trusted in-process callers keep the filesystem read authority. (cherry picked from commit 7ae855e12ba6c5bc99c7ae75d65d984661f3bbb5) * refactor(workspace-files): name the file access confinement Replace the contain boolean with a named FileConfinement carried by the service, and move the outside-workspace refusal into one helper shared by file reads and watches. No Remote interface or behavior changes. (cherry picked from commit 1c4dbd68220df7c559f84cf2782f9626c5b2ef4b) * refactor(workspace-files): name the path mode PathScope Replace the FileConfinement/confinement vocabulary with PathScope, and rename its module and test. The values and behavior are unchanged. # Conflicts: # packages/api/workspace-files/src/index.ts # packages/api/workspace-files/tsconfig.host.json (cherry picked from commit 5d3f7b31dc6a1dbcf44c5fdd59295402bf40cf76) * refactor(workspace-files): accept several workspace roots in the path check The confinement helper and change feed now take several resolved roots; the current scope still supplies one. WorkspaceFileScope.workspaceRoot remains the primary root, so a future multi-workspace Session can add optional roots without changing endpoint signatures, path arguments, or the client address. (cherry picked from commit 73fd59be92c421c378b7fe5606d8d7c5806b13cb) * fix(workspace-files): keep the multi-root watch check covered Pass the primary watch root separately and iterate the roots list, so the feed keeps full coverage for the multi-root preparation. Add braces to the multi-root test arrow for the lint rule. (cherry picked from commit 1286aac6a6d93e693dbb33f2feaa71e6252424e0) * test(workspace-files): assert a refusal never reports the target kind The outside-workspace failure carries only the path, so a share reader learns nothing about what it was refused. stat, read, readBytes, list, and a relative escape are each asserted not to carry a kind. (cherry picked from commit a9495de0ff63a1aac325d1cb62b8111c188ae8a5) * test(workspace-files): keep the search caps in the shared harness config Rebasing over the search endpoint left configOf() without the search limits the master harness passed inline, so every search call reached the subprocess provider with an undefined graceMs. configOf and peer() now take Caps and supply the suite defaults. (cherry picked from commit 70cecb9b352ce5c1e17482429b1539483e101d60) * docs(workspace-files): describe the read confinement against the search-era structure The master README added the search section and rewrote the file-read checks without a workspace-containment check. Those paragraphs now state which caller the check applies to, the change feed mentions the non-owner watch, and the source map lists path-scope.ts. Bilingual hashes re-recorded with verify-translation-pairing --write. (cherry picked from commit e61fdabaf2fb9b0c0bc507ef5ceea0f213f70683) * fix(liveshare): keep workspaceFiles/search in the reader session-read role The classification table is the single source for POLICY_DECIDED_ACTIONS, so the new search endpoint must also appear in the read role's actions. (cherry picked from commit 665093b07cfee87be105fdc71a7d58fe25974788) * docs(catalog): regenerate the client and config catalogs Removing the viewer share-path tab drops its client slot entry, and the workspace file import shifts the Config source line. (cherry picked from commit 7bb9295a18b011971b4338171a60d16ff82eebd1) * docs(catalog): regenerate the config catalog source line (cherry picked from commit 2d98a59afc8aa6e2a9ac268d4446bcd8cd5eeb26) * fix(liveshare): let share readers preview workspace files The served page keeps the shipped Sidebar and now reads the shared Session workspace through workspaceFiles: stat, read, readBytes, list and changes join the Session read role, while the file service confines every non-owner read to that workspace root. The viewer tab type that answered each file address with "a share hands over paths, not contents" is removed, so the shipped document preview opens the file. Refs #7901 (cherry picked from 5e0ceac3faa)(partial: liveshare files only) * fix(ui-jobs): offer the stop control only with job/kill access (cherry picked from commit 804956ece9c09b2fac6180cd78da7aa7393ae0de) * fix(ui-chat): attribute a reader's steering row while it is pending Chat declared the message-source seat on the user node registration, so an admitted steering row rendered the shared bubble without asking for it and a Host-pending steering occurrence carried no source to ask with. Move the seat to the flow: it renders user rows, admitted steering rows, and pending steering occurrences, and hands the same renderer to each. Liveshare's selector now elects a share-viewer source of either kind, so a reader's interjection states its author from the moment it is sent. (cherry picked from c802aef8392)(partial: liveshare client files only) * docs(liveshare): state when a reader's interjection shows its author A local submission echo carries no source, so the author line appears once the Host records the input in the Inbox, not when the reader sends it. (cherry picked from 42001b1294d)(partial: liveshare client files only) * docs(liveshare): describe the seat source arriving as row props (cherry picked from commit 466e25328c5c42c792bfb30bba05ff790259bf99) * fix(liveshare): refuse /permission to share readers The commands executor runs a command handler inside the owner Host with no reader-specific narrowing, so a reader line such as `/permission danger-full-access` left the shared Session unconfined with no approval. The read role's condition now parses the `commands/execute` line and refuses the owner-only command names, starting with `/permission`, with the new `command-owner-only` reason the viewer page classifies. Every other command keeps following visibility. * feat(permission-presets): add the permissionPresets/set Remote The `/permission` command switches a Session's sandbox mode and approval policy inside the owner Host's own handler, which gives a share reader that reaches `commands/execute` no endpoint decision to meet. The switch now has a Remote face: `permissionPresets/set` names the Session it writes as its `session` resource, so the Gateway decides who may call it before any preset is resolved or any knob changes. The request carries the Session id and the preset name only. An unknown preset and a Session this process does not hold live both refuse with `gateway/bad-request` before writing. The call reports the selection the Session reads back after the switch. The command reaches the same switch, keeping its ordering and its `success` and `error` text. Because a Remote parameter cannot carry an Agent, the command supplies the approval write itself so its model-visible policy notice still follows the switch. Co-Authored-By: DeepSeek Harness <[email protected]> * fix(liveshare): classify permissionPresets/set owner-only The new preset endpoint writes the source Session's sandbox mode and approval policy, so no share reader role may reach it at any tier. The viewer endpoint classification records it as owner-only, and the viewer access policy spec proves a reader is refused on the shared Session, on its own forks, and on a Session outside the share, and that no reader grant carries the action. The owner-only command whitelist stays as the second defense: the commands handler runs inside the owner Host, so a reader line must not depend on that handler continuing to route through the endpoint. Co-Authored-By: DeepSeek Harness <[email protected]> * test(liveshare): keep every permission preset endpoint owner-only The classification table's completeness gate proves a new generated endpoint has a row, but not that the row keeps a reader out. This case reads the table and fails when any `permissionPresets/*` endpoint is classified as anything other than owner-only, so an endpoint added there without its class checked turns the suite red instead of widening a reader's reach. Co-Authored-By: DeepSeek Harness <[email protected]> * docs(catalog): regenerate for the preset set Remote The new `permissionPresets/set` Remote adds its signature and its request type to the generated service and type catalogs, maps the request type to the permission presets subsystem page, and shifts the permission preset config source line. The permission presets subsystem pages describe the write path and its Remote face on both sides. Co-Authored-By: DeepSeek Harness <[email protected]> * test: construct SessionId values and keep the approval notice lock The rebased specs called SessionId as a value while importing it as a type, so every case threw ReferenceError. Construct the ids the way the packages already do, and keep the /permission case that locks the single model-visible approval notice. * test(liveshare): load the terminal controller without a built artifact The spec resolved a generated typert artifact at module load, so a clean checkout failed before any case ran. * docs(liveshare): state the reader limits the review asked about Marks the answer path's dependence on timed asks, records that @ mentions list every host session, and explains which commands stay owner-only. * feat(liveshare): let a viewer manage the goal of a visible Session The goal is Session data, not the workspace sandbox, so the same visibility rule that already covers goals/get and goals/edit applies to create, pause, resume, complete and clear. The /goal command reaches the same service, so the endpoint and the command now agree. # Conflicts: # packages/experimental/liveshare/README.i18n.yaml * fix(liveshare): keep the terminal component titles The shareable mark's localized titles were spread onto the metadata record, which put `en` and `zh` at the top level instead of in the `titles` field the catalog reads. A core bundle without display metadata therefore offered the terminal with no product name at all. * fix(workspace-files): decide the path scope before stat A non-owner read probed the path with `lstat` before it checked containment, so reading an absent path outside the workspace answered `not-found` while an existing one answered `outside-workspace`. That let a share reader probe whether any path on the owner's machine exists. Every confined read now resolves and confines its target first: `read`, `stat`, `readBytes` (including a path relative to a base file) and `list`. The final `lstat` still reports the component's own kind, and the owner keeps the filesystem's authority, including its previous answer for an absent path. * docs(liveshare): drop the queue-verb mention `session/updateQueue` is not in the viewer Session read role, and viewer queue management is not part of this change. The role's rationale now names the reach it actually carries, and the workspace file actions no longer leak whether a path outside the workspace exists. * test(liveshare): describe the terminal suite's actual coverage * chore: regenerate the catalogs the viewer capability change moves session-reference, user-questions and the permission presets all feed the Cordis, persistence and doc-graph generators, so their artifacts were stale. * fix(liveshare): keep the command refusal copy paired and cover the file paths The English notice read "/permission on", which the locale gate tokenised together while the translations kept the command alone. The workspace-file and preset paths the coverage lane flagged now have cases of their own. * test(workspace-files): accept either refusal code for a UNC base Windows resolves an unreachable UNC host through the local backend's ancestor walk, which reports an IO failure instead of the not-found POSIX reads. Both refuse the read; the code belongs to that backend, not to the path-scope decision this case covers. * refactor(liveshare): leave the command surface to its own change Running a slash command is a separate decision from what a reader may read: the executor wraps several capabilities in one opaque call, so the endpoint that admits it is not the place to decide them. This change keeps the reader capabilities and the preset endpoint, and returns the command wiring when the command surface itself is reshaped. * refactor(liveshare): leave the workspace file preview and terminal grant out Reading a Session's data and reaching into the owner's workspace or shell are different promises: the first follows visibility, the second changes what the owner's machine does. This change keeps the reader capabilities that describe Session data and returns the other two for their own discussion. * refactor(jobs): let the session resolver name the job endpoints' Session The session resource resolver already reads a top-level sessionId, so the explicit readers restated what it derives. Removing them keeps one rule for how a Session resource is named. * test(liveshare): drop the workspace preview stubs the strip left behind The viewer shell no longer opens workspace files, so the fixture route and the assertion about it no longer describe anything. * fix(jobs): bind the job endpoints to the Session they name The session resolver reads a top-level sessionId, but these methods take a request object and no lookup parameter, so the request fell through to the global resource and a reader was refused. The explicit readers state the Session the Gateway must authorise. * refactor(jobs): let the session resolver name the job endpoints' Session The session controller's resolver already reads the sessionId of the first object argument, so an explicit reader on these methods restated a rule the Gateway already applies. The tests now install the session controller and assert the resource the production composition produces. * refactor(session-controller): take the resolve input as one argument An exported function cannot destructure its parameters, because the JSDoc gate names them one by one. * docs(liveshare): describe the capabilities this change actually opens The workspace file preview, the terminal grant and the command surface moved out of this change, so the package reference and the PR description now state what remains. * docs(persistence): refresh the catalog after the preset JSDoc edit The permission-presets module doc grew a line, so the recorded source line for its persisted event moved from 60 to 61. --------- Co-authored-by: DeepSeek Harness <[email protected]>
235 lines
11 KiB
Markdown
235 lines
11 KiB
Markdown
# 会话引用
|
|
|
|
[English](session-reference.md) | 中文
|
|
|
|
由 Host 支撑的文件发现,以及结构化的跨会话引用请求与准备后的消息上下文。[文件引用约定](../../packages/context/file-reference)负责仅含路径的补全记录与语法;[会话引用约定](../../packages/context/session-reference)定义规范 URI、当前表层投影、标签安全的 JSON 与字节保留、稳定错误和不可信的模型提示词。宿主适配器使用这些类型,而不会把各自 UI 的提及语法传入 agent(智能体)核心。
|
|
|
|
来源:[`packages/context/file-reference/src/types.ts`](../../packages/context/file-reference/src/types.ts) · [`packages/context/session-reference/src/types.ts`](../../packages/context/session-reference/src/types.ts)
|
|
|
|
## 文件候选项
|
|
|
|
`FileReferenceCandidate` 是仅含路径的发现结果。被寻址的 agent 提供工作目录范围;提供方负责排序和命名空间访问,但不会读取文件内容。
|
|
|
|
```ts type-equiv
|
|
/** One path-only completion candidate inside the target session cwd. */
|
|
interface FileReferenceCandidate {
|
|
/** User-facing path accepted by normal prompts and filesystem tools. */
|
|
path: string
|
|
/** Directories keep completion open; files finish the mention. */
|
|
kind: 'file' | 'directory'
|
|
}
|
|
```
|
|
|
|
## 输入与候选项
|
|
|
|
`SessionReferenceInput` 是与宿主无关的选择。id 具有权威性;label 是随快照携带的显示元数据。
|
|
|
|
```ts type-equiv
|
|
/** One source session selected by a host. */
|
|
interface SessionReferenceInput {
|
|
/** Opaque source session identity. */
|
|
sessionId: SessionId
|
|
/** Optional user-facing mention label. */
|
|
label?: string
|
|
}
|
|
```
|
|
|
|
`SessionReferenceCandidate` 是面向宿主的发现输出。存在最新 Session 标题时,它的 `label` 使用该标题;可选显示文本则优先使用 subagent 的持久创建 label。筛选会同时搜索两者、Session id 与 cwd,绝不搜索 transcript(文本记录)。Remote 候选在 `displayTitle` 存在时用它标记规范 mention。
|
|
|
|
```ts type-equiv
|
|
/** One host-facing candidate from exact session metadata. */
|
|
interface SessionReferenceCandidate {
|
|
/** Opaque source session identity. */
|
|
sessionId: SessionId
|
|
/** Latest log-backed title, falling back to the opaque session id. */
|
|
label: string
|
|
/** Display and canonical-mention text, preferring a subagent's durable creation label over {@link label}. */
|
|
displayTitle?: string
|
|
/** Source session working directory, when recorded. */
|
|
cwd?: string
|
|
/**
|
|
* True when {@link SessionReferenceCandidate.cwd} is recorded and equals the
|
|
* requesting agent's. Hosts that only surface a distinguishing location
|
|
* read this instead of comparing paths they never received.
|
|
*/
|
|
sameWorkspace: boolean
|
|
/** Source session creation time in Unix epoch milliseconds. */
|
|
createdAt: number
|
|
}
|
|
```
|
|
|
|
`sessionReferenceResolver/candidates` Remote 方法向浏览器消费方提供同一发现能力,并为每个候选附上规范提示词 mention。
|
|
|
|
```ts type-equiv
|
|
/** One discovery candidate carrying its canonical prompt mention. */
|
|
interface SessionReferenceMentionCandidate extends SessionReferenceCandidate {
|
|
/** Canonical `@[label](dsh-session:…)` mention serialized into the prompt draft. */
|
|
mention: string
|
|
}
|
|
```
|
|
|
|
## 准备后的消息
|
|
|
|
准备过程保留可读的当前消息内容,并最多返回一个聚合上下文。其持久 source 记录会把 `capturedThroughSeq` 保留为被引用 Session 原始 generation 中的坐标,绝不会把它重新解释为所在 Session 的 seq。`capturedFormatVersion` 记录该 generation;缺失表示已发布格式 v0。
|
|
|
|
```ts type-equiv
|
|
/** Durable source session, cited event seqs, and snapshot facts for prepared cross-session context. */
|
|
interface SessionReferenceSource {
|
|
kind: 'session-reference'
|
|
/** Material lifted out of another session's log (`recall` context form). */
|
|
form: 'recall'
|
|
version: 1
|
|
references: {
|
|
sessionId: string
|
|
label: string
|
|
/** Source Session format generation; absence identifies version 0. */
|
|
capturedFormatVersion?: number
|
|
capturedThroughSeq: OptionalSessionSeq
|
|
compacted: boolean
|
|
originalMessages: number
|
|
retainedMessages: number
|
|
omittedMessages: number
|
|
omittedBytes: number
|
|
truncated: boolean
|
|
inputIndex: number
|
|
}[]
|
|
}
|
|
```
|
|
|
|
```ts type-equiv
|
|
/** Direct message content and optional referenced-session context. */
|
|
interface PreparedReferencedMessage {
|
|
/** Readable message content after host mention tokens are removed. */
|
|
content: ContentBlock[]
|
|
/** Aggregated untrusted snapshot, absent when the message has no references. */
|
|
additionalContext?: UserMessage
|
|
}
|
|
```
|
|
|
|
## 错误
|
|
|
|
`SessionReferenceError.code` 区分无效配置或输入、自引用、数量限制、源读取失败、预算失败和取消。宿主协议会把这些 code 映射到各自的错误封装,无需检查提示词字节。
|
|
|
|
```ts type-equiv
|
|
/** Stable failure codes exposed to host adapters. */
|
|
type SessionReferenceErrorCode =
|
|
| 'SESSION_REFERENCE_INVALID_CONFIG'
|
|
| 'SESSION_REFERENCE_INVALID_REFERENCE'
|
|
| 'SESSION_REFERENCE_SELF_REFERENCE'
|
|
| 'SESSION_REFERENCE_TOO_MANY'
|
|
| 'SESSION_REFERENCE_READ_FAILED'
|
|
| 'SESSION_REFERENCE_BUDGET_EXCEEDED'
|
|
| 'SESSION_REFERENCE_CANCELLED'
|
|
```
|
|
|
|
<!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
|
|
|
|
<a id="cordis-surface"></a>
|
|
|
|
## Cordis API
|
|
|
|
Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnpm run verify-cordis-catalog` in doc-sync; regenerate with `pnpm run gen-cordis-catalog`) — the language sides differ only in locale-specific paired document paths. Signature blocks use a `ts cordis-catalog` fence and keep the original source JSDoc; dispatch modes are defined in the [primer](../cordis-primer.zh.md#dispatch-modes), and the framework-inherited `ctx` API lives in [cordis-api/inherited.md](../cordis-api/inherited.md).
|
|
|
|
<a id="ctxfilereferences--filereferenceservice-abstract-seam"></a>
|
|
|
|
### `ctx.fileReferences` — `FileReferenceService` (abstract seam)
|
|
|
|
Host capability for cancellable file-reference discovery.
|
|
|
|
```ts cordis-catalog
|
|
/**
|
|
* List file and directory candidates for one agent's working directory.
|
|
* @param agent - target agent whose session cwd bounds discovery.
|
|
* @param query - path text following `@` or `@"`.
|
|
* @param signal - caller cancellation.
|
|
* @returns deterministic path-only candidates.
|
|
*/
|
|
abstract list( agent: Agent, query: string, signal: AbortSignal, ): Promise<FileReferenceCandidate[]>
|
|
```
|
|
|
|
Types: [Agent](core.zh.md)
|
|
|
|
Source: [`packages/context/file-reference/src/index.ts`](../../packages/context/file-reference/src/index.ts)
|
|
|
|
<a id="ctxsessionfilereferences--sessionfilereferences"></a>
|
|
|
|
### `ctx.sessionFileReferences` — `SessionFileReferences`
|
|
|
|
Host Remote adapter over the composed file-reference provider.
|
|
|
|
```ts cordis-catalog
|
|
/**
|
|
* List file and directory candidates for one Agent's working directory.
|
|
* @param agent - target Agent resolved from the Session identity on the wire.
|
|
* @param query - path text following `@` or `@"`.
|
|
* @param signal - caller cancellation.
|
|
* @returns deterministic path-only candidates from the composed provider.
|
|
*/
|
|
@Remote list( agent: Agent, query: string, signal: AbortSignal, ): Promise<FileReferenceCandidate[]>
|
|
```
|
|
|
|
Types: [Agent](core.zh.md)
|
|
|
|
Source: [`packages/api/session-controller/src/file-references.ts`](../../packages/api/session-controller/src/file-references.ts)
|
|
|
|
<a id="ctxsessionreferenceresolver--sessionreferenceresolver"></a>
|
|
|
|
### `ctx.sessionReferenceResolver` — `SessionReferenceResolver`
|
|
|
|
Exact-read consumer that prepares immutable cross-session message context.
|
|
|
|
```ts cordis-catalog
|
|
/**
|
|
* List reference candidates, ranked by working-directory affinity.
|
|
*
|
|
* Discovery runs at keystroke rate, so titles and subagent labels only ever
|
|
* come from projection reads; sessions without either fall back to their id.
|
|
*
|
|
* The list names every Session the session index holds, whatever identity the
|
|
* caller acts for; it is not narrowed to Sessions that caller else can read.
|
|
* A share viewer therefore learns the id, title, and working-directory path of
|
|
* each Session on the owner Host, and {@link prepare} reads the snapshot of a
|
|
* cited Session without asking who cited it. That exposure is a recorded
|
|
* LiveShare limitation, not a grant: narrowing the list is deferred.
|
|
* @param agent - target agent; self is excluded and its cwd drives ranking.
|
|
* @param query - optional search text: label and display title match
|
|
* fuzzily, session id and working directory as substrings. Matches keep the
|
|
* working-directory affinity order; relevance breaks ties within it.
|
|
* @param limit - optional positive result cap.
|
|
* @param signal - optional cancellation boundary for host autocomplete teardown.
|
|
* @returns candidates with canonical mention labels and presentation titles.
|
|
*/
|
|
async listCandidates( agent: Agent, query: string = '', limit: number = this.config.candidateLimit, signal?: AbortSignal, ): Promise<SessionReferenceCandidate[]>
|
|
|
|
/**
|
|
* Remote face of {@link listCandidates}: the configured candidate limit
|
|
* applies, and every candidate carries the canonical mention a host inserts
|
|
* into the prompt draft.
|
|
* @param agent - target agent; self is excluded and its cwd drives ranking.
|
|
* @param query - optional search text, matched as {@link listCandidates} matches it.
|
|
* @param signal - caller cancellation.
|
|
* @returns mention-carrying candidates in rank order.
|
|
*/
|
|
@Remote('candidates') async remoteExportCandidates( agent: Agent, query: string, signal: AbortSignal, ): Promise<SessionReferenceMentionCandidate[]>
|
|
|
|
/**
|
|
* Snapshot all references for one accepted direct message and return one aggregated durable context.
|
|
* Automatic budgets use the context capacity of `route`.
|
|
* Missing model capacity or adapter uses 64 KiB; other metadata lookup failures and cancellation reject preparation.
|
|
* Truncated previews include omission facts and a full-snapshot spill locator, or an explicit unavailable notice.
|
|
* Cancellation prevents context publication, including when storage completes after cancellation.
|
|
* @param agent - target agent; references to it are rejected.
|
|
* @param content - already host-normalized readable message content.
|
|
* @param references - structured source sessions in mention order.
|
|
* @param route - provider and model whose context capacity sizes the previews.
|
|
* @param signal - optional cancellation boundary for the active turn.
|
|
* @returns detached content and optional referenced-session context.
|
|
*/
|
|
async prepare( agent: Agent, content: ContentBlock[], references: SessionReferenceInput[], route: Readonly<Pick<LlmCallConfig, 'provider' | 'model'>>, signal?: AbortSignal, ): Promise<PreparedReferencedMessage>
|
|
```
|
|
|
|
Types: [Agent](core.zh.md) · [ContentBlock](llm-streaming.zh.md) · [LlmCallConfig](llm-streaming.zh.md)
|
|
|
|
Source: [`packages/context/session-reference/src/index.ts`](../../packages/context/session-reference/src/index.ts)
|
|
<!-- END GENERATED cordis-surface -->
|