@botiverse/oar 0.3.0 → 0.4.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/README.md +31 -2
- package/dist/contracts/inventory.d.ts +65 -0
- package/dist/contracts/inventory.d.ts.map +1 -0
- package/dist/contracts/inventory.js +2 -0
- package/dist/contracts/inventory.js.map +1 -0
- package/dist/contracts/runtime.d.ts +3 -2
- package/dist/contracts/runtime.d.ts.map +1 -1
- package/dist/contracts/runtime.js +9 -1
- package/dist/contracts/runtime.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/runtimes/claude/account-usage.d.ts +5 -26
- package/dist/runtimes/claude/account-usage.d.ts.map +1 -1
- package/dist/runtimes/claude/account-usage.js +122 -178
- package/dist/runtimes/claude/account-usage.js.map +1 -1
- package/dist/runtimes/claude/index.d.ts +4 -1
- package/dist/runtimes/claude/index.d.ts.map +1 -1
- package/dist/runtimes/claude/index.js +4 -0
- package/dist/runtimes/claude/index.js.map +1 -1
- package/dist/runtimes/claude/inventory.d.ts +9 -0
- package/dist/runtimes/claude/inventory.d.ts.map +1 -0
- package/dist/runtimes/claude/inventory.js +120 -0
- package/dist/runtimes/claude/inventory.js.map +1 -0
- package/dist/runtimes/codex/app-server-client.d.ts +1 -1
- package/dist/runtimes/codex/app-server-client.d.ts.map +1 -1
- package/dist/runtimes/codex/app-server-client.js +2 -2
- package/dist/runtimes/codex/app-server-client.js.map +1 -1
- package/dist/runtimes/codex/index.d.ts +4 -1
- package/dist/runtimes/codex/index.d.ts.map +1 -1
- package/dist/runtimes/codex/index.js +4 -0
- package/dist/runtimes/codex/index.js.map +1 -1
- package/dist/runtimes/codex/inventory.d.ts +11 -0
- package/dist/runtimes/codex/inventory.d.ts.map +1 -0
- package/dist/runtimes/codex/inventory.js +88 -0
- package/dist/runtimes/codex/inventory.js.map +1 -0
- package/dist/runtimes/grok/index.d.ts +3 -1
- package/dist/runtimes/grok/index.d.ts.map +1 -1
- package/dist/runtimes/grok/index.js +3 -0
- package/dist/runtimes/grok/index.js.map +1 -1
- package/dist/runtimes/grok/inventory.d.ts +7 -0
- package/dist/runtimes/grok/inventory.d.ts.map +1 -0
- package/dist/runtimes/grok/inventory.js +47 -0
- package/dist/runtimes/grok/inventory.js.map +1 -0
- package/dist/runtimes/kimi/index.d.ts +1 -1
- package/dist/runtimes/kimi/index.d.ts.map +1 -1
- package/dist/runtimes/pi/index.d.ts +3 -1
- package/dist/runtimes/pi/index.d.ts.map +1 -1
- package/dist/runtimes/pi/index.js +3 -0
- package/dist/runtimes/pi/index.js.map +1 -1
- package/dist/runtimes/pi/inventory.d.ts +4 -0
- package/dist/runtimes/pi/inventory.d.ts.map +1 -0
- package/dist/runtimes/pi/inventory.js +51 -0
- package/dist/runtimes/pi/inventory.js.map +1 -0
- package/dist/shared/inventory.d.ts +22 -0
- package/dist/shared/inventory.d.ts.map +1 -0
- package/dist/shared/inventory.js +59 -0
- package/dist/shared/inventory.js.map +1 -0
- package/package.json +1 -1
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const piRuntime: {
|
|
7
7
|
readonly id: "pi";
|
|
8
|
+
readonly skills: import("../../index.js").InventoryReader<import("../../index.js").SkillEntry>;
|
|
9
|
+
readonly tools: import("../../index.js").InventoryReader<import("../../index.js").ToolEntry>;
|
|
8
10
|
readonly installation: import("../../index.js").InstallationProbe;
|
|
9
11
|
readonly listModels: import("../../index.js").ModelLister;
|
|
10
12
|
readonly session: import("../../index.js").StartSession;
|
|
11
|
-
};
|
|
13
|
+
} & import("../../index.js").RuntimeInventories;
|
|
12
14
|
export { piListModels, projectPiModels } from "./list-models.js";
|
|
13
15
|
export { piSession } from "./session.js";
|
|
14
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtimes/pi/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtimes/pi/index.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,eAAO,MAAM,SAAS;;;;;;;+CAOpB,CAAC;AAEH,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { piSkills, piTools } from "./inventory.js";
|
|
1
2
|
import { defineRuntime } from "../../contracts/runtime.js";
|
|
2
3
|
import { piInstallation } from "./installation.js";
|
|
3
4
|
import { piListModels } from "./list-models.js";
|
|
@@ -9,6 +10,8 @@ import { piSession } from "./session.js";
|
|
|
9
10
|
*/
|
|
10
11
|
export const piRuntime = defineRuntime({
|
|
11
12
|
id: "pi",
|
|
13
|
+
skills: piSkills,
|
|
14
|
+
tools: piTools,
|
|
12
15
|
installation: piInstallation,
|
|
13
16
|
listModels: piListModels,
|
|
14
17
|
session: piSession,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtimes/pi/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAC;IACrC,EAAE,EAAE,IAAI;IACR,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,YAAY;IACxB,OAAO,EAAE,SAAS;CACnB,CAAC,CAAC;AAEH,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtimes/pi/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAC;IACrC,EAAE,EAAE,IAAI;IACR,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,YAAY;IACxB,OAAO,EAAE,SAAS;CACnB,CAAC,CAAC;AAEH,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inventory.d.ts","sourceRoot":"","sources":["../../../src/runtimes/pi/inventory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAmC,UAAU,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAqD5H,eAAO,MAAM,QAAQ,6BAAsC,CAAC;AAC5D,eAAO,MAAM,OAAO,4BAAqC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { asRecord } from "../../shared/json.js";
|
|
2
|
+
import { inventoryOk, inventoryRead, unsupportedInventory, workspaceScope } from "../../shared/inventory.js";
|
|
3
|
+
function piInventories(session, scope) {
|
|
4
|
+
return {
|
|
5
|
+
skills: () => {
|
|
6
|
+
const result = session.resourceLoader.getSkills();
|
|
7
|
+
const items = result.skills.map((skill) => ({
|
|
8
|
+
name: skill.name, description: skill.description, path: skill.filePath,
|
|
9
|
+
disableModelInvocation: skill.disableModelInvocation, source: skill.sourceInfo.source,
|
|
10
|
+
}));
|
|
11
|
+
return inventoryOk(scope, "discovered", items, result.diagnostics.length > 0);
|
|
12
|
+
},
|
|
13
|
+
tools: () => {
|
|
14
|
+
const active = new Set(session.getActiveToolNames());
|
|
15
|
+
const items = session.getAllTools().map((tool) => {
|
|
16
|
+
const schema = asRecord(tool.parameters);
|
|
17
|
+
return { name: tool.name, description: tool.description, active: active.has(tool.name),
|
|
18
|
+
...(schema === null ? {} : { inputSchema: schema }) };
|
|
19
|
+
});
|
|
20
|
+
return inventoryOk(scope, "registered", items);
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function reader(select) {
|
|
25
|
+
return async (installation, options = {}) => {
|
|
26
|
+
if (installation.via !== "bundled") {
|
|
27
|
+
return unsupportedInventory("installation_unsupported", "Pi inventory requires the bundled SDK");
|
|
28
|
+
}
|
|
29
|
+
const scope = workspaceScope(options);
|
|
30
|
+
// Cleanup stays inside the task: if the caller times out during SDK startup,
|
|
31
|
+
// the eventual session is still disposed. No trust-store write or model prompt.
|
|
32
|
+
const result = await inventoryRead(async () => {
|
|
33
|
+
const sdk = await import("@earendil-works/pi-coding-agent");
|
|
34
|
+
const agentDir = process.env.OAR_PI_AGENT_DIR ?? sdk.getAgentDir();
|
|
35
|
+
const services = await sdk.createAgentSessionServices({ cwd: scope.cwd, agentDir });
|
|
36
|
+
const { session } = await sdk.createAgentSessionFromServices({
|
|
37
|
+
services, sessionManager: sdk.SessionManager.inMemory(scope.cwd),
|
|
38
|
+
});
|
|
39
|
+
try {
|
|
40
|
+
return select(piInventories(session, scope))();
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
session.dispose();
|
|
44
|
+
}
|
|
45
|
+
}, options.timeoutMs);
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export const piSkills = reader((readers) => readers.skills);
|
|
50
|
+
export const piTools = reader((readers) => readers.tools);
|
|
51
|
+
//# sourceMappingURL=inventory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inventory.js","sourceRoot":"","sources":["../../../src/runtimes/pi/inventory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAM7G,SAAS,aAAa,CAAC,OAAqB,EAAE,KAAqB;IACjE,OAAO;QACL,MAAM,EAAE,GAAG,EAAE;YACX,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC;YAClD,MAAM,KAAK,GAAiB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBACxD,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ;gBACtE,sBAAsB,EAAE,KAAK,CAAC,sBAAsB,EAAE,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,MAAM;aACtF,CAAC,CAAC,CAAC;YACJ,OAAO,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAChF,CAAC;QACD,KAAK,EAAE,GAAG,EAAE;YACV,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;YACrD,MAAM,KAAK,GAAgB,OAAO,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC5D,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU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;aACjE,CAAC,CAAC;YACH,IAAI,CAAC;gBACH,OAAO,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;YACjD,CAAC;oBAAS,CAAC;gBACT,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,CAAC;QACH,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QACtB,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AACD,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { InventoryOptions, InventoryResult, InventoryScope } from "../contracts/inventory.js";
|
|
2
|
+
import { type JsonRecord } from "./json.js";
|
|
3
|
+
export type NativeInventoryRequest = (method: string, params: JsonRecord) => Promise<JsonRecord>;
|
|
4
|
+
export declare function workspaceScope(options?: InventoryOptions): InventoryScope & {
|
|
5
|
+
readonly cwd: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function inventoryOk<T>(scope: InventoryScope, view: Extract<InventoryResult<T>, {
|
|
8
|
+
kind: "ok";
|
|
9
|
+
}>["view"], items: readonly T[], partial?: boolean): InventoryResult<T>;
|
|
10
|
+
export declare function unsupportedInventory(code: Extract<InventoryResult<never>, {
|
|
11
|
+
kind: "unsupported";
|
|
12
|
+
}>["code"], reason: string): InventoryResult<never>;
|
|
13
|
+
export declare function unavailableInventory(code: Extract<InventoryResult<never>, {
|
|
14
|
+
kind: "unavailable";
|
|
15
|
+
}>["code"], reason: string): InventoryResult<never>;
|
|
16
|
+
export declare function nativeRows(value: unknown): JsonRecord[];
|
|
17
|
+
export declare function named(row: JsonRecord): string;
|
|
18
|
+
export declare function textField(key: string, value: unknown): Record<string, string>;
|
|
19
|
+
export declare function boolField(key: string, value: unknown): Record<string, boolean>;
|
|
20
|
+
/** Bound a read with a deadline; subprocess callers dispose their owned process in finally. */
|
|
21
|
+
export declare function inventoryRead<T>(read: () => Promise<InventoryResult<T>>, timeoutMs?: number): Promise<InventoryResult<T>>;
|
|
22
|
+
//# sourceMappingURL=inventory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inventory.d.ts","sourceRoot":"","sources":["../../src/shared/inventory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACnG,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAEtD,MAAM,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AACjG,wBAAgB,cAAc,CAAC,OAAO,GAAE,gBAAqB,GAAG,cAAc,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAExG;AACD,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,OAAO,UAAQ,GAAG,eAAe,CAAC,CAAC,CAAC,CAEzK;AACD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,CAEnJ;AACD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,CAEnJ;AACD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,EAAE,CAWvD;AACD,wBAAgB,KAAK,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAK7C;AACD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE7E;AACD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE9E;AACD,+FAA+F;AAC/F,wBAAsB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,SAAS,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAgB/H"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { resolve as resolvePath } from "node:path";
|
|
2
|
+
import { asRecord } from "./json.js";
|
|
3
|
+
export function workspaceScope(options = {}) {
|
|
4
|
+
return { kind: "workspace", cwd: resolvePath(options.cwd ?? process.cwd()) };
|
|
5
|
+
}
|
|
6
|
+
export function inventoryOk(scope, view, items, partial = false) {
|
|
7
|
+
return { kind: "ok", scope, observedAt: new Date().toISOString(), view, items, partial };
|
|
8
|
+
}
|
|
9
|
+
export function unsupportedInventory(code, reason) {
|
|
10
|
+
return { kind: "unsupported", code, reason };
|
|
11
|
+
}
|
|
12
|
+
export function unavailableInventory(code, reason) {
|
|
13
|
+
return { kind: "unavailable", code, reason };
|
|
14
|
+
}
|
|
15
|
+
export function nativeRows(value) {
|
|
16
|
+
if (!Array.isArray(value)) {
|
|
17
|
+
throw new TypeError("Native inventory response has no list");
|
|
18
|
+
}
|
|
19
|
+
return value.map((item) => {
|
|
20
|
+
const row = asRecord(item);
|
|
21
|
+
if (row === null) {
|
|
22
|
+
throw new TypeError("Native inventory entry is not an object");
|
|
23
|
+
}
|
|
24
|
+
return row;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export function named(row) {
|
|
28
|
+
if (typeof row.name !== "string") {
|
|
29
|
+
throw new TypeError("Native inventory entry has no name");
|
|
30
|
+
}
|
|
31
|
+
return row.name;
|
|
32
|
+
}
|
|
33
|
+
export function textField(key, value) {
|
|
34
|
+
return typeof value === "string" ? { [key]: value } : {};
|
|
35
|
+
}
|
|
36
|
+
export function boolField(key, value) {
|
|
37
|
+
return typeof value === "boolean" ? { [key]: value } : {};
|
|
38
|
+
}
|
|
39
|
+
/** Bound a read with a deadline; subprocess callers dispose their owned process in finally. */
|
|
40
|
+
export async function inventoryRead(read, timeoutMs = 15_000) {
|
|
41
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
42
|
+
throw new RangeError("timeoutMs must be positive and finite");
|
|
43
|
+
}
|
|
44
|
+
let timer = undefined;
|
|
45
|
+
const deadline = new Promise((resolve) => {
|
|
46
|
+
timer = setTimeout(() => { resolve(unavailableInventory("timeout", "Native inventory query timed out")); }, timeoutMs);
|
|
47
|
+
});
|
|
48
|
+
try {
|
|
49
|
+
return await Promise.race([read(), deadline]);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// Raw native errors can contain command arguments, headers or credentials.
|
|
53
|
+
return unavailableInventory("query_failed", "Native inventory query failed");
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
clearTimeout(timer);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=inventory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inventory.js","sourceRoot":"","sources":["../../src/shared/inventory.ts"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