@jigging/agent-method 0.1.0-alpha.4 → 0.1.0-alpha.5
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/AGENTS.md +2 -0
- package/dist/index.d.ts +2 -2
- package/package.json +2 -2
- package/src/index.ts +1 -1
- package/test/fixtures/public-result-types.ts +17 -0
- package/test/public-result-types.test.ts +41 -0
package/AGENTS.md
CHANGED
|
@@ -73,6 +73,8 @@ ordinary Flow, preserving operator ownership of Agent execution.
|
|
|
73
73
|
- The ordinary ACP package imports this same method. `checkAgentResult` lets
|
|
74
74
|
consumers independently check any selected
|
|
75
75
|
Agent's dynamic structured result; it grants no authority or provenance.
|
|
76
|
+
Its validated `AgentResult` is assignable to portable FLOW JSON without a
|
|
77
|
+
cast; arbitrary exceptions and non-JSON values are not.
|
|
76
78
|
|
|
77
79
|
## Work Guidance
|
|
78
80
|
|
package/dist/index.d.ts
CHANGED
|
@@ -51,14 +51,14 @@ export interface PreparedAgent {
|
|
|
51
51
|
readonly request: AgentTransportInput;
|
|
52
52
|
readonly session?: AgentSessionRequest;
|
|
53
53
|
}
|
|
54
|
-
export
|
|
54
|
+
export type AgentResult = {
|
|
55
55
|
readonly outcome: 'done' | 'blocked' | 'limit';
|
|
56
56
|
readonly output: {
|
|
57
57
|
readonly text: string;
|
|
58
58
|
readonly structured?: JsonValue;
|
|
59
59
|
readonly session?: AgentSessionReceipt;
|
|
60
60
|
};
|
|
61
|
-
}
|
|
61
|
+
};
|
|
62
62
|
/** Independently check an Agent Flow result at its consumer's boundary. */
|
|
63
63
|
export declare function checkAgentResult(value: unknown, responseSchema?: JsonObject): AgentResult;
|
|
64
64
|
/** Prepare one bounded request. The returned data confers no execution authority. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jigging/agent-method",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"description": "A reusable bounded Agent method with an ordinary FLOW entrypoint",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"test"
|
|
48
48
|
],
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@jigging/flow": "0.1.0-alpha.
|
|
50
|
+
"@jigging/flow": "0.1.0-alpha.13",
|
|
51
51
|
"@types/node": "24.13.3",
|
|
52
52
|
"typescript": "7.0.2"
|
|
53
53
|
}
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type AgentResult, checkAgentResult } from '@jigging/agent-method'
|
|
2
|
+
import type { JsonValue, RunHandler } from '@jigging/flow'
|
|
3
|
+
|
|
4
|
+
const result: AgentResult = checkAgentResult({ outcome: 'done', output: { text: 'answer' } })
|
|
5
|
+
const direct: JsonValue = result
|
|
6
|
+
const nested: JsonValue = { agent: result }
|
|
7
|
+
const handler: RunHandler = async () => ({ outcome: 'done', output: result })
|
|
8
|
+
|
|
9
|
+
void [direct, nested, handler]
|
|
10
|
+
|
|
11
|
+
// @ts-expect-error Functions are not JSON values.
|
|
12
|
+
const functionOutput: JsonValue = () => 'answer'
|
|
13
|
+
// @ts-expect-error Undefined is not a JSON value.
|
|
14
|
+
const undefinedOutput: JsonValue = undefined
|
|
15
|
+
// @ts-expect-error Error objects are not JSON values.
|
|
16
|
+
const errorOutput: JsonValue = new Error('unhandled')
|
|
17
|
+
void [functionOutput, undefinedOutput, errorOutput]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { test } from 'bun:test'
|
|
2
|
+
import { execFileSync } from 'node:child_process'
|
|
3
|
+
import { copyFile, mkdir, mkdtemp, rm, symlink } from 'node:fs/promises'
|
|
4
|
+
import { tmpdir } from 'node:os'
|
|
5
|
+
import { join } from 'node:path'
|
|
6
|
+
import { fileURLToPath } from 'node:url'
|
|
7
|
+
|
|
8
|
+
test('public Agent results compose with FLOW JSON without casts', async () => {
|
|
9
|
+
const method = fileURLToPath(new URL('../', import.meta.url))
|
|
10
|
+
const flow = fileURLToPath(new URL('../../flow-sdk/', import.meta.url))
|
|
11
|
+
const consumer = await mkdtemp(join(tmpdir(), 'agent-public-types-'))
|
|
12
|
+
try {
|
|
13
|
+
await mkdir(join(consumer, 'node_modules/@jigging'), { recursive: true })
|
|
14
|
+
await symlink(method, join(consumer, 'node_modules/@jigging/agent-method'))
|
|
15
|
+
await symlink(flow, join(consumer, 'node_modules/@jigging/flow'))
|
|
16
|
+
await copyFile(
|
|
17
|
+
new URL('./fixtures/public-result-types.ts', import.meta.url),
|
|
18
|
+
join(consumer, 'consumer.ts'),
|
|
19
|
+
)
|
|
20
|
+
execFileSync(
|
|
21
|
+
process.execPath,
|
|
22
|
+
[
|
|
23
|
+
join(method, 'node_modules/typescript/bin/tsc'),
|
|
24
|
+
'--ignoreConfig',
|
|
25
|
+
'--noEmit',
|
|
26
|
+
'--strict',
|
|
27
|
+
'--exactOptionalPropertyTypes',
|
|
28
|
+
'--target',
|
|
29
|
+
'ES2022',
|
|
30
|
+
'--module',
|
|
31
|
+
'NodeNext',
|
|
32
|
+
'--moduleResolution',
|
|
33
|
+
'NodeNext',
|
|
34
|
+
'consumer.ts',
|
|
35
|
+
],
|
|
36
|
+
{ cwd: consumer, stdio: 'pipe' },
|
|
37
|
+
)
|
|
38
|
+
} finally {
|
|
39
|
+
await rm(consumer, { recursive: true, force: true })
|
|
40
|
+
}
|
|
41
|
+
})
|