appduct 0.13.0 → 0.14.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 +3 -2
- package/dist/bin.js +61 -4
- package/dist/cli/result-types.d.ts +8 -1
- package/dist/cli/routes/daemon/index.js +58 -1
- package/dist/cli/routes/daemon/run.js +152 -22
- package/dist/cli/routes/daemon/start.js +58 -1
- package/dist/cli/routes/daemon/status.js +58 -1
- package/dist/cli/routes/daemon/stop.js +58 -1
- package/dist/cli/routes/doctor.js +58 -1
- package/dist/cli/routes/events/index.d.ts +0 -3
- package/dist/cli/routes/events/index.js +60 -2
- package/dist/cli/routes/events/ls.d.ts +5 -0
- package/dist/cli/routes/events/ls.js +1798 -0
- package/dist/cli/routes/events/since.js +58 -1
- package/dist/cli/routes/events/tail.js +58 -1
- package/dist/cli/routes/init.js +58 -1
- package/dist/cli/routes/keygen.js +58 -1
- package/dist/cli/routes/mcp.js +108 -1
- package/dist/cli/routes/sessions/index.js +58 -1
- package/dist/cli/routes/sessions/link.js +58 -1
- package/dist/cli/routes/sessions/ls.js +58 -1
- package/dist/cli/routes/sessions/revoke.js +58 -1
- package/dist/cli/routes/tools/call.js +58 -1
- package/dist/cli/routes/tools/describe.js +58 -1
- package/dist/cli/routes/tools/index.js +58 -1
- package/dist/cli/routes/tools/ls.js +58 -1
- package/dist/commands/events-ls.d.ts +21 -0
- package/dist/daemon/calls.d.ts +3 -1
- package/dist/daemon/event-bus.d.ts +10 -0
- package/dist/daemon/registry.d.ts +20 -12
- package/dist/daemon/rpc-errors.d.ts +3 -0
- package/dist/daemon/sessions.d.ts +4 -2
- package/dist/index.js +61 -4
- package/dist/mcp/app-tools.d.ts +19 -0
- package/dist/mcp/events-tool.d.ts +39 -0
- package/package.json +2 -2
|
@@ -1049,6 +1049,7 @@ var formatJson = (value, flags) => {
|
|
|
1049
1049
|
import pc from "picocolors";
|
|
1050
1050
|
import {
|
|
1051
1051
|
formatAgentWebSocketUrl,
|
|
1052
|
+
renderEventSignature,
|
|
1052
1053
|
renderToolSignature,
|
|
1053
1054
|
summarizeToolDescription
|
|
1054
1055
|
} from "@appduct/shared";
|
|
@@ -1144,6 +1145,13 @@ var formatDevice = (device) => {
|
|
|
1144
1145
|
const label = parts.length > 0 ? parts.join(" ") : "unknown device";
|
|
1145
1146
|
return device.os ? `${label} (${device.os})` : label;
|
|
1146
1147
|
};
|
|
1148
|
+
var SUSPEND_REASON_LABELS = {
|
|
1149
|
+
app_backgrounded: "app in background",
|
|
1150
|
+
connection_lost: "connection lost"
|
|
1151
|
+
};
|
|
1152
|
+
var formatSessionState = (session) => {
|
|
1153
|
+
return session.suspendReason ? `${session.state} (${SUSPEND_REASON_LABELS[session.suspendReason]})` : session.state;
|
|
1154
|
+
};
|
|
1147
1155
|
var renderLsData = (colors, data, now) => {
|
|
1148
1156
|
if (data.length === 0) {
|
|
1149
1157
|
return [colors.dim("Sessions"), " No Appduct sessions are registered."];
|
|
@@ -1152,7 +1160,7 @@ var renderLsData = (colors, data, now) => {
|
|
|
1152
1160
|
const headers = ["Alias", "State", "Device", "Tools", "Age"];
|
|
1153
1161
|
const rows = data.map((session) => [
|
|
1154
1162
|
session.alias,
|
|
1155
|
-
session
|
|
1163
|
+
formatSessionState(session),
|
|
1156
1164
|
formatDevice(session.device),
|
|
1157
1165
|
String(session.toolCount),
|
|
1158
1166
|
formatAge(session.claimedAt ?? session.createdAt, nowIso)
|
|
@@ -1326,6 +1334,53 @@ var renderToolsListData = (colors, data, flags, full) => {
|
|
|
1326
1334
|
}
|
|
1327
1335
|
return full ? renderToolsFullListing(colors, data, flags) : renderToolSummaryTable(colors, data);
|
|
1328
1336
|
};
|
|
1337
|
+
var renderEventsTruncationLine = (data) => {
|
|
1338
|
+
const offset = data.offset ?? 0;
|
|
1339
|
+
if (data.events.length >= data.total) {
|
|
1340
|
+
return [];
|
|
1341
|
+
}
|
|
1342
|
+
return [
|
|
1343
|
+
"",
|
|
1344
|
+
`Showing ${data.events.length} of ${data.total} events (offset ${offset}). Narrow with --name <glob> or page with --offset <n>.`
|
|
1345
|
+
];
|
|
1346
|
+
};
|
|
1347
|
+
var renderEventsListData = (colors, data, flags) => {
|
|
1348
|
+
const [only] = data.events;
|
|
1349
|
+
if (data.name !== void 0 && !data.name.includes("*") && only !== void 0) {
|
|
1350
|
+
return renderFields(
|
|
1351
|
+
colors.green(`Event: ${only.name}`),
|
|
1352
|
+
[
|
|
1353
|
+
["Signature", renderEventSignature(only)],
|
|
1354
|
+
["Description", only.description],
|
|
1355
|
+
["Payload schema", only.payload_schema]
|
|
1356
|
+
],
|
|
1357
|
+
flags
|
|
1358
|
+
);
|
|
1359
|
+
}
|
|
1360
|
+
if (data.events.length === 0 && data.total > 0) {
|
|
1361
|
+
return [
|
|
1362
|
+
colors.green("Events"),
|
|
1363
|
+
` No events at offset ${data.offset ?? 0}; ${data.total} matching event${data.total === 1 ? "" : "s"} in total.`
|
|
1364
|
+
];
|
|
1365
|
+
}
|
|
1366
|
+
if (data.events.length === 0) {
|
|
1367
|
+
return [
|
|
1368
|
+
colors.green("Events"),
|
|
1369
|
+
data.name === void 0 ? " No events declared." : ` No events match ${JSON.stringify(data.name)}.`
|
|
1370
|
+
];
|
|
1371
|
+
}
|
|
1372
|
+
const lines = data.events.flatMap((event) => [
|
|
1373
|
+
` ${renderEventSignature(event)}`,
|
|
1374
|
+
` ${summarizeToolDescription(event.description)}`
|
|
1375
|
+
]);
|
|
1376
|
+
return [
|
|
1377
|
+
colors.green("Events"),
|
|
1378
|
+
...lines,
|
|
1379
|
+
...renderEventsTruncationLine(data),
|
|
1380
|
+
"",
|
|
1381
|
+
"Run `appduct events ls --name <name>` for an event's full payload schema."
|
|
1382
|
+
];
|
|
1383
|
+
};
|
|
1329
1384
|
var renderInvokeData = (colors, data, flags) => {
|
|
1330
1385
|
return [colors.green("Result"), formatScalar(data, flags)];
|
|
1331
1386
|
};
|
|
@@ -1517,6 +1572,8 @@ var renderSuccessData = (colors, command, data, options) => {
|
|
|
1517
1572
|
return renderToolsListData(colors, data, flags, options.full);
|
|
1518
1573
|
case "tools describe":
|
|
1519
1574
|
return renderToolDetail(colors, data, flags);
|
|
1575
|
+
case "events ls":
|
|
1576
|
+
return renderEventsListData(colors, data, flags);
|
|
1520
1577
|
case "tools call":
|
|
1521
1578
|
return renderInvokeData(colors, data, flags);
|
|
1522
1579
|
case "sessions revoke":
|
|
@@ -1078,6 +1078,7 @@ var formatJson = (value, flags) => {
|
|
|
1078
1078
|
import pc from "picocolors";
|
|
1079
1079
|
import {
|
|
1080
1080
|
formatAgentWebSocketUrl,
|
|
1081
|
+
renderEventSignature,
|
|
1081
1082
|
renderToolSignature,
|
|
1082
1083
|
summarizeToolDescription
|
|
1083
1084
|
} from "@appduct/shared";
|
|
@@ -1173,6 +1174,13 @@ var formatDevice = (device) => {
|
|
|
1173
1174
|
const label = parts.length > 0 ? parts.join(" ") : "unknown device";
|
|
1174
1175
|
return device.os ? `${label} (${device.os})` : label;
|
|
1175
1176
|
};
|
|
1177
|
+
var SUSPEND_REASON_LABELS = {
|
|
1178
|
+
app_backgrounded: "app in background",
|
|
1179
|
+
connection_lost: "connection lost"
|
|
1180
|
+
};
|
|
1181
|
+
var formatSessionState = (session) => {
|
|
1182
|
+
return session.suspendReason ? `${session.state} (${SUSPEND_REASON_LABELS[session.suspendReason]})` : session.state;
|
|
1183
|
+
};
|
|
1176
1184
|
var renderLsData = (colors, data, now) => {
|
|
1177
1185
|
if (data.length === 0) {
|
|
1178
1186
|
return [colors.dim("Sessions"), " No Appduct sessions are registered."];
|
|
@@ -1181,7 +1189,7 @@ var renderLsData = (colors, data, now) => {
|
|
|
1181
1189
|
const headers = ["Alias", "State", "Device", "Tools", "Age"];
|
|
1182
1190
|
const rows = data.map((session) => [
|
|
1183
1191
|
session.alias,
|
|
1184
|
-
session
|
|
1192
|
+
formatSessionState(session),
|
|
1185
1193
|
formatDevice(session.device),
|
|
1186
1194
|
String(session.toolCount),
|
|
1187
1195
|
formatAge(session.claimedAt ?? session.createdAt, nowIso)
|
|
@@ -1355,6 +1363,53 @@ var renderToolsListData = (colors, data, flags, full) => {
|
|
|
1355
1363
|
}
|
|
1356
1364
|
return full ? renderToolsFullListing(colors, data, flags) : renderToolSummaryTable(colors, data);
|
|
1357
1365
|
};
|
|
1366
|
+
var renderEventsTruncationLine = (data) => {
|
|
1367
|
+
const offset = data.offset ?? 0;
|
|
1368
|
+
if (data.events.length >= data.total) {
|
|
1369
|
+
return [];
|
|
1370
|
+
}
|
|
1371
|
+
return [
|
|
1372
|
+
"",
|
|
1373
|
+
`Showing ${data.events.length} of ${data.total} events (offset ${offset}). Narrow with --name <glob> or page with --offset <n>.`
|
|
1374
|
+
];
|
|
1375
|
+
};
|
|
1376
|
+
var renderEventsListData = (colors, data, flags) => {
|
|
1377
|
+
const [only] = data.events;
|
|
1378
|
+
if (data.name !== void 0 && !data.name.includes("*") && only !== void 0) {
|
|
1379
|
+
return renderFields(
|
|
1380
|
+
colors.green(`Event: ${only.name}`),
|
|
1381
|
+
[
|
|
1382
|
+
["Signature", renderEventSignature(only)],
|
|
1383
|
+
["Description", only.description],
|
|
1384
|
+
["Payload schema", only.payload_schema]
|
|
1385
|
+
],
|
|
1386
|
+
flags
|
|
1387
|
+
);
|
|
1388
|
+
}
|
|
1389
|
+
if (data.events.length === 0 && data.total > 0) {
|
|
1390
|
+
return [
|
|
1391
|
+
colors.green("Events"),
|
|
1392
|
+
` No events at offset ${data.offset ?? 0}; ${data.total} matching event${data.total === 1 ? "" : "s"} in total.`
|
|
1393
|
+
];
|
|
1394
|
+
}
|
|
1395
|
+
if (data.events.length === 0) {
|
|
1396
|
+
return [
|
|
1397
|
+
colors.green("Events"),
|
|
1398
|
+
data.name === void 0 ? " No events declared." : ` No events match ${JSON.stringify(data.name)}.`
|
|
1399
|
+
];
|
|
1400
|
+
}
|
|
1401
|
+
const lines = data.events.flatMap((event) => [
|
|
1402
|
+
` ${renderEventSignature(event)}`,
|
|
1403
|
+
` ${summarizeToolDescription(event.description)}`
|
|
1404
|
+
]);
|
|
1405
|
+
return [
|
|
1406
|
+
colors.green("Events"),
|
|
1407
|
+
...lines,
|
|
1408
|
+
...renderEventsTruncationLine(data),
|
|
1409
|
+
"",
|
|
1410
|
+
"Run `appduct events ls --name <name>` for an event's full payload schema."
|
|
1411
|
+
];
|
|
1412
|
+
};
|
|
1358
1413
|
var renderInvokeData = (colors, data, flags) => {
|
|
1359
1414
|
return [colors.green("Result"), formatScalar(data, flags)];
|
|
1360
1415
|
};
|
|
@@ -1546,6 +1601,8 @@ var renderSuccessData = (colors, command, data, options) => {
|
|
|
1546
1601
|
return renderToolsListData(colors, data, flags, options.full);
|
|
1547
1602
|
case "tools describe":
|
|
1548
1603
|
return renderToolDetail(colors, data, flags);
|
|
1604
|
+
case "events ls":
|
|
1605
|
+
return renderEventsListData(colors, data, flags);
|
|
1549
1606
|
case "tools call":
|
|
1550
1607
|
return renderInvokeData(colors, data, flags);
|
|
1551
1608
|
case "sessions revoke":
|
|
@@ -1048,6 +1048,7 @@ var formatJson = (value, flags) => {
|
|
|
1048
1048
|
import pc from "picocolors";
|
|
1049
1049
|
import {
|
|
1050
1050
|
formatAgentWebSocketUrl,
|
|
1051
|
+
renderEventSignature,
|
|
1051
1052
|
renderToolSignature,
|
|
1052
1053
|
summarizeToolDescription
|
|
1053
1054
|
} from "@appduct/shared";
|
|
@@ -1143,6 +1144,13 @@ var formatDevice = (device) => {
|
|
|
1143
1144
|
const label = parts.length > 0 ? parts.join(" ") : "unknown device";
|
|
1144
1145
|
return device.os ? `${label} (${device.os})` : label;
|
|
1145
1146
|
};
|
|
1147
|
+
var SUSPEND_REASON_LABELS = {
|
|
1148
|
+
app_backgrounded: "app in background",
|
|
1149
|
+
connection_lost: "connection lost"
|
|
1150
|
+
};
|
|
1151
|
+
var formatSessionState = (session) => {
|
|
1152
|
+
return session.suspendReason ? `${session.state} (${SUSPEND_REASON_LABELS[session.suspendReason]})` : session.state;
|
|
1153
|
+
};
|
|
1146
1154
|
var renderLsData = (colors, data, now) => {
|
|
1147
1155
|
if (data.length === 0) {
|
|
1148
1156
|
return [colors.dim("Sessions"), " No Appduct sessions are registered."];
|
|
@@ -1151,7 +1159,7 @@ var renderLsData = (colors, data, now) => {
|
|
|
1151
1159
|
const headers = ["Alias", "State", "Device", "Tools", "Age"];
|
|
1152
1160
|
const rows = data.map((session) => [
|
|
1153
1161
|
session.alias,
|
|
1154
|
-
session
|
|
1162
|
+
formatSessionState(session),
|
|
1155
1163
|
formatDevice(session.device),
|
|
1156
1164
|
String(session.toolCount),
|
|
1157
1165
|
formatAge(session.claimedAt ?? session.createdAt, nowIso)
|
|
@@ -1325,6 +1333,53 @@ var renderToolsListData = (colors, data, flags, full) => {
|
|
|
1325
1333
|
}
|
|
1326
1334
|
return full ? renderToolsFullListing(colors, data, flags) : renderToolSummaryTable(colors, data);
|
|
1327
1335
|
};
|
|
1336
|
+
var renderEventsTruncationLine = (data) => {
|
|
1337
|
+
const offset = data.offset ?? 0;
|
|
1338
|
+
if (data.events.length >= data.total) {
|
|
1339
|
+
return [];
|
|
1340
|
+
}
|
|
1341
|
+
return [
|
|
1342
|
+
"",
|
|
1343
|
+
`Showing ${data.events.length} of ${data.total} events (offset ${offset}). Narrow with --name <glob> or page with --offset <n>.`
|
|
1344
|
+
];
|
|
1345
|
+
};
|
|
1346
|
+
var renderEventsListData = (colors, data, flags) => {
|
|
1347
|
+
const [only] = data.events;
|
|
1348
|
+
if (data.name !== void 0 && !data.name.includes("*") && only !== void 0) {
|
|
1349
|
+
return renderFields(
|
|
1350
|
+
colors.green(`Event: ${only.name}`),
|
|
1351
|
+
[
|
|
1352
|
+
["Signature", renderEventSignature(only)],
|
|
1353
|
+
["Description", only.description],
|
|
1354
|
+
["Payload schema", only.payload_schema]
|
|
1355
|
+
],
|
|
1356
|
+
flags
|
|
1357
|
+
);
|
|
1358
|
+
}
|
|
1359
|
+
if (data.events.length === 0 && data.total > 0) {
|
|
1360
|
+
return [
|
|
1361
|
+
colors.green("Events"),
|
|
1362
|
+
` No events at offset ${data.offset ?? 0}; ${data.total} matching event${data.total === 1 ? "" : "s"} in total.`
|
|
1363
|
+
];
|
|
1364
|
+
}
|
|
1365
|
+
if (data.events.length === 0) {
|
|
1366
|
+
return [
|
|
1367
|
+
colors.green("Events"),
|
|
1368
|
+
data.name === void 0 ? " No events declared." : ` No events match ${JSON.stringify(data.name)}.`
|
|
1369
|
+
];
|
|
1370
|
+
}
|
|
1371
|
+
const lines = data.events.flatMap((event) => [
|
|
1372
|
+
` ${renderEventSignature(event)}`,
|
|
1373
|
+
` ${summarizeToolDescription(event.description)}`
|
|
1374
|
+
]);
|
|
1375
|
+
return [
|
|
1376
|
+
colors.green("Events"),
|
|
1377
|
+
...lines,
|
|
1378
|
+
...renderEventsTruncationLine(data),
|
|
1379
|
+
"",
|
|
1380
|
+
"Run `appduct events ls --name <name>` for an event's full payload schema."
|
|
1381
|
+
];
|
|
1382
|
+
};
|
|
1328
1383
|
var renderInvokeData = (colors, data, flags) => {
|
|
1329
1384
|
return [colors.green("Result"), formatScalar(data, flags)];
|
|
1330
1385
|
};
|
|
@@ -1516,6 +1571,8 @@ var renderSuccessData = (colors, command, data, options) => {
|
|
|
1516
1571
|
return renderToolsListData(colors, data, flags, options.full);
|
|
1517
1572
|
case "tools describe":
|
|
1518
1573
|
return renderToolDetail(colors, data, flags);
|
|
1574
|
+
case "events ls":
|
|
1575
|
+
return renderEventsListData(colors, data, flags);
|
|
1519
1576
|
case "tools call":
|
|
1520
1577
|
return renderInvokeData(colors, data, flags);
|
|
1521
1578
|
case "sessions revoke":
|
|
@@ -458,6 +458,7 @@ var formatJson = (value, flags) => {
|
|
|
458
458
|
import pc from "picocolors";
|
|
459
459
|
import {
|
|
460
460
|
formatAgentWebSocketUrl,
|
|
461
|
+
renderEventSignature,
|
|
461
462
|
renderToolSignature,
|
|
462
463
|
summarizeToolDescription
|
|
463
464
|
} from "@appduct/shared";
|
|
@@ -553,6 +554,13 @@ var formatDevice = (device) => {
|
|
|
553
554
|
const label = parts.length > 0 ? parts.join(" ") : "unknown device";
|
|
554
555
|
return device.os ? `${label} (${device.os})` : label;
|
|
555
556
|
};
|
|
557
|
+
var SUSPEND_REASON_LABELS = {
|
|
558
|
+
app_backgrounded: "app in background",
|
|
559
|
+
connection_lost: "connection lost"
|
|
560
|
+
};
|
|
561
|
+
var formatSessionState = (session) => {
|
|
562
|
+
return session.suspendReason ? `${session.state} (${SUSPEND_REASON_LABELS[session.suspendReason]})` : session.state;
|
|
563
|
+
};
|
|
556
564
|
var renderLsData = (colors, data, now) => {
|
|
557
565
|
if (data.length === 0) {
|
|
558
566
|
return [colors.dim("Sessions"), " No Appduct sessions are registered."];
|
|
@@ -561,7 +569,7 @@ var renderLsData = (colors, data, now) => {
|
|
|
561
569
|
const headers = ["Alias", "State", "Device", "Tools", "Age"];
|
|
562
570
|
const rows = data.map((session) => [
|
|
563
571
|
session.alias,
|
|
564
|
-
session
|
|
572
|
+
formatSessionState(session),
|
|
565
573
|
formatDevice(session.device),
|
|
566
574
|
String(session.toolCount),
|
|
567
575
|
formatAge(session.claimedAt ?? session.createdAt, nowIso)
|
|
@@ -735,6 +743,53 @@ var renderToolsListData = (colors, data, flags, full) => {
|
|
|
735
743
|
}
|
|
736
744
|
return full ? renderToolsFullListing(colors, data, flags) : renderToolSummaryTable(colors, data);
|
|
737
745
|
};
|
|
746
|
+
var renderEventsTruncationLine = (data) => {
|
|
747
|
+
const offset = data.offset ?? 0;
|
|
748
|
+
if (data.events.length >= data.total) {
|
|
749
|
+
return [];
|
|
750
|
+
}
|
|
751
|
+
return [
|
|
752
|
+
"",
|
|
753
|
+
`Showing ${data.events.length} of ${data.total} events (offset ${offset}). Narrow with --name <glob> or page with --offset <n>.`
|
|
754
|
+
];
|
|
755
|
+
};
|
|
756
|
+
var renderEventsListData = (colors, data, flags) => {
|
|
757
|
+
const [only] = data.events;
|
|
758
|
+
if (data.name !== void 0 && !data.name.includes("*") && only !== void 0) {
|
|
759
|
+
return renderFields(
|
|
760
|
+
colors.green(`Event: ${only.name}`),
|
|
761
|
+
[
|
|
762
|
+
["Signature", renderEventSignature(only)],
|
|
763
|
+
["Description", only.description],
|
|
764
|
+
["Payload schema", only.payload_schema]
|
|
765
|
+
],
|
|
766
|
+
flags
|
|
767
|
+
);
|
|
768
|
+
}
|
|
769
|
+
if (data.events.length === 0 && data.total > 0) {
|
|
770
|
+
return [
|
|
771
|
+
colors.green("Events"),
|
|
772
|
+
` No events at offset ${data.offset ?? 0}; ${data.total} matching event${data.total === 1 ? "" : "s"} in total.`
|
|
773
|
+
];
|
|
774
|
+
}
|
|
775
|
+
if (data.events.length === 0) {
|
|
776
|
+
return [
|
|
777
|
+
colors.green("Events"),
|
|
778
|
+
data.name === void 0 ? " No events declared." : ` No events match ${JSON.stringify(data.name)}.`
|
|
779
|
+
];
|
|
780
|
+
}
|
|
781
|
+
const lines = data.events.flatMap((event) => [
|
|
782
|
+
` ${renderEventSignature(event)}`,
|
|
783
|
+
` ${summarizeToolDescription(event.description)}`
|
|
784
|
+
]);
|
|
785
|
+
return [
|
|
786
|
+
colors.green("Events"),
|
|
787
|
+
...lines,
|
|
788
|
+
...renderEventsTruncationLine(data),
|
|
789
|
+
"",
|
|
790
|
+
"Run `appduct events ls --name <name>` for an event's full payload schema."
|
|
791
|
+
];
|
|
792
|
+
};
|
|
738
793
|
var renderInvokeData = (colors, data, flags) => {
|
|
739
794
|
return [colors.green("Result"), formatScalar(data, flags)];
|
|
740
795
|
};
|
|
@@ -926,6 +981,8 @@ var renderSuccessData = (colors, command, data, options) => {
|
|
|
926
981
|
return renderToolsListData(colors, data, flags, options.full);
|
|
927
982
|
case "tools describe":
|
|
928
983
|
return renderToolDetail(colors, data, flags);
|
|
984
|
+
case "events ls":
|
|
985
|
+
return renderEventsListData(colors, data, flags);
|
|
929
986
|
case "tools call":
|
|
930
987
|
return renderInvokeData(colors, data, flags);
|
|
931
988
|
case "sessions revoke":
|
|
@@ -2,8 +2,5 @@
|
|
|
2
2
|
* Route for `appduct events` — itself a router over the events verbs, so `events tail` loads only
|
|
3
3
|
* `tail.ts` (issue #96). cac matches only the noun (`cli/create-cli.ts`), so the verb arrives here
|
|
4
4
|
* as the first positional rather than as a cac command of its own.
|
|
5
|
-
*
|
|
6
|
-
* `ls` is reserved for the catalog issue #95 adds; until it lands, `events ls` falls through to
|
|
7
|
-
* `unknown` below like any other unrecognized verb, naming `tail`/`since` as the ones that exist.
|
|
8
5
|
*/
|
|
9
6
|
export declare const route: import("../../router.js").Route;
|
|
@@ -213,6 +213,7 @@ var formatJson = (value, flags) => {
|
|
|
213
213
|
import pc from "picocolors";
|
|
214
214
|
import {
|
|
215
215
|
formatAgentWebSocketUrl,
|
|
216
|
+
renderEventSignature,
|
|
216
217
|
renderToolSignature,
|
|
217
218
|
summarizeToolDescription
|
|
218
219
|
} from "@appduct/shared";
|
|
@@ -308,6 +309,13 @@ var formatDevice = (device) => {
|
|
|
308
309
|
const label = parts.length > 0 ? parts.join(" ") : "unknown device";
|
|
309
310
|
return device.os ? `${label} (${device.os})` : label;
|
|
310
311
|
};
|
|
312
|
+
var SUSPEND_REASON_LABELS = {
|
|
313
|
+
app_backgrounded: "app in background",
|
|
314
|
+
connection_lost: "connection lost"
|
|
315
|
+
};
|
|
316
|
+
var formatSessionState = (session) => {
|
|
317
|
+
return session.suspendReason ? `${session.state} (${SUSPEND_REASON_LABELS[session.suspendReason]})` : session.state;
|
|
318
|
+
};
|
|
311
319
|
var renderLsData = (colors, data, now) => {
|
|
312
320
|
if (data.length === 0) {
|
|
313
321
|
return [colors.dim("Sessions"), " No Appduct sessions are registered."];
|
|
@@ -316,7 +324,7 @@ var renderLsData = (colors, data, now) => {
|
|
|
316
324
|
const headers = ["Alias", "State", "Device", "Tools", "Age"];
|
|
317
325
|
const rows = data.map((session) => [
|
|
318
326
|
session.alias,
|
|
319
|
-
session
|
|
327
|
+
formatSessionState(session),
|
|
320
328
|
formatDevice(session.device),
|
|
321
329
|
String(session.toolCount),
|
|
322
330
|
formatAge(session.claimedAt ?? session.createdAt, nowIso)
|
|
@@ -490,6 +498,53 @@ var renderToolsListData = (colors, data, flags, full) => {
|
|
|
490
498
|
}
|
|
491
499
|
return full ? renderToolsFullListing(colors, data, flags) : renderToolSummaryTable(colors, data);
|
|
492
500
|
};
|
|
501
|
+
var renderEventsTruncationLine = (data) => {
|
|
502
|
+
const offset = data.offset ?? 0;
|
|
503
|
+
if (data.events.length >= data.total) {
|
|
504
|
+
return [];
|
|
505
|
+
}
|
|
506
|
+
return [
|
|
507
|
+
"",
|
|
508
|
+
`Showing ${data.events.length} of ${data.total} events (offset ${offset}). Narrow with --name <glob> or page with --offset <n>.`
|
|
509
|
+
];
|
|
510
|
+
};
|
|
511
|
+
var renderEventsListData = (colors, data, flags) => {
|
|
512
|
+
const [only] = data.events;
|
|
513
|
+
if (data.name !== void 0 && !data.name.includes("*") && only !== void 0) {
|
|
514
|
+
return renderFields(
|
|
515
|
+
colors.green(`Event: ${only.name}`),
|
|
516
|
+
[
|
|
517
|
+
["Signature", renderEventSignature(only)],
|
|
518
|
+
["Description", only.description],
|
|
519
|
+
["Payload schema", only.payload_schema]
|
|
520
|
+
],
|
|
521
|
+
flags
|
|
522
|
+
);
|
|
523
|
+
}
|
|
524
|
+
if (data.events.length === 0 && data.total > 0) {
|
|
525
|
+
return [
|
|
526
|
+
colors.green("Events"),
|
|
527
|
+
` No events at offset ${data.offset ?? 0}; ${data.total} matching event${data.total === 1 ? "" : "s"} in total.`
|
|
528
|
+
];
|
|
529
|
+
}
|
|
530
|
+
if (data.events.length === 0) {
|
|
531
|
+
return [
|
|
532
|
+
colors.green("Events"),
|
|
533
|
+
data.name === void 0 ? " No events declared." : ` No events match ${JSON.stringify(data.name)}.`
|
|
534
|
+
];
|
|
535
|
+
}
|
|
536
|
+
const lines = data.events.flatMap((event) => [
|
|
537
|
+
` ${renderEventSignature(event)}`,
|
|
538
|
+
` ${summarizeToolDescription(event.description)}`
|
|
539
|
+
]);
|
|
540
|
+
return [
|
|
541
|
+
colors.green("Events"),
|
|
542
|
+
...lines,
|
|
543
|
+
...renderEventsTruncationLine(data),
|
|
544
|
+
"",
|
|
545
|
+
"Run `appduct events ls --name <name>` for an event's full payload schema."
|
|
546
|
+
];
|
|
547
|
+
};
|
|
493
548
|
var renderInvokeData = (colors, data, flags) => {
|
|
494
549
|
return [colors.green("Result"), formatScalar(data, flags)];
|
|
495
550
|
};
|
|
@@ -681,6 +736,8 @@ var renderSuccessData = (colors, command, data, options) => {
|
|
|
681
736
|
return renderToolsListData(colors, data, flags, options.full);
|
|
682
737
|
case "tools describe":
|
|
683
738
|
return renderToolDetail(colors, data, flags);
|
|
739
|
+
case "events ls":
|
|
740
|
+
return renderEventsListData(colors, data, flags);
|
|
684
741
|
case "tools call":
|
|
685
742
|
return renderInvokeData(colors, data, flags);
|
|
686
743
|
case "sessions revoke":
|
|
@@ -828,12 +885,13 @@ var createRouter = (table, options) => {
|
|
|
828
885
|
// src/cli/routes/events/index.ts
|
|
829
886
|
var route = createRouter(
|
|
830
887
|
{
|
|
888
|
+
ls: () => import("./ls.js"),
|
|
831
889
|
tail: () => import("./tail.js"),
|
|
832
890
|
since: () => import("./since.js")
|
|
833
891
|
},
|
|
834
892
|
{
|
|
835
893
|
unknown: (verb) => usageError(
|
|
836
|
-
`The events command requires a verb: tail or since (got ${verb === void 0 ? "none" : `"${verb}"`}).`
|
|
894
|
+
`The events command requires a verb: ls, tail, or since (got ${verb === void 0 ? "none" : `"${verb}"`}).`
|
|
837
895
|
)
|
|
838
896
|
}
|
|
839
897
|
);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Route for `appduct events ls` — loaded by `routes/events/index.ts`'s router only when it runs
|
|
2
|
+
* (issue #124). Takes `--name <glob>`, `--limit` and `--offset` but not `--payload-max-bytes`, which only means something for
|
|
3
|
+
* a posted event's payload. */
|
|
4
|
+
import type { Route } from "../../router.js";
|
|
5
|
+
export declare const route: Route;
|