@unigent/cli 0.1.1 → 0.1.3

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.
Files changed (76) hide show
  1. package/dist/register.js +9 -1
  2. package/dist/register.js.map +1 -1
  3. package/package.json +2 -11
  4. package/node_modules/@unigent/core/dist/adapter_process.d.ts +0 -25
  5. package/node_modules/@unigent/core/dist/adapter_process.d.ts.map +0 -1
  6. package/node_modules/@unigent/core/dist/adapter_process.js +0 -46
  7. package/node_modules/@unigent/core/dist/adapter_process.js.map +0 -1
  8. package/node_modules/@unigent/core/dist/args.d.ts +0 -17
  9. package/node_modules/@unigent/core/dist/args.d.ts.map +0 -1
  10. package/node_modules/@unigent/core/dist/args.js +0 -233
  11. package/node_modules/@unigent/core/dist/args.js.map +0 -1
  12. package/node_modules/@unigent/core/dist/backend.d.ts +0 -83
  13. package/node_modules/@unigent/core/dist/backend.d.ts.map +0 -1
  14. package/node_modules/@unigent/core/dist/backend.js +0 -2
  15. package/node_modules/@unigent/core/dist/backend.js.map +0 -1
  16. package/node_modules/@unigent/core/dist/checkpoint.d.ts +0 -26
  17. package/node_modules/@unigent/core/dist/checkpoint.d.ts.map +0 -1
  18. package/node_modules/@unigent/core/dist/checkpoint.js +0 -107
  19. package/node_modules/@unigent/core/dist/checkpoint.js.map +0 -1
  20. package/node_modules/@unigent/core/dist/checkpoint_fingerprint.d.ts +0 -4
  21. package/node_modules/@unigent/core/dist/checkpoint_fingerprint.d.ts.map +0 -1
  22. package/node_modules/@unigent/core/dist/checkpoint_fingerprint.js +0 -41
  23. package/node_modules/@unigent/core/dist/checkpoint_fingerprint.js.map +0 -1
  24. package/node_modules/@unigent/core/dist/completion.d.ts +0 -9
  25. package/node_modules/@unigent/core/dist/completion.d.ts.map +0 -1
  26. package/node_modules/@unigent/core/dist/completion.js +0 -4
  27. package/node_modules/@unigent/core/dist/completion.js.map +0 -1
  28. package/node_modules/@unigent/core/dist/errors.d.ts +0 -43
  29. package/node_modules/@unigent/core/dist/errors.d.ts.map +0 -1
  30. package/node_modules/@unigent/core/dist/errors.js +0 -48
  31. package/node_modules/@unigent/core/dist/errors.js.map +0 -1
  32. package/node_modules/@unigent/core/dist/events.d.ts +0 -101
  33. package/node_modules/@unigent/core/dist/events.d.ts.map +0 -1
  34. package/node_modules/@unigent/core/dist/events.js +0 -105
  35. package/node_modules/@unigent/core/dist/events.js.map +0 -1
  36. package/node_modules/@unigent/core/dist/index.d.ts +0 -19
  37. package/node_modules/@unigent/core/dist/index.d.ts.map +0 -1
  38. package/node_modules/@unigent/core/dist/index.js +0 -10
  39. package/node_modules/@unigent/core/dist/index.js.map +0 -1
  40. package/node_modules/@unigent/core/dist/json_schema_validator.d.ts +0 -8
  41. package/node_modules/@unigent/core/dist/json_schema_validator.d.ts.map +0 -1
  42. package/node_modules/@unigent/core/dist/json_schema_validator.js +0 -27
  43. package/node_modules/@unigent/core/dist/json_schema_validator.js.map +0 -1
  44. package/node_modules/@unigent/core/dist/mcp.d.ts +0 -12
  45. package/node_modules/@unigent/core/dist/mcp.d.ts.map +0 -1
  46. package/node_modules/@unigent/core/dist/mcp.js +0 -117
  47. package/node_modules/@unigent/core/dist/mcp.js.map +0 -1
  48. package/node_modules/@unigent/core/dist/runtime.d.ts +0 -109
  49. package/node_modules/@unigent/core/dist/runtime.d.ts.map +0 -1
  50. package/node_modules/@unigent/core/dist/runtime.js +0 -976
  51. package/node_modules/@unigent/core/dist/runtime.js.map +0 -1
  52. package/node_modules/@unigent/core/dist/schema.d.ts +0 -15
  53. package/node_modules/@unigent/core/dist/schema.d.ts.map +0 -1
  54. package/node_modules/@unigent/core/dist/schema.js +0 -71
  55. package/node_modules/@unigent/core/dist/schema.js.map +0 -1
  56. package/node_modules/@unigent/core/dist/source_tools.d.ts +0 -7
  57. package/node_modules/@unigent/core/dist/source_tools.d.ts.map +0 -1
  58. package/node_modules/@unigent/core/dist/source_tools.js +0 -450
  59. package/node_modules/@unigent/core/dist/source_tools.js.map +0 -1
  60. package/node_modules/@unigent/core/dist/tool.d.ts +0 -41
  61. package/node_modules/@unigent/core/dist/tool.d.ts.map +0 -1
  62. package/node_modules/@unigent/core/dist/tool.js +0 -43
  63. package/node_modules/@unigent/core/dist/tool.js.map +0 -1
  64. package/node_modules/@unigent/core/dist/tools.d.ts +0 -7
  65. package/node_modules/@unigent/core/dist/tools.d.ts.map +0 -1
  66. package/node_modules/@unigent/core/dist/tools.js +0 -3
  67. package/node_modules/@unigent/core/dist/tools.js.map +0 -1
  68. package/node_modules/@unigent/core/dist/trace.d.ts +0 -82
  69. package/node_modules/@unigent/core/dist/trace.d.ts.map +0 -1
  70. package/node_modules/@unigent/core/dist/trace.js +0 -235
  71. package/node_modules/@unigent/core/dist/trace.js.map +0 -1
  72. package/node_modules/@unigent/core/dist/usage.d.ts +0 -26
  73. package/node_modules/@unigent/core/dist/usage.d.ts.map +0 -1
  74. package/node_modules/@unigent/core/dist/usage.js +0 -47
  75. package/node_modules/@unigent/core/dist/usage.js.map +0 -1
  76. package/node_modules/@unigent/core/package.json +0 -68
