@deepseek-ai/dsh-spill-policy 0.2.2-rc.1 → 0.2.2-rc.3

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAaxC,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD,wCAAwC;AACxC,MAAM,WAAW,MAAM;IACrB,mIAAmI;IACnI,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,8BAA8B;AAC9B,eAAO,MAAM,IAAI,iBAAiB,CAAA;AAClC,iEAAiE;AACjE,eAAO,MAAM,MAAM,UAAY,CAAA;AAC/B,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAA6C,CAAA;AAS1E;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CA4GxD"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AASA,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAA;AAEtF,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAA;AAMvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAW9C,8BAA8B;AAC9B,MAAM,CAAC,MAAM,IAAI,GAAG,cAAc,CAAA;AAClC,iEAAiE;AACjE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,CAAA;AAC/B,MAAM,CAAC,MA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AAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QACzD,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,QAAQ,IAAI,CAAC;eAC1C,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC;YACxD,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAClF,CAAC;QACD,IAAI,IAAI,GAAG,CAAC;YAAE,OAAO,KAAK,CAAA;QAC1B,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC,MAAM,CAAA;IACjC,CAAC;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retention.d.ts","sourceRoot":"","sources":["../../src/retention.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,0EAA0E;AAC1E,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,YAAY,EAAE;IAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC,CAAA;AAE/E,gFAAgF;AAChF,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,eAAe,EAAE,CAAA;IACvB,IAAI,EAAE,eAAe,EAAE,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;CACtB;AA0BD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,SAAS,eAAe,EAAE,EACnC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,MAAM,GACxC,eAAe,CAoDjB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retention.js","sourceRoot":"","sources":["../../src/retention.ts"],"names":[],"mappings":"AAcA,mFA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,MAAM,GAAG,CAAC,MAAkC,EAAU,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,MAAM,CAAA;IACpH,OAAO;QACL,IAAI;QACJ,IAAI;QACJ,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC;QACxD,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC;KAC7D,CAAA;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAEzD,iGAAiG;AACjG,MAAM,WAAW,eAAe;IAC9B,kEAAkE;IAClE,KAAK,CAAC,EAAE;QACN,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,wDAAwD;gBACxD,EAAE,EAAE,SAAS,CAAA;aACd,CAAA;SACF,CAAA;KACF,CAAA;CACF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-spill-policy",
3
3
  "description": "Token-budgeted tool-result retention with recoverable text and image paths",
4
- "version": "0.2.2-rc.1",
4
+ "version": "0.2.2-rc.3",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -30,50 +30,53 @@
30
30
  "locale/*.json",
31
31
  "lib/index.js",
32
32
  "lib/types/**/*.js",
33
- "lib/types/**/*.d.ts"
33
+ "lib/types/**/*.d.ts",
34
+ "lib/types/**/*.d.ts.map",
35
+ "lib/**/*.js.map",
36
+ "src"
34
37
  ],
35
38
  "license": "MIT",
36
39
  "peerDependencies": {
37
- "@deepseek-ai/dsh-llm": "0.2.2-rc.1",
38
- "@deepseek-ai/dsh-output-retention": "0.2.2-rc.1",
39
- "@deepseek-ai/dsh-session": "0.2.2-rc.1",
40
- "@deepseek-ai/dsh-spill": "0.2.2-rc.1",
41
- "@deepseek-ai/dsh-tools": "0.2.2-rc.1",
40
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.3",
41
+ "@deepseek-ai/dsh-output-retention": "0.2.2-rc.3",
42
+ "@deepseek-ai/dsh-session": "0.2.2-rc.3",
43
+ "@deepseek-ai/dsh-spill": "0.2.2-rc.3",
44
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.3",
42
45
  "@deepseek-ai/cordis": "~4.1.0",
43
- "@deepseek-ai/dsh-attachment": "0.2.2-rc.1",
44
- "@deepseek-ai/dsh-fs": "0.2.2-rc.1",
45
- "@deepseek-ai/dsh-token-meter": "0.2.2-rc.1"
46
+ "@deepseek-ai/dsh-attachment": "0.2.2-rc.3",
47
+ "@deepseek-ai/dsh-fs": "0.2.2-rc.3",
48
+ "@deepseek-ai/dsh-token-meter": "0.2.2-rc.3"
46
49
  },
