Merge remote-tracking branch 'origin/master' into stack/pr-6426
This commit is contained in:
commit
da864e3377
1830 files changed
+34392
-9735
No files matched your search
@@ -21,8 +21,8 @@
|
||||
en: 41bdda1ac32df558
|
||||
zh: aa5d0e325924066b
|
||||
/session-controller/session-media-references:
|
||||
en: 49a3d0e8e92017d3
|
||||
zh: 91302aa3dd6e9378
|
||||
en: 25e40cb508265c01
|
||||
zh: c8ce39a94997af00
|
||||
/session-controller/configuration:
|
||||
en: c92590fbaf75e45e
|
||||
zh: fcac67017bb0e3ab
|
||||
|
||||
@@ -86,7 +86,7 @@ References keep local Session data, scoped Contexts, and history streams alive,
|
||||
<a id="session-media-references"></a>
|
||||
## Session media references
|
||||
|
||||
`SessionMediaReferences` mounts `GET|HEAD /api/file?path=<absolute path>` on the authenticated `connection.fetch` channel when `connection`, `fs`, and `attachments` are composed. It reads ordinary files through `ctx.fs`, including temporary paths outside registered workspaces and files in remote providers. Neither directory containment nor MIME categories restrict access; `mime-types` supplies the response type, with `application/octet-stream` for unknown extensions. GET reuses `readBytes` for preflight and ongoing byte limits; HEAD reads metadata only. All files use `ctx.attachments.imageLimits.maxImageBytes` (normally 20 MiB); exceeding this limit returns 413. Responses contain the complete file, ignore Range, and carry `private, no-store`, `nosniff`, and a sandbox CSP so directly opened HTML/SVG cannot execute with the API origin. The Client rewrite lives in `ui-chat` (`AssistantMarkdown`); audio/video responses are available, while Markdown audio/video player nodes remain separate work.
|
||||
`SessionMediaReferences` mounts `GET|HEAD /api/file?path=<absolute path>` on the authenticated `connection.fetch` channel when `connection`, `fs`, and `attachments` are composed. It reads ordinary files through `ctx.fs`, including temporary paths outside registered workspaces and files in remote providers. Neither directory containment nor MIME categories restrict access; `mime-types` supplies the response type, with `application/octet-stream` for unknown extensions. GET reuses `readBytes` for preflight and ongoing byte limits; HEAD reads metadata only. All files use `ctx.attachments.imageLimits.maxImageBytes` (normally 50 MiB); exceeding this limit returns 413. Responses contain the complete file, ignore Range, and carry `private, no-store`, `nosniff`, and a sandbox CSP so directly opened HTML/SVG cannot execute with the API origin. The Client rewrite lives in `ui-chat` (`AssistantMarkdown`); audio/video responses are available, while Markdown audio/video player nodes remain separate work.
|
||||
|
||||
GUI model selection requires the exact provider/model pair in the available catalog; unavailable choices reject with `session/model-unavailable`. Prompt admission retains the saved route without a catalog availability gate, so request execution reports missing credentials or unavailable models. `initializeDefaultModel()` saves the first available account model after login when no other provider has a configured API key; credential checks use configured references independently of model availability. A provider with no available models rejects initialization with `session/provider-models-unavailable`. Availability never substitutes another model or rewrites a Session selection.
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ Client 的首次 `follow`、重连首屏与 `loadOlder()` 至少请求 50 条以
|
||||
<a id="session-media-references"></a>
|
||||
## 会话媒体引用
|
||||
|
||||
当 `connection`、`fs` 与 `attachments` 均被组合时,`SessionMediaReferences` 在鉴权 `connection.fetch` 通道上挂载 `GET|HEAD /api/file?path=<绝对路径>`。它通过 `ctx.fs` 读取普通文件,包括已注册工作区之外的临时路径与远程提供方中的文件。目录包含关系与 MIME 类别均不限制访问;`mime-types` 提供响应类型,未知扩展名使用 `application/octet-stream`。GET 复用 `readBytes` 执行读取前及读取中的字节限制;HEAD 只读取元数据。所有文件均使用 `ctx.attachments.imageLimits.maxImageBytes`(通常为 20 MiB);超过此上限返回 413。响应包含完整文件,忽略 Range,并携带 `private, no-store`、`nosniff` 与沙箱 CSP,使直接打开的 HTML/SVG 无法以 API 源身份执行脚本。客户端重写位于 `ui-chat`(`AssistantMarkdown`);音视频文件响应已可用,Markdown 音视频播放器节点仍是独立工作。
|
||||
当 `connection`、`fs` 与 `attachments` 均被组合时,`SessionMediaReferences` 在鉴权 `connection.fetch` 通道上挂载 `GET|HEAD /api/file?path=<绝对路径>`。它通过 `ctx.fs` 读取普通文件,包括已注册工作区之外的临时路径与远程提供方中的文件。目录包含关系与 MIME 类别均不限制访问;`mime-types` 提供响应类型,未知扩展名使用 `application/octet-stream`。GET 复用 `readBytes` 执行读取前及读取中的字节限制;HEAD 只读取元数据。所有文件均使用 `ctx.attachments.imageLimits.maxImageBytes`(通常为 50 MiB);超过此上限返回 413。响应包含完整文件,忽略 Range,并携带 `private, no-store`、`nosniff` 与沙箱 CSP,使直接打开的 HTML/SVG 无法以 API 源身份执行脚本。客户端重写位于 `ui-chat`(`AssistantMarkdown`);音视频文件响应已可用,Markdown 音视频播放器节点仍是独立工作。
|
||||
|
||||
GUI 模型选择要求确切提供方/模型对出现在可用目录中;不可用的选择以 `session/model-unavailable` 拒绝。提示词准入保留已保存的路由,不按目录可用性阻断发送,由请求执行报告凭据缺失或模型不可用。`initializeDefaultModel()` 在账号登录后、其他提供方均未配置 API key 时,将第一个可用账号模型保存为默认模型;凭据检查使用已配置的引用,不依赖模型是否可用。提供方没有可用模型时,初始化以 `session/provider-models-unavailable` 拒绝。可用性变化不会替换模型或改写会话选择。
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"meta": {
|
||||
"title": "セッション制御 API",
|
||||
"description": "セッションの読み取り、実行制御、状態更新をクライアントに提供します。"
|
||||
}
|
||||
}
|
||||
@@ -107,8 +107,11 @@ describe('sessions.fork', () => {
|
||||
const ctx = await composed()
|
||||
try {
|
||||
const source = ctx.sessions.prepare(sid('current-cold'), { meta: { cwd: '/proj' } })
|
||||
const detach = ctx.effect(() => ctx.sessions.enter(source))
|
||||
ctx.sessions.announce(source)
|
||||
source.append('turn/start', { turn: 1 })
|
||||
source.append('turn/end', { turn: 1, reason: { kind: 'completed' } })
|
||||
await detach()
|
||||
const snapshot: SessionPersistenceSnapshot = {
|
||||
header: source.header,
|
||||
revision: SessionPersistenceRevision('test:cold-source'),
|
||||
|
||||
@@ -122,20 +122,24 @@ async function harness(options: HarnessOptions = {}) {
|
||||
archivedSessionIds: archived,
|
||||
} as never)
|
||||
|
||||
/** Run setup on the unpublished Session, then publish it and its Agent, as the Agent factory does. */
|
||||
/** Enter the Session for setup, then announce creation as the Agent factory does. */
|
||||
const publish = async (
|
||||
session: Session,
|
||||
setup: Parameters<AgentFactory['createAgent']>[1]['setup'],
|
||||
): Promise<{ agent: Agent; dispose: () => Promise<void> }> => {
|
||||
const agent = stubAgent(session)
|
||||
;(agent as { ctx?: Context }).ctx = ctx
|
||||
await setup?.(ctx, agent)
|
||||
ctx.effect(function* () {
|
||||
yield ctx.sessions.enter(session)
|
||||
const detach = ctx.effect(() => ctx.sessions.enter(session))
|
||||
try {
|
||||
ctx.sessions.announce(session)
|
||||
}, 'test: published Session')
|
||||
const unregister = await ctx.agents.register(agent)
|
||||
return { agent, dispose: async () => { await unregister() } }
|
||||
const commit = await setup?.(ctx, agent)
|
||||
commit?.commit()
|
||||
const unregister = await ctx.agents.register(agent)
|
||||
return { agent, dispose: async () => { await unregister(); await detach() } }
|
||||
} catch (error) {
|
||||
await detach()
|
||||
throw error
|
||||
}
|
||||
}
|
||||
const factory: AgentFactory = {
|
||||
async createAgent(_ownerCtx, create) {
|
||||
|
||||
@@ -278,11 +278,6 @@ describe('SessionHistoryController', () => {
|
||||
}
|
||||
const seed = [event('fixture/start', SessionSeq(0))]
|
||||
cold(ctx, header, seed)
|
||||
agentCtx.on('session/created', (session) => {
|
||||
if (session.id !== sessionId) return
|
||||
append(session, 'fixture/setup-one', {})
|
||||
append(session, 'fixture/setup-two', {})
|
||||
})
|
||||
const abort = new AbortController()
|
||||
const iterator = transport.follow({ address: { kind: 'session', sessionId } }, abort.signal)
|
||||
[Symbol.asyncIterator]()
|
||||
@@ -292,6 +287,8 @@ describe('SessionHistoryController', () => {
|
||||
const attached = agentCtx.sessions.prepare(sessionId, { meta: header, seed })
|
||||
agentCtx.sessions.enter(attached)
|
||||
agentCtx.sessions.announce(attached)
|
||||
append(attached, 'fixture/setup-one', {})
|
||||
append(attached, 'fixture/setup-two', {})
|
||||
await expect(iterator.next()).resolves.toMatchObject({
|
||||
done: false,
|
||||
value: { type: 'event', event: { type: 'session/end-seed', seq: 1 } },
|
||||
|
||||
Reference in new issue
Block a user