@tangle-network/create-agent-app 0.48.2 → 0.48.4
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
CHANGED
package/template/_package.json
CHANGED
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@tangle-network/agent-eval": "0.182.0",
|
|
25
|
-
"@tangle-network/agent-integrations": ">=0.
|
|
26
|
-
"@tangle-network/agent-interface": "2.
|
|
27
|
-
"@tangle-network/agent-runtime": "0.
|
|
25
|
+
"@tangle-network/agent-integrations": ">=0.54.2 <0.55.0",
|
|
26
|
+
"@tangle-network/agent-interface": "2.10.0",
|
|
27
|
+
"@tangle-network/agent-runtime": ">=0.247.0 <0.248.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@tangle-network/agent-eval": "0.182.0",
|
|
31
|
-
"@tangle-network/agent-integrations": "0.
|
|
32
|
-
"@tangle-network/agent-interface": "2.
|
|
31
|
+
"@tangle-network/agent-integrations": "0.54.2",
|
|
32
|
+
"@tangle-network/agent-interface": "2.10.0",
|
|
33
33
|
"@tangle-network/agent-knowledge": "17.0.2",
|
|
34
|
-
"@tangle-network/agent-runtime": "0.
|
|
35
|
-
"@tangle-network/sandbox": "0.
|
|
34
|
+
"@tangle-network/agent-runtime": "0.247.0",
|
|
35
|
+
"@tangle-network/sandbox": "0.45.0",
|
|
36
36
|
"@types/node": "^22.20.1",
|
|
37
37
|
"typescript": "^7.0.2",
|
|
38
38
|
"viem": "^2.0.0",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@tangle-network/agent-app": "__AGENT_APP_VERSION__",
|
|
23
|
-
"@tangle-network/agent-gateway": "0.
|
|
24
|
-
"@tangle-network/agent-interface": "2.
|
|
25
|
-
"@tangle-network/agent-runtime": "0.
|
|
26
|
-
"@tangle-network/sandbox": "0.
|
|
23
|
+
"@tangle-network/agent-gateway": "0.11.4",
|
|
24
|
+
"@tangle-network/agent-interface": "2.10.0",
|
|
25
|
+
"@tangle-network/agent-runtime": "0.247.0",
|
|
26
|
+
"@tangle-network/sandbox": "0.45.0",
|
|
27
27
|
"better-auth": "^1.7.2",
|
|
28
28
|
"drizzle-orm": "^0.45.2",
|
|
29
29
|
"hono": "^4.13.5",
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@tangle-network/agent-eval": "0.182.0",
|
|
34
|
-
"@tangle-network/agent-integrations": ">=0.
|
|
34
|
+
"@tangle-network/agent-integrations": ">=0.54.2 <0.55.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@tangle-network/agent-eval": "0.182.0",
|
|
38
|
-
"@tangle-network/agent-integrations": "0.
|
|
38
|
+
"@tangle-network/agent-integrations": "0.54.2",
|
|
39
39
|
"@tangle-network/agent-knowledge": "17.0.2",
|
|
40
40
|
"@cloudflare/workers-types": "^5.20260827.1",
|
|
41
41
|
"@types/better-sqlite3": "^9.6.0",
|
|
@@ -145,12 +145,10 @@ export function createSandboxProduce(env: AppEnv) {
|
|
|
145
145
|
...(executionLimits?.maxReasoningTokens
|
|
146
146
|
? { maxReasoningTokens: executionLimits.maxReasoningTokens }
|
|
147
147
|
: {}),
|
|
148
|
+
// Gateway output is inclusive of reasoning. Keep the same total
|
|
149
|
+
// ceiling even when a separate reasoning subset was authorized.
|
|
148
150
|
...(executionLimits?.maxOutputTokens !== undefined
|
|
149
|
-
|
|
150
|
-
? {
|
|
151
|
-
maxTotalOutputTokens:
|
|
152
|
-
executionLimits.maxOutputTokens + executionLimits.maxReasoningTokens,
|
|
153
|
-
}
|
|
151
|
+
? { maxTotalOutputTokens: executionLimits.maxOutputTokens }
|
|
154
152
|
: {}),
|
|
155
153
|
harness: config.harness,
|
|
156
154
|
systemPrompt: config.systemPrompt,
|
|
@@ -513,7 +513,7 @@ describe('e2e: fake sandbox producer → streamed turn → persisted transcript'
|
|
|
513
513
|
input_tokens: 40,
|
|
514
514
|
output_tokens: 20,
|
|
515
515
|
reasoning_tokens: 5,
|
|
516
|
-
tool_tokens:
|
|
516
|
+
tool_tokens: null, // The producer did not report this subset.
|
|
517
517
|
tool_call_count: 1,
|
|
518
518
|
provider_cost_nanodollars: 12_300_000,
|
|
519
519
|
total_cost_nanodollars: 12_300_000,
|
|
@@ -727,10 +727,10 @@ describe('e2e: fake sandbox producer → streamed turn → persisted transcript'
|
|
|
727
727
|
expect(receivedLimits).toMatchObject({
|
|
728
728
|
maxInputTokens: config.gateway.maxProviderInputTokens,
|
|
729
729
|
maxOutputTokens: 321,
|
|
730
|
-
maxReasoningTokens: 321,
|
|
731
|
-
maxToolTokens: 321,
|
|
732
730
|
maxToolCalls: 8,
|
|
733
731
|
})
|
|
732
|
+
expect(receivedLimits).not.toHaveProperty('maxReasoningTokens')
|
|
733
|
+
expect(receivedLimits).not.toHaveProperty('maxToolTokens')
|
|
734
734
|
expect(receivedLimits?.maxProviderCostUsd).toBeGreaterThan(0)
|
|
735
735
|
})
|
|
736
736
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import type { ChatTurnProduceArgs } from '@tangle-network/agent-app/chat-routes'
|
|
3
|
+
|
|
4
|
+
const boundary = vi.hoisted(() => ({
|
|
5
|
+
claim: vi.fn(),
|
|
6
|
+
ensure: vi.fn(),
|
|
7
|
+
stream: vi.fn(),
|
|
8
|
+
}))
|
|
9
|
+
vi.mock('@tangle-network/agent-app/sandbox', async (importOriginal) => ({
|
|
10
|
+
...await importOriginal<typeof import('@tangle-network/agent-app/sandbox')>(),
|
|
11
|
+
createD1PrewarmClaimStore: boundary.claim,
|
|
12
|
+
ensureWorkspaceSandbox: boundary.ensure,
|
|
13
|
+
streamSandboxPrompt: boundary.stream,
|
|
14
|
+
}))
|
|
15
|
+
import { createSandboxProduce } from '../src/sandbox'
|
|
16
|
+
import type { AppEnv } from '../src/env'
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
vi.clearAllMocks()
|
|
20
|
+
boundary.claim.mockReturnValue({
|
|
21
|
+
acquire: async () => true,
|
|
22
|
+
release: async () => undefined,
|
|
23
|
+
isHeld: async () => false,
|
|
24
|
+
inspect: async () => ({ status: 'absent' as const }),
|
|
25
|
+
acquireLease: async () => ({ key: 'workspace-1::opencode', expiresAt: Date.now() + 180000 }),
|
|
26
|
+
releaseLease: async () => undefined,
|
|
27
|
+
})
|
|
28
|
+
boundary.ensure.mockResolvedValue({ id: 'box-1' })
|
|
29
|
+
boundary.stream.mockImplementation(async function* () {
|
|
30
|
+
yield { type: 'result', data: { finalText: 'Done.' } }
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const env = {
|
|
35
|
+
DB: {}, BETTER_AUTH_URL: 'http://localhost:8787', BETTER_AUTH_SECRET: 'test-only-secret',
|
|
36
|
+
SANDBOX_API_KEY: 'not-a-live-key', SANDBOX_GATEWAY_URL: 'https://sandbox.example.test',
|
|
37
|
+
} as AppEnv
|
|
38
|
+
|
|
39
|
+
async function dispatch(limits: ChatTurnProduceArgs<void>['executionLimits']) {
|
|
40
|
+
const producer = await createSandboxProduce(env)({
|
|
41
|
+
request: new Request('http://localhost:8787/api/chat', { method: 'POST' }),
|
|
42
|
+
body: { threadId: 'thread-1', content: 'Hello' },
|
|
43
|
+
identity: { tenantId: 'workspace-1', sessionId: 'thread-1', userId: 'user-1', turnIndex: 0 },
|
|
44
|
+
context: undefined, prompt: 'Hello', executionId: 'execution-1', turnStreamId: 'turn-1',
|
|
45
|
+
priorMessages: [], userMessageId: 'message-1', executionLimits: limits,
|
|
46
|
+
})
|
|
47
|
+
for await (const _event of producer.stream) { /* Drain the actual producer. */ }
|
|
48
|
+
expect(boundary.stream).toHaveBeenCalledTimes(1)
|
|
49
|
+
const call = boundary.stream.mock.calls[0]
|
|
50
|
+
if (!call) throw new Error('The actual producer did not call the native stream boundary')
|
|
51
|
+
return call[3]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
describe('Gateway inclusive output budget at the native sandbox boundary', () => {
|
|
55
|
+
it.each([undefined, 100, 0])('does not add the reasoning subset (%s) to total output authority', async reasoning => {
|
|
56
|
+
const options = await dispatch({
|
|
57
|
+
maxOutputTokens: 321,
|
|
58
|
+
...(reasoning !== undefined ? { maxReasoningTokens: reasoning } : {}),
|
|
59
|
+
})
|
|
60
|
+
expect(options.maxOutputTokens).toBe(321)
|
|
61
|
+
expect(options.maxTotalOutputTokens).toBe(321)
|
|
62
|
+
if (reasoning === undefined) expect(options).not.toHaveProperty('maxReasoningTokens')
|
|
63
|
+
else if (reasoning === 0) expect(options.effort).toBe('none')
|
|
64
|
+
else expect(options.maxReasoningTokens).toBe(reasoning)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('does not invent token ceilings for an uncapped browser turn', async () => {
|
|
68
|
+
const options = await dispatch(undefined)
|
|
69
|
+
expect(options).not.toHaveProperty('maxOutputTokens')
|
|
70
|
+
expect(options).not.toHaveProperty('maxTotalOutputTokens')
|
|
71
|
+
expect(options).not.toHaveProperty('maxReasoningTokens')
|
|
72
|
+
})
|
|
73
|
+
})
|