toolcraft 0.0.117 → 0.0.119
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/composition.json +2 -17
- package/dist/composition.json +2 -17
- package/node_modules/@poe-code/agent-defs/package.json +0 -2
- package/node_modules/@poe-code/agent-human-in-loop/package.json +0 -2
- package/node_modules/@poe-code/agent-mcp-config/package.json +0 -2
- package/node_modules/@poe-code/config-mutations/package.json +0 -2
- package/node_modules/@poe-code/frontmatter/package.json +0 -2
- package/node_modules/@poe-code/process-runner/package.json +0 -2
- package/node_modules/@poe-code/task-list/package.json +0 -2
- package/node_modules/auth-store/package.json +0 -2
- package/node_modules/tiny-mcp-client/package.json +0 -2
- package/node_modules/tiny-stdio-mcp-server/dist/composition.json +1 -1
- package/node_modules/tiny-stdio-mcp-server/dist/server.js +9 -21
- package/node_modules/tiny-stdio-mcp-server/dist/uri-template.d.ts +6 -0
- package/node_modules/tiny-stdio-mcp-server/dist/uri-template.js +363 -0
- package/node_modules/toolcraft-design/package.json +0 -2
- package/node_modules/toolcraft-schema/package.json +3 -2
- package/package.json +5 -9
- package/node_modules/pct-encode/.travis.yml +0 -7
- package/node_modules/pct-encode/AUTHORS +0 -2
- package/node_modules/pct-encode/LICENSE +0 -11
- package/node_modules/pct-encode/README.md +0 -20
- package/node_modules/pct-encode/index.js +0 -23
- package/node_modules/pct-encode/package.json +0 -23
- package/node_modules/pct-encode/test.js +0 -10
- package/node_modules/uri-template/AUTHORS +0 -2
- package/node_modules/uri-template/LICENSE +0 -19
- package/node_modules/uri-template/README.md +0 -34
- package/node_modules/uri-template/dist/ast.d.ts +0 -28
- package/node_modules/uri-template/dist/ast.js +0 -27
- package/node_modules/uri-template/dist/expander.d.ts +0 -3
- package/node_modules/uri-template/dist/expander.js +0 -165
- package/node_modules/uri-template/dist/grammar.d.ts +0 -13
- package/node_modules/uri-template/dist/grammar.js +0 -749
- package/node_modules/uri-template/dist/index.d.ts +0 -19
- package/node_modules/uri-template/dist/index.js +0 -43
- package/node_modules/uri-template/lib/ast.ts +0 -59
- package/node_modules/uri-template/lib/expander.ts +0 -175
- package/node_modules/uri-template/lib/grammar.js +0 -773
- package/node_modules/uri-template/lib/grammar.pegjs +0 -33
- package/node_modules/uri-template/lib/index.ts +0 -33
- package/node_modules/uri-template/package.json +0 -33
- package/node_modules/uri-template-lite/README.md +0 -86
- package/node_modules/uri-template-lite/index.js +0 -140
- package/node_modules/uri-template-lite/package.json +0 -43
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as AST from "./ast";
|
|
2
|
-
export declare type RuleToNode = {
|
|
3
|
-
template: AST.Template;
|
|
4
|
-
literal: AST.Literal;
|
|
5
|
-
expression: AST.Expression;
|
|
6
|
-
operator: AST.Operator;
|
|
7
|
-
variables: AST.Variable[];
|
|
8
|
-
variable: AST.Variable;
|
|
9
|
-
listMarker: AST.ExplodeModifier;
|
|
10
|
-
substr: AST.SubstrModifier;
|
|
11
|
-
extension: string;
|
|
12
|
-
};
|
|
13
|
-
export declare function parse(input: string): {
|
|
14
|
-
ast: AST.Template;
|
|
15
|
-
expand: (values: Record<string, unknown>) => string;
|
|
16
|
-
toString: () => string;
|
|
17
|
-
};
|
|
18
|
-
export declare function parseRule<StartRule extends keyof RuleToNode>(input: string, startRule?: StartRule): RuleToNode[StartRule];
|
|
19
|
-
export * from "./expander";
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
22
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
23
|
-
};
|
|
24
|
-
exports.__esModule = true;
|
|
25
|
-
exports.parseRule = exports.parse = void 0;
|
|
26
|
-
var grammar = __importStar(require("./grammar.js"));
|
|
27
|
-
var AST = __importStar(require("./ast"));
|
|
28
|
-
var expander_1 = require("./expander");
|
|
29
|
-
function parse(input) {
|
|
30
|
-
var ast = parseRule(input, "template");
|
|
31
|
-
return {
|
|
32
|
-
ast: ast,
|
|
33
|
-
expand: function (values) { return (0, expander_1.expandTemplate)(ast, values); },
|
|
34
|
-
toString: function () { return AST.toString(ast); }
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
exports.parse = parse;
|
|
38
|
-
function parseRule(input, startRule) {
|
|
39
|
-
if (startRule === void 0) { startRule = "template"; }
|
|
40
|
-
return grammar.parse(input, { startRule: startRule });
|
|
41
|
-
}
|
|
42
|
-
exports.parseRule = parseRule;
|
|
43
|
-
__exportStar(require("./expander"), exports);
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { abort } from "process";
|
|
2
|
-
|
|
3
|
-
export interface Template {
|
|
4
|
-
type: "template";
|
|
5
|
-
parts: (Literal | Expression)[];
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface Literal {
|
|
9
|
-
type: "literal";
|
|
10
|
-
value: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface Expression {
|
|
14
|
-
type: "expression";
|
|
15
|
-
operator: Operator;
|
|
16
|
-
variables: Variable[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type Operator = "/" | ";" | "." | "?" | "&" | "+" | "#" | "";
|
|
20
|
-
|
|
21
|
-
export interface Variable {
|
|
22
|
-
type: "variable";
|
|
23
|
-
name: string;
|
|
24
|
-
modifier?: SubstrModifier | ExplodeModifier;
|
|
25
|
-
extension?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface ExplodeModifier {
|
|
29
|
-
type: "explode";
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface SubstrModifier {
|
|
33
|
-
type: "substr";
|
|
34
|
-
length: number;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function toString(
|
|
38
|
-
node: Template | Literal | Expression | Variable
|
|
39
|
-
): string {
|
|
40
|
-
switch (node.type) {
|
|
41
|
-
case "template":
|
|
42
|
-
return node.parts.map(toString).join("");
|
|
43
|
-
case "literal":
|
|
44
|
-
return node.value;
|
|
45
|
-
case "expression":
|
|
46
|
-
return `{${node.operator}${node.variables.map(toString).join(",")}}`;
|
|
47
|
-
case "variable":
|
|
48
|
-
let out = node.name;
|
|
49
|
-
if (node.modifier?.type == "explode") {
|
|
50
|
-
out += "*";
|
|
51
|
-
} else if (node.modifier?.type == "substr") {
|
|
52
|
-
out += `:${node.modifier.length}`;
|
|
53
|
-
}
|
|
54
|
-
if (node.extension) {
|
|
55
|
-
out += `(${node.extension})`;
|
|
56
|
-
}
|
|
57
|
-
return out;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { Template, Expression, Operator, Variable } from "./ast";
|
|
2
|
-
|
|
3
|
-
import pctEncode from "pct-encode";
|
|
4
|
-
import { abort } from "process";
|
|
5
|
-
|
|
6
|
-
const encoders = {
|
|
7
|
-
UrlSafe: pctEncode(/[^\w~.-]/g),
|
|
8
|
-
Restricted: pctEncode(/[^\w.~:\/\?#\[\]@!\$&'()*+,;=%-]|%(?!\d\d)/g),
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export function expandTemplate(
|
|
12
|
-
ast: Template,
|
|
13
|
-
values: Record<string, unknown>
|
|
14
|
-
): string {
|
|
15
|
-
const strings = ast.parts.map((part) => {
|
|
16
|
-
switch (part.type) {
|
|
17
|
-
case "literal":
|
|
18
|
-
return part.value;
|
|
19
|
-
case "expression":
|
|
20
|
-
return expandExpression(part, values);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
return strings.join("");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface ExpansionConfig {
|
|
27
|
-
first: string;
|
|
28
|
-
sep: string;
|
|
29
|
-
empty: string;
|
|
30
|
-
named: boolean;
|
|
31
|
-
encode: (s: string) => string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const defaults: ExpansionConfig = {
|
|
35
|
-
first: "",
|
|
36
|
-
sep: ",",
|
|
37
|
-
empty: "",
|
|
38
|
-
encode: encoders.UrlSafe,
|
|
39
|
-
named: false,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const OperatorConfigs: { [op in Operator]: ExpansionConfig } = {
|
|
43
|
-
"": { ...defaults },
|
|
44
|
-
"+": { ...defaults, encode: encoders.Restricted },
|
|
45
|
-
"#": { ...defaults, encode: encoders.Restricted, first: "#", empty: "#" },
|
|
46
|
-
"/": { ...defaults, first: "/", sep: "/" },
|
|
47
|
-
".": { ...defaults, first: ".", sep: ".", empty: "." },
|
|
48
|
-
";": { ...defaults, first: ";", sep: ";", named: true },
|
|
49
|
-
"?": { ...defaults, first: "?", sep: "&", empty: "=", named: true },
|
|
50
|
-
"&": { ...defaults, first: "&", sep: "&", empty: "=", named: true },
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export function expandExpression(
|
|
54
|
-
expression: Expression,
|
|
55
|
-
values: Record<string, unknown>
|
|
56
|
-
): string {
|
|
57
|
-
const config = OperatorConfigs[expression.operator];
|
|
58
|
-
|
|
59
|
-
const strings: string[] = [];
|
|
60
|
-
expression.variables.forEach((variable) => {
|
|
61
|
-
const value = values[variable.name];
|
|
62
|
-
if (!present(value)) return;
|
|
63
|
-
const string = expandVariable(variable, value, config);
|
|
64
|
-
strings.push(string || "");
|
|
65
|
-
});
|
|
66
|
-
if (strings.length === 0) {
|
|
67
|
-
return "";
|
|
68
|
-
}
|
|
69
|
-
const expanded = strings.join(config.sep);
|
|
70
|
-
if (expanded.length === 0) {
|
|
71
|
-
return config.empty;
|
|
72
|
-
}
|
|
73
|
-
return config.first + expanded;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function expandVariable(
|
|
77
|
-
variable: Variable,
|
|
78
|
-
value: unknown,
|
|
79
|
-
config: ExpansionConfig
|
|
80
|
-
): string | undefined {
|
|
81
|
-
if (value == null) {
|
|
82
|
-
throw new TypeError(
|
|
83
|
-
`tried to expand null value for variable ${variable.name}, this is a bug in uri-template`
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
if (variable.modifier?.type === "explode") {
|
|
87
|
-
return expandValueExplode(variable, value, config);
|
|
88
|
-
} else {
|
|
89
|
-
return expandValueSingle(variable, value, config);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function expandValueSingle(
|
|
94
|
-
variable: Variable,
|
|
95
|
-
value: unknown,
|
|
96
|
-
{ empty, encode, named }: ExpansionConfig
|
|
97
|
-
): string {
|
|
98
|
-
if (typeof value === "object" && variable.modifier?.type === "substr") {
|
|
99
|
-
throw new Error(
|
|
100
|
-
"Prefixed variables do not support lists/maps. Check " + variable.name
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
let out;
|
|
104
|
-
if (Array.isArray(value)) {
|
|
105
|
-
out = value.map(encode).join(",");
|
|
106
|
-
} else if (typeof value === "object") {
|
|
107
|
-
out = Object.entries(value as object)
|
|
108
|
-
.map((entry) => entry.map(encode).join(","))
|
|
109
|
-
.join(",");
|
|
110
|
-
} else {
|
|
111
|
-
out = (value as string).toString();
|
|
112
|
-
if (variable.modifier?.type === "substr") {
|
|
113
|
-
out = out.substring(0, variable.modifier.length);
|
|
114
|
-
}
|
|
115
|
-
out = encode(out);
|
|
116
|
-
}
|
|
117
|
-
if (named) {
|
|
118
|
-
if (out) {
|
|
119
|
-
out = `${variable.name}=${out}`;
|
|
120
|
-
} else {
|
|
121
|
-
out = `${variable.name}${empty}`;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return out;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function expandValueExplode(
|
|
128
|
-
variable: Variable,
|
|
129
|
-
value: unknown,
|
|
130
|
-
{ encode, named, sep }: ExpansionConfig
|
|
131
|
-
): string {
|
|
132
|
-
if (Array.isArray(value)) {
|
|
133
|
-
let items = value.map(encode);
|
|
134
|
-
if (named) {
|
|
135
|
-
items = items.map((item) => `${variable.name}=${item}`);
|
|
136
|
-
}
|
|
137
|
-
return items.join(sep);
|
|
138
|
-
} else if (typeof value === "object") {
|
|
139
|
-
const pairs: string[] = [];
|
|
140
|
-
Object.entries(value as object).forEach(([k, v]) => {
|
|
141
|
-
k = encode(k);
|
|
142
|
-
if (Array.isArray(v)) {
|
|
143
|
-
v.forEach((item) => {
|
|
144
|
-
pairs.push(`${k}=${encode(item)}`);
|
|
145
|
-
});
|
|
146
|
-
} else {
|
|
147
|
-
pairs.push(`${k}=${encode(v)}`);
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
return pairs.join(sep);
|
|
151
|
-
} else {
|
|
152
|
-
const s = (value as string).toString();
|
|
153
|
-
return encode(s);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function present(v: unknown): boolean {
|
|
158
|
-
switch (typeof v) {
|
|
159
|
-
case "undefined":
|
|
160
|
-
return false;
|
|
161
|
-
case "object":
|
|
162
|
-
if (v == null) {
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
if (Array.isArray(v)) {
|
|
166
|
-
return v.length > 0;
|
|
167
|
-
}
|
|
168
|
-
for (const k in v) {
|
|
169
|
-
if ((v as Record<string, unknown>)[k] != null) return true;
|
|
170
|
-
}
|
|
171
|
-
return false;
|
|
172
|
-
default:
|
|
173
|
-
return true;
|
|
174
|
-
}
|
|
175
|
-
}
|