@tangle-network/create-agent-app 0.61.3 → 0.62.0
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/template/CUSTOMIZE.md +1 -1
- package/template/README.md +1 -1
- package/template/_package.json +5 -5
- package/template/agent.config.ts +0 -2
- package/template/src/agent-surfaces.ts +1 -1
- package/template/src/worker.ts +4 -4
- package/template-chat/_package.json +4 -4
- package/template-chat/agent.config.ts +0 -2
- package/template-chat/src/agent-surfaces.ts +1 -1
- package/template-chat/src/turn-lock.ts +4 -1
- package/template-chat/src/worker.ts +5 -5
- package/template-chat/tests/chat-turn.e2e.test.ts +1 -1
- package/template/tests/agent-access.test.ts +0 -20
package/package.json
CHANGED
package/template/CUSTOMIZE.md
CHANGED
|
@@ -83,7 +83,7 @@ Discovery: **Does the customized agent hold its contract?**
|
|
|
83
83
|
then `pnpm dev` to exercise `/chat` for real.
|
|
84
84
|
|
|
85
85
|
Before exposing `/chat`, pass a trusted server-side `HeadlessAuth.authenticate`
|
|
86
|
-
resolver to `
|
|
86
|
+
resolver to `createHeadlessWorker`; the default handler refuses work. The resolver must
|
|
87
87
|
validate the session/key, choose the authorized workspace, and enforce budgets.
|
|
88
88
|
Public discovery intentionally reports this skeleton as not ready. Do not
|
|
89
89
|
change that claim until the configured product's client flow is proved.
|
package/template/README.md
CHANGED
|
@@ -45,7 +45,7 @@ grounded in real records, never fabricated. See `AGENTS.md` for the full contrac
|
|
|
45
45
|
Public `/agent-setup.md`, `/llms.txt` and `/.well-known/tangle-agent.json` describe
|
|
46
46
|
this skeleton's readiness truthfully. The default `/chat` fails closed with
|
|
47
47
|
503 `auth.not_configured`. Install a trusted `HeadlessAuth.authenticate`
|
|
48
|
-
resolver through `
|
|
48
|
+
resolver through `createHeadlessWorker` before enabling it. Never derive identity from
|
|
49
49
|
request-body userId/workspaceId. Update the public contract only after proving
|
|
50
50
|
real authentication, authorization, spending and results. Use the default chat
|
|
51
51
|
template for the assembled local-key operator API and browser owner setup.
|
package/template/_package.json
CHANGED
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
"@tangle-network/agent-app": "__AGENT_APP_VERSION__"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@tangle-network/agent-eval": "0.220.
|
|
24
|
+
"@tangle-network/agent-eval": "0.220.2",
|
|
25
25
|
"@tangle-network/agent-integrations": "0.75.4",
|
|
26
26
|
"@tangle-network/agent-interface": "5.7.0",
|
|
27
|
-
"@tangle-network/agent-runtime": "0.
|
|
27
|
+
"@tangle-network/agent-runtime": "0.344.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@tangle-network/agent-eval": "0.220.
|
|
30
|
+
"@tangle-network/agent-eval": "0.220.2",
|
|
31
31
|
"@tangle-network/agent-integrations": "0.75.4",
|
|
32
32
|
"@tangle-network/agent-interface": "5.7.0",
|
|
33
33
|
"@tangle-network/agent-knowledge": "22.0.13",
|
|
34
|
-
"@tangle-network/agent-runtime": "0.
|
|
35
|
-
"@tangle-network/sandbox": "0.64.
|
|
34
|
+
"@tangle-network/agent-runtime": "0.344.0",
|
|
35
|
+
"@tangle-network/sandbox": "0.64.19",
|
|
36
36
|
"@types/node": "^22.20.1",
|
|
37
37
|
"typescript": "^7.0.2",
|
|
38
38
|
"viem": "^2.0.0",
|
package/template/agent.config.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createAgentSurfaceHandler, renderAgentSetupSkill, type AgentSurfaceConfig } from '@tangle-network/agent-app/agent-surfaces'
|
|
2
2
|
|
|
3
3
|
/** The headless skeleton must not advertise customer readiness before auth exists. */
|
|
4
|
-
export function
|
|
4
|
+
export function headlessAgentSurfaces(origin: string) {
|
|
5
5
|
const product: AgentSurfaceConfig = {
|
|
6
6
|
id: '__PACKAGE_NAME__', name: '__PROJECT_NAME__', origin,
|
|
7
7
|
summary: 'A headless tool-loop development skeleton. External-agent operation is disabled until the product installs trusted authentication and workspace authorization.',
|
package/template/src/worker.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* proposals stay proposals.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import {
|
|
18
|
+
import { headlessAgentSurfaces } from './agent-surfaces'
|
|
19
19
|
import { config } from '../agent.config'
|
|
20
20
|
import { createAgentApp, type AppBindings } from './agent-app'
|
|
21
21
|
import {
|
|
@@ -72,9 +72,9 @@ function buildSystemPrompt(): string {
|
|
|
72
72
|
export interface HeadlessAuth {
|
|
73
73
|
authenticate(request: Request, env: AppBindings): Promise<AppToolContext | null>
|
|
74
74
|
}
|
|
75
|
-
export function
|
|
75
|
+
export function createHeadlessWorker(auth?: HeadlessAuth) { return {
|
|
76
76
|
async fetch(request: Request, env: AppBindings): Promise<Response> {
|
|
77
|
-
const surface =
|
|
77
|
+
const surface = headlessAgentSurfaces(new URL(request.url).origin).handle(request)
|
|
78
78
|
if (surface) return surface
|
|
79
79
|
const url = new URL(request.url)
|
|
80
80
|
if (url.pathname !== '/chat' || request.method !== 'POST') {
|
|
@@ -124,4 +124,4 @@ export function createWorker(auth?: HeadlessAuth) { return {
|
|
|
124
124
|
},
|
|
125
125
|
} }
|
|
126
126
|
|
|
127
|
-
export default
|
|
127
|
+
export default createHeadlessWorker()
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"@tangle-network/agent-app": "__AGENT_APP_VERSION__",
|
|
25
25
|
"@tangle-network/agent-gateway": "0.11.4",
|
|
26
26
|
"@tangle-network/agent-interface": "5.7.0",
|
|
27
|
-
"@tangle-network/agent-runtime": "0.
|
|
28
|
-
"@tangle-network/sandbox": "0.64.
|
|
27
|
+
"@tangle-network/agent-runtime": "0.344.0",
|
|
28
|
+
"@tangle-network/sandbox": "0.64.19",
|
|
29
29
|
"better-auth": "^1.7.2",
|
|
30
30
|
"drizzle-orm": "^0.45.2",
|
|
31
31
|
"hono": "^4.13.5",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"nanostores": "1.5.4"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@tangle-network/agent-eval": "0.220.
|
|
43
|
+
"@tangle-network/agent-eval": "0.220.2",
|
|
44
44
|
"@tangle-network/agent-integrations": "0.75.4"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@tangle-network/agent-eval": "0.220.
|
|
47
|
+
"@tangle-network/agent-eval": "0.220.2",
|
|
48
48
|
"@tangle-network/agent-integrations": "0.75.4",
|
|
49
49
|
"@tangle-network/agent-knowledge": "22.0.13",
|
|
50
50
|
"@cloudflare/workers-types": "^5.20260827.1",
|
|
@@ -3,7 +3,7 @@ import { operatorOpenApi } from './openapi'
|
|
|
3
3
|
import { config } from '../agent.config'
|
|
4
4
|
|
|
5
5
|
/** Public customer docs, separate from the repository's coding-agent AGENTS.md. */
|
|
6
|
-
export function
|
|
6
|
+
export function chatAgentSurfaces(origin: string, runEnabled = false) {
|
|
7
7
|
const api = `${origin}/api/operator/v1`
|
|
8
8
|
const product: AgentSurfaceConfig = {
|
|
9
9
|
id: '__PACKAGE_NAME__', name: config.name, origin,
|
|
@@ -5,8 +5,11 @@ import { TurnStreamDO as SharedTurnStreamDO, TURN_STREAM_STORAGE_KEYS, type Dura
|
|
|
5
5
|
* the actual backend execution. Elapsed time alone never proves it stopped.
|
|
6
6
|
* Auth, atomic admission, fencing and release remain owned by the shared DO.
|
|
7
7
|
*/
|
|
8
|
-
export class
|
|
8
|
+
export class DetachedTurnStreamDO extends SharedTurnStreamDO {
|
|
9
9
|
protected override async loadActiveLock(): Promise<DurableTurnLock | null> {
|
|
10
10
|
return await this.state.storage.get<DurableTurnLock>(TURN_STREAM_STORAGE_KEYS.lock) ?? null
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
// Preserve the generated Worker binding and its integration entrypoint.
|
|
15
|
+
export { DetachedTurnStreamDO as TurnStreamDO }
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
* POST /v1/agents/:slug/chat/completions OpenAI-compatible API
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
export { TurnStreamDO } from './turn-lock'
|
|
22
|
+
export { DetachedTurnStreamDO as TurnStreamDO } from './turn-lock'
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import { chatAgentSurfaces } from './agent-surfaces'
|
|
25
25
|
import { createArtifactIndex } from './files'
|
|
26
26
|
import type { peekWorkspaceSandbox } from '@tangle-network/agent-app/sandbox'
|
|
27
27
|
import { config } from '../agent.config'
|
|
@@ -67,7 +67,7 @@ const defaultAssembly: WorkerAssembly = {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/** Build the Worker around one app assembly. Tests inject the real app with a test database. */
|
|
70
|
-
export function
|
|
70
|
+
export function createChatWorker(assembly: WorkerAssembly = defaultAssembly): ExportedHandler<AppEnv> {
|
|
71
71
|
// Reuse the database-backed chat assembly within one Worker environment.
|
|
72
72
|
// Build the gateway per request so its background work binds to that
|
|
73
73
|
// request's ExecutionContext. Durable stores remain authoritative.
|
|
@@ -85,7 +85,7 @@ export function createWorker(assembly: WorkerAssembly = defaultAssembly): Export
|
|
|
85
85
|
return {
|
|
86
86
|
async fetch(request: Request, rawEnv: AppEnv, ctx: ExecutionContext): Promise<Response> {
|
|
87
87
|
const env = withLimitAlarms(rawEnv)
|
|
88
|
-
const surfaces =
|
|
88
|
+
const surfaces = chatAgentSurfaces(new URL(env.BETTER_AUTH_URL).origin, env.OPERATOR_RUN_ENABLED === 'true')
|
|
89
89
|
const surface = surfaces.handle(request)
|
|
90
90
|
if (surface) return surface
|
|
91
91
|
const url = new URL(request.url)
|
|
@@ -151,4 +151,4 @@ export function createWorker(assembly: WorkerAssembly = defaultAssembly): Export
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
export default
|
|
154
|
+
export default createChatWorker()
|
|
@@ -51,7 +51,7 @@ import type { AppEnv } from '../src/env'
|
|
|
51
51
|
import { buildGatewayApp, type GatewayAppOptions } from '../src/gateway'
|
|
52
52
|
import { appSlug } from '../src/sandbox'
|
|
53
53
|
import { ARTIFACT_ROOT } from '../src/files'
|
|
54
|
-
import { createWorker, type WorkerAssembly } from '../src/worker'
|
|
54
|
+
import { createChatWorker as createWorker, type WorkerAssembly } from '../src/worker'
|
|
55
55
|
|
|
56
56
|
const BASE = 'http://localhost:8787'
|
|
57
57
|
const MODEL = 'test/model-1'
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import worker, { createWorker } from '../src/worker'
|
|
3
|
-
import type { AppBindings } from '../src/agent-app'
|
|
4
|
-
|
|
5
|
-
const env = {} as AppBindings
|
|
6
|
-
|
|
7
|
-
describe('headless external-agent boundary', () => {
|
|
8
|
-
it('serves discovery without credentials but never trusts request-body identity', async () => {
|
|
9
|
-
const manifest = await worker.fetch(new Request('https://product.example/.well-known/tangle-agent.json'), env)
|
|
10
|
-
expect(manifest.status).toBe(200)
|
|
11
|
-
expect((await manifest.json() as { ready: boolean }).ready).toBe(false)
|
|
12
|
-
const response = await worker.fetch(new Request('https://product.example/chat', {
|
|
13
|
-
method: 'POST', headers: { 'content-type': 'application/json' },
|
|
14
|
-
body: JSON.stringify({ message: 'run', userId: 'owner', workspaceId: 'other-owner' }),
|
|
15
|
-
}), env)
|
|
16
|
-
expect(response.status).toBe(503)
|
|
17
|
-
const denied = createWorker({ authenticate: async () => null })
|
|
18
|
-
expect((await denied.fetch(new Request('https://product.example/chat', { method: 'POST', body: '{}' }), env)).status).toBe(401)
|
|
19
|
-
})
|
|
20
|
-
})
|