47
50
  "dependencies": {
48
51
  "@deepseek-ai/schemastery": "~3.19.0"
49
52
  },
50
53
  "devDependencies": {
51
- "@deepseek-ai/dsh-agent": "0.2.2-rc.1",
52
- "@deepseek-ai/dsh-ptc-runtime-node": "0.2.2-rc.1",
53
- "@deepseek-ai/dsh-llm": "0.2.2-rc.1",
54
- "@deepseek-ai/dsh-output-retention": "0.2.2-rc.1",
55
- "@deepseek-ai/dsh-session": "0.2.2-rc.1",
56
- "@deepseek-ai/dsh-spill": "0.2.2-rc.1",
57
- "@deepseek-ai/dsh-tool-testkit": "0.2.2-rc.1",
58
- "@deepseek-ai/dsh-tools": "0.2.2-rc.1",
54
+ "@deepseek-ai/dsh-agent": "0.2.2-rc.3",
55
+ "@deepseek-ai/dsh-ptc-runtime-node": "0.2.2-rc.3",
56
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.3",
57
+ "@deepseek-ai/dsh-output-retention": "0.2.2-rc.3",
58
+ "@deepseek-ai/dsh-session": "0.2.2-rc.3",
59
+ "@deepseek-ai/dsh-spill": "0.2.2-rc.3",
60
+ "@deepseek-ai/dsh-tool-testkit": "0.2.2-rc.3",
61
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.3",
59
62
  "@deepseek-ai/cordis": "~4.1.0",
60
- "@deepseek-ai/dsh-fs-local": "0.2.2-rc.1",
61
- "@deepseek-ai/dsh-subprocess-local": "0.2.2-rc.1",
62
- "@deepseek-ai/dsh-sandbox-local": "0.2.2-rc.1",
63
- "@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.1",
64
- "@deepseek-ai/dsh-session-projection": "0.2.2-rc.1",
65
- "@deepseek-ai/dsh-attachment": "0.2.2-rc.1",
66
- "@deepseek-ai/dsh-fs": "0.2.2-rc.1",
67
- "@deepseek-ai/dsh-token-meter": "0.2.2-rc.1",
68
- "@deepseek-ai/dsh-mcp-client": "0.2.2-rc.1",
69
- "@deepseek-ai/dsh-spill-local": "0.2.2-rc.1",
70
- "@deepseek-ai/dsh-llm-deepseek": "0.2.2-rc.1",
71
- "@deepseek-ai/dsh-ptc-runtime": "0.2.2-rc.1",
72
- "@deepseek-ai/dsh-attachment-local": "0.2.2-rc.1",
73
- "@deepseek-ai/dsh-tool-executor-native": "0.2.2-rc.1",
74
- "@deepseek-ai/dsh-tool-executor-ptc": "0.2.2-rc.1",
75
- "@deepseek-ai/dsh-tool-fs": "0.2.2-rc.1",
63
+ "@deepseek-ai/dsh-fs-local": "0.2.2-rc.3",
64
+ "@deepseek-ai/dsh-subprocess-local": "0.2.2-rc.3",
65
+ "@deepseek-ai/dsh-sandbox-local": "0.2.2-rc.3",
66
+ "@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.3",
67
+ "@deepseek-ai/dsh-session-projection": "0.2.2-rc.3",
68
+ "@deepseek-ai/dsh-attachment": "0.2.2-rc.3",
69
+ "@deepseek-ai/dsh-fs": "0.2.2-rc.3",
70
+ "@deepseek-ai/dsh-token-meter": "0.2.2-rc.3",
71
+ "@deepseek-ai/dsh-mcp-client": "0.2.2-rc.3",
72
+ "@deepseek-ai/dsh-spill-local": "0.2.2-rc.3",
73
+ "@deepseek-ai/dsh-llm-deepseek": "0.2.2-rc.3",
74
+ "@deepseek-ai/dsh-ptc-runtime": "0.2.2-rc.3",
75
+ "@deepseek-ai/dsh-attachment-local": "0.2.2-rc.3",
76
+ "@deepseek-ai/dsh-tool-executor-native": "0.2.2-rc.3",
77
+ "@deepseek-ai/dsh-tool-executor-ptc": "0.2.2-rc.3",
78
+ "@deepseek-ai/dsh-tool-fs": "0.2.2-rc.3",
76
79
  "sharp": "0.35.5",
77
- "@deepseek-ai/dsh-agent-loop-testkit": "0.2.2-rc.1"
80
+ "@deepseek-ai/dsh-agent-loop-testkit": "0.2.2-rc.3"
78
81
  }
79
82
  }
package/src/index.ts ADDED
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Token-budgeted tool content with recoverable text and image addresses.
3
+ * Post-execute policies settle before retention; canonical program values
4
+ * remain intact. Missing recovery storage or image pricing keeps the original
5
+ * content and reports the reason through the logger.
6
+ * @module @deepseek-ai/dsh-spill-policy
7
+ */
8
+ import type {} from '@deepseek-ai/dsh-tool-executor-ptc'
9
+ import type { Context } from '@deepseek-ai/cordis'
10
+ import z from '@deepseek-ai/schemastery'
11
+ import { createUserMessage, resolveImageAttachmentAccess } from '@deepseek-ai/dsh-llm'
12
+ import type { ContentBlock, ImageBlock, LlmImageRequestPrice, ToolCallId } from '@deepseek-ai/dsh-llm'
13
+ import { estimateContent } from '@deepseek-ai/dsh-token-meter/estimate'
14
+ import type { SpillRef } from '@deepseek-ai/dsh-spill'
15
+ import type { PostToolDecision, ToolExecution } from '@deepseek-ai/dsh-tools'
16
+ import type {} from '@deepseek-ai/dsh-attachment'
17
+ import type {} from '@deepseek-ai/dsh-fs'
18
+ import type { SpillPolicyExec } from './types.ts'
19
+ import { formatSpillNotice } from './notice.ts'
20
+ import { retainContent } from './retention.ts'
21
+ import type { RetainableBlock } from './retention.ts'
22
+
23
+ export type { SpillPolicyExec } from './types.ts'
24
+
25
+ /** Optional result-retention budget. */
26
+ export interface Config {
27
+ /** Maximum estimated tokens in a retained result, including image descriptors and omission notices. Omitted disables retention. */
28
+ maxInlineTokens?: number
29
+ }
30
+
31
+ /** Cordis plugin identity. */
32
+ export const name = 'spill-policy'
33
+ /** Tools own both model-facing results and PTC dispatch logs. */
34
+ export const inject = ['tools']
35
+ export const Config: z<Config> = z.object({ maxInlineTokens: z.number() })
36
+
37
+ /** Narrow the model's ordered content without rewriting unsupported blocks. */
38
+ function retainable(content: readonly ContentBlock[]): content is RetainableBlock[] {
39
+ return content.every(block => block.type === 'text' || block.type === 'image')
40
+ }
41
+
42
+ const GAP = { type: 'text', text: '\n\n[...]\n\n' } as const
43
+
44
+ /**
45
+ * Mount token retention for accepted tool results and PTC log copies.
46
+ * @param ctx - tool registry and optional pricing, filesystem, attachment, and spill services.
47
+ * @param config - maximum estimated result tokens; omission disables the plugin.
48
+ */
49
+ export function apply(ctx: Context, config: Config): void {
50
+ const cap = config.maxInlineTokens
51
+ if (cap === undefined) return
52
+ if (!Number.isSafeInteger(cap) || cap < 0) {
53
+ throw new Error(`spill-policy: maxInlineTokens must be a non-negative integer (got ${cap})`)
54
+ }
55
+ const maxTokens = cap
56
+
57
+ /** Price actual request images and their accompanying descriptor text. */
58
+ function pricing(exec: ToolExecution, images: ImageBlock[]): (block: RetainableBlock) => number {
59
+ const costs = new Map<ImageBlock, number>()
60
+ if (images.length > 0) {
61
+ const routed = exec.agent?.session.requestHeader()?.config
62
+ const provider = routed?.provider ?? exec.agent?.options.provider
63
+ const model = routed?.model ?? exec.agent?.options.model
64
+ const calculator = provider === undefined || model === undefined
65
+ ? undefined
66
+ : ctx.get('llm')?.imageRequestPricing(provider, model)
67
+ if (calculator === undefined) throw new Error('the current model has no image token calculator')
68
+ const prices = calculator.priceImages(images)
69
+ if (prices.length !== images.length) throw new Error('image token calculator returned an inconsistent occurrence count')
70
+ for (const [index, image] of images.entries()) {
71
+ const cost = prices[index] as LlmImageRequestPrice
72
+ costs.set(image, cost.visualTokens + estimateContent([{ type: 'text', text: cost.text }]))
73
+ }
74
+ }
75
+ return block => block.type === 'image' ? costs.get(block) as number : estimateContent([block])
76
+ }
77
+
78
+ /** Full ordered text with an execution-readable attachment path at each image position. */
79
+ function fullText(content: RetainableBlock[]): string {
80
+ return content.map((block) => {
81
+ if (block.type === 'text') return block.text
82
+ const attachments = ctx.get('attachments')
83
+ const fs = ctx.get('fs')
84
+ const access = attachments === undefined || fs === undefined ? undefined : resolveImageAttachmentAccess(
85
+ attachments, path => fs.processPathFromHostPath(path), block.attachment)
86
+ if (access === undefined) throw new Error(`image ${block.attachment.attachmentId} has no readable attachment path`)
87
+ return `\n[Image: ${JSON.stringify(access.readonlyPath)}; ${block.attachment.mediaType}; ${block.attachment.width}x${block.attachment.height}. Use read_image to view it.]\n`
88
+ }).join('')
89
+ }
90
+
91
+ /** Recoverably bound one display copy; failures leave successful tool content visible. */
92
+ async function bound(
93
+ exec: ToolExecution, content: ContentBlock[], toolName: string, callId: ToolCallId, label: 'result' | 'dispatch',
94
+ ): Promise<ContentBlock[] | undefined> {
95
+ if (!retainable(content)) return undefined
96
+ try {
97
+ const images = content.filter((block): block is ImageBlock => block.type === 'image')
98
+ const price = pricing(exec, images)
99
+ if (content.reduce((total, block) => total + price(block), 0) <= maxTokens) return undefined
100
+ const owner = (exec as SpillPolicyExec).agent?.session.header.id
101
+ if (owner === undefined) throw new Error(`no session owner for ${toolName} ${label}`)
102
+ const spillStore = ctx.get('spillStore')
103
+ if (spillStore === undefined) throw new Error('no ctx.spillStore backend loaded')
104
+ const ref: SpillRef = await spillStore.saveText({
105
+ owner: { sessionId: owner }, source: { kind: 'tool', toolName, callId, label },
106
+ suggestedName: `${toolName}.txt`, content: fullText(content),
107
+ })
108
+ const totalBytes = content.reduce((total, block) => total + (block.type === 'text' ? Buffer.byteLength(block.text, 'utf8') : 0), 0)
109
+ const notice = (bytes: number, count: number): Extract<RetainableBlock, { type: 'text' }> => ({
110
+ type: 'text', text: formatSpillNotice({ kind: 'exact', count: bytes }, ref, count),
111
+ })
112
+ const worstNotice = notice(totalBytes, images.length)
113
+ const reserved = price(GAP) + price({ type: 'text', text: `\n\n${worstNotice.text}` })
114
+ if (price(worstNotice) > maxTokens) throw new Error(`spill notice for ${toolName} exceeds maxInlineTokens`)
115
+ const retained = retainContent(content, Math.max(0, maxTokens - reserved), price)
116
+ const footer = notice(retained.omittedBytes, retained.omittedImages)
117
+ const result = retained.head.length + retained.tail.length === 0
118
+ ? [footer]
119
+ : [...retained.head, GAP, ...retained.tail, { type: 'text' as const, text: `\n\n${footer.text}` }]
120
+ // Adjacent text has one framing cost on the wire and in the spill preview.
121
+ const merged: ContentBlock[] = []
122
+ for (const block of result) {
123
+ const previous = merged.at(-1)
124
+ if (block.type === 'text' && previous?.type === 'text') previous.text += block.text
125
+ else merged.push(block.type === 'text' ? { ...block } : block)
126
+ }
127
+ return merged
128
+ } catch (error: unknown) {
129
+ ctx.logger.warn(`spill-policy: ${String(error)}; keeping the inline content`)
130
+ return undefined
131
+ }
132
+ }
133
+
134
+ ctx.on('tools/post-execute', async (exec, result, next): Promise<PostToolDecision> => {
135
+ const decision = await next()
136
+ if (decision.kind !== 'accept' || Object.hasOwn(decision, 'value') || exec.name === 'read') return decision
137
+ const content = decision.content ?? result.content
138
+ const hasImages = content.some(block => block.type === 'image')
139
+ // Text-only PTC bindings retain their asynchronous log-only spill path.
140
+ if (exec.parent !== undefined && !hasImages) return decision
141
+ const retained = await bound(exec, content, exec.name, exec.callId, exec.parent === undefined ? 'result' : 'dispatch')
142
+ if (retained === undefined) return decision
143
+ const additionalContexts = [...decision.additionalContexts ?? []]
144
+ if (exec.parent !== undefined && !result.isError && hasImages && !retained.some(block => block.type === 'image')) {
145
+ additionalContexts.push(createUserMessage({ content: retained, source: { kind: 'ptc-mode' } }))
146
+ }
147
+ return {
148
+ kind: 'accept', content: retained,
149
+ ...additionalContexts.length > 0 ? { additionalContexts } : {},
150
+ }
151
+ }, { prepend: true })
152
+
153
+ ctx.on('tools/ptc-dispatch-log', async (dispatch, next): Promise<ContentBlock[]> => {
154
+ const content = await next()
155
+ return await bound(dispatch.exec, content, dispatch.name, dispatch.subCallId, 'dispatch') ?? content
156
+ }, { prepend: true })
157
+ }
package/src/notice.ts ADDED
@@ -0,0 +1,59 @@
1
+ /** Browser-safe formatting and recognition of persisted spill-policy notices. */
2
+ import { describeOmitted, type Omitted } from '@deepseek-ai/dsh-output-retention'
3
+ import type { SpillRef } from '@deepseek-ai/dsh-spill'
4
+
5
+ const OPEN = '('
6
+ const CLOSE = ')'
7
+ const LOCATION = ' Full formatted result stored at: '
8
+ const GUIDANCE_SEPARATOR = '. '
9
+ const SEPARATOR = '\n\n'
10
+ const EXACT_OMISSION = describeOmitted({ kind: 'exact', count: 0 }, 'bytes')
11
+ const COUNT_OFFSET = EXACT_OMISSION.indexOf('0')
12
+ const COUNT_SUFFIX = EXACT_OMISSION.slice(COUNT_OFFSET + 1)
13
+
14
+ /**
15
+ * Format the notice appended to a retained preview, preserving its persisted spelling.
16
+ * @param omitted - bytes omitted by the retention policy.
17
+ * @param ref - saved text locator and retrieval guidance.
18
+ * @param images - number of whole images omitted alongside text.
19
+ * @returns the complete notice without a leading preview separator.
20
+ */
21
+ export function formatSpillNotice(omitted: Omitted, ref: Pick<SpillRef, 'locator' | 'retrievalHint'>, images = 0): string {
22
+ const imageNotice = images > 0 ? ` Omitted ${images} images.` : ''
23
+ return `${OPEN}${describeOmitted(omitted, 'bytes')}${imageNotice}${LOCATION}${ref.locator}${GUIDANCE_SEPARATOR}${ref.retrievalHint}${CLOSE}`
24
+ }
25
+
26
+ function isOmission(text: string): boolean {
27
+ const imageNotice = / Omitted ([1-9][0-9]*) images\.$/.exec(text)
28
+ if (imageNotice !== null) {
29
+ if (!Number.isSafeInteger(Number(imageNotice[1]))) return false
30
+ text = text.slice(0, imageNotice.index)
31
+ }
32
+ if (text === describeOmitted({ kind: 'none' }, 'bytes')
33
+ || text === describeOmitted({ kind: 'unknown' }, 'bytes')) return true
34
+ const count = Number(text.slice(COUNT_OFFSET, text.length - COUNT_SUFFIX.length))
35
+ return Number.isSafeInteger(count) && count >= 0
36
+ && text === describeOmitted({ kind: 'exact', count }, 'bytes')
37
+ }
38
+
39
+ /**
40
+ * Recognize a final spill-policy notice in persisted text, including notice-only output.
41
+ * This identifies the text convention, not authenticated tool-output origin.
42
+ * @param text - complete recorded text result.
43
+ * @returns whether a complete notice occupies the end of the result.
44
+ */
45
+ export function hasSpillNotice(text: string): boolean {
46
+ if (!text.endsWith(CLOSE)) return false
47
+ let start = 0
48
+ while (true) {
49
+ const next = text.indexOf(`${SEPARATOR}${OPEN}`, start)
50
+ const candidate = text.slice(start, next < 0 ? -CLOSE.length : next)
51
+ const location = candidate.indexOf(LOCATION, OPEN.length)
52
+ if (candidate.startsWith(OPEN) && location >= 0
53
+ && isOmission(candidate.slice(OPEN.length, location))) {
54
+ return text.indexOf(GUIDANCE_SEPARATOR, start + location + LOCATION.length) >= 0
55
+ }
56
+ if (next < 0) return false
57
+ start = next + SEPARATOR.length
58
+ }
59
+ }
@@ -0,0 +1,104 @@
1
+ /** Ordered head/tail retention of text and indivisible images. @module @deepseek-ai/dsh-spill-policy/retention */
2
+ import type { ContentBlock } from '@deepseek-ai/dsh-llm'
3
+
4
+ /** Content whose text can be split and whose images must remain whole. */
5
+ export type RetainableBlock = Extract<ContentBlock, { type: 'text' | 'image' }>
6
+
7
+ /** Retained ends and exact quantities excluded from their original sequence. */
8
+ export interface RetainedContent {
9
+ head: RetainableBlock[]
10
+ tail: RetainableBlock[]
11
+ omittedBytes: number
12
+ omittedImages: number
13
+ }
14
+
15
+ /** Preserve a UTF-16 code point when a text budget cuts between its surrogates. */
16
+ function textSlice(text: string, length: number, tail: boolean): string {
17
+ let cut = tail ? text.length - length : length
18
+ const previous = text.charCodeAt(cut - 1)
19
+ const current = text.charCodeAt(cut)
20
+ if (previous >= 0xd800 && previous <= 0xdbff && current >= 0xdc00 && current <= 0xdfff) {
21
+ cut += tail ? 1 : -1
22
+ }
23
+ return tail ? text.slice(cut) : text.slice(0, cut)
24
+ }
25
+
26
+ /** Largest contiguous text end fitting a monotonic token estimate. */
27
+ function fitText(text: string, budget: number, tail: boolean, price: (block: RetainableBlock) => number): string {
28
+ let low = 0
29
+ let high = text.length
30
+ while (low < high) {
31
+ const middle = Math.ceil((low + high) / 2)
32
+ const candidate = textSlice(text, middle, tail)
33
+ if (candidate.length === 0 || price({ type: 'text', text: candidate }) <= budget) low = middle
34
+ else high = middle - 1
35
+ }
36
+ return textSlice(text, low, tail)
37
+ }
38
+
39
+ /**
40
+ * Retain contiguous ends without moving or partially retaining an image.
41
+ * Each end receives half the content budget; unused space at an indivisible
42
+ * image stays unused. Text pricing must be monotonic in retained length.
43
+ * @param content - ordered text and image blocks whose total price exceeds budget.
44
+ * @param budget - non-negative integer token budget after reserving notices.
45
+ * @param price - model-route cost of one retained block, including its framing.
46
+ * @returns retained ends and omitted UTF-8 text bytes and whole images.
47
+ */
48
+ export function retainContent(
49
+ content: readonly RetainableBlock[],
50
+ budget: number,
51
+ price: (block: RetainableBlock) => number,
52
+ ): RetainedContent {
53
+ const head: RetainableBlock[] = []
54
+ const tail: RetainableBlock[] = []
55
+ let first = 0
56
+ let last = content.length - 1
57
+ let headCharacters = 0
58
+ let remaining = Math.ceil(budget / 2)
59
+ while (first <= last) {
60
+ const block = content[first] as RetainableBlock
61
+ const cost = price(block)
62
+ if (cost <= remaining) {
63
+ head.push(block)
64
+ remaining -= cost
65
+ first++
66
+ continue
67
+ }
68
+ if (block.type === 'text') {
69
+ const text = fitText(block.text, remaining, false, price)
70
+ headCharacters = text.length
71
+ if (text.length > 0) head.push({ type: 'text', text })
72
+ }
73
+ break
74
+ }
75
+ remaining = Math.floor(budget / 2)
76
+ while (last >= first) {
77
+ const original = content[last] as RetainableBlock
78
+ const block = last === first && original.type === 'text'
79
+ ? { type: 'text' as const, text: original.text.slice(headCharacters) }
80
+ : original
81
+ const cost = price(block)
82
+ if (cost <= remaining) {
83
+ tail.push(block)
84
+ remaining -= cost
85
+ last--
86
+ continue
87
+ }
88
+ if (block.type === 'text') {
89
+ const text = fitText(block.text, remaining, true, price)
90
+ if (text.length > 0) tail.push({ type: 'text', text })
91
+ }
92
+ break
93
+ }
94
+ tail.reverse()
95
+ const bytes = (blocks: readonly RetainableBlock[]): number => blocks.reduce(
96
+ (total, block) => total + (block.type === 'text' ? Buffer.byteLength(block.text, 'utf8') : 0), 0)
97
+ const images = (blocks: readonly RetainableBlock[]): number => blocks.filter(block => block.type === 'image').length
98
+ return {
99
+ head,
100
+ tail,
101
+ omittedBytes: bytes(content) - bytes(head) - bytes(tail),
102
+ omittedImages: images(content) - images(head) - images(tail),
103
+ }
104
+ }
package/src/types.ts ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Vocabulary for the spill-policy plugin: the minimal structural view of a tool
3
+ * execution the policy needs to derive the owning session for a spill artifact.
4
+ *
5
+ * `@deepseek-ai/dsh-tools`' `ToolExecution` satisfies this shape, so the policy
6
+ * reads `exec` straight through without importing `dsh-tools` or `dsh-agent`.
7
+ * Only the session HEADER id is read — the same identity every other subsystem
8
+ * keys off (see `dsh-tool-bash`'s owner derivation).
9
+ *
10
+ * @module @deepseek-ai/dsh-spill-policy/types
11
+ */
12
+
13
+ import type { SessionId } from '@deepseek-ai/dsh-session'
14
+
15
+ /** Minimal structural view of a tool execution: the owning session's header id, when present. */
16
+ export interface SpillPolicyExec {
17
+ /** The agent on whose behalf the call runs, when there is one. */
18
+ agent?: {
19
+ session: {
20
+ header: {
21
+ /** The canonical session identity — the spill owner. */
22
+ id: SessionId
23
+ }
24
+ }
25
+ }
26
+ }