agentinit 1.1.0 → 1.2.1
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/CHANGELOG.md +25 -0
- package/README.md +27 -0
- package/dist/agentinit-1.2.1.tgz +0 -0
- package/dist/index.js +125 -495
- package/package.json +3 -3
- package/dist/agentinit-1.1.0.tgz +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
## [1.2.1](https://github.com/agentinit/agentinit/compare/v1.2.0...v1.2.1) (2025-09-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* upd package ([06fa82f](https://github.com/agentinit/agentinit/commit/06fa82fb67e296e85330806084ecea12f6916f05))
|
|
7
|
+
|
|
8
|
+
# [1.2.0](https://github.com/agentinit/agentinit/compare/v1.1.0...v1.2.0) (2025-09-20)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* pckg lock ([ed4acbb](https://github.com/agentinit/agentinit/commit/ed4acbbc27c6342a109c81b91e6a23f264de1b9f))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* add --header flag support for HTTP MCP custom headers ([45a065f](https://github.com/agentinit/agentinit/commit/45a065f3b3876056acc76df4291db1808b94040a))
|
|
19
|
+
|
|
20
|
+
# [1.1.1](https://github.com/agentinit/agentinit/compare/v1.1.0...v1.1.1) (TBD)
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* add --header flag support for HTTP MCP custom headers ([COMMIT_HASH](https://github.com/agentinit/agentinit/commit/COMMIT_HASH))
|
|
25
|
+
|
|
1
26
|
# [1.1.0](https://github.com/agentinit/agentinit/compare/v1.0.1...v1.1.0) (2025-09-19)
|
|
2
27
|
|
|
3
28
|
|
package/README.md
CHANGED
|
@@ -142,11 +142,33 @@ npx agentinit apply \
|
|
|
142
142
|
npx agentinit apply \
|
|
143
143
|
--mcp-http github "https://api.githubcopilot.com/mcp/" --auth "Bearer YOUR_GITHUB_PAT"
|
|
144
144
|
|
|
145
|
+
# Configure HTTP MCP with custom headers
|
|
146
|
+
npx agentinit apply \
|
|
147
|
+
--mcp-http context7 "https://mcp.context7.com/mcp" \
|
|
148
|
+
--header "CONTEXT7_API_KEY:YOUR_API_KEY"
|
|
149
|
+
|
|
150
|
+
# Multiple custom headers
|
|
151
|
+
npx agentinit apply \
|
|
152
|
+
--mcp-http api_server "https://api.example.com/mcp" \
|
|
153
|
+
--header "X-API-Key:YOUR_API_KEY" \
|
|
154
|
+
--header "X-Client-ID:YOUR_CLIENT_ID"
|
|
155
|
+
|
|
156
|
+
# Combine Bearer auth with custom headers
|
|
157
|
+
npx agentinit apply \
|
|
158
|
+
--mcp-http advanced_api "https://api.example.com/mcp" \
|
|
159
|
+
--auth "Bearer YOUR_TOKEN" \
|
|
160
|
+
--header "X-Custom-Header:custom_value"
|
|
161
|
+
|
|
145
162
|
# Configure Docker-based MCP with environment
|
|
146
163
|
npx agentinit apply \
|
|
147
164
|
--mcp-stdio browserbase "docker run -i --rm ghcr.io/metorial/mcp-container--browserbase--mcp-server-browserbase--browserbase node cli.js" \
|
|
148
165
|
--env "BROWSERBASE_API_KEY=browserbase-api-key"
|
|
149
166
|
|
|
167
|
+
# Global configuration with custom headers
|
|
168
|
+
npx agentinit apply --global --client claude \
|
|
169
|
+
--mcp-http context7 "https://mcp.context7.com/mcp" \
|
|
170
|
+
--header "CONTEXT7_API_KEY:YOUR_API_KEY"
|
|
171
|
+
|
|
150
172
|
# Verify MCPs immediately after configuration
|
|
151
173
|
npx agentinit apply --verify-mcp \
|
|
152
174
|
--mcp-stdio everything "npx -y @modelcontextprotocol/server-everything"
|
|
@@ -154,6 +176,11 @@ npx agentinit apply --verify-mcp \
|
|
|
154
176
|
|
|
155
177
|
This generates `.agentinit/agentinit.toml` with your MCP configurations.
|
|
156
178
|
|
|
179
|
+
**MCP Authentication Options**:
|
|
180
|
+
- `--auth "Bearer TOKEN"` - Adds Authorization header for Bearer token authentication
|
|
181
|
+
- `--header "KEY:VALUE"` - Adds custom headers in KEY:VALUE format (can be used multiple times)
|
|
182
|
+
- Both flags can be combined for APIs requiring multiple authentication methods
|
|
183
|
+
|
|
157
184
|
**MCP Verification**: Use the `--verify-mcp` flag to test MCP servers immediately after configuration. This ensures servers are reachable and shows their available tools, resources, and prompts.
|
|
158
185
|
|
|
159
186
|
#### Rules Configuration
|
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -13753,402 +13753,6 @@ var require_toml = __commonJS((exports) => {
|
|
|
13753
13753
|
exports.stringify = require_stringify2();
|
|
13754
13754
|
});
|
|
13755
13755
|
|
|
13756
|
-
// node_modules/tiktoken/tiktoken_bg.cjs
|
|
13757
|
-
var require_tiktoken_bg = __commonJS((exports, module) => {
|
|
13758
|
-
var getUint8ArrayMemory0 = function() {
|
|
13759
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
13760
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
13761
|
-
}
|
|
13762
|
-
return cachedUint8ArrayMemory0;
|
|
13763
|
-
};
|
|
13764
|
-
var getStringFromWasm0 = function(ptr, len) {
|
|
13765
|
-
ptr = ptr >>> 0;
|
|
13766
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
13767
|
-
};
|
|
13768
|
-
var addHeapObject = function(obj) {
|
|
13769
|
-
if (heap_next === heap.length)
|
|
13770
|
-
heap.push(heap.length + 1);
|
|
13771
|
-
const idx = heap_next;
|
|
13772
|
-
heap_next = heap[idx];
|
|
13773
|
-
heap[idx] = obj;
|
|
13774
|
-
return idx;
|
|
13775
|
-
};
|
|
13776
|
-
var handleError = function(f, args) {
|
|
13777
|
-
try {
|
|
13778
|
-
return f.apply(this, args);
|
|
13779
|
-
} catch (e) {
|
|
13780
|
-
wasm.__wbindgen_export_0(addHeapObject(e));
|
|
13781
|
-
}
|
|
13782
|
-
};
|
|
13783
|
-
var getObject = function(idx) {
|
|
13784
|
-
return heap[idx];
|
|
13785
|
-
};
|
|
13786
|
-
var dropObject = function(idx) {
|
|
13787
|
-
if (idx < 132)
|
|
13788
|
-
return;
|
|
13789
|
-
heap[idx] = heap_next;
|
|
13790
|
-
heap_next = idx;
|
|
13791
|
-
};
|
|
13792
|
-
var takeObject = function(idx) {
|
|
13793
|
-
const ret = getObject(idx);
|
|
13794
|
-
dropObject(idx);
|
|
13795
|
-
return ret;
|
|
13796
|
-
};
|
|
13797
|
-
var passStringToWasm0 = function(arg, malloc, realloc) {
|
|
13798
|
-
if (realloc === undefined) {
|
|
13799
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
13800
|
-
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
13801
|
-
getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
13802
|
-
WASM_VECTOR_LEN = buf.length;
|
|
13803
|
-
return ptr2;
|
|
13804
|
-
}
|
|
13805
|
-
let len = arg.length;
|
|
13806
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
13807
|
-
const mem = getUint8ArrayMemory0();
|
|
13808
|
-
let offset = 0;
|
|
13809
|
-
for (;offset < len; offset++) {
|
|
13810
|
-
const code = arg.charCodeAt(offset);
|
|
13811
|
-
if (code > 127)
|
|
13812
|
-
break;
|
|
13813
|
-
mem[ptr + offset] = code;
|
|
13814
|
-
}
|
|
13815
|
-
if (offset !== len) {
|
|
13816
|
-
if (offset !== 0) {
|
|
13817
|
-
arg = arg.slice(offset);
|
|
13818
|
-
}
|
|
13819
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
13820
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
13821
|
-
const ret = encodeString(arg, view);
|
|
13822
|
-
offset += ret.written;
|
|
13823
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
13824
|
-
}
|
|
13825
|
-
WASM_VECTOR_LEN = offset;
|
|
13826
|
-
return ptr;
|
|
13827
|
-
};
|
|
13828
|
-
var isLikeNone = function(x) {
|
|
13829
|
-
return x === undefined || x === null;
|
|
13830
|
-
};
|
|
13831
|
-
var getDataViewMemory0 = function() {
|
|
13832
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
|
|
13833
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
13834
|
-
}
|
|
13835
|
-
return cachedDataViewMemory0;
|
|
13836
|
-
};
|
|
13837
|
-
var getUint32ArrayMemory0 = function() {
|
|
13838
|
-
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
13839
|
-
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
13840
|
-
}
|
|
13841
|
-
return cachedUint32ArrayMemory0;
|
|
13842
|
-
};
|
|
13843
|
-
var getArrayU32FromWasm0 = function(ptr, len) {
|
|
13844
|
-
ptr = ptr >>> 0;
|
|
13845
|
-
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
13846
|
-
};
|
|
13847
|
-
var passArray8ToWasm0 = function(arg, malloc) {
|
|
13848
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
13849
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
13850
|
-
WASM_VECTOR_LEN = arg.length;
|
|
13851
|
-
return ptr;
|
|
13852
|
-
};
|
|
13853
|
-
var passArray32ToWasm0 = function(arg, malloc) {
|
|
13854
|
-
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
13855
|
-
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
13856
|
-
WASM_VECTOR_LEN = arg.length;
|
|
13857
|
-
return ptr;
|
|
13858
|
-
};
|
|
13859
|
-
var getArrayU8FromWasm0 = function(ptr, len) {
|
|
13860
|
-
ptr = ptr >>> 0;
|
|
13861
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
13862
|
-
};
|
|
13863
|
-
var wasm;
|
|
13864
|
-
exports.__wbg_set_wasm = function(val) {
|
|
13865
|
-
wasm = val;
|
|
13866
|
-
};
|
|
13867
|
-
var lTextDecoder = typeof TextDecoder === "undefined" ? (0, module.require)("util").TextDecoder : TextDecoder;
|
|
13868
|
-
var cachedTextDecoder = new lTextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
13869
|
-
cachedTextDecoder.decode();
|
|
13870
|
-
var cachedUint8ArrayMemory0 = null;
|
|
13871
|
-
var heap = new Array(128).fill(undefined);
|
|
13872
|
-
heap.push(undefined, null, true, false);
|
|
13873
|
-
var heap_next = heap.length;
|
|
13874
|
-
var WASM_VECTOR_LEN = 0;
|
|
13875
|
-
var lTextEncoder = typeof TextEncoder === "undefined" ? (0, module.require)("util").TextEncoder : TextEncoder;
|
|
13876
|
-
var cachedTextEncoder = new lTextEncoder("utf-8");
|
|
13877
|
-
var encodeString = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) {
|
|
13878
|
-
return cachedTextEncoder.encodeInto(arg, view);
|
|
13879
|
-
} : function(arg, view) {
|
|
13880
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
13881
|
-
view.set(buf);
|
|
13882
|
-
return {
|
|
13883
|
-
read: arg.length,
|
|
13884
|
-
written: buf.length
|
|
13885
|
-
};
|
|
13886
|
-
};
|
|
13887
|
-
var cachedDataViewMemory0 = null;
|
|
13888
|
-
var cachedUint32ArrayMemory0 = null;
|
|
13889
|
-
exports.get_encoding = function(encoding, extend_special_tokens) {
|
|
13890
|
-
if (wasm == null)
|
|
13891
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
13892
|
-
try {
|
|
13893
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
13894
|
-
const ptr0 = passStringToWasm0(encoding, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
13895
|
-
const len0 = WASM_VECTOR_LEN;
|
|
13896
|
-
wasm.get_encoding(retptr, ptr0, len0, addHeapObject(extend_special_tokens));
|
|
13897
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
13898
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
13899
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
13900
|
-
if (r2) {
|
|
13901
|
-
throw takeObject(r1);
|
|
13902
|
-
}
|
|
13903
|
-
return Tiktoken.__wrap(r0);
|
|
13904
|
-
} finally {
|
|
13905
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
13906
|
-
}
|
|
13907
|
-
};
|
|
13908
|
-
exports.encoding_for_model = function(model, extend_special_tokens) {
|
|
13909
|
-
if (wasm == null)
|
|
13910
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
13911
|
-
try {
|
|
13912
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
13913
|
-
const ptr0 = passStringToWasm0(model, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
13914
|
-
const len0 = WASM_VECTOR_LEN;
|
|
13915
|
-
wasm.encoding_for_model(retptr, ptr0, len0, addHeapObject(extend_special_tokens));
|
|
13916
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
13917
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
13918
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
13919
|
-
if (r2) {
|
|
13920
|
-
throw takeObject(r1);
|
|
13921
|
-
}
|
|
13922
|
-
return Tiktoken.__wrap(r0);
|
|
13923
|
-
} finally {
|
|
13924
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
13925
|
-
}
|
|
13926
|
-
};
|
|
13927
|
-
exports.get_encoding_name_for_model = function(model) {
|
|
13928
|
-
if (wasm == null)
|
|
13929
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
13930
|
-
let deferred3_0;
|
|
13931
|
-
let deferred3_1;
|
|
13932
|
-
try {
|
|
13933
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
13934
|
-
const ptr0 = passStringToWasm0(model, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
13935
|
-
const len0 = WASM_VECTOR_LEN;
|
|
13936
|
-
wasm.get_encoding_name_for_model(retptr, ptr0, len0);
|
|
13937
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
13938
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
13939
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
13940
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
13941
|
-
var ptr2 = r0;
|
|
13942
|
-
var len2 = r1;
|
|
13943
|
-
if (r3) {
|
|
13944
|
-
ptr2 = 0;
|
|
13945
|
-
len2 = 0;
|
|
13946
|
-
throw takeObject(r2);
|
|
13947
|
-
}
|
|
13948
|
-
deferred3_0 = ptr2;
|
|
13949
|
-
deferred3_1 = len2;
|
|
13950
|
-
return getStringFromWasm0(ptr2, len2);
|
|
13951
|
-
} finally {
|
|
13952
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
13953
|
-
wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
|
|
13954
|
-
}
|
|
13955
|
-
};
|
|
13956
|
-
var TiktokenFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
13957
|
-
}, unregister: () => {
|
|
13958
|
-
} } : new FinalizationRegistry((ptr) => wasm.__wbg_tiktoken_free(ptr >>> 0, 1));
|
|
13959
|
-
|
|
13960
|
-
class Tiktoken {
|
|
13961
|
-
constructor(tiktoken_bfe, special_tokens, pat_str) {
|
|
13962
|
-
if (wasm == null)
|
|
13963
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
13964
|
-
const ptr0 = passStringToWasm0(tiktoken_bfe, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
13965
|
-
const len0 = WASM_VECTOR_LEN;
|
|
13966
|
-
const ptr1 = passStringToWasm0(pat_str, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
13967
|
-
const len1 = WASM_VECTOR_LEN;
|
|
13968
|
-
const ret = wasm.tiktoken_new(ptr0, len0, addHeapObject(special_tokens), ptr1, len1);
|
|
13969
|
-
this.__wbg_ptr = ret >>> 0;
|
|
13970
|
-
TiktokenFinalization.register(this, this.__wbg_ptr, this);
|
|
13971
|
-
return this;
|
|
13972
|
-
}
|
|
13973
|
-
get name() {
|
|
13974
|
-
try {
|
|
13975
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
13976
|
-
wasm.tiktoken_name(retptr, this.__wbg_ptr);
|
|
13977
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
13978
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
13979
|
-
let v1;
|
|
13980
|
-
if (r0 !== 0) {
|
|
13981
|
-
v1 = getStringFromWasm0(r0, r1).slice();
|
|
13982
|
-
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
13983
|
-
}
|
|
13984
|
-
return v1;
|
|
13985
|
-
} finally {
|
|
13986
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
13987
|
-
}
|
|
13988
|
-
}
|
|
13989
|
-
static __wrap(ptr) {
|
|
13990
|
-
ptr = ptr >>> 0;
|
|
13991
|
-
const obj = Object.create(Tiktoken.prototype);
|
|
13992
|
-
obj.__wbg_ptr = ptr;
|
|
13993
|
-
TiktokenFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
13994
|
-
return obj;
|
|
13995
|
-
}
|
|
13996
|
-
__destroy_into_raw() {
|
|
13997
|
-
const ptr = this.__wbg_ptr;
|
|
13998
|
-
this.__wbg_ptr = 0;
|
|
13999
|
-
TiktokenFinalization.unregister(this);
|
|
14000
|
-
return ptr;
|
|
14001
|
-
}
|
|
14002
|
-
free() {
|
|
14003
|
-
if (wasm == null)
|
|
14004
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
14005
|
-
const ptr = this.__destroy_into_raw();
|
|
14006
|
-
wasm.__wbg_tiktoken_free(ptr, 0);
|
|
14007
|
-
}
|
|
14008
|
-
encode(text, allowed_special, disallowed_special) {
|
|
14009
|
-
if (wasm == null)
|
|
14010
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
14011
|
-
try {
|
|
14012
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
14013
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
14014
|
-
const len0 = WASM_VECTOR_LEN;
|
|
14015
|
-
wasm.tiktoken_encode(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(allowed_special), addHeapObject(disallowed_special));
|
|
14016
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
14017
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
14018
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
14019
|
-
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
14020
|
-
if (r3) {
|
|
14021
|
-
throw takeObject(r2);
|
|
14022
|
-
}
|
|
14023
|
-
var v2 = getArrayU32FromWasm0(r0, r1).slice();
|
|
14024
|
-
wasm.__wbindgen_export_3(r0, r1 * 4, 4);
|
|
14025
|
-
return v2;
|
|
14026
|
-
} finally {
|
|
14027
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
14028
|
-
}
|
|
14029
|
-
}
|
|
14030
|
-
encode_ordinary(text) {
|
|
14031
|
-
if (wasm == null)
|
|
14032
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
14033
|
-
try {
|
|
14034
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
14035
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
14036
|
-
const len0 = WASM_VECTOR_LEN;
|
|
14037
|
-
wasm.tiktoken_encode_ordinary(retptr, this.__wbg_ptr, ptr0, len0);
|
|
14038
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
14039
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
14040
|
-
var v2 = getArrayU32FromWasm0(r0, r1).slice();
|
|
14041
|
-
wasm.__wbindgen_export_3(r0, r1 * 4, 4);
|
|
14042
|
-
return v2;
|
|
14043
|
-
} finally {
|
|
14044
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
14045
|
-
}
|
|
14046
|
-
}
|
|
14047
|
-
encode_with_unstable(text, allowed_special, disallowed_special) {
|
|
14048
|
-
if (wasm == null)
|
|
14049
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
14050
|
-
try {
|
|
14051
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
14052
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
14053
|
-
const len0 = WASM_VECTOR_LEN;
|
|
14054
|
-
wasm.tiktoken_encode_with_unstable(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(allowed_special), addHeapObject(disallowed_special));
|
|
14055
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
14056
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
14057
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
14058
|
-
if (r2) {
|
|
14059
|
-
throw takeObject(r1);
|
|
14060
|
-
}
|
|
14061
|
-
return takeObject(r0);
|
|
14062
|
-
} finally {
|
|
14063
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
14064
|
-
}
|
|
14065
|
-
}
|
|
14066
|
-
encode_single_token(bytes) {
|
|
14067
|
-
if (wasm == null)
|
|
14068
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
14069
|
-
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_1);
|
|
14070
|
-
const len0 = WASM_VECTOR_LEN;
|
|
14071
|
-
const ret = wasm.tiktoken_encode_single_token(this.__wbg_ptr, ptr0, len0);
|
|
14072
|
-
return ret >>> 0;
|
|
14073
|
-
}
|
|
14074
|
-
decode(tokens) {
|
|
14075
|
-
if (wasm == null)
|
|
14076
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
14077
|
-
try {
|
|
14078
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
14079
|
-
const ptr0 = passArray32ToWasm0(tokens, wasm.__wbindgen_export_1);
|
|
14080
|
-
const len0 = WASM_VECTOR_LEN;
|
|
14081
|
-
wasm.tiktoken_decode(retptr, this.__wbg_ptr, ptr0, len0);
|
|
14082
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
14083
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
14084
|
-
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
14085
|
-
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
14086
|
-
return v2;
|
|
14087
|
-
} finally {
|
|
14088
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
14089
|
-
}
|
|
14090
|
-
}
|
|
14091
|
-
decode_single_token_bytes(token) {
|
|
14092
|
-
if (wasm == null)
|
|
14093
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
14094
|
-
try {
|
|
14095
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
14096
|
-
wasm.tiktoken_decode_single_token_bytes(retptr, this.__wbg_ptr, token);
|
|
14097
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
14098
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
14099
|
-
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
14100
|
-
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
14101
|
-
return v1;
|
|
14102
|
-
} finally {
|
|
14103
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
14104
|
-
}
|
|
14105
|
-
}
|
|
14106
|
-
token_byte_values() {
|
|
14107
|
-
if (wasm == null)
|
|
14108
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
14109
|
-
const ret = wasm.tiktoken_token_byte_values(this.__wbg_ptr);
|
|
14110
|
-
return takeObject(ret);
|
|
14111
|
-
}
|
|
14112
|
-
}
|
|
14113
|
-
exports.Tiktoken = Tiktoken;
|
|
14114
|
-
exports.__wbg_parse_def2e24ef1252aff = function() {
|
|
14115
|
-
return handleError(function(arg0, arg1) {
|
|
14116
|
-
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
14117
|
-
return addHeapObject(ret);
|
|
14118
|
-
}, arguments);
|
|
14119
|
-
};
|
|
14120
|
-
exports.__wbg_stringify_f7ed6987935b4a24 = function() {
|
|
14121
|
-
return handleError(function(arg0) {
|
|
14122
|
-
const ret = JSON.stringify(getObject(arg0));
|
|
14123
|
-
return addHeapObject(ret);
|
|
14124
|
-
}, arguments);
|
|
14125
|
-
};
|
|
14126
|
-
exports.__wbindgen_error_new = function(arg0, arg1) {
|
|
14127
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
14128
|
-
return addHeapObject(ret);
|
|
14129
|
-
};
|
|
14130
|
-
exports.__wbindgen_is_undefined = function(arg0) {
|
|
14131
|
-
const ret = getObject(arg0) === undefined;
|
|
14132
|
-
return ret;
|
|
14133
|
-
};
|
|
14134
|
-
exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
14135
|
-
takeObject(arg0);
|
|
14136
|
-
};
|
|
14137
|
-
exports.__wbindgen_string_get = function(arg0, arg1) {
|
|
14138
|
-
if (wasm == null)
|
|
14139
|
-
throw new Error("tiktoken: WASM binary has not been propery initialized.");
|
|
14140
|
-
const obj = getObject(arg1);
|
|
14141
|
-
const ret = typeof obj === "string" ? obj : undefined;
|
|
14142
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
14143
|
-
var len1 = WASM_VECTOR_LEN;
|
|
14144
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
14145
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
14146
|
-
};
|
|
14147
|
-
exports.__wbindgen_throw = function(arg0, arg1) {
|
|
14148
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
14149
|
-
};
|
|
14150
|
-
});
|
|
14151
|
-
|
|
14152
13756
|
// node_modules/ajv/lib/refs/data.json
|
|
14153
13757
|
var require_data = __commonJS((exports, module) => {
|
|
14154
13758
|
module.exports = {
|
|
@@ -15150,8 +14754,8 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
15150
14754
|
wsComponents.secure = undefined;
|
|
15151
14755
|
}
|
|
15152
14756
|
if (wsComponents.resourceName) {
|
|
15153
|
-
var _wsComponents$resourc = wsComponents.resourceName.split("?"), _wsComponents$resourc2 = slicedToArray(_wsComponents$resourc, 2),
|
|
15154
|
-
wsComponents.path =
|
|
14757
|
+
var _wsComponents$resourc = wsComponents.resourceName.split("?"), _wsComponents$resourc2 = slicedToArray(_wsComponents$resourc, 2), path = _wsComponents$resourc2[0], query = _wsComponents$resourc2[1];
|
|
14758
|
+
wsComponents.path = path && path !== "/" ? path : undefined;
|
|
15155
14759
|
wsComponents.query = query;
|
|
15156
14760
|
wsComponents.resourceName = undefined;
|
|
15157
14761
|
}
|
|
@@ -15517,12 +15121,12 @@ var require_util3 = __commonJS((exports, module) => {
|
|
|
15517
15121
|
return "\'" + escapeQuotes(str2) + "\'";
|
|
15518
15122
|
};
|
|
15519
15123
|
var getPathExpr = function(currentPath, expr, jsonPointers, isNumber) {
|
|
15520
|
-
var
|
|
15521
|
-
return joinPaths(currentPath,
|
|
15124
|
+
var path = jsonPointers ? "\'/\' + " + expr + (isNumber ? "" : ".replace(/~/g, \'~0\').replace(/\\//g, \'~1\')") : isNumber ? "\'[\' + " + expr + " + \']\'" : "\'[\\\'\' + " + expr + " + \'\\\']\'";
|
|
15125
|
+
return joinPaths(currentPath, path);
|
|
15522
15126
|
};
|
|
15523
15127
|
var getPath = function(currentPath, prop, jsonPointers) {
|
|
15524
|
-
var
|
|
15525
|
-
return joinPaths(currentPath,
|
|
15128
|
+
var path = jsonPointers ? toQuotedString("/" + escapeJsonPointer(prop)) : toQuotedString(getProperty(prop));
|
|
15129
|
+
return joinPaths(currentPath, path);
|
|
15526
15130
|
};
|
|
15527
15131
|
var getData = function($data, lvl, paths2) {
|
|
15528
15132
|
var up, jsonPointer, data, matches;
|
|
@@ -20322,7 +19926,7 @@ var require_ajv = __commonJS((exports, module) => {
|
|
|
20322
19926
|
|
|
20323
19927
|
// node_modules/isexe/windows.js
|
|
20324
19928
|
var require_windows = __commonJS((exports, module) => {
|
|
20325
|
-
var checkPathExt = function(
|
|
19929
|
+
var checkPathExt = function(path, options2) {
|
|
20326
19930
|
var pathext = options2.pathExt !== undefined ? options2.pathExt : process.env.PATHEXT;
|
|
20327
19931
|
if (!pathext) {
|
|
20328
19932
|
return true;
|
|
@@ -20333,40 +19937,40 @@ var require_windows = __commonJS((exports, module) => {
|
|
|
20333
19937
|
}
|
|
20334
19938
|
for (var i = 0;i < pathext.length; i++) {
|
|
20335
19939
|
var p = pathext[i].toLowerCase();
|
|
20336
|
-
if (p &&
|
|
19940
|
+
if (p && path.substr(-p.length).toLowerCase() === p) {
|
|
20337
19941
|
return true;
|
|
20338
19942
|
}
|
|
20339
19943
|
}
|
|
20340
19944
|
return false;
|
|
20341
19945
|
};
|
|
20342
|
-
var checkStat = function(stat,
|
|
19946
|
+
var checkStat = function(stat, path, options2) {
|
|
20343
19947
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
20344
19948
|
return false;
|
|
20345
19949
|
}
|
|
20346
|
-
return checkPathExt(
|
|
19950
|
+
return checkPathExt(path, options2);
|
|
20347
19951
|
};
|
|
20348
|
-
var isexe = function(
|
|
20349
|
-
|
|
20350
|
-
cb(er, er ? false : checkStat(stat,
|
|
19952
|
+
var isexe = function(path, options2, cb) {
|
|
19953
|
+
fs14.stat(path, function(er, stat) {
|
|
19954
|
+
cb(er, er ? false : checkStat(stat, path, options2));
|
|
20351
19955
|
});
|
|
20352
19956
|
};
|
|
20353
|
-
var sync = function(
|
|
20354
|
-
return checkStat(
|
|
19957
|
+
var sync = function(path, options2) {
|
|
19958
|
+
return checkStat(fs14.statSync(path), path, options2);
|
|
20355
19959
|
};
|
|
20356
19960
|
module.exports = isexe;
|
|
20357
19961
|
isexe.sync = sync;
|
|
20358
|
-
var
|
|
19962
|
+
var fs14 = __require("fs");
|
|
20359
19963
|
});
|
|
20360
19964
|
|
|
20361
19965
|
// node_modules/isexe/mode.js
|
|
20362
19966
|
var require_mode = __commonJS((exports, module) => {
|
|
20363
|
-
var isexe = function(
|
|
20364
|
-
|
|
19967
|
+
var isexe = function(path, options2, cb) {
|
|
19968
|
+
fs14.stat(path, function(er, stat) {
|
|
20365
19969
|
cb(er, er ? false : checkStat(stat, options2));
|
|
20366
19970
|
});
|
|
20367
19971
|
};
|
|
20368
|
-
var sync = function(
|
|
20369
|
-
return checkStat(
|
|
19972
|
+
var sync = function(path, options2) {
|
|
19973
|
+
return checkStat(fs14.statSync(path), options2);
|
|
20370
19974
|
};
|
|
20371
19975
|
var checkStat = function(stat, options2) {
|
|
20372
19976
|
return stat.isFile() && checkMode(stat, options2);
|
|
@@ -20386,12 +19990,12 @@ var require_mode = __commonJS((exports, module) => {
|
|
|
20386
19990
|
};
|
|
20387
19991
|
module.exports = isexe;
|
|
20388
19992
|
isexe.sync = sync;
|
|
20389
|
-
var
|
|
19993
|
+
var fs14 = __require("fs");
|
|
20390
19994
|
});
|
|
20391
19995
|
|
|
20392
19996
|
// node_modules/isexe/index.js
|
|
20393
19997
|
var require_isexe = __commonJS((exports, module) => {
|
|
20394
|
-
var isexe = function(
|
|
19998
|
+
var isexe = function(path, options2, cb) {
|
|
20395
19999
|
if (typeof options2 === "function") {
|
|
20396
20000
|
cb = options2;
|
|
20397
20001
|
options2 = {};
|
|
@@ -20401,7 +20005,7 @@ var require_isexe = __commonJS((exports, module) => {
|
|
|
20401
20005
|
throw new TypeError("callback not provided");
|
|
20402
20006
|
}
|
|
20403
20007
|
return new Promise(function(resolve9, reject) {
|
|
20404
|
-
isexe(
|
|
20008
|
+
isexe(path, options2 || {}, function(er, is) {
|
|
20405
20009
|
if (er) {
|
|
20406
20010
|
reject(er);
|
|
20407
20011
|
} else {
|
|
@@ -20410,7 +20014,7 @@ var require_isexe = __commonJS((exports, module) => {
|
|
|
20410
20014
|
});
|
|
20411
20015
|
});
|
|
20412
20016
|
}
|
|
20413
|
-
core(
|
|
20017
|
+
core(path, options2 || {}, function(er, is) {
|
|
20414
20018
|
if (er) {
|
|
20415
20019
|
if (er.code === "EACCES" || options2 && options2.ignoreErrors) {
|
|
20416
20020
|
er = null;
|
|
@@ -20420,9 +20024,9 @@ var require_isexe = __commonJS((exports, module) => {
|
|
|
20420
20024
|
cb(er, is);
|
|
20421
20025
|
});
|
|
20422
20026
|
};
|
|
20423
|
-
var sync = function(
|
|
20027
|
+
var sync = function(path, options2) {
|
|
20424
20028
|
try {
|
|
20425
|
-
return core.sync(
|
|
20029
|
+
return core.sync(path, options2 || {});
|
|
20426
20030
|
} catch (er) {
|
|
20427
20031
|
if (options2 && options2.ignoreErrors || er.code === "EACCES") {
|
|
20428
20032
|
return false;
|
|
@@ -20431,7 +20035,7 @@ var require_isexe = __commonJS((exports, module) => {
|
|
|
20431
20035
|
}
|
|
20432
20036
|
}
|
|
20433
20037
|
};
|
|
20434
|
-
var
|
|
20038
|
+
var fs14 = __require("fs");
|
|
20435
20039
|
var core;
|
|
20436
20040
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
20437
20041
|
core = require_windows();
|
|
@@ -20445,7 +20049,7 @@ var require_isexe = __commonJS((exports, module) => {
|
|
|
20445
20049
|
// node_modules/which/which.js
|
|
20446
20050
|
var require_which = __commonJS((exports, module) => {
|
|
20447
20051
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
20448
|
-
var
|
|
20052
|
+
var path = __require("path");
|
|
20449
20053
|
var COLON = isWindows ? ";" : ":";
|
|
20450
20054
|
var isexe = require_isexe();
|
|
20451
20055
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -20481,7 +20085,7 @@ var require_which = __commonJS((exports, module) => {
|
|
|
20481
20085
|
return opt.all && found.length ? resolve9(found) : reject(getNotFoundError(cmd));
|
|
20482
20086
|
const ppRaw = pathEnv[i];
|
|
20483
20087
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
20484
|
-
const pCmd =
|
|
20088
|
+
const pCmd = path.join(pathPart, cmd);
|
|
20485
20089
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
20486
20090
|
resolve9(subStep(p, i, 0));
|
|
20487
20091
|
});
|
|
@@ -20508,7 +20112,7 @@ var require_which = __commonJS((exports, module) => {
|
|
|
20508
20112
|
for (let i = 0;i < pathEnv.length; i++) {
|
|
20509
20113
|
const ppRaw = pathEnv[i];
|
|
20510
20114
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
20511
|
-
const pCmd =
|
|
20115
|
+
const pCmd = path.join(pathPart, cmd);
|
|
20512
20116
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
20513
20117
|
for (let j = 0;j < pathExt.length; j++) {
|
|
20514
20118
|
const cur = p + pathExt[j];
|
|
@@ -20565,7 +20169,7 @@ var require_resolveCommand = __commonJS((exports, module) => {
|
|
|
20565
20169
|
try {
|
|
20566
20170
|
resolved = which.sync(parsed.command, {
|
|
20567
20171
|
path: env2[getPathKey({ env: env2 })],
|
|
20568
|
-
pathExt: withoutPathExt ?
|
|
20172
|
+
pathExt: withoutPathExt ? path.delimiter : undefined
|
|
20569
20173
|
});
|
|
20570
20174
|
} catch (e) {
|
|
20571
20175
|
} finally {
|
|
@@ -20574,14 +20178,14 @@ var require_resolveCommand = __commonJS((exports, module) => {
|
|
|
20574
20178
|
}
|
|
20575
20179
|
}
|
|
20576
20180
|
if (resolved) {
|
|
20577
|
-
resolved =
|
|
20181
|
+
resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
20578
20182
|
}
|
|
20579
20183
|
return resolved;
|
|
20580
20184
|
};
|
|
20581
20185
|
var resolveCommand = function(parsed) {
|
|
20582
20186
|
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
20583
20187
|
};
|
|
20584
|
-
var
|
|
20188
|
+
var path = __require("path");
|
|
20585
20189
|
var which = require_which();
|
|
20586
20190
|
var getPathKey = require_path_key();
|
|
20587
20191
|
module.exports = resolveCommand;
|
|
@@ -20622,8 +20226,8 @@ var require_shebang_command = __commonJS((exports, module) => {
|
|
|
20622
20226
|
if (!match) {
|
|
20623
20227
|
return null;
|
|
20624
20228
|
}
|
|
20625
|
-
const [
|
|
20626
|
-
const binary =
|
|
20229
|
+
const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
20230
|
+
const binary = path.split("/").pop();
|
|
20627
20231
|
if (binary === "env") {
|
|
20628
20232
|
return argument;
|
|
20629
20233
|
}
|
|
@@ -20638,14 +20242,14 @@ var require_readShebang = __commonJS((exports, module) => {
|
|
|
20638
20242
|
const buffer = Buffer.alloc(size);
|
|
20639
20243
|
let fd;
|
|
20640
20244
|
try {
|
|
20641
|
-
fd =
|
|
20642
|
-
|
|
20643
|
-
|
|
20245
|
+
fd = fs14.openSync(command, "r");
|
|
20246
|
+
fs14.readSync(fd, buffer, 0, size, 0);
|
|
20247
|
+
fs14.closeSync(fd);
|
|
20644
20248
|
} catch (e) {
|
|
20645
20249
|
}
|
|
20646
20250
|
return shebangCommand(buffer.toString());
|
|
20647
20251
|
};
|
|
20648
|
-
var
|
|
20252
|
+
var fs14 = __require("fs");
|
|
20649
20253
|
var shebangCommand = require_shebang_command();
|
|
20650
20254
|
module.exports = readShebang;
|
|
20651
20255
|
});
|
|
@@ -20670,7 +20274,7 @@ var require_parse3 = __commonJS((exports, module) => {
|
|
|
20670
20274
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
20671
20275
|
if (parsed.options.forceShell || needsShell) {
|
|
20672
20276
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
20673
|
-
parsed.command =
|
|
20277
|
+
parsed.command = path.normalize(parsed.command);
|
|
20674
20278
|
parsed.command = escape.command(parsed.command);
|
|
20675
20279
|
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
20676
20280
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -20699,7 +20303,7 @@ var require_parse3 = __commonJS((exports, module) => {
|
|
|
20699
20303
|
};
|
|
20700
20304
|
return options2.shell ? parsed : parseNonShell(parsed);
|
|
20701
20305
|
};
|
|
20702
|
-
var
|
|
20306
|
+
var path = __require("path");
|
|
20703
20307
|
var resolveCommand = require_resolveCommand();
|
|
20704
20308
|
var escape = require_escape();
|
|
20705
20309
|
var readShebang = require_readShebang();
|
|
@@ -23269,6 +22873,19 @@ class MCPParser {
|
|
|
23269
22873
|
}
|
|
23270
22874
|
}
|
|
23271
22875
|
i += 2;
|
|
22876
|
+
} else if (nextArg === "--header" && i + 1 < args.length) {
|
|
22877
|
+
const headerStr = args[i + 1];
|
|
22878
|
+
if (headerStr) {
|
|
22879
|
+
const colonIndex = headerStr.indexOf(":");
|
|
22880
|
+
if (colonIndex > 0 && colonIndex < headerStr.length - 1) {
|
|
22881
|
+
const key = headerStr.substring(0, colonIndex).trim();
|
|
22882
|
+
const value = headerStr.substring(colonIndex + 1).trim();
|
|
22883
|
+
if (key && value) {
|
|
22884
|
+
server.headers[key] = value;
|
|
22885
|
+
}
|
|
22886
|
+
}
|
|
22887
|
+
}
|
|
22888
|
+
i += 2;
|
|
23272
22889
|
} else if (nextArg.startsWith("--mcp-")) {
|
|
23273
22890
|
break;
|
|
23274
22891
|
} else {
|
|
@@ -23846,45 +23463,12 @@ function getFullGlobalConfigPath(globalConfigPath, globalConfigPaths) {
|
|
|
23846
23463
|
// src/core/rulesApplicator.ts
|
|
23847
23464
|
import {resolve as resolve7} from "path";
|
|
23848
23465
|
|
|
23849
|
-
// node_modules/tiktoken/tiktoken.cjs
|
|
23850
|
-
var __dirname = "/home/runner/work/agentinit/agentinit/node_modules/tiktoken";
|
|
23851
|
-
var wasm = require_tiktoken_bg();
|
|
23852
|
-
var imports = {};
|
|
23853
|
-
imports["./tiktoken_bg.js"] = wasm;
|
|
23854
|
-
var path = __require("path");
|
|
23855
|
-
var fs7 = __require("fs");
|
|
23856
|
-
var candidates = __dirname.split(path.sep).reduce((memo, _, index, array) => {
|
|
23857
|
-
const prefix = array.slice(0, index + 1).join(path.sep) + path.sep;
|
|
23858
|
-
if (!prefix.includes("node_modules" + path.sep)) {
|
|
23859
|
-
memo.unshift(path.join(prefix, "node_modules", "tiktoken", "", "./tiktoken_bg.wasm"));
|
|
23860
|
-
}
|
|
23861
|
-
return memo;
|
|
23862
|
-
}, []);
|
|
23863
|
-
candidates.unshift(path.join(__dirname, "./tiktoken_bg.wasm"));
|
|
23864
|
-
var bytes = null;
|
|
23865
|
-
for (const candidate of candidates) {
|
|
23866
|
-
try {
|
|
23867
|
-
bytes = fs7.readFileSync(candidate);
|
|
23868
|
-
break;
|
|
23869
|
-
} catch {
|
|
23870
|
-
}
|
|
23871
|
-
}
|
|
23872
|
-
if (bytes == null)
|
|
23873
|
-
throw new Error("Missing tiktoken_bg.wasm");
|
|
23874
|
-
var wasmModule = new WebAssembly.Module(bytes);
|
|
23875
|
-
var wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
23876
|
-
wasm.__wbg_set_wasm(wasmInstance.exports);
|
|
23877
|
-
var $get_encoding = wasm["get_encoding"];
|
|
23878
|
-
var $encoding_for_model = wasm["encoding_for_model"];
|
|
23879
|
-
var $get_encoding_name_for_model = wasm["get_encoding_name_for_model"];
|
|
23880
|
-
var $Tiktoken = wasm["Tiktoken"];
|
|
23881
|
-
|
|
23882
23466
|
// node_modules/contextcalc/dist/lib/index.js
|
|
23883
23467
|
async function isBinaryFile(filePath) {
|
|
23884
23468
|
try {
|
|
23885
|
-
const
|
|
23469
|
+
const fs7 = await import("node:fs/promises");
|
|
23886
23470
|
const buffer = Buffer.alloc(1024);
|
|
23887
|
-
const fd = await
|
|
23471
|
+
const fd = await fs7.open(filePath, "r");
|
|
23888
23472
|
try {
|
|
23889
23473
|
const { bytesRead } = await fd.read(buffer, 0, 1024, 0);
|
|
23890
23474
|
for (let i = 0;i < bytesRead; i++) {
|
|
@@ -23904,6 +23488,53 @@ async function isBinaryFile(filePath) {
|
|
|
23904
23488
|
var estimateBinaryTokens = function(sizeInBytes) {
|
|
23905
23489
|
return Math.ceil(sizeInBytes / 4);
|
|
23906
23490
|
};
|
|
23491
|
+
import {get_encoding} from "tiktoken";
|
|
23492
|
+
var initializeTiktoken = function() {
|
|
23493
|
+
if (tiktokenInstance) {
|
|
23494
|
+
return tiktokenInstance;
|
|
23495
|
+
}
|
|
23496
|
+
try {
|
|
23497
|
+
const encoding = get_encoding(ENCODING_NAME);
|
|
23498
|
+
try {
|
|
23499
|
+
encoding.encode("test");
|
|
23500
|
+
} catch (validationError) {
|
|
23501
|
+
throw new Error(`Tiktoken encoding validation failed: ${validationError instanceof Error ? validationError.message : "Unknown validation error"}`);
|
|
23502
|
+
}
|
|
23503
|
+
tiktokenInstance = {
|
|
23504
|
+
encoding,
|
|
23505
|
+
isInitialized: true
|
|
23506
|
+
};
|
|
23507
|
+
return tiktokenInstance;
|
|
23508
|
+
} catch (error) {
|
|
23509
|
+
const errorInstance = error instanceof Error ? error : new Error(String(error));
|
|
23510
|
+
if (errorInstance.message.includes("tiktoken_bg.wasm")) {
|
|
23511
|
+
const enhancedError = new Error(`Failed to load tiktoken WebAssembly module: ${errorInstance.message}
|
|
23512
|
+
|
|
23513
|
+
` + `This usually happens when using contextcalc as a dependency. Try:
|
|
23514
|
+
1. Ensure tiktoken is installed: npm install tiktoken
|
|
23515
|
+
2. If using in a bundled environment, ensure WASM files are copied
|
|
23516
|
+
3. Check that the tiktoken_bg.wasm file is accessible in your project
|
|
23517
|
+
|
|
23518
|
+
For more help, see: https://github.com/agentinit/contextcalc/issues`);
|
|
23519
|
+
enhancedError.cause = errorInstance;
|
|
23520
|
+
tiktokenInstance = {
|
|
23521
|
+
encoding: {},
|
|
23522
|
+
isInitialized: false,
|
|
23523
|
+
error: enhancedError
|
|
23524
|
+
};
|
|
23525
|
+
} else {
|
|
23526
|
+
tiktokenInstance = {
|
|
23527
|
+
encoding: {},
|
|
23528
|
+
isInitialized: false,
|
|
23529
|
+
error: new Error(`Failed to initialize tokenizer with encoding '${ENCODING_NAME}': ${errorInstance.message}`)
|
|
23530
|
+
};
|
|
23531
|
+
}
|
|
23532
|
+
return tiktokenInstance;
|
|
23533
|
+
}
|
|
23534
|
+
};
|
|
23535
|
+
var getTiktoken = function() {
|
|
23536
|
+
return initializeTiktoken();
|
|
23537
|
+
};
|
|
23907
23538
|
var getTokenizer = function() {
|
|
23908
23539
|
if (!tokenizerInstance) {
|
|
23909
23540
|
tokenizerInstance = new Tokenizer;
|
|
@@ -24035,6 +23666,7 @@ var DOCS_EXTENSIONS = new Set([
|
|
|
24035
23666
|
".md",
|
|
24036
23667
|
".markdown",
|
|
24037
23668
|
".mdx",
|
|
23669
|
+
".mdc",
|
|
24038
23670
|
".txt",
|
|
24039
23671
|
".text",
|
|
24040
23672
|
".rst",
|
|
@@ -24046,27 +23678,24 @@ var DOCS_EXTENSIONS = new Set([
|
|
|
24046
23678
|
".wiki"
|
|
24047
23679
|
]);
|
|
24048
23680
|
var ENCODING_NAME = "o200k_base";
|
|
23681
|
+
var tiktokenInstance = null;
|
|
24049
23682
|
|
|
24050
23683
|
class Tokenizer {
|
|
24051
|
-
|
|
23684
|
+
tiktokenWrapper;
|
|
24052
23685
|
constructor() {
|
|
24053
|
-
|
|
24054
|
-
this.encoding = $get_encoding(ENCODING_NAME);
|
|
24055
|
-
} catch (error) {
|
|
24056
|
-
throw new Error(`Failed to initialize tokenizer with encoding '${ENCODING_NAME}': ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
24057
|
-
}
|
|
23686
|
+
this.tiktokenWrapper = getTiktoken();
|
|
24058
23687
|
}
|
|
24059
23688
|
async countTokens(filePath) {
|
|
24060
23689
|
try {
|
|
24061
|
-
const
|
|
24062
|
-
const stats = await
|
|
23690
|
+
const fs7 = await import("node:fs/promises");
|
|
23691
|
+
const stats = await fs7.stat(filePath);
|
|
24063
23692
|
if (await isBinaryFile(filePath)) {
|
|
24064
23693
|
return {
|
|
24065
23694
|
tokens: estimateBinaryTokens(stats.size),
|
|
24066
23695
|
lines: 0
|
|
24067
23696
|
};
|
|
24068
23697
|
}
|
|
24069
|
-
const content = await
|
|
23698
|
+
const content = await fs7.readFile(filePath, "utf8");
|
|
24070
23699
|
const tokens = this.countTokensFromText(content);
|
|
24071
23700
|
const lines = this.countLines(content);
|
|
24072
23701
|
return { tokens, lines };
|
|
@@ -24075,12 +23704,14 @@ class Tokenizer {
|
|
|
24075
23704
|
}
|
|
24076
23705
|
}
|
|
24077
23706
|
countTokensFromText(text) {
|
|
23707
|
+
if (!this.tiktokenWrapper.isInitialized) {
|
|
23708
|
+
throw new Error("Tiktoken is not properly initialized. Cannot provide accurate token counts.");
|
|
23709
|
+
}
|
|
24078
23710
|
try {
|
|
24079
|
-
const tokens = this.encoding.encode(text);
|
|
23711
|
+
const tokens = this.tiktokenWrapper.encoding.encode(text);
|
|
24080
23712
|
return tokens.length;
|
|
24081
23713
|
} catch (error) {
|
|
24082
|
-
|
|
24083
|
-
return Math.ceil(text.length / 4);
|
|
23714
|
+
throw new Error(`Failed to encode text for token counting: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
24084
23715
|
}
|
|
24085
23716
|
}
|
|
24086
23717
|
countLines(text) {
|
|
@@ -24092,11 +23723,6 @@ class Tokenizer {
|
|
|
24092
23723
|
`) ? lines - 1 : lines;
|
|
24093
23724
|
}
|
|
24094
23725
|
dispose() {
|
|
24095
|
-
try {
|
|
24096
|
-
this.encoding.free();
|
|
24097
|
-
} catch (error) {
|
|
24098
|
-
console.warn("Warning: Failed to free tokenizer encoding:", error instanceof Error ? error.message : "Unknown error");
|
|
24099
|
-
}
|
|
24100
23726
|
}
|
|
24101
23727
|
formatTokenCount(count) {
|
|
24102
23728
|
const thresholds = [
|
|
@@ -26281,8 +25907,8 @@ function addIssueToContext(ctx, issueData) {
|
|
|
26281
25907
|
ctx.common.issues.push(issue);
|
|
26282
25908
|
}
|
|
26283
25909
|
var makeIssue = (params) => {
|
|
26284
|
-
const { data, path
|
|
26285
|
-
const fullPath = [...
|
|
25910
|
+
const { data, path, errorMaps, issueData } = params;
|
|
25911
|
+
const fullPath = [...path, ...issueData.path || []];
|
|
26286
25912
|
const fullIssue = {
|
|
26287
25913
|
...issueData,
|
|
26288
25914
|
path: fullPath
|
|
@@ -26571,11 +26197,11 @@ function custom(check, _params = {}, fatal) {
|
|
|
26571
26197
|
}
|
|
26572
26198
|
|
|
26573
26199
|
class ParseInputLazyPath {
|
|
26574
|
-
constructor(parent, value,
|
|
26200
|
+
constructor(parent, value, path, key) {
|
|
26575
26201
|
this._cachedPath = [];
|
|
26576
26202
|
this.parent = parent;
|
|
26577
26203
|
this.data = value;
|
|
26578
|
-
this._path =
|
|
26204
|
+
this._path = path;
|
|
26579
26205
|
this._key = key;
|
|
26580
26206
|
}
|
|
26581
26207
|
get path() {
|
|
@@ -32980,6 +32606,10 @@ async function applyCommand(args) {
|
|
|
32980
32606
|
logger.info(" agentinit apply --client claude \\");
|
|
32981
32607
|
logger.info(' --mcp-http github "https://api.githubcopilot.com/mcp/" --auth "Bearer YOUR_GITHUB_PAT"');
|
|
32982
32608
|
logger.info("");
|
|
32609
|
+
logger.info(" # HTTP MCP with custom headers");
|
|
32610
|
+
logger.info(" agentinit apply --global --client claude \\");
|
|
32611
|
+
logger.info(' --mcp-http context7 "https://mcp.context7.com/mcp" --header "CONTEXT7_API_KEY:your_api_key"');
|
|
32612
|
+
logger.info("");
|
|
32983
32613
|
logger.info(" # Multiple MCPs with auto-detection");
|
|
32984
32614
|
logger.info(" agentinit apply \\");
|
|
32985
32615
|
logger.info(' --mcp-stdio supabase "npx -y @supabase/mcp-server-supabase@latest" \\');
|
|
@@ -33003,11 +32633,11 @@ async function applyCommand(args) {
|
|
|
33003
32633
|
const mcpArgs = args.filter((arg, index) => {
|
|
33004
32634
|
if (arg === "--client" || arg === "--agent" || arg === "--global" || arg === "--verify-mcp")
|
|
33005
32635
|
return false;
|
|
33006
|
-
if (arg === "--rules" || arg === "--rule-raw" || arg === "--rules-file" || arg === "--rules-remote"
|
|
32636
|
+
if (arg === "--rules" || arg === "--rule-raw" || arg === "--rules-file" || arg === "--rules-remote")
|
|
33007
32637
|
return false;
|
|
33008
32638
|
if (index > 0 && (args[index - 1] === "--client" || args[index - 1] === "--agent"))
|
|
33009
32639
|
return false;
|
|
33010
|
-
if (index > 0 && (args[index - 1] === "--rules" || args[index - 1] === "--rule-raw" || args[index - 1] === "--rules-file" || args[index - 1] === "--rules-remote"
|
|
32640
|
+
if (index > 0 && (args[index - 1] === "--rules" || args[index - 1] === "--rule-raw" || args[index - 1] === "--rules-file" || args[index - 1] === "--rules-remote"))
|
|
33011
32641
|
return false;
|
|
33012
32642
|
return true;
|
|
33013
32643
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentinit",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "A CLI tool for managing and configuring AI coding agents",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"agentinit": "dist/index.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "bun build src/index.ts --outdir dist --target node && cp -r src/templates dist/",
|
|
11
|
+
"build": "bun build src/index.ts --outdir dist --target node --external tiktoken && cp -r src/templates dist/",
|
|
12
12
|
"dev": "bun run src/index.ts",
|
|
13
13
|
"test": "vitest run",
|
|
14
14
|
"test:watch": "vitest",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@iarna/toml": "^2.2.5",
|
|
41
41
|
"@modelcontextprotocol/sdk": "^1.18.0",
|
|
42
42
|
"commander": "^12.1.0",
|
|
43
|
-
"contextcalc": "^1.3.
|
|
43
|
+
"contextcalc": "^1.3.5",
|
|
44
44
|
"gray-matter": "^4.0.3",
|
|
45
45
|
"js-yaml": "^4.1.0",
|
|
46
46
|
"kleur": "^4.1.5",
|
package/dist/agentinit-1.1.0.tgz
DELETED
|
Binary file
|