@cobol-ts/ai-tools 0.0.0-stage → 0.0.41
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 +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/src/tools.d.ts +16 -0
- package/dist/src/tools.js +15 -0
- package/dist/src/tools.js.map +1 -0
- package/dist/src/tools.spec.d.ts +1 -0
- package/dist/src/tools.spec.js +13 -0
- package/dist/src/tools.spec.js.map +1 -0
- package/index.ts +1 -0
- package/package.json +59 -3
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# `@cobol-ts/ai-tools`
|
|
2
|
+
|
|
3
|
+
The composition root injects named tools. Runners select tool names from their own configuration. `validator(name)` resolves a `Message => Promise<string[]>` capability; an empty array means success. `finished(name)` resolves a `(outcome: unknown) => void` capability. Missing names and wrong types fail at resolution, before any AI call. Tools know nothing about runners. No separate tool declarations in YAML.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/tools';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./src/tools"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Message } from '@cobol-ts/ai';
|
|
2
|
+
export type Validator = (message: Message) => Promise<string[]>;
|
|
3
|
+
export type Finished = (outcome: unknown) => void;
|
|
4
|
+
export type Tool = {
|
|
5
|
+
readonly type: 'validator';
|
|
6
|
+
readonly validate: Validator;
|
|
7
|
+
} | {
|
|
8
|
+
readonly type: 'finished';
|
|
9
|
+
readonly finish: Finished;
|
|
10
|
+
};
|
|
11
|
+
export type ToolRegistry = Readonly<Record<string, Tool>>;
|
|
12
|
+
export interface ToolRepository {
|
|
13
|
+
validator(name: string): Validator;
|
|
14
|
+
finished(name: string): Finished;
|
|
15
|
+
}
|
|
16
|
+
export declare function createToolRepository(tools: ToolRegistry): ToolRepository;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createToolRepository = createToolRepository;
|
|
4
|
+
function createToolRepository(tools) {
|
|
5
|
+
const get = (name, type) => {
|
|
6
|
+
if (!Object.prototype.hasOwnProperty.call(tools, name))
|
|
7
|
+
throw new Error(`Unknown AI tool '${name}' (expected ${type})`);
|
|
8
|
+
const tool = tools[name];
|
|
9
|
+
if (tool.type !== type)
|
|
10
|
+
throw new Error(`AI tool '${name}' has type '${tool.type}', expected '${type}'`);
|
|
11
|
+
return tool;
|
|
12
|
+
};
|
|
13
|
+
return { validator: name => get(name, 'validator').validate, finished: name => get(name, 'finished').finish };
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/tools.ts"],"names":[],"mappings":";;AAaA,oDAQC;AARD,SAAgB,oBAAoB,CAAC,KAAmB;IACpD,MAAM,GAAG,GAAG,CAAyB,IAAY,EAAE,IAAO,EAA4B,EAAE;QACpF,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,eAAe,IAAI,GAAG,CAAC,CAAA;QACvH,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAA;QACxB,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,YAAY,IAAI,eAAe,IAAI,CAAC,IAAI,gBAAgB,IAAI,GAAG,CAAC,CAAA;QACxG,OAAO,IAAgC,CAAA;IAC3C,CAAC,CAAA;IACD,OAAO,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,MAAM,EAAC,CAAA;AAC/G,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const index_1 = require("../index");
|
|
4
|
+
test('resolves typed capabilities and rejects wrong or absent tools', () => {
|
|
5
|
+
const validate = async () => [];
|
|
6
|
+
const finish = () => { };
|
|
7
|
+
const repository = (0, index_1.createToolRepository)({ graph: { type: 'validator', validate }, done: { type: 'finished', finish } });
|
|
8
|
+
expect(repository.validator('graph')).toBe(validate);
|
|
9
|
+
expect(repository.finished('done')).toBe(finish);
|
|
10
|
+
expect(() => repository.validator('done')).toThrow('expected');
|
|
11
|
+
expect(() => repository.finished('missing')).toThrow('Unknown AI tool');
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=tools.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.spec.js","sourceRoot":"","sources":["../../src/tools.spec.ts"],"names":[],"mappings":";;AAAA,oCAA6C;AAE7C,IAAI,CAAC,+DAA+D,EAAE,GAAG,EAAE;IACvE,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE,CAAC,EAAE,CAAA;IAC/B,MAAM,MAAM,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;IACvB,MAAM,UAAU,GAAG,IAAA,4BAAoB,EAAC,EAAC,KAAK,EAAE,EAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAC,EAAE,IAAI,EAAE,EAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAC,EAAC,CAAC,CAAA;IACjH,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACpD,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAChD,MAAM,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAC9D,MAAM,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;AAC3E,CAAC,CAAC,CAAA"}
|
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/tools'
|
package/package.json
CHANGED
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobol-ts/ai-tools",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"description": "Named typed deterministic AI tools",
|
|
4
|
+
"version": "0.0.41",
|
|
5
|
+
"main": "dist/index",
|
|
6
|
+
"types": "dist/index",
|
|
7
|
+
"browserslist": {
|
|
8
|
+
"development": [
|
|
9
|
+
"last 1 chrome version",
|
|
10
|
+
"last 1 firefox version",
|
|
11
|
+
"last 1 safari version"
|
|
12
|
+
],
|
|
13
|
+
"production": [
|
|
14
|
+
">0.2%",
|
|
15
|
+
"not dead",
|
|
16
|
+
"not op_mini all"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@cobol-ts/ai": "0.0.41"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typescript": "^5.2.2",
|
|
24
|
+
"@testing-library/jest-dom": "^6.1.4",
|
|
25
|
+
"@types/jest": "^29.0.0",
|
|
26
|
+
"@types/node": "^14.0.0",
|
|
27
|
+
"jest": "^29.0.0",
|
|
28
|
+
"ts-jest": "^29.0.0"
|
|
29
|
+
},
|
|
30
|
+
"eslintConfig": {
|
|
31
|
+
"extends": [
|
|
32
|
+
"react-app",
|
|
33
|
+
"react-app/jest"
|
|
34
|
+
],
|
|
35
|
+
"overrides": [
|
|
36
|
+
{
|
|
37
|
+
"files": [
|
|
38
|
+
"**/*.stories.*"
|
|
39
|
+
],
|
|
40
|
+
"rules": {
|
|
41
|
+
"import/no-anonymous-default-export": "off"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"dist/index.js",
|
|
48
|
+
"dist/index.d.ts",
|
|
49
|
+
"dist/src/",
|
|
50
|
+
"dist/**/*"
|
|
51
|
+
],
|
|
52
|
+
"keywords": [
|
|
53
|
+
"indexing"
|
|
54
|
+
],
|
|
55
|
+
"license": "MIT",
|
|
56
|
+
"module": "./index.ts",
|
|
57
|
+
"repository": "git@github.com:intellimaintain/intellimaintain.git",
|
|
58
|
+
"scripts": {
|
|
59
|
+
"test": "jest --config jest.config.json --env node",
|
|
60
|
+
"test:watch": "npm run test -- --watch"
|
|
61
|
+
}
|
|
6
62
|
}
|