@codeworksh/aikit 0.4.0 → 0.4.1-dev.20260530133305
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/LICENSE +21 -0
- package/README.md +109 -137
- package/cli.d.mts +1 -0
- package/cli.mjs +308 -0
- package/cli.mjs.map +1 -0
- package/codex-DfYk740t.mjs +521 -0
- package/codex-DfYk740t.mjs.map +1 -0
- package/index.d.mts +7197 -0
- package/index.mjs +1478 -0
- package/index.mjs.map +1 -0
- package/oauth/openai/codex.d.mts +107 -0
- package/oauth/openai/codex.mjs +2 -0
- package/package.json +28 -33
- package/{dist/pack/index.mjs → registry-CYfzJ6lk.mjs} +210 -3300
- package/registry-CYfzJ6lk.mjs.map +1 -0
- package/dist/pack/agent/codemode/drivers/drivers.d.mts +0 -7
- package/dist/pack/agent/codemode/drivers/drivers.mjs +0 -122
- package/dist/pack/agent/codemode/drivers/drivers.mjs.map +0 -1
- package/dist/pack/codemode-BEDXG7WN.d.mts +0 -8736
- package/dist/pack/index.d.mts +0 -71
- package/dist/pack/index.mjs.map +0 -1
- package/src/agent/agent.ts +0 -790
- package/src/agent/codemode/codemode.ts +0 -561
- package/src/agent/codemode/drivers/drivers.ts +0 -1
- package/src/agent/codemode/drivers/quickjs-wasi-driver.ts +0 -149
- package/src/agent/codemode/index.ts +0 -1
- package/src/agent/loop.ts +0 -903
- package/src/agent.ts +0 -11
- package/src/event/event.ts +0 -277
- package/src/index.ts +0 -6
- package/src/llm.ts +0 -31
- package/src/message/message.ts +0 -311
- package/src/model/catalog.ts +0 -94
- package/src/model/model.ts +0 -250
- package/src/model/transform.ts +0 -59
- package/src/provider/provider.ts +0 -60
- package/src/provider/providers/anthropic/index.ts +0 -792
- package/src/provider/providers/github/github.ts +0 -34
- package/src/provider/providers/openai/completions.ts +0 -953
- package/src/provider/providers/utils.ts +0 -7
- package/src/provider/register.ts +0 -6
- package/src/provider/stream.ts +0 -278
- package/src/stream.ts +0 -72
- package/src/utils/eventstream.ts +0 -95
- package/src/utils/helpers.ts +0 -24
- package/src/utils/jsonparse.ts +0 -32
- package/src/utils/overflow.ts +0 -121
- package/src/utils/sanitize.ts +0 -25
- package/src/utils/validation.ts +0 -87
package/src/utils/validation.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description Validation powered by TypeBox's built-in schema compiler.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { Static, TSchema } from "typebox";
|
|
6
|
-
import Schema from "typebox/schema";
|
|
7
|
-
import Value from "typebox/value";
|
|
8
|
-
|
|
9
|
-
import type { Agent } from "../agent/agent";
|
|
10
|
-
import type { Message } from "../message/message";
|
|
11
|
-
|
|
12
|
-
const validators = new WeakMap<TSchema, ReturnType<typeof Schema.Compile>>();
|
|
13
|
-
|
|
14
|
-
function getValidator<T extends TSchema>(schema: T): ReturnType<typeof Schema.Compile<T>> {
|
|
15
|
-
const existing = validators.get(schema) as ReturnType<typeof Schema.Compile<T>> | undefined;
|
|
16
|
-
if (existing) return existing;
|
|
17
|
-
|
|
18
|
-
const validator = Schema.Compile(schema);
|
|
19
|
-
validators.set(schema, validator);
|
|
20
|
-
return validator;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function errorPath(error: { instancePath?: string; params?: Record<string, unknown> }): string {
|
|
24
|
-
if (error.instancePath) return error.instancePath.substring(1);
|
|
25
|
-
|
|
26
|
-
const requiredProperties = error.params?.requiredProperties;
|
|
27
|
-
if (Array.isArray(requiredProperties)) return requiredProperties.join(", ");
|
|
28
|
-
|
|
29
|
-
return "root";
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Validates an arbitrary value against a TypeBox schema and returns the coerced value.
|
|
34
|
-
*/
|
|
35
|
-
export function validateSchema<T extends TSchema>(schema: T, value: unknown, label: string): Static<T> {
|
|
36
|
-
const validator = getValidator(schema);
|
|
37
|
-
const input = Value.Convert(schema, structuredClone(value));
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
return validator.Parse(input);
|
|
41
|
-
} catch {
|
|
42
|
-
const [_result, validationErrors] = validator.Errors(input);
|
|
43
|
-
const errors =
|
|
44
|
-
validationErrors
|
|
45
|
-
.map((err) => {
|
|
46
|
-
return ` - ${errorPath(err)}: ${err.message}`;
|
|
47
|
-
})
|
|
48
|
-
.join("\n") || "Unknown Validation Error";
|
|
49
|
-
|
|
50
|
-
throw new Error(
|
|
51
|
-
[
|
|
52
|
-
`Validation Failed For ${label}`,
|
|
53
|
-
`${errors}\n`,
|
|
54
|
-
"Received Value:",
|
|
55
|
-
`${JSON.stringify(value, null, 2)}\n`,
|
|
56
|
-
].join("\n"),
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Finds a tool by name and validates the tool call arguments against its TypeBox schema
|
|
63
|
-
*/
|
|
64
|
-
export function validateToolCall<T extends Message.Tool>(
|
|
65
|
-
tools: T[],
|
|
66
|
-
toolExecution: Agent.ToolCallInFlight,
|
|
67
|
-
): Message.ToolArguments<T> {
|
|
68
|
-
const tool = tools.find((t) => t.name === toolExecution.name);
|
|
69
|
-
if (!tool) {
|
|
70
|
-
throw new Error(`Tool "${toolExecution.name}" not found`);
|
|
71
|
-
}
|
|
72
|
-
return validateToolArguments(tool, toolExecution);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Validates tool call arguments against the tool's TypeBox schema
|
|
77
|
-
*/
|
|
78
|
-
export function validateToolArguments<T extends Message.Tool>(
|
|
79
|
-
tool: T,
|
|
80
|
-
toolExecution: Agent.ToolCallInFlight,
|
|
81
|
-
): Message.ToolArguments<T> {
|
|
82
|
-
return validateSchema(
|
|
83
|
-
tool.parameters,
|
|
84
|
-
toolExecution.rawArgs,
|
|
85
|
-
`Tool "${toolExecution.name}"`,
|
|
86
|
-
) as Message.ToolArguments<T>;
|
|
87
|
-
}
|