@a-dray/aglib 0.3.3 → 0.4.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/dist/agent.d.ts +1 -1
- package/dist/agent.js.map +1 -1
- package/dist/harness/adapters/native/loop.js +243 -53
- package/dist/harness/adapters/native/loop.js.map +1 -1
- package/dist/harness/harness.d.ts +10 -1
- package/dist/harness/harness.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model/adapters/anthropic/index.js +49 -11
- package/dist/model/adapters/anthropic/index.js.map +1 -1
- package/dist/model/adapters/fake/index.d.ts +2 -1
- package/dist/model/adapters/fake/index.js +1 -0
- package/dist/model/adapters/fake/index.js.map +1 -1
- package/dist/model/adapters/openai-compatible/index.js +96 -7
- package/dist/model/adapters/openai-compatible/index.js.map +1 -1
- package/dist/model/adapters/openai-responses/index.d.ts +33 -0
- package/dist/model/adapters/openai-responses/index.js +730 -0
- package/dist/model/adapters/openai-responses/index.js.map +1 -0
- package/dist/model/conformance.js +1 -1
- package/dist/model/conformance.js.map +1 -1
- package/dist/model/index.d.ts +1 -1
- package/dist/model/index.js.map +1 -1
- package/dist/model/model.d.ts +24 -4
- package/dist/model/model.js.map +1 -1
- package/dist/run.js +72 -20
- package/dist/run.js.map +1 -1
- package/dist/session/entry.d.ts +11 -1
- package/dist/session/entry.js.map +1 -1
- package/dist/session/index.d.ts +1 -1
- package/dist/session/index.js.map +1 -1
- package/dist/session/messages.d.ts +2 -1
- package/dist/session/messages.js +5 -2
- package/dist/session/messages.js.map +1 -1
- package/dist/store/conformance.js +2 -1
- package/dist/store/conformance.js.map +1 -1
- package/dist/tools/execute.d.ts +0 -2
- package/dist/tools/execute.js +22 -17
- package/dist/tools/execute.js.map +1 -1
- package/dist/tools/tool.d.ts +8 -5
- package/dist/tools/tool.js +1 -0
- package/dist/tools/tool.js.map +1 -1
- package/package.json +20 -1
package/dist/tools/tool.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../../src/tools/tool.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAe,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../../src/tools/tool.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAe,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAuFxB;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAA4B,KAOrD;IACC,MAAM,UAAU,GAAG,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAc,CAAC;IAC7D,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC;YAClB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,UAAU;YACV,GAAG,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5D,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACjE,CAAC;QACF,OAAO,CAAC,GAAY;YAClB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YAC3C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO,GAAG,CAAC;oBACT,OAAO,EAAE,yBAAyB,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;oBAChF,OAAO,EAAE,IAAI;iBACd,CAAC,CAAC;YACL,CAAC;YACD,OAAO,EAAE,CAAC;gBACR,KAAK,EAAE,MAAM,CAAC,IAAiB;gBAC/B,4DAA4D;gBAC5D,mEAAmE;gBACnE,GAAG,EAAE,KAAK,EAAE,OAAoB,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAyB,EAAE,OAAO,CAAC;aAC9F,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Content } from \"../content.js\";\n\nimport type { Delivery, ToolCall, ToolResult } from \"../session/entry.js\";\nimport type { JsonValue } from \"../json.js\";\nimport { err, ok, type Result } from \"../result.js\";\nimport { z } from \"zod\";\n\n/** What a tool tells a model about itself. Declared here because a tool owns it. */\nexport interface ToolSpec {\n name: string;\n description: string;\n /** JSON Schema. */\n parameters: JsonValue;\n /** The model may continue its turn while the application runs this tool. */\n async?: boolean;\n annotations?: { readOnly?: boolean; sequential?: boolean };\n}\n\nexport interface ToolContext {\n sessionId: string;\n runId: string;\n callId: string;\n signal: AbortSignal;\n /**\n * Deliver input to another session, committed with this run's own entries.\n * This is the whole of agent-to-agent messaging: spawning a child, replying\n * to a parent and messaging a peer are the same call, and either the sending\n * turn commits with the delivery or neither happens.\n *\n * `from` is not yours to state. The executor stamps this session, because a\n * tool that supplied its own sender could omit it — losing the provenance a\n * recipient reads to tell a peer's message from its user's — or claim to be\n * a session it is not. It was a value two callers each rebuilt from\n * `sessionId`, which is a second field for a fact another field already\n * determines.\n */\n enqueue(delivery: Omit<Delivery, \"from\">): void;\n /** Progress for a live viewer. Never recovery state. */\n report(data: JsonValue): void;\n}\n\nexport interface Tool {\n spec: ToolSpec;\n /** Validates raw arguments once, before any authority decision sees them. */\n prepare(raw: unknown): Result<{ input: JsonValue; run(context: ToolContext): Promise<ToolResult> }, ToolResult>;\n}\n\n/**\n * The entire permission model.\n *\n * One function over parsed arguments, supplied by the application, which\n * already owns identity, tenancy and policy. There is no grant vocabulary, no\n * principal and no second batch-level hook: anything those expressed, a closure\n * expresses better.\n *\n * Two outcomes, not three. There was a `pause`, which parked the batch and\n * committed an approval request — and nothing could ever resolve it, because\n * resuming an exact batch is only possible in a harness we own, and three of\n * the four are not. An approval that works in one harness and dead-ends in the\n * others is worse than none. A call needing permission is rejected with a\n * message saying so; the application asks whoever approves, and their answer\n * arrives as ordinary input on the session, which is a path that already works\n * everywhere. `recipes/agent-service` shows the whole round trip.\n *\n * The gate does not weaken by being a rejection: this runs on every call and\n * cannot be routed around. What an application gives up is exact-argument\n * replay, since the model re-issues rather than resuming. An application that\n * needs the stronger thing keys its approval on the call id and a hash of the\n * parsed input, so a re-issue that differs misses and is refused again.\n */\nexport type Decide = (call: {\n tool: ToolSpec;\n input: JsonValue;\n sessionId: string;\n runId: string;\n callId: string;\n}) =>\n | { action: \"execute\" }\n | { action: \"reject\"; message: string }\n | Promise<{ action: \"execute\" } | { action: \"reject\"; message: string }>;\n\n/** What a harness is handed to reach application tools. */\nexport interface ToolExecutor {\n list(): readonly ToolSpec[];\n /** Each completion carries only the deliveries made by that call. */\n execute(input: { calls: readonly ToolCall[]; signal?: AbortSignal }): AsyncIterable<{\n callId: string;\n result: ToolResult;\n deliveries: readonly Delivery[];\n }>;\n}\n\n/**\n * Declares a tool from a runtime schema. The argument type of `execute` is\n * derived from that schema, so there is never a hand-maintained interface to\n * keep in step with the validation.\n */\nexport function defineTool<TSchema extends z.ZodType>(input: {\n name: string;\n description: string;\n schema: TSchema;\n async?: boolean;\n annotations?: ToolSpec[\"annotations\"];\n execute(args: z.output<TSchema>, context: ToolContext): ToolResult | Promise<ToolResult>;\n}): Tool {\n const parameters = z.toJSONSchema(input.schema) as JsonValue;\n return Object.freeze({\n spec: Object.freeze({\n name: input.name,\n description: input.description,\n parameters,\n ...(input.async !== undefined ? { async: input.async } : {}),\n ...(input.annotations ? { annotations: input.annotations } : {}),\n }),\n prepare(raw: unknown) {\n const parsed = input.schema.safeParse(raw);\n if (!parsed.success) {\n return err({\n content: `Invalid arguments for ${input.name}: ${z.prettifyError(parsed.error)}`,\n isError: true,\n });\n }\n return ok({\n input: parsed.data as JsonValue,\n // Throws are normalized by the executor, which has to cover\n // hand-written tools anyway; catching here too would be dead code.\n run: async (context: ToolContext) => input.execute(parsed.data as z.output<TSchema>, context),\n });\n },\n });\n}\n\n/** Re-exported for the same reason the model port re-exports its own. */\nexport type { Content, ToolResult };\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a-dray/aglib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A small TypeScript toolkit for building your own agent harness.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,6 +59,10 @@
|
|
|
59
59
|
"types": "./dist/model/adapters/openai-compatible/index.d.ts",
|
|
60
60
|
"import": "./dist/model/adapters/openai-compatible/index.js"
|
|
61
61
|
},
|
|
62
|
+
"./model/adapters/openai-responses": {
|
|
63
|
+
"types": "./dist/model/adapters/openai-responses/index.d.ts",
|
|
64
|
+
"import": "./dist/model/adapters/openai-responses/index.js"
|
|
65
|
+
},
|
|
62
66
|
"./model/adapters/fake": {
|
|
63
67
|
"types": "./dist/model/adapters/fake/index.d.ts",
|
|
64
68
|
"import": "./dist/model/adapters/fake/index.js"
|
|
@@ -103,7 +107,22 @@
|
|
|
103
107
|
"dependencies": {
|
|
104
108
|
"zod": "^4.4.3"
|
|
105
109
|
},
|
|
110
|
+
"peerDependencies": {
|
|
111
|
+
"openai": "^7.10.0",
|
|
112
|
+
"ws": "^8.18.0"
|
|
113
|
+
},
|
|
114
|
+
"peerDependenciesMeta": {
|
|
115
|
+
"openai": {
|
|
116
|
+
"optional": true
|
|
117
|
+
},
|
|
118
|
+
"ws": {
|
|
119
|
+
"optional": true
|
|
120
|
+
}
|
|
121
|
+
},
|
|
106
122
|
"devDependencies": {
|
|
123
|
+
"openai": "^7.10.0",
|
|
124
|
+
"ws": "^8.18.0",
|
|
125
|
+
"@types/ws": "^8.18.1",
|
|
107
126
|
"@types/bun": "^1.3.14",
|
|
108
127
|
"typescript": "^6.0.3"
|
|
109
128
|
},
|