@tangle-network/create-agent-app 0.60.208 → 0.60.210

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/create-agent-app",
3
- "version": "0.60.208",
3
+ "version": "0.60.210",
4
4
  "description": "Create a tested Tangle agent application with either a tool loop or a complete chat interface.",
5
5
  "keywords": [
6
6
  "tangle",
@@ -1,88 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from 'vitest'
2
-
3
- const sandboxMocks = vi.hoisted(() => ({
4
- createClaimStore: vi.fn(),
5
- ensureWorkspace: vi.fn(),
6
- peekWorkspace: vi.fn(),
7
- }))
8
-
9
- vi.mock('@tangle-network/agent-app/sandbox', async (importOriginal) => {
10
- const actual = await importOriginal<typeof import('@tangle-network/agent-app/sandbox')>()
11
- return {
12
- ...actual,
13
- createD1PrewarmClaimStore: sandboxMocks.createClaimStore,
14
- ensureWorkspaceSandbox: sandboxMocks.ensureWorkspace,
15
- peekWorkspaceSandbox: sandboxMocks.peekWorkspace,
16
- }
17
- })
18
-
19
- import { createSandboxProduce } from '../src/sandbox'
20
- import type { AppEnv } from '../src/env'
21
-
22
- describe('sandbox foreground provisioning', () => {
23
- beforeEach(() => {
24
- vi.clearAllMocks()
25
- })
26
-
27
- it('runs createSandboxProduce through the shared fenced claim', async () => {
28
- const lease = { key: 'workspace-1::opencode', expiresAt: 123 }
29
- const claim = {
30
- acquire: vi.fn(async () => true),
31
- release: vi.fn(async () => undefined),
32
- isHeld: vi.fn(async () => false),
33
- inspect: vi.fn(async () => ({ status: 'absent' as const })),
34
- acquireLease: vi.fn(async () => lease),
35
- releaseLease: vi.fn(async () => undefined),
36
- }
37
- const box = { id: 'box-1' }
38
- const db = {} as D1Database
39
- const env: AppEnv = {
40
- DB: db,
41
- BETTER_AUTH_URL: 'http://localhost:8787',
42
- BETTER_AUTH_SECRET: 'test-secret',
43
- SANDBOX_API_KEY: 'sandbox-key',
44
- SANDBOX_GATEWAY_URL: 'https://sandbox.example.test',
45
- }
46
- sandboxMocks.createClaimStore.mockReturnValue(claim)
47
- sandboxMocks.ensureWorkspace.mockResolvedValue(box)
48
-
49
- const producer = await createSandboxProduce(env)({
50
- request: new Request('http://localhost:8787/api/chat', { method: 'POST' }),
51
- body: { threadId: 'thread-1', content: 'Hello' },
52
- identity: {
53
- tenantId: 'workspace-1',
54
- sessionId: 'thread-1',
55
- userId: 'user-1',
56
- turnIndex: 0,
57
- },
58
- context: undefined,
59
- prompt: 'Hello',
60
- executionId: 'execution-1',
61
- turnStreamId: 'turn-1',
62
- priorMessages: [],
63
- userMessageId: 'message-1',
64
- })
65
-
66
- expect(producer.stream).toBeDefined()
67
- expect(sandboxMocks.createClaimStore).toHaveBeenCalledWith(db)
68
- expect(claim.acquireLease).toHaveBeenCalledWith('workspace-1::opencode', 180)
69
- expect(sandboxMocks.ensureWorkspace).toHaveBeenCalledWith(
70
- expect.objectContaining({ name: expect.any(Function) }),
71
- { workspaceId: 'workspace-1', userId: 'user-1', harness: 'opencode' },
72
- )
73
- expect(claim.releaseLease).toHaveBeenCalledWith(lease)
74
- expect(sandboxMocks.peekWorkspace).not.toHaveBeenCalled()
75
- })
76
- })
77
-
78
- it('listing decisions never provisions or resumes paid compute', async () => {
79
- const { resolveSidecarConnection } = await import('../src/sandbox')
80
- sandboxMocks.ensureWorkspace.mockClear()
81
- sandboxMocks.peekWorkspace.mockResolvedValue({ status: 'absent' })
82
- const result = await resolveSidecarConnection({ DB: {} as D1Database,
83
- BETTER_AUTH_URL: 'http://localhost:8787', BETTER_AUTH_SECRET: 'fixture',
84
- SANDBOX_API_KEY: 'fixture', SANDBOX_GATEWAY_URL: 'https://sandbox.example.test',
85
- }, { workspaceId: 'owner', userId: 'owner', threadId: 'thread' }, { readOnly: true })
86
- expect(result).toBeNull()
87
- expect(sandboxMocks.ensureWorkspace).not.toHaveBeenCalled()
88
- })