@shardworks/spider-apparatus 0.1.238 → 0.1.239
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/dist/rig-view.d.ts +9 -6
- package/dist/rig-view.d.ts.map +1 -1
- package/dist/rig-view.js +23 -15
- package/dist/rig-view.js.map +1 -1
- package/dist/tools/rig-list.d.ts.map +1 -1
- package/dist/tools/rig-list.js +1 -2
- package/dist/tools/rig-list.js.map +1 -1
- package/dist/tools/rig-show.d.ts.map +1 -1
- package/dist/tools/rig-show.js +1 -2
- package/dist/tools/rig-show.js.map +1 -1
- package/package.json +9 -9
package/dist/rig-view.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Rig view aggregator — builds the UI-facing RigView from a persisted
|
|
3
|
-
* RigDoc by joining against the
|
|
3
|
+
* RigDoc by joining against the Animator's per-session cost snapshot.
|
|
4
4
|
*
|
|
5
5
|
* Read-only. Pure derived fields; never persisted.
|
|
6
6
|
*
|
|
@@ -11,18 +11,21 @@
|
|
|
11
11
|
* zeros; sessions that are missing from the book are skipped silently.
|
|
12
12
|
* - tokenUsage fields are optional: when no contributing session has
|
|
13
13
|
* tokenUsage, the aggregate inputTokens/outputTokens are omitted.
|
|
14
|
+
*
|
|
15
|
+
* The cost data comes from AnimatorApi.getSessionCosts — the Animator owns
|
|
16
|
+
* the shape of cost answers, so consumers like this aggregator do not reach
|
|
17
|
+
* into the sessions book directly.
|
|
14
18
|
*/
|
|
15
|
-
import type { StacksApi } from '@shardworks/stacks-apparatus';
|
|
16
19
|
import type { RigDoc, RigView } from './types.ts';
|
|
17
20
|
/**
|
|
18
|
-
* Build a RigView for a single rig by
|
|
19
|
-
* (if any)
|
|
21
|
+
* Build a RigView for a single rig by asking the Animator for cost/token
|
|
22
|
+
* snapshots of every engine's session (if any) and summing across them.
|
|
20
23
|
*
|
|
21
24
|
* Does not mutate the rig. Safe to call on every read.
|
|
22
25
|
*/
|
|
23
|
-
export declare function enrichRigView(rig: RigDoc
|
|
26
|
+
export declare function enrichRigView(rig: RigDoc): Promise<RigView>;
|
|
24
27
|
/**
|
|
25
28
|
* Enrich an array of rigs in parallel.
|
|
26
29
|
*/
|
|
27
|
-
export declare function enrichRigViews(rigs: RigDoc[]
|
|
30
|
+
export declare function enrichRigViews(rigs: RigDoc[]): Promise<RigView[]>;
|
|
28
31
|
//# sourceMappingURL=rig-view.d.ts.map
|
package/dist/rig-view.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rig-view.d.ts","sourceRoot":"","sources":["../src/rig-view.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rig-view.d.ts","sourceRoot":"","sources":["../src/rig-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,EACV,MAAM,EACN,OAAO,EAGR,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA8DjE;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAEvE"}
|
package/dist/rig-view.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Rig view aggregator — builds the UI-facing RigView from a persisted
|
|
3
|
-
* RigDoc by joining against the
|
|
3
|
+
* RigDoc by joining against the Animator's per-session cost snapshot.
|
|
4
4
|
*
|
|
5
5
|
* Read-only. Pure derived fields; never persisted.
|
|
6
6
|
*
|
|
@@ -11,15 +11,19 @@
|
|
|
11
11
|
* zeros; sessions that are missing from the book are skipped silently.
|
|
12
12
|
* - tokenUsage fields are optional: when no contributing session has
|
|
13
13
|
* tokenUsage, the aggregate inputTokens/outputTokens are omitted.
|
|
14
|
+
*
|
|
15
|
+
* The cost data comes from AnimatorApi.getSessionCosts — the Animator owns
|
|
16
|
+
* the shape of cost answers, so consumers like this aggregator do not reach
|
|
17
|
+
* into the sessions book directly.
|
|
14
18
|
*/
|
|
19
|
+
import { guild } from '@shardworks/nexus-core';
|
|
15
20
|
/**
|
|
16
|
-
* Build a RigView for a single rig by
|
|
17
|
-
* (if any)
|
|
21
|
+
* Build a RigView for a single rig by asking the Animator for cost/token
|
|
22
|
+
* snapshots of every engine's session (if any) and summing across them.
|
|
18
23
|
*
|
|
19
24
|
* Does not mutate the rig. Safe to call on every read.
|
|
20
25
|
*/
|
|
21
|
-
export async function enrichRigView(rig
|
|
22
|
-
const sessionsBook = stacks.readBook('animator', 'sessions');
|
|
26
|
+
export async function enrichRigView(rig) {
|
|
23
27
|
// Collect (engineId, sessionId) pairs to look up.
|
|
24
28
|
const pairs = [];
|
|
25
29
|
for (const engine of rig.engines || []) {
|
|
@@ -31,19 +35,23 @@ export async function enrichRigView(rig, stacks) {
|
|
|
31
35
|
if (pairs.length === 0) {
|
|
32
36
|
return { ...rig };
|
|
33
37
|
}
|
|
34
|
-
//
|
|
35
|
-
|
|
38
|
+
// Resolve the Animator via the same apparatus-resolution mechanism
|
|
39
|
+
// Spider's engines use elsewhere, and fetch cost snapshots in a single
|
|
40
|
+
// bulk call. Missing ids are silently omitted from the returned Map
|
|
41
|
+
// (see AnimatorApi.getSessionCosts), which preserves the "missing = zero
|
|
42
|
+
// contribution" semantic this aggregator has always had.
|
|
43
|
+
const animator = guild().apparatus('animator');
|
|
44
|
+
const costs = await animator.getSessionCosts(pairs.map((p) => p.sessionId));
|
|
36
45
|
const engineCosts = {};
|
|
37
46
|
let totalCostUsd = 0;
|
|
38
47
|
let totalInputTokens = 0;
|
|
39
48
|
let totalOutputTokens = 0;
|
|
40
49
|
let anyTokenUsage = false;
|
|
41
|
-
for (
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const outputTokens = session?.tokenUsage?.outputTokens;
|
|
50
|
+
for (const { engineId, sessionId } of pairs) {
|
|
51
|
+
const cost = costs.get(sessionId);
|
|
52
|
+
const costUsd = cost?.costUsd ?? 0;
|
|
53
|
+
const inputTokens = cost?.inputTokens;
|
|
54
|
+
const outputTokens = cost?.outputTokens;
|
|
47
55
|
const engineCost = { costUsd };
|
|
48
56
|
if (inputTokens !== undefined)
|
|
49
57
|
engineCost.inputTokens = inputTokens;
|
|
@@ -74,7 +82,7 @@ export async function enrichRigView(rig, stacks) {
|
|
|
74
82
|
/**
|
|
75
83
|
* Enrich an array of rigs in parallel.
|
|
76
84
|
*/
|
|
77
|
-
export async function enrichRigViews(rigs
|
|
78
|
-
return Promise.all(rigs.map((r) => enrichRigView(r
|
|
85
|
+
export async function enrichRigViews(rigs) {
|
|
86
|
+
return Promise.all(rigs.map((r) => enrichRigView(r)));
|
|
79
87
|
}
|
|
80
88
|
//# sourceMappingURL=rig-view.js.map
|
package/dist/rig-view.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rig-view.js","sourceRoot":"","sources":["../src/rig-view.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rig-view.js","sourceRoot":"","sources":["../src/rig-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAS/C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAW;IAC7C,kDAAkD;IAClD,MAAM,KAAK,GAAmD,EAAE,CAAC;IACjE,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;QACvC,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YACrB,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;QACnE,CA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YAC9B,gBAAgB,IAAI,WAAW,CAAC;YAChC,aAAa,GAAG,IAAI,CAAC;QACvB,CAAC;QACD,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YAC/B,iBAAiB,IAAI,YAAY,CAAC;YAClC,aAAa,GAAG,IAAI,CAAC;QACvB,CAAC;IACH,CAAC;IAED,MAAM,WAAW,GAAmB,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;IAC9D,IAAI,aAAa,EAAE,CAAC;QAClB,WAAW,CAAC,WAAW,GAAG,gBAAgB,CAAC;QAC3C,WAAW,CAAC,YAAY,GAAG,iBAAiB,CAAC;IAC/C,CAAC;IAED,OAAO;QACL,GAAG,GAAG;QACN,WAAW;QACX,WAAW;KACZ,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAc;IACjD,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rig-list.d.ts","sourceRoot":"","sources":["../../src/tools/rig-list.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"rig-list.d.ts","sourceRoot":"","sources":["../../src/tools/rig-list.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;;;;;;;;;;;;AAMxB,wBAiCG"}
|
package/dist/tools/rig-list.js
CHANGED
|
@@ -34,13 +34,12 @@ export default tool({
|
|
|
34
34
|
handler: async (params) => {
|
|
35
35
|
const g = guild();
|
|
36
36
|
const spider = g.apparatus('spider');
|
|
37
|
-
const stacks = g.apparatus('stacks');
|
|
38
37
|
const rigs = await spider.list({
|
|
39
38
|
status: params.status,
|
|
40
39
|
limit: params.limit,
|
|
41
40
|
offset: params.offset,
|
|
42
41
|
});
|
|
43
|
-
return enrichRigViews(rigs
|
|
42
|
+
return enrichRigViews(rigs);
|
|
44
43
|
},
|
|
45
44
|
});
|
|
46
45
|
//# sourceMappingURL=rig-list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rig-list.js","sourceRoot":"","sources":["../../src/tools/rig-list.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"rig-list.js","sourceRoot":"","sources":["../../src/tools/rig-list.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,eAAe,IAAI,CAAC;IAClB,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,iCAAiC;IAC9C,YAAY,EACV,+DAA+D;QAC/D,4EAA4E;QAC5E,4EAA4E;QAC5E,0EAA0E;IAC5E,MAAM,EAAE;QACN,MAAM,EAAE,CAAC;aACN,IAAI,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;aAC5D,QAAQ,EAAE;aACV,QAAQ,CAAC,uBAAuB,CAAC;QACpC,KAAK,EAAE,CAAC;aACL,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,0CAA0C,CAAC;QACvD,MAAM,EAAE,CAAC;aACN,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,4BAA4B,CAAC;KAC1C;IACD,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,KAAK,EAAE,MAAM,EAAsB,EAAE;QAC5C,MAAM,CAAC,GAAG,KAAK,EAAE,CAAC;QAClB,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,CAAY,QAAQ,CAAC,CAAC;QAChD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC;YAC7B,MAAM,EAAE,MAAM,CAAC,MAA+B;YAC9C,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,MAAM,EAAE,MAAM,CAAC,MAAM;SACtB,CAAC,CAAC;QACH,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rig-show.d.ts","sourceRoot":"","sources":["../../src/tools/rig-show.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;;;;
|
|
1
|
+
{"version":3,"file":"rig-show.d.ts","sourceRoot":"","sources":["../../src/tools/rig-show.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;;;;AAMxB,wBAiBG"}
|
package/dist/tools/rig-show.js
CHANGED
|
@@ -22,9 +22,8 @@ export default tool({
|
|
|
22
22
|
handler: async (params) => {
|
|
23
23
|
const g = guild();
|
|
24
24
|
const spider = g.apparatus('spider');
|
|
25
|
-
const stacks = g.apparatus('stacks');
|
|
26
25
|
const rig = await spider.show(params.id);
|
|
27
|
-
return enrichRigView(rig
|
|
26
|
+
return enrichRigView(rig);
|
|
28
27
|
},
|
|
29
28
|
});
|
|
30
29
|
//# sourceMappingURL=rig-show.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rig-show.js","sourceRoot":"","sources":["../../src/tools/rig-show.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"rig-show.js","sourceRoot":"","sources":["../../src/tools/rig-show.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,eAAe,IAAI,CAAC;IAClB,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,sBAAsB;IACnC,YAAY,EACV,wEAAwE;QACxE,gFAAgF;QAChF,uGAAuG;IACzG,MAAM,EAAE;QACN,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;KAClD;IACD,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,KAAK,EAAE,MAAM,EAAoB,EAAE;QAC1C,MAAM,CAAC,GAAG,KAAK,EAAE,CAAC;QAClB,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,CAAY,QAAQ,CAAC,CAAC;QAChD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACzC,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shardworks/spider-apparatus",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.239",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"hono": "^4.7.11",
|
|
23
23
|
"yaml": "^2.0.0",
|
|
24
24
|
"zod": "4.3.6",
|
|
25
|
-
"@shardworks/fabricator-apparatus": "0.1.
|
|
26
|
-
"@shardworks/
|
|
27
|
-
"@shardworks/
|
|
28
|
-
"@shardworks/
|
|
29
|
-
"@shardworks/
|
|
30
|
-
"@shardworks/
|
|
31
|
-
"@shardworks/
|
|
25
|
+
"@shardworks/fabricator-apparatus": "0.1.239",
|
|
26
|
+
"@shardworks/stacks-apparatus": "0.1.239",
|
|
27
|
+
"@shardworks/clerk-apparatus": "0.1.239",
|
|
28
|
+
"@shardworks/codexes-apparatus": "0.1.239",
|
|
29
|
+
"@shardworks/tools-apparatus": "0.1.239",
|
|
30
|
+
"@shardworks/loom-apparatus": "0.1.239",
|
|
31
|
+
"@shardworks/animator-apparatus": "0.1.239"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "25.5.0",
|
|
35
|
-
"@shardworks/nexus-core": "0.1.
|
|
35
|
+
"@shardworks/nexus-core": "0.1.239"
|
|
36
36
|
},
|
|
37
37
|
"files": [
|
|
38
38
|
"dist",
|