picocode-core 0.9.122 → 0.9.124
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.
- package/package.json +1 -1
- package/src/agent.js +4 -1
- package/src/attachments.js +2 -2
- package/src/tools/recorder.js +1 -0
package/package.json
CHANGED
package/src/agent.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises'
|
|
2
2
|
import { compose, scope, model, noToolsCalled, Inherit, getText } from '@prsm/ai'
|
|
3
|
+
import { mediaTypeFor } from './attachments.js'
|
|
3
4
|
|
|
4
5
|
async function hydratePart(part) {
|
|
5
6
|
if (part.type !== 'image' || part.source?.kind !== 'path') return part
|
|
7
|
+
const mediaType = part.source.mediaType || mediaTypeFor(part.source.path)
|
|
8
|
+
if (!mediaType) return { type: 'text', text: `[image unavailable: ${part.source.path}]` }
|
|
6
9
|
try {
|
|
7
10
|
const data = await readFile(part.source.path)
|
|
8
11
|
return {
|
|
9
12
|
type: 'image',
|
|
10
|
-
source: { kind: 'base64', mediaType
|
|
13
|
+
source: { kind: 'base64', mediaType, data: data.toString('base64') },
|
|
11
14
|
}
|
|
12
15
|
} catch {
|
|
13
16
|
return { type: 'text', text: `[image unavailable: ${part.source.path}]` }
|
package/src/attachments.js
CHANGED
|
@@ -99,7 +99,7 @@ export function placeholderizeImagePaths(text, { attachments, nextId, exists = e
|
|
|
99
99
|
out += part.text
|
|
100
100
|
} else {
|
|
101
101
|
const placeholder = `[Image #${nextId()}]`
|
|
102
|
-
attachments.set(placeholder, { path: part.source.path, mediaType: part.source.mediaType })
|
|
102
|
+
attachments.set(placeholder, { path: part.source.path, mediaType: part.source.mediaType || mediaTypeFor(part.source.path) })
|
|
103
103
|
out += placeholder
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -114,7 +114,7 @@ export function inputTextFromContent(content, { attachments, nextId }) {
|
|
|
114
114
|
out += part.text
|
|
115
115
|
} else if (part.type === 'image' && part.source?.path) {
|
|
116
116
|
const placeholder = `[Image #${nextId()}]`
|
|
117
|
-
attachments.set(placeholder, { path: part.source.path, mediaType: part.source.mediaType })
|
|
117
|
+
attachments.set(placeholder, { path: part.source.path, mediaType: part.source.mediaType || mediaTypeFor(part.source.path) })
|
|
118
118
|
out += placeholder
|
|
119
119
|
} else {
|
|
120
120
|
out += '[image]'
|