@@ -1,117 +0,0 @@
1
- import { randomBytes, timingSafeEqual } from "node:crypto";
2
- import { createServer, } from "node:http";
3
- import { McpServer as ProtocolServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
- import { StreamableHTTPServerTransport, } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
5
- import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
6
- const METHOD_NOT_ALLOWED = 405;
7
- const MISDIRECTED_REQUEST = 421;
8
- const NOT_FOUND = 404;
9
- const UNAUTHORIZED = 401;
10
- const INTERNAL_SERVER_ERROR = 500;
11
- const TOKEN_BYTES = 32;
12
- function authorized(request, token) {
13
- const supplied = request.headers.authorization;
14
- const prefix = "Bearer ";
15
- if (supplied?.startsWith(prefix) !== true) {
16
- return false;
17
- }
18
- const candidate = Buffer.from(supplied.slice(prefix.length), "base64url");
19
- return candidate.length === token.length && timingSafeEqual(candidate, token);
20
- }
21
- function registerTools(server, tools) {
22
- const byName = new Map(tools.map((tool) => [tool.name, tool]));
23
- server.server.setRequestHandler(ListToolsRequestSchema, async () => await Promise.resolve({
24
- tools: tools.map((tool) => ({
25
- name: tool.name,
26
- description: tool.description,
27
- inputSchema: tool.parameters,
28
- })),
29
- }));
30
- server.server.setRequestHandler(CallToolRequestSchema, async (request) => {
31
- const tool = byName.get(request.params.name);
32
- if (tool === undefined) {
33
- return {
34
- content: [{ type: "text", text: `unknown tool: ${request.params.name}` }],
35
- isError: true,
36
- };
37
- }
38
- const result = await tool.execute(request.params.arguments ?? {});
39
- return {
40
- content: [{ type: "text", text: result.content }],
41
- isError: result.isError,
42
- };
43
- });
44
- }
45
- async function closeServer(server) {
46
- await new Promise((resolve) => {
47
- server.closeAllConnections();
48
- server.close(() => resolve());
49
- });
50
- }
51
- function sendError(response, status, message) {
52
- response.writeHead(status, { "Content-Type": "application/json" }).end(JSON.stringify({
53
- jsonrpc: "2.0",
54
- id: null,
55
- error: { code: -32_603, message },
56
- }));
57
- }
58
- async function handleRequest(request, response, tools, allowedHost) {
59
- const mcp = new ProtocolServer({ name: "unigent", version: "0.1.1" }, { capabilities: { tools: {} } });
60
- registerTools(mcp, tools);
61
- const options = {
62
- enableJsonResponse: true,
63
- enableDnsRebindingProtection: true,
64
- allowedHosts: [allowedHost],
65
- };
66
- const transport = new StreamableHTTPServerTransport(options);
67
- try {
68
- // The SDK's optional callback properties do not satisfy exactOptionalPropertyTypes.
69
- await mcp.connect(transport);
70
- await transport.handleRequest(request, response);
71
- }
72
- finally {
73
- await mcp.close();
74
- }
75
- }
76
- /** Start an isolated MCP server for a single backend turn. */
77
- async function startMcpToolServer(tools) {
78
- const token = randomBytes(TOKEN_BYTES);
79
- const authorizationHeader = `Bearer ${token.toString("base64url")}`;
80
- let allowedHost = "";
81
- const server = createServer((request, response) => {
82
- if (request.url !== "/mcp") {
83
- sendError(response, NOT_FOUND, "not found");
84
- return;
85
- }
86
- if (request.method !== "POST") {
87
- sendError(response, METHOD_NOT_ALLOWED, "method not allowed");
88
- return;
89
- }
90
- if (request.headers.host !== allowedHost) {
91
- sendError(response, MISDIRECTED_REQUEST, "invalid host");
92
- return;
93
- }
94
- if (!authorized(request, token)) {
95
- sendError(response, UNAUTHORIZED, "unauthorized");
96
- return;
97
- }
98
- handleRequest(request, response, tools, allowedHost).catch((error) => {
99
- if (response.headersSent) {
100
- response.end();
101
- }
102
- else {
103
- sendError(response, INTERNAL_SERVER_ERROR, String(error));
104
- }
105
- });
106
- });
107
- await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
108
- const address = server.address();
109
- allowedHost = `127.0.0.1:${address.port}`;
110
- return {
111
- url: `http://${allowedHost}/mcp`,
112
- authorizationHeader,
113
- close: async () => await closeServer(server),
114
- };
115
- }
116
- export { startMcpToolServer };
117
- //# sourceMappingURL=mcp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,YAAY,GAIb,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,SAAS,IAAI,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EACL,6BAA6B,GAE9B,MAAM,oDAAoD,CAAC;AAE5D,OAAO,EACL,qBAAqB,EAErB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAU5C,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB,SAAS,UAAU,CAAC,OAAwB,EAAE,KAAa;IACzD,MAAM,QAAQ,GAAG,OAA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,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;YAChC,SAAS,CAAC,QAAQ,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;YAClD,OAAO;QACT,CAAC;QACD,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YAC5E,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;gBACzB,QAAQ,CAAC,GAAG,EAAE,CAAC;YACjB,CAAC;iBAAM,CAAC;gBACN,SAAS,CAAC,QAAQ,EAAE,qBAAqB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC5D,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;IAC7E,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAiB,CAAC;IAChD,WAAW,GAAG,aAAa,OAAO,CAAC,IAAI,EAAE,CAAC;IAC1C,OAAO;QACL,GAAG,EAAE,UAAU,WAAW,MAAM;QAChC,mBAAmB;QACnB,KAAK,EAAE,KAAK,IAAmB,EAAE,CAAC,MAAM,WAAW,CAAC,MAAM,CAAC;KAC5D,CAAC;AACJ,CAAC;AAGD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -1,109 +0,0 @@
1
- import type { Backend } from "./backend.js";
2
- import type { CheckpointStore } from "./checkpoint.js";
3
- import type { Done } from "./completion.js";
4
- import { type AgentEvent, type AgentTrace } from "./events.js";
5
- import { type OutputSchema } from "./schema.js";
6
- import { type SourceToolFunction, type ToolDefinition } from "./tool.js";
7
- import type { FailTool } from "./tools.js";
8
- import { type AgentUsage } from "./usage.js";
9
- /** Wall-clock duration accepted by Unigent limits. */
10
- type Duration = `${number}s` | `${number}m` | `${number}h`;
11
- /** Scoped system-prompt contribution. */
12
- type SystemPrompt = {
13
- readonly append: string;
14
- } | {
15
- readonly replace: string;
16
- };
17
- /** Limits enforced by the generic runtime. */
18
- interface AgentLimits {
19
- /** Best-effort cumulative cap; concurrent turns can settle beyond it before accounting folds. */
20
- readonly budgetUsd?: number;
21
- /** Wall-clock cap applied independently to each backend turn. */
22
- readonly turnDuration?: Duration;
23
- readonly nestedAgentDepth?: number;
24
- }
25
- /** Tool values accepted by an agent. */
26
- type AgentTool = SourceToolFunction | ToolDefinition | FailTool;
27
- /** Initial agent definition. */
28
- interface AgentOptions {
29
- readonly name: string;
30
- readonly source?: string;
31
- readonly backend: Backend;
32
- readonly model: string;
33
- readonly thinking?: string;
34
- readonly systemPrompt?: SystemPrompt;
35
- readonly tools?: readonly AgentTool[];
36
- readonly retries?: number;
37
- readonly repairAttempts?: number;
38
- readonly limits?: AgentLimits;
39
- readonly checkpoint?: CheckpointStore;
40
- readonly checkpointKey?: string;
41
- }
42
- /** Immutable overrides applied through `with()` or `scope()`. */
43
- interface AgentOverrides {
44
- readonly backend?: Backend;
45
- readonly model?: string;
46
- readonly thinking?: string;
47
- readonly systemPrompt?: SystemPrompt;
48
- readonly retries?: number;
49
- readonly repairAttempts?: number;
50
- readonly limits?: AgentLimits;
51
- readonly checkpoint?: CheckpointStore | false;
52
- readonly checkpointKey?: string;
53
- }
54
- /** Workflow-boundary controls accepted only by `scope()`. */
55
- interface AgentScopeOptions extends AgentOverrides {
56
- readonly signal?: AbortSignal;
57
- readonly duration?: Duration;
58
- /** Maximum completed root traces retained by this explicit scope (default: 50). */
59
- readonly retainTraces?: number;
60
- }
61
- /** Final value and telemetry produced by an awaited run. */
62
- interface AgentRunResult<Output> {
63
- readonly output: Output;
64
- readonly usage: AgentUsage;
65
- readonly trace: AgentTrace;
66
- }
67
- /** Immediately-started, awaitable agent execution. */
68
- interface AgentRun<Output> extends PromiseLike<AgentRunResult<Output>> {
69
- readonly events: AsyncIterable<AgentEvent>;
70
- readonly usage: AgentUsage;
71
- readonly trace: AgentTrace;
72
- abort: (reason?: unknown) => void;
73
- }
74
- /** Stateful single-flight conversation. */
75
- interface AgentSession {
76
- run: {
77
- (prompt: string): AgentRun<string>;
78
- (prompt: string, completion: Done): AgentRun<void>;
79
- <Output>(prompt: string, schema: OutputSchema<Output>): AgentRun<Output>;
80
- };
81
- fork: () => AgentSession;
82
- readonly usage: AgentUsage;
83
- }
84
- /** Reusable immutable agent handle. */
85
- interface Agent {
86
- with: (overrides: AgentOverrides) => Agent;
87
- scope: (name: string, options?: AgentScopeOptions) => AgentScope;
88
- session: () => AgentSession;
89
- run: {
90
- (prompt: string): AgentRun<string>;
91
- (prompt: string, completion: Done): AgentRun<void>;
92
- <Output>(prompt: string, schema: OutputSchema<Output>): AgentRun<Output>;
93
- };
94
- }
95
- /** Long-lived aggregation scope; each child run owns one complete trace. */
96
- interface AgentScope extends Agent {
97
- readonly name: string;
98
- readonly path: readonly string[];
99
- readonly usage: AgentUsage;
100
- readonly traces: readonly AgentTrace[];
101
- abort: (reason?: unknown) => void;
102
- annotate: (attributes: Readonly<Record<string, unknown>>) => void;
103
- log: (message: string, level?: "info" | "warn" | "error") => void;
104
- }
105
- /** Create an immutable universal agent handle. */
106
- declare function agent(options: AgentOptions): Agent;
107
- export type { Agent, AgentLimits, AgentOptions, AgentOverrides, AgentRun, AgentRunResult, AgentScope, AgentScopeOptions, AgentSession, AgentTool, Duration, SystemPrompt, };
108
- export { agent };
109
- //# sourceMappingURL=runtime.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,OAAO,EAMR,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAoB,eAAe,EAAmB,MAAM,iBAAiB,CAAC;AAE1F,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAW5C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