@agentrific/server 0.2.0 → 0.3.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/CHANGELOG.md +8 -0
- package/cli.js +29 -4
- package/cli.js.map +2 -2
- package/index.js +29 -4
- package/index.js.map +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -465,6 +465,11 @@ var SessionSchema = z2.object({
|
|
|
465
465
|
gitFlow: GitFlowSchema.optional(),
|
|
466
466
|
gitDelivery: GitDeliverySchema.optional(),
|
|
467
467
|
preparation: RunPreparationSchema.optional(),
|
|
468
|
+
usage: z2.object({
|
|
469
|
+
tokens: z2.number().nonnegative(),
|
|
470
|
+
turns: z2.number().int().nonnegative(),
|
|
471
|
+
tools: z2.number().int().nonnegative()
|
|
472
|
+
}).optional(),
|
|
468
473
|
createdAt: z2.string().datetime(),
|
|
469
474
|
updatedAt: z2.string().datetime()
|
|
470
475
|
});
|
|
@@ -528,6 +533,7 @@ var SessionEventSchema = z2.discriminatedUnion("type", [
|
|
|
528
533
|
}),
|
|
529
534
|
z2.object({
|
|
530
535
|
type: z2.literal("message.completed"),
|
|
536
|
+
tokens: z2.number().nonnegative().optional(),
|
|
531
537
|
model: ModelIdentitySchema.optional(),
|
|
532
538
|
sessionId: z2.string(),
|
|
533
539
|
messageId: z2.string().optional(),
|
|
@@ -1090,7 +1096,7 @@ async function startControl(directory, security2, status, maintenance2) {
|
|
|
1090
1096
|
// package.json
|
|
1091
1097
|
var package_default = {
|
|
1092
1098
|
name: "@agentrific/server",
|
|
1093
|
-
version: "0.
|
|
1099
|
+
version: "0.3.0",
|
|
1094
1100
|
description: "Self-hosted control plane for long-running coding agents",
|
|
1095
1101
|
keywords: [
|
|
1096
1102
|
"agentrific",
|
|
@@ -1783,13 +1789,29 @@ var AgentController = class {
|
|
|
1783
1789
|
const entry = {
|
|
1784
1790
|
session,
|
|
1785
1791
|
agent,
|
|
1786
|
-
unsubscribe:
|
|
1792
|
+
unsubscribe: () => {
|
|
1793
|
+
},
|
|
1787
1794
|
running: false,
|
|
1788
1795
|
stopping: false,
|
|
1789
1796
|
pending: []
|
|
1790
1797
|
};
|
|
1798
|
+
entry.unsubscribe = agent.subscribe((event) => {
|
|
1799
|
+
this.emit(event);
|
|
1800
|
+
if (event.type !== "message.completed" && event.type !== "tool.started") return;
|
|
1801
|
+
const usage = entry.session.usage ?? { tokens: 0, turns: 0, tools: 0 };
|
|
1802
|
+
entry.session = {
|
|
1803
|
+
...entry.session,
|
|
1804
|
+
usage: {
|
|
1805
|
+
tokens: usage.tokens + (event.type === "message.completed" ? event.tokens ?? 0 : 0),
|
|
1806
|
+
turns: usage.turns + (event.type === "message.completed" ? 1 : 0),
|
|
1807
|
+
tools: usage.tools + (event.type === "tool.started" ? 1 : 0)
|
|
1808
|
+
},
|
|
1809
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1810
|
+
};
|
|
1811
|
+
this.emit({ type: "session.updated", session: entry.session });
|
|
1812
|
+
});
|
|
1791
1813
|
if (agent.model) {
|
|
1792
|
-
entry.session = { ...session, model: agent.model };
|
|
1814
|
+
entry.session = { ...entry.session, model: agent.model };
|
|
1793
1815
|
this.emit({ type: "session.updated", session: entry.session });
|
|
1794
1816
|
}
|
|
1795
1817
|
this.active.set(session.id, entry);
|
|
@@ -2981,6 +3003,7 @@ function createPiFactory(files, models2, delivery2, createSession = createAgentS
|
|
|
2981
3003
|
sessionId,
|
|
2982
3004
|
messageId: assistantMessageId,
|
|
2983
3005
|
text,
|
|
3006
|
+
tokens: event.message.usage.totalTokens,
|
|
2984
3007
|
model: models2.identity(event.message.provider, event.message.model)
|
|
2985
3008
|
});
|
|
2986
3009
|
assistantMessageId = void 0;
|
|
@@ -3004,7 +3027,8 @@ function createPiFactory(files, models2, delivery2, createSession = createAgentS
|
|
|
3004
3027
|
sessionId,
|
|
3005
3028
|
toolCallId: event.toolCallId,
|
|
3006
3029
|
tool: event.toolName,
|
|
3007
|
-
|
|
3030
|
+
// Preserve complete Bash arguments so multiline commands can be inspected.
|
|
3031
|
+
input: event.toolName === "bash" ? JSON.stringify(event.args) : boundedJson(event.args, 1200),
|
|
3008
3032
|
filePath: filePaths.get(event.toolCallId)
|
|
3009
3033
|
});
|
|
3010
3034
|
return true;
|
|
@@ -4233,6 +4257,7 @@ async function createAndStartSession(input) {
|
|
|
4233
4257
|
status: "starting",
|
|
4234
4258
|
agent: input.agent,
|
|
4235
4259
|
model: selectedModel,
|
|
4260
|
+
usage: { tokens: 0, turns: 0, tools: 0 },
|
|
4236
4261
|
gitFlow: input.gitFlow,
|
|
4237
4262
|
branch: null,
|
|
4238
4263
|
createdAt: now,
|