feat: add agent image attachments and bump version to 1.2.17
This commit is contained in:
@@ -11,7 +11,7 @@ vm.runInNewContext(ts.transpileModule(fs.readFileSync(require.resolve('../src/re
|
||||
const source = ts.createSourceFile('useAiAgent.ts', fs.readFileSync(require.resolve('../src/renderer/src/features/workspace/useAiAgent.ts'), 'utf8'), ts.ScriptTarget.Latest, true)
|
||||
let payloadExpression
|
||||
function visit(node) {
|
||||
if (ts.isCallExpression(node) && node.expression.getText(source) === 'JSON.stringify' && node.arguments[0]?.getText(source).includes('options.attachments')) {
|
||||
if (ts.isCallExpression(node) && node.expression.getText(source) === 'JSON.stringify' && node.arguments[0]?.getText(source).includes('imageTokens')) {
|
||||
payloadExpression = node.getText(source)
|
||||
}
|
||||
ts.forEachChild(node, visit)
|
||||
@@ -19,14 +19,22 @@ function visit(node) {
|
||||
visit(source)
|
||||
assert.ok(payloadExpression, 'Agent request JSON serialization must exist')
|
||||
|
||||
function serialize(attachments, finalize = false, request = '설정 위치 알려줘') {
|
||||
function serialize(attachments, finalize = false, request = '설정 위치 알려줘', imageTokens = []) {
|
||||
return JSON.parse(vm.runInNewContext(payloadExpression, {
|
||||
courseId: 'course-1', weekNumber: 3, request, options: { attachments }, finalize,
|
||||
textAttachments: attachments ?? [], imageTokens,
|
||||
agentPlanRequestText: contextApi.agentPlanRequestText,
|
||||
context: { modules: [{ name: 'Control', files: [] }], runtimeLogs: [] }
|
||||
}))
|
||||
}
|
||||
|
||||
test('sends image reference tokens without image bytes or public URLs on every context round', () => {
|
||||
const body = serialize(undefined, true, '이미지 분석', ['signed-image-token'])
|
||||
assert.deepEqual(body.imageTokens, ['signed-image-token'])
|
||||
assert.equal(Object.hasOwn(body, 'attachments'), false)
|
||||
assert.equal(JSON.stringify(body).includes('base64'), false)
|
||||
})
|
||||
|
||||
for (const attachments of [undefined, []]) {
|
||||
test(`omits attachments when ${attachments ? 'empty' : 'undefined'}`, () => {
|
||||
const body = serialize(attachments)
|
||||
|
||||
Reference in New Issue
Block a user