@jsm-mit/sultana-agent-tools-package 0.2.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/README.md +133 -0
- package/dist/create-salon-tools.d.ts +37 -0
- package/dist/create-salon-tools.d.ts.map +1 -0
- package/dist/create-salon-tools.js +30 -0
- package/dist/errors.d.ts +11 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +39 -0
- package/dist/ic-salon-core-port.d.ts +57 -0
- package/dist/ic-salon-core-port.d.ts.map +1 -0
- package/dist/ic-salon-core-port.js +160 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/persona.d.ts +18 -0
- package/dist/persona.d.ts.map +1 -0
- package/dist/persona.js +49 -0
- package/dist/salon-core-port.d.ts +144 -0
- package/dist/salon-core-port.d.ts.map +1 -0
- package/dist/salon-core-port.js +11 -0
- package/dist/tools/args.d.ts +30 -0
- package/dist/tools/args.d.ts.map +1 -0
- package/dist/tools/args.js +89 -0
- package/dist/tools/promos.d.ts +7 -0
- package/dist/tools/promos.d.ts.map +1 -0
- package/dist/tools/promos.js +438 -0
- package/dist/tools/schedule.d.ts +4 -0
- package/dist/tools/schedule.d.ts.map +1 -0
- package/dist/tools/schedule.js +300 -0
- package/dist/tools/services.d.ts +7 -0
- package/dist/tools/services.d.ts.map +1 -0
- package/dist/tools/services.js +309 -0
- package/dist/types.d.ts +63 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +14 -0
- package/package.json +48 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tool contract. Deliberately framework-agnostic: the shape matches what OpenAI, Anthropic
|
|
3
|
+
* and `@jsm-mit/chat-agent-package` all want from a function tool, so wiring this package into an
|
|
4
|
+
* agent host is registration, not translation.
|
|
5
|
+
*/
|
|
6
|
+
/** A JSON Schema object describing a tool's arguments. Kept loose on purpose — the schema travels
|
|
7
|
+
* to a model provider verbatim and every provider accepts a slightly different dialect. */
|
|
8
|
+
export interface ToolParametersSchema {
|
|
9
|
+
type: "object";
|
|
10
|
+
properties: Record<string, unknown>;
|
|
11
|
+
required?: string[];
|
|
12
|
+
additionalProperties?: boolean;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
export type ToolErrorCode =
|
|
16
|
+
/** The model sent arguments the tool rejected before any canister call. */
|
|
17
|
+
"invalid_arguments"
|
|
18
|
+
/** The named entity is not in this salon. */
|
|
19
|
+
| "not_found"
|
|
20
|
+
/** The canister refused the caller — wrong identity, or a revoked agent grant. */
|
|
21
|
+
| "not_authorized"
|
|
22
|
+
/** The daily action quota is spent, or the call was refused at the inspection stage. */
|
|
23
|
+
| "quota_exceeded"
|
|
24
|
+
/** The canister returned a business error. */
|
|
25
|
+
| "canister_error"
|
|
26
|
+
/** Transport failure — no reply from the replica. */
|
|
27
|
+
| "unavailable";
|
|
28
|
+
/**
|
|
29
|
+
* Every tool returns one of these. **`execute` never throws**: an agent has to be able to read the
|
|
30
|
+
* failure and ask about it, and a thrown error in a tool-calling loop is either swallowed by the
|
|
31
|
+
* host or ends the conversation.
|
|
32
|
+
*/
|
|
33
|
+
export type ToolResult = {
|
|
34
|
+
status: "ok";
|
|
35
|
+
summary: string;
|
|
36
|
+
data?: unknown;
|
|
37
|
+
}
|
|
38
|
+
/** The tool made NO canister call. `summary` describes what would happen, built from resolved
|
|
39
|
+
* arguments (worker names and service-type labels already looked up), and `echo` carries the
|
|
40
|
+
* exact arguments to send back with `confirmed: true`. */
|
|
41
|
+
| {
|
|
42
|
+
status: "confirmation_required";
|
|
43
|
+
summary: string;
|
|
44
|
+
echo: Record<string, unknown>;
|
|
45
|
+
} | {
|
|
46
|
+
status: "error";
|
|
47
|
+
summary: string;
|
|
48
|
+
code: ToolErrorCode;
|
|
49
|
+
};
|
|
50
|
+
export interface AgentTool {
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly description: string;
|
|
53
|
+
readonly parameters: ToolParametersSchema;
|
|
54
|
+
/** A short Polish line a chat shows while the tool runs — present continuous, ending with "…"
|
|
55
|
+
* ("Sprawdzam listę usług…"). Never sent to the model. A write tool called with
|
|
56
|
+
* `confirmed: false` shows the same line: the preview is still work the owner waits for. */
|
|
57
|
+
readonly progress: string;
|
|
58
|
+
execute(args: Record<string, unknown>): Promise<ToolResult>;
|
|
59
|
+
}
|
|
60
|
+
export declare function ok(summary: string, data?: unknown): ToolResult;
|
|
61
|
+
export declare function err(code: ToolErrorCode, summary: string): ToolResult;
|
|
62
|
+
export declare function needsConfirmation(summary: string, echo: Record<string, unknown>): ToolResult;
|
|
63
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;2FAC2F;AAC3F,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAI/B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,MAAM,MAAM,aAAa;AACrB,2EAA2E;AACzE,mBAAmB;AACrB,6CAA6C;GAC3C,WAAW;AACb,kFAAkF;GAChF,gBAAgB;AAClB,wFAAwF;GACtF,gBAAgB;AAClB,8CAA8C;GAC5C,gBAAgB;AAClB,qDAAqD;GACnD,aAAa,CAAC;AAEpB;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAChB;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE;AACnD;;0DAE0D;GACxD;IAAE,MAAM,EAAE,uBAAuB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACnF;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAEhE,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,oBAAoB,CAAC;IAC1C;;gGAE4F;IAC5F,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC/D;AAED,wBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,CAE9D;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,CAEpE;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,CAE5F"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tool contract. Deliberately framework-agnostic: the shape matches what OpenAI, Anthropic
|
|
3
|
+
* and `@jsm-mit/chat-agent-package` all want from a function tool, so wiring this package into an
|
|
4
|
+
* agent host is registration, not translation.
|
|
5
|
+
*/
|
|
6
|
+
export function ok(summary, data) {
|
|
7
|
+
return data === undefined ? { status: "ok", summary } : { status: "ok", summary, data };
|
|
8
|
+
}
|
|
9
|
+
export function err(code, summary) {
|
|
10
|
+
return { status: "error", code, summary };
|
|
11
|
+
}
|
|
12
|
+
export function needsConfirmation(summary, echo) {
|
|
13
|
+
return { status: "confirmation_required", summary, echo };
|
|
14
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jsm-mit/sultana-agent-tools-package",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Agent tool layer for a Sultana salon: framework-agnostic tools (services, promos, schedule) over the Sultana core canister wrapper, plus a read-only set that needs no identity.",
|
|
5
|
+
"homepage": "https://github.com/JSM-Sultana/sultana-agent-tools-package#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/JSM-Sultana/sultana-agent-tools-package/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/JSM-Sultana/sultana-agent-tools-package.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"author": "",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "dist/index.js",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist/"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc && tsc -p tsconfig.tests.json",
|
|
29
|
+
"clean": "rm -rf dist",
|
|
30
|
+
"test": "node --import tsx --test \"tests/**/*.test.ts\"",
|
|
31
|
+
"sandbox": "npx tsx --env-file-if-exists=.env sandbox/main.ts",
|
|
32
|
+
"prepare": "npm run build",
|
|
33
|
+
"test-tools": "npx tsx --env-file-if-exists=.env --test tests/integration/test-salon-tools.ts",
|
|
34
|
+
"whoami": "npx tsx --env-file-if-exists=.env sandbox/whoami.ts",
|
|
35
|
+
"publish-public": "bash scripts/publish-public.sh"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@icp-sdk/core": "^6.1.0",
|
|
39
|
+
"@jsm-mit/sultana-core-motoko-package": "^0.16.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@jsm-mit/utils-package": "^0.5.0",
|
|
43
|
+
"@types/node": "^25.5.2",
|
|
44
|
+
"openai": "^4.104.0",
|
|
45
|
+
"tsx": "^4.18.0",
|
|
46
|
+
"typescript": "^5.9.3"
|
|
47
|
+
}
|
|
48
|
+
}
|