@plico-ai/sdk 0.0.0-reserved.0 → 0.1.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/NOTICE +4 -0
- package/README.md +32 -3
- package/dist/index.d.ts +22 -0
- package/dist/index.js +15 -0
- package/dist/infer.d.ts +55 -0
- package/dist/infer.js +1 -0
- package/package.json +32 -8
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
# @plico-ai/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Typed helpers for writing a Plico project. Both return their argument unchanged; they exist so your editor can check the file.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
```ts
|
|
6
|
+
// plico.config.ts
|
|
7
|
+
import { defineConfig } from "@plico-ai/sdk";
|
|
8
|
+
|
|
9
|
+
export default defineConfig({ schemaVersion: 1, name: "Support Agent", template: "internal-ops" });
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
// tools/create-ticket.tool.ts
|
|
14
|
+
import { defineTool } from "@plico-ai/sdk";
|
|
15
|
+
|
|
16
|
+
export default defineTool({
|
|
17
|
+
name: "create_ticket",
|
|
18
|
+
description: "Create a support ticket.",
|
|
19
|
+
inputSchema: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: { title: { type: "string" } },
|
|
22
|
+
required: ["title"],
|
|
23
|
+
},
|
|
24
|
+
capabilities: ["ticket:write"],
|
|
25
|
+
approval: { required: false },
|
|
26
|
+
handler: async (input) => ({ created: input.title }), // input: { title: string }
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`defineTool` infers the handler `input` from `inputSchema`:
|
|
31
|
+
|
|
32
|
+
- A JSON Schema is read for `type`, `enum`, `const`, `properties`, `required` and `items`. Any other keyword makes that part `unknown`; it never becomes a type error.
|
|
33
|
+
- A Zod schema (3 or 4) gives its parsed output type. Add `zod` to your project to use one.
|
|
34
|
+
|
|
35
|
+
You do not need to install `@plico-ai/sdk` in the project. `plico validate` and `plico run` resolve it from the project when it is there, and fall back to the copy that comes with the CLI. Install it when you want editor types.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ProjectConfig, ProviderInput, ToolApprovalPolicy, ToolDefinition, ToolHandlerContext } from "@plico-ai/contracts";
|
|
2
|
+
import type { InferToolInput, SchemaInput } from "./infer.js";
|
|
3
|
+
export type { ProjectConfig, ProviderInput, ToolApprovalPolicy, ToolArtifactContext, ToolDefinition, ToolHandlerContext, } from "@plico-ai/contracts";
|
|
4
|
+
export type { InferToolInput } from "./infer.js";
|
|
5
|
+
/** A tool as written in `tools/*.tool.ts`, with the handler input typed from `inputSchema`. */
|
|
6
|
+
export interface ToolSpec<Schema extends SchemaInput> {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
inputSchema: Schema;
|
|
10
|
+
capabilities: string[];
|
|
11
|
+
approval: ToolApprovalPolicy;
|
|
12
|
+
handler: (input: InferToolInput<Schema>, context: ToolHandlerContext) => unknown;
|
|
13
|
+
}
|
|
14
|
+
/** Declare a tool. Returns the object unchanged; the types infer `input` from `inputSchema`. */
|
|
15
|
+
export declare function defineTool<const Schema extends SchemaInput>(tool: ToolSpec<Schema>): ToolDefinition;
|
|
16
|
+
/** Declare `plico.config.ts`. Returns the object unchanged; the types check it. */
|
|
17
|
+
export declare function defineConfig(config: ProjectConfig): ProjectConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Declare `providers/<name>.ts`: a function that returns any AI SDK language model. Returns the
|
|
20
|
+
* function unchanged. Plico wraps the model behind its own model port.
|
|
21
|
+
*/
|
|
22
|
+
export declare function defineProvider(provider: (input: ProviderInput) => unknown): (input: ProviderInput) => unknown;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Declare a tool. Returns the object unchanged; the types infer `input` from `inputSchema`. */
|
|
2
|
+
export function defineTool(tool) {
|
|
3
|
+
return tool;
|
|
4
|
+
}
|
|
5
|
+
/** Declare `plico.config.ts`. Returns the object unchanged; the types check it. */
|
|
6
|
+
export function defineConfig(config) {
|
|
7
|
+
return config;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Declare `providers/<name>.ts`: a function that returns any AI SDK language model. Returns the
|
|
11
|
+
* function unchanged. Plico wraps the model behind its own model port.
|
|
12
|
+
*/
|
|
13
|
+
export function defineProvider(provider) {
|
|
14
|
+
return provider;
|
|
15
|
+
}
|
package/dist/infer.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ZodInputSchema } from "@plico-ai/contracts";
|
|
2
|
+
/** JSON Schema as written in a tool file: `const` inference makes its arrays readonly. */
|
|
3
|
+
export type ReadonlyJson = string | number | boolean | null | readonly ReadonlyJson[] | {
|
|
4
|
+
readonly [keyword: string]: ReadonlyJson | undefined;
|
|
5
|
+
};
|
|
6
|
+
export type SchemaInput = boolean | ZodInputSchema | {
|
|
7
|
+
readonly [keyword: string]: ReadonlyJson | undefined;
|
|
8
|
+
};
|
|
9
|
+
type Simplify<T> = {
|
|
10
|
+
[K in keyof T]: T[K];
|
|
11
|
+
} & {};
|
|
12
|
+
type RequiredKeys<S> = S extends {
|
|
13
|
+
required: readonly (infer R)[];
|
|
14
|
+
} ? R & string : never;
|
|
15
|
+
type InferObject<S> = S extends {
|
|
16
|
+
properties: infer P;
|
|
17
|
+
} ? Simplify<{
|
|
18
|
+
[K in keyof P & RequiredKeys<S>]: InferJsonSchema<P[K]>;
|
|
19
|
+
} & {
|
|
20
|
+
[K in Exclude<keyof P, RequiredKeys<S>>]?: InferJsonSchema<P[K]>;
|
|
21
|
+
}> : Record<string, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* The TypeScript type of a JSON Schema value, for the keywords tools use most: `type`, `enum`,
|
|
24
|
+
* `const`, `properties`, `required` and `items`. Anything else is `unknown`, never an error.
|
|
25
|
+
*/
|
|
26
|
+
export type InferJsonSchema<S> = S extends {
|
|
27
|
+
const: infer C;
|
|
28
|
+
} ? C : S extends {
|
|
29
|
+
enum: readonly (infer E)[];
|
|
30
|
+
} ? E : S extends {
|
|
31
|
+
type: "string";
|
|
32
|
+
} ? string : S extends {
|
|
33
|
+
type: "number" | "integer";
|
|
34
|
+
} ? number : S extends {
|
|
35
|
+
type: "boolean";
|
|
36
|
+
} ? boolean : S extends {
|
|
37
|
+
type: "null";
|
|
38
|
+
} ? null : S extends {
|
|
39
|
+
type: "array";
|
|
40
|
+
items: infer Item;
|
|
41
|
+
} ? InferJsonSchema<Item>[] : S extends {
|
|
42
|
+
type: "array";
|
|
43
|
+
} ? unknown[] : S extends {
|
|
44
|
+
type: "object";
|
|
45
|
+
} ? InferObject<S> : unknown;
|
|
46
|
+
type InferZod<S> = S extends {
|
|
47
|
+
safeParseAsync(input: unknown): Promise<infer Result>;
|
|
48
|
+
} ? Extract<Result, {
|
|
49
|
+
success: true;
|
|
50
|
+
}> extends {
|
|
51
|
+
data: infer Data;
|
|
52
|
+
} ? Data : unknown : unknown;
|
|
53
|
+
/** The input a tool handler receives, from either a Zod schema or a JSON Schema. */
|
|
54
|
+
export type InferToolInput<S> = S extends ZodInputSchema ? InferZod<S> : InferJsonSchema<S>;
|
|
55
|
+
export {};
|
package/dist/infer.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,21 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plico-ai/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Typed helpers for writing Plico projects: defineConfig and defineTool",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://plico.sohab.dev",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/ITZSHOAIB/plico.git"
|
|
9
|
+
"url": "git+https://github.com/ITZSHOAIB/plico.git",
|
|
10
|
+
"directory": "packages/sdk"
|
|
10
11
|
},
|
|
11
12
|
"keywords": [
|
|
12
13
|
"plico",
|
|
13
|
-
"agent"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"README.md"
|
|
14
|
+
"agent",
|
|
15
|
+
"typescript",
|
|
16
|
+
"authoring"
|
|
17
17
|
],
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"type": "module",
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"NOTICE",
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@plico-ai/contracts": "0.1.0"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=22.18.0"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
42
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
|
|
43
|
+
"test": "vitest run"
|
|
20
44
|
}
|
|
21
|
-
}
|
|
45
|
+
}
|