@gobing-ai/ts-ai-runner 0.5.22 → 0.5.24
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/README.md +5 -0
- package/dist/decision/decision-maker.d.ts +6 -0
- package/dist/decision/decision-maker.d.ts.map +1 -1
- package/dist/decision/decision-maker.js +6 -0
- package/dist/decision/types.d.ts +6 -0
- package/dist/decision/types.d.ts.map +1 -1
- package/dist/decision/typesafe-driver.d.ts.map +1 -1
- package/dist/decision/typesafe-driver.js +6 -1
- package/package.json +4 -4
- package/src/decision/decision-maker.ts +12 -0
- package/src/decision/types.ts +6 -0
- package/src/decision/typesafe-driver.ts +7 -1
package/README.md
CHANGED
|
@@ -867,6 +867,11 @@ const myDriver: DecisionDriver = {
|
|
|
867
867
|
const custom = createDecisionMaker({ driver: myDriver }); // no TYPESAFE_API_KEY required
|
|
868
868
|
```
|
|
869
869
|
|
|
870
|
+
A driver that owns something outside the JS heap — a warm worker process, a socket, a pool — also
|
|
871
|
+
implements the optional `dispose(): void` hook, and `createDecisionMaker` forwards it as
|
|
872
|
+
`maker.dispose()`. It is never run against a backend that was not already resolved, and it must be
|
|
873
|
+
safe to call more than once; the maker is not usable afterwards.
|
|
874
|
+
|
|
870
875
|
## Boundary Notes
|
|
871
876
|
|
|
872
877
|
- This package is a command adapter, not an agent orchestration framework.
|
|
@@ -18,6 +18,12 @@ export interface DecisionMaker {
|
|
|
18
18
|
yes?: Desc;
|
|
19
19
|
no?: Desc;
|
|
20
20
|
}): Promise<NoulAnswer>;
|
|
21
|
+
/**
|
|
22
|
+
* Release the driver's own resources (a warm worker process, a socket, a pool), if it owns any.
|
|
23
|
+
* Optional: a driver that owns nothing omits it. Never constructs a driver just to dispose it,
|
|
24
|
+
* is safe to call more than once, and leaves the maker unusable — resolve it again instead.
|
|
25
|
+
*/
|
|
26
|
+
dispose?(): void | Promise<void>;
|
|
21
27
|
}
|
|
22
28
|
/** Available named decision backends (task 0080, task 0085). */
|
|
23
29
|
export type DecisionBackend = 'typesafe' | 'laya-local' | 'fm-local';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decision-maker.d.ts","sourceRoot":"","sources":["../../src/decision/decision-maker.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACR,UAAU,EACV,YAAY,EACZ,cAAc,EACd,aAAa,EACb,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,WAAW,EACd,MAAM,SAAS,CAAC;AAKjB,yFAAyF;AACzF,MAAM,WAAW,aAAa;IAC1B,iFAAiF;IACjF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sFAAsF;IACtF,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,GAAG,EAAE;QAC/C,KAAK,EAAE,aAAa,CAAC;QACrB,SAAS,EAAE,CAAC,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,yEAAyE;IACzE,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EACzB,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,IAAI,EACZ,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,GACxB,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5B,gFAAgF;IAChF,KAAK,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAC1G,wEAAwE;IACxE,IAAI,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,IAAI,CAAC;QAAC,EAAE,CAA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export function createDecisionMaker(options = {}) {
|
|
|
104
104
|
};
|
|
105
105
|
return {
|
|
106
106
|
driver: options.driver?.name ?? options.backend ?? 'typesafe',
|
|
107
|
+
// Only an injected or already-resolved driver is a candidate: running the lazy factory
|
|
108
|
+
// here would construct a backend (and, for the local ones, spawn a process) purely to
|
|
109
|
+
// close it.
|
|
110
|
+
dispose: async () => {
|
|
111
|
+
await (options.driver ?? resolvedDriver)?.dispose?.();
|
|
112
|
+
},
|
|
107
113
|
ask,
|
|
108
114
|
// R4/R5: each sugar method is one `ask` with exactly one `q.*` question,
|
|
109
115
|
// unwrapping the single answer — no second driver call, no duplicated
|
package/dist/decision/types.d.ts
CHANGED
|
@@ -101,5 +101,11 @@ export interface DecisionDriver {
|
|
|
101
101
|
questions: Record<string, Question>;
|
|
102
102
|
model?: string;
|
|
103
103
|
}): Promise<Record<string, Answer>>;
|
|
104
|
+
/**
|
|
105
|
+
* Release whatever the driver owns outside the JS heap — a warm worker process, a socket, a
|
|
106
|
+
* pool. Optional: a driver that owns no such resource omits it. Must be safe to call more than
|
|
107
|
+
* once, and the driver is not expected to answer after it runs.
|
|
108
|
+
*/
|
|
109
|
+
dispose?(): void;
|
|
104
110
|
}
|
|
105
111
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/decision/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,mCAAmC;AACnC,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,EAAE,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAErF,mFAAmF;AACnF,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,IAAI,EAAE,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,CAAC;AAE3E,0FAA0F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C;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"typesafe-driver.d.ts","sourceRoot":"","sources":["../../src/decision/typesafe-driver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAwBH,OAAO,KAAK,EAAU,cAAc,EAAY,MAAM,SAAS,CAAC;AAGhE,0FAA0F;AAC1F,MAAM,WAAW,oBAAoB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,cAAc,CAoDjF"}
|
|
@@ -36,10 +36,15 @@ export function createTypesafeDriver(config) {
|
|
|
36
36
|
name: 'typesafe',
|
|
37
37
|
async ask({ state, questions, model }) {
|
|
38
38
|
validateQuestions(questions);
|
|
39
|
+
// The neutral contract allows `null` state ("no caller context") and the SDK type
|
|
40
|
+
// accepts it, but the wire drops a null field and the API answers 422 "state: Field
|
|
41
|
+
// required" — so every fully parameterless decision used to fall back on this backend.
|
|
42
|
+
// Same null→'' mapping the laya and fm drivers already apply; structured state passes
|
|
43
|
+
// through untouched (the wire accepts an object or array).
|
|
39
44
|
let result;
|
|
40
45
|
try {
|
|
41
46
|
const sdkQuestions = Object.fromEntries(Object.entries(questions).map(([name, question]) => [name, toSdkQuestion(question)]));
|
|
42
|
-
result = await client.systemOne({ state, questions: sdkQuestions, model });
|
|
47
|
+
result = await client.systemOne({ state: state ?? '', questions: sdkQuestions, model });
|
|
43
48
|
}
|
|
44
49
|
catch (err) {
|
|
45
50
|
translateError(err);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gobing-ai/ts-ai-runner",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.24",
|
|
4
4
|
"description": "@gobing-ai/ts-ai-runner — Coding-agent shims, detection, doctor checks, and prompt execution.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"release": "echo 'Manual publish is disabled. Releases go through GitHub Actions via Trusted Publishing — push a tag: git tag @gobing-ai/ts-ai-runner-v<version> && git push --tags' && exit 1"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@gobing-ai/ts-infra": "^0.5.
|
|
51
|
-
"@gobing-ai/ts-runtime": "^0.5.
|
|
50
|
+
"@gobing-ai/ts-infra": "^0.5.24",
|
|
51
|
+
"@gobing-ai/ts-runtime": "^0.5.24",
|
|
52
52
|
"@typesafe-ai/sdk": "0.6.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/bun": "1.3.14",
|
|
56
|
-
"@gobing-ai/ts-db": "^0.5.
|
|
56
|
+
"@gobing-ai/ts-db": "^0.5.24"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
@@ -40,6 +40,12 @@ export interface DecisionMaker {
|
|
|
40
40
|
score(state: DecisionState, prompt: Desc, rubric: readonly [Desc, Desc, ...Desc[]]): Promise<ScoreAnswer>;
|
|
41
41
|
/** Yes/no judgment. Sugar over `ask` with exactly one noul question. */
|
|
42
42
|
noul(state: DecisionState, prompt?: Desc, outcomes?: { yes?: Desc; no?: Desc }): Promise<NoulAnswer>;
|
|
43
|
+
/**
|
|
44
|
+
* Release the driver's own resources (a warm worker process, a socket, a pool), if it owns any.
|
|
45
|
+
* Optional: a driver that owns nothing omits it. Never constructs a driver just to dispose it,
|
|
46
|
+
* is safe to call more than once, and leaves the maker unusable — resolve it again instead.
|
|
47
|
+
*/
|
|
48
|
+
dispose?(): void | Promise<void>;
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
/** Available named decision backends (task 0080, task 0085). */
|
|
@@ -191,6 +197,12 @@ export function createDecisionMaker(options: DecisionMakerOptions = {}): Decisio
|
|
|
191
197
|
|
|
192
198
|
return {
|
|
193
199
|
driver: options.driver?.name ?? options.backend ?? 'typesafe',
|
|
200
|
+
// Only an injected or already-resolved driver is a candidate: running the lazy factory
|
|
201
|
+
// here would construct a backend (and, for the local ones, spawn a process) purely to
|
|
202
|
+
// close it.
|
|
203
|
+
dispose: async () => {
|
|
204
|
+
await (options.driver ?? resolvedDriver)?.dispose?.();
|
|
205
|
+
},
|
|
194
206
|
ask,
|
|
195
207
|
// R4/R5: each sugar method is one `ask` with exactly one `q.*` question,
|
|
196
208
|
// unwrapping the single answer — no second driver call, no duplicated
|
package/src/decision/types.ts
CHANGED
|
@@ -108,4 +108,10 @@ export interface DecisionDriver {
|
|
|
108
108
|
questions: Record<string, Question>;
|
|
109
109
|
model?: string;
|
|
110
110
|
}): Promise<Record<string, Answer>>;
|
|
111
|
+
/**
|
|
112
|
+
* Release whatever the driver owns outside the JS heap — a warm worker process, a socket, a
|
|
113
|
+
* pool. Optional: a driver that owns no such resource omits it. Must be safe to call more than
|
|
114
|
+
* once, and the driver is not expected to answer after it runs.
|
|
115
|
+
*/
|
|
116
|
+
dispose?(): void;
|
|
111
117
|
}
|
|
@@ -69,12 +69,18 @@ export function createTypesafeDriver(config: TypesafeDriverConfig): DecisionDriv
|
|
|
69
69
|
name: 'typesafe',
|
|
70
70
|
async ask({ state, questions, model }) {
|
|
71
71
|
validateQuestions(questions);
|
|
72
|
+
|
|
73
|
+
// The neutral contract allows `null` state ("no caller context") and the SDK type
|
|
74
|
+
// accepts it, but the wire drops a null field and the API answers 422 "state: Field
|
|
75
|
+
// required" — so every fully parameterless decision used to fall back on this backend.
|
|
76
|
+
// Same null→'' mapping the laya and fm drivers already apply; structured state passes
|
|
77
|
+
// through untouched (the wire accepts an object or array).
|
|
72
78
|
let result: SystemOneResult<Record<string, SdkQuestion>>;
|
|
73
79
|
try {
|
|
74
80
|
const sdkQuestions = Object.fromEntries(
|
|
75
81
|
Object.entries(questions).map(([name, question]) => [name, toSdkQuestion(question)]),
|
|
76
82
|
);
|
|
77
|
-
result = await client.systemOne({ state, questions: sdkQuestions, model });
|
|
83
|
+
result = await client.systemOne({ state: state ?? '', questions: sdkQuestions, model });
|
|
78
84
|
} catch (err) {
|
|
79
85
|
translateError(err);
|
|
80
86
|
}
|