deepline 0.3.573 → 0.3.575
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/bundling-sources/sdk/src/config.ts +19 -0
- package/dist/bundling-sources/sdk/src/play.ts +7 -4
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/types.ts +8 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +0 -18
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +8 -0
- package/dist/bundling-sources/shared_libs/play-runtime/builtin-pacing.ts +18 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +4 -1
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-receipt-gateway.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/vercel-fly-rollback-alignment.ts +0 -14
- package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +4 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +43 -7
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +56 -20
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +45 -7
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +6 -66
- package/dist/cli/agents-BCLO3KQJ.js +996 -0
- package/dist/cli/agents-ULGDKUTM.mjs +996 -0
- package/dist/cli/{auth-XX3HLRQ2.mjs → auth-4WCL7A6W.mjs} +5 -5
- package/dist/cli/auth-DXUHEL5I.js +44 -0
- package/dist/cli/{billing-QASEPOBL.mjs → billing-7JQ6EUQU.mjs} +10 -10
- package/dist/cli/{billing-6TY2HMC6.js → billing-BF5LVXOM.js} +106 -106
- package/dist/cli/{chunk-NUH56LTU.mjs → chunk-2T7XOKVL.mjs} +5 -5
- package/dist/cli/{chunk-KQZBN7TB.js → chunk-2UM3I2MY.js} +1 -1
- package/dist/cli/{chunk-MQOJ7SP4.mjs → chunk-3PVKXUSJ.mjs} +9 -1
- package/dist/cli/{chunk-6JTJP3WO.mjs → chunk-56N3XAT6.mjs} +5 -5
- package/dist/cli/{chunk-T2QI52F2.mjs → chunk-5D7OJY4W.mjs} +1 -1
- package/dist/cli/{chunk-JAW75RAO.js → chunk-5H6254MJ.js} +27 -20
- package/dist/cli/{chunk-N3VZTISZ.js → chunk-5VSHQG5E.js} +8 -8
- package/dist/cli/{chunk-KART6FR6.js → chunk-636GD4IR.js} +2 -2
- package/dist/cli/{chunk-XWO4J34B.js → chunk-6IKLITVH.js} +6 -6
- package/dist/cli/{chunk-Z6KWSBOX.js → chunk-737Y7QGT.js} +41 -41
- package/dist/cli/{chunk-XVFRNNL2.js → chunk-7DLAJ6JJ.js} +53 -53
- package/dist/cli/{chunk-GWPXWKQR.js → chunk-AO56MZ7D.js} +15 -7
- package/dist/cli/{chunk-DIZI5YGW.js → chunk-AS5XGOZY.js} +2 -2
- package/dist/cli/{chunk-ESKNCTFI.mjs → chunk-BM536WWR.mjs} +1 -1
- package/dist/cli/{chunk-LPYUGPTF.mjs → chunk-BONMEBWZ.mjs} +4 -4
- package/dist/cli/{chunk-4LWBURSS.mjs → chunk-BQUAE6LQ.mjs} +1 -1
- package/dist/cli/{chunk-QDQOXHXQ.mjs → chunk-CVY4MBXH.mjs} +5 -5
- package/dist/cli/{chunk-N6KF6X3D.js → chunk-DMPGJCNZ.js} +177 -6
- package/dist/cli/{chunk-ENHQBPR5.mjs → chunk-DWUESXDD.mjs} +4 -3
- package/dist/cli/{chunk-5NEJOCOK.mjs → chunk-E4RYSSXX.mjs} +2 -2
- package/dist/cli/{chunk-IZK2BLBW.js → chunk-EV3OPDHF.js} +20 -20
- package/dist/cli/{chunk-YKHXWO7N.js → chunk-EZIXKNKM.js} +3 -3
- package/dist/cli/{chunk-64MOX3SN.mjs → chunk-FDCU3VAJ.mjs} +174 -3
- package/dist/cli/{chunk-X3BGF6UU.js → chunk-FXXERR52.js} +10 -10
- package/dist/cli/{chunk-BM4GE67C.mjs → chunk-FYKHAT2F.mjs} +81 -7
- package/dist/cli/{chunk-UNTBQY64.js → chunk-G2H6SQQY.js} +11 -11
- package/dist/cli/{chunk-WQEGXOUT.js → chunk-G4WPDCXA.js} +48 -48
- package/dist/cli/{chunk-OG3YWDYA.js → chunk-GB4IZ5TV.js} +13 -13
- package/dist/cli/{chunk-N5VL6BHF.mjs → chunk-GQZFZG6R.mjs} +2 -2
- package/dist/cli/{chunk-JCVAVHDP.mjs → chunk-H3CG72RZ.mjs} +21 -16
- package/dist/cli/{chunk-FXLVMWWA.js → chunk-H6JMRLAZ.js} +280 -275
- package/dist/cli/{chunk-UBTEDSIK.js → chunk-HEOM3FAC.js} +20 -20
- package/dist/cli/{chunk-CY3BUFMG.js → chunk-HO76C7AE.js} +2 -2
- package/dist/cli/{chunk-XAIXTB74.mjs → chunk-IAJ65IDZ.mjs} +4 -4
- package/dist/cli/{chunk-ENLJ67CZ.mjs → chunk-IBYMGR5Y.mjs} +1 -1
- package/dist/cli/{chunk-4K6UVILG.mjs → chunk-IOWLFWWG.mjs} +2 -2
- package/dist/cli/{chunk-NJTTRJ32.mjs → chunk-JGLCK2XF.mjs} +2 -2
- package/dist/cli/{chunk-DLWVJ66I.js → chunk-KNCNFL76.js} +4 -4
- package/dist/cli/{chunk-XLN4Z654.mjs → chunk-MN7JLH2T.mjs} +2 -2
- package/dist/cli/{chunk-IXCGWJJZ.mjs → chunk-MWLOBURN.mjs} +2 -2
- package/dist/cli/{chunk-6ASDTHEN.js → chunk-MXK4M7HP.js} +21 -17
- package/dist/cli/{chunk-C52RRBYB.mjs → chunk-NF722E6C.mjs} +1 -1
- package/dist/cli/{chunk-TNCJ2J76.js → chunk-PQYDO72W.js} +26 -26
- package/dist/cli/{chunk-PW3PADXI.mjs → chunk-QEDRUURT.mjs} +1 -1
- package/dist/cli/{chunk-QFDT35HF.mjs → chunk-QKP3WYSZ.mjs} +3 -3
- package/dist/cli/{chunk-M2UJWUWX.mjs → chunk-RHRRY2BX.mjs} +3 -3
- package/dist/cli/{chunk-HUJMFETO.mjs → chunk-RW3URFZK.mjs} +7 -3
- package/dist/cli/{chunk-TBLP7HDL.js → chunk-SKHUWQZE.js} +10 -9
- package/dist/cli/{chunk-WSXRJ2RZ.mjs → chunk-SYQTBHRX.mjs} +3 -3
- package/dist/cli/{chunk-ANSHNREL.mjs → chunk-TMFR2B45.mjs} +3 -3
- package/dist/cli/{chunk-5MCC4D25.mjs → chunk-TTBZ7QXX.mjs} +1 -1
- package/dist/cli/{chunk-ROSPYLDN.mjs → chunk-UQZP7XBQ.mjs} +17 -10
- package/dist/cli/{chunk-TJSKDOXN.js → chunk-V5XLENWK.js} +7 -7
- package/dist/cli/{chunk-DSE45YP4.mjs → chunk-X47J55ZJ.mjs} +2 -2
- package/dist/cli/{chunk-FUVVTHXE.js → chunk-XFV353R2.js} +23 -23
- package/dist/cli/{chunk-OPD6XUIG.js → chunk-YNAXKA23.js} +5 -5
- package/dist/cli/{chunk-LHPYCJNL.js → chunk-ZO65VJRJ.js} +87 -13
- package/dist/cli/{chunk-2USXCXPZ.js → chunk-ZQXJYO5P.js} +5 -5
- package/dist/cli/{chunk-UZLTBBAG.js → chunk-ZS6DT4LD.js} +15 -15
- package/dist/cli/{chunk-KQLIG4YR.js → chunk-ZYSJND73.js} +9 -9
- package/dist/cli/command-docs.js +3 -3
- package/dist/cli/command-docs.mjs +2 -2
- package/dist/cli/{concurrent-runs-help-IILHMHBX.mjs → concurrent-runs-help-HITK6EOO.mjs} +7 -7
- package/dist/cli/concurrent-runs-help-JLWY54WL.js +22 -0
- package/dist/cli/{csv-OSJQVDAS.js → csv-RS7XHQ4P.js} +13 -13
- package/dist/cli/{csv-VGYW2PQZ.mjs → csv-V2T23MXT.mjs} +4 -4
- package/dist/cli/{db-3IQYT3WD.mjs → db-OQ4RNTGE.mjs} +6 -6
- package/dist/cli/{db-2IMS6K2F.js → db-WFIVRPKY.js} +27 -27
- package/dist/cli/describe-33PBWO5O.js +50 -0
- package/dist/cli/{describe-IGJ4CHUC.mjs → describe-AXV2EEX3.mjs} +21 -21
- package/dist/cli/describe-core.d.mts +13 -2
- package/dist/cli/describe-core.d.ts +13 -2
- package/dist/cli/describe-core.js +4 -4
- package/dist/cli/describe-core.mjs +3 -3
- package/dist/cli/{executions-VOJN4NPF.js → executions-5H2RIWZ3.js} +8 -8
- package/dist/cli/{executions-6F3PLVCR.mjs → executions-THP5ZDBQ.mjs} +6 -6
- package/dist/cli/{feedback-BP5G27DT.mjs → feedback-2EJPILGE.mjs} +6 -6
- package/dist/cli/{feedback-5N7GKSMC.js → feedback-UOI6UEGA.js} +14 -14
- package/dist/cli/git-2OPYEPYW.js +26 -0
- package/dist/cli/{git-FHNCP7QA.mjs → git-DI3LJIAT.mjs} +5 -5
- package/dist/cli/index.js +152 -148
- package/dist/cli/index.mjs +51 -47
- package/dist/cli/{integrations-KKCEEWDU.mjs → integrations-DJYS5VRK.mjs} +7 -7
- package/dist/cli/{integrations-JZV55BZT.js → integrations-TYN2BSQ6.js} +29 -29
- package/dist/cli/{legacy-noops-OVOHF47E.js → legacy-noops-GXQHNLGJ.js} +9 -9
- package/dist/cli/{legacy-noops-YOPWDLRG.mjs → legacy-noops-Z457BB6O.mjs} +6 -6
- package/dist/cli/{mcp-SJAXFYTI.mjs → mcp-NAW3GFNN.mjs} +4 -4
- package/dist/cli/{mcp-F2XGBA6W.js → mcp-WMBOOTQL.js} +24 -24
- package/dist/cli/{monitors-PFH3FQLD.mjs → monitors-A7NYAXSJ.mjs} +7 -7
- package/dist/cli/{monitors-RQRNQRYB.js → monitors-OOQVE7XR.js} +100 -100
- package/dist/cli/{org-PZC6SUZD.mjs → org-7YCDUSZE.mjs} +6 -6
- package/dist/cli/{org-WPOEKMTG.js → org-D2AMIVBS.js} +121 -121
- package/dist/cli/{outcomes-EXOCNHOC.js → outcomes-2FKZDJSQ.js} +17 -15
- package/dist/cli/{outcomes-ZS7XD3KQ.mjs → outcomes-TNTKCUEO.mjs} +9 -7
- package/dist/cli/{play-UKSRFVIU.mjs → play-L6CVHSN4.mjs} +88 -33
- package/dist/cli/{play-JS2TEEE7.js → play-NWKHCHVZ.js} +393 -338
- package/dist/cli/{providers-U6IODPMJ.mjs → providers-22LO747B.mjs} +6 -6
- package/dist/cli/{providers-3U4MWBLU.js → providers-PZGOI5CN.js} +9 -9
- package/dist/cli/{quickstart-G5QN5CUE.mjs → quickstart-3ZRVKGMH.mjs} +4 -4
- package/dist/cli/{quickstart-SHBAEDX6.js → quickstart-LLWOC2GR.js} +6 -6
- package/dist/cli/{run-3ZOJ6V7C.mjs → run-D46W2GUA.mjs} +48 -27
- package/dist/cli/{run-SZRKNLUT.js → run-SNF23STR.js} +70 -49
- package/dist/cli/search-H57MZPLF.js +32 -0
- package/dist/cli/{search-2VX5WNMJ.mjs → search-XWVCICIX.mjs} +7 -7
- package/dist/cli/{search-output-WGDHYYHX.js → search-output-36GHD67U.js} +12 -9
- package/dist/cli/{search-output-U5N2O6IA.mjs → search-output-YM5QXFQQ.mjs} +9 -6
- package/dist/cli/{secrets-SQKP5ILO.mjs → secrets-7PTZEFRC.mjs} +6 -6
- package/dist/cli/{secrets-UITJOGVQ.js → secrets-UXCIHG5I.js} +15 -15
- package/dist/cli/{sessions-LSXO2OKX.mjs → sessions-DTXJKRP4.mjs} +6 -6
- package/dist/cli/sessions-JJZMQSH4.js +23 -0
- package/dist/cli/{settings-YGYRDPOK.mjs → settings-74B6UOS4.mjs} +12 -12
- package/dist/cli/{settings-VZI675JG.js → settings-EYSDZE37.js} +85 -85
- package/dist/cli/{setup-GXGXRWKN.mjs → setup-2QRZ36CH.mjs} +9 -9
- package/dist/cli/{setup-OJ33NOWK.js → setup-E7PVXBPL.js} +49 -49
- package/dist/cli/{skills-3VDYIFAX.mjs → skills-2WZ7N3UW.mjs} +7 -7
- package/dist/cli/skills-RIF2DCZI.js +37 -0
- package/dist/cli/tools-7VRQ4GSI.js +57 -0
- package/dist/cli/{tools-3TKEGDBP.mjs → tools-YK5SCUZD.mjs} +19 -19
- package/dist/cli/{update-K6A4QXTC.mjs → update-563YQK53.mjs} +9 -9
- package/dist/cli/update-CMZAIAES.js +37 -0
- package/dist/cli/{views-2PPIVWDK.mjs → views-ISNCRZUP.mjs} +6 -6
- package/dist/cli/{views-SGGO77XS.js → views-OLPS6TPG.js} +21 -21
- package/dist/cli/{workflow-JTG6QEFO.mjs → workflow-B3ZKU3OR.mjs} +7 -7
- package/dist/cli/{workflow-YSFOOTPB.js → workflow-CUSCTYMW.js} +17 -17
- package/dist/{client-DCnExziW.d.ts → client-BrdMPFCM.d.ts} +1 -1
- package/dist/{client-ClJlqkKt.d.mts → client-CF-bsrtI.d.mts} +1 -1
- package/dist/{client-core-DAOPQnGD.d.mts → client-core-DM1ZedOG.d.mts} +8 -0
- package/dist/{client-core-BKq5ZNAl.d.ts → client-core-rMoUWSYM.d.ts} +8 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +128 -126
- package/dist/plays/play-description.d.mts +1 -1
- package/dist/plays/play-description.d.ts +1 -1
- package/dist/plays/run-request.d.mts +1 -1
- package/dist/plays/run-request.d.ts +1 -1
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +5 -5
- package/dist/server.mjs +3 -3
- package/package.json +1 -1
- package/dist/cli/auth-DGR7ZQJL.js +0 -44
- package/dist/cli/concurrent-runs-help-HEIDXAM2.js +0 -22
- package/dist/cli/describe-LBU4I6SU.js +0 -50
- package/dist/cli/git-JUSPUUOH.js +0 -26
- package/dist/cli/search-TAFMLK4K.js +0 -32
- package/dist/cli/sessions-RA6FBIHJ.js +0 -23
- package/dist/cli/skills-J5QVWKLQ.js +0 -37
- package/dist/cli/tools-3PQXQGXL.js +0 -57
- package/dist/cli/update-CA3DZ75E.js +0 -37
- /package/dist/cli/{chunk-2RIKOPIM.mjs → chunk-HECXJBED.mjs} +0 -0
- /package/dist/cli/{chunk-H4ALLC2X.js → chunk-TJCENACZ.js} +0 -0
|
@@ -0,0 +1,996 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkEV3OPDHFjs = require('./chunk-EV3OPDHF.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkAO56MZ7Djs = require('./chunk-AO56MZ7D.js');
|
|
8
|
+
require('./chunk-KNCNFL76.js');
|
|
9
|
+
require('./chunk-6VLFQZK6.js');
|
|
10
|
+
require('./chunk-XNYIZMNQ.js');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _chunkLFQJW4S2js = require('./chunk-LFQJW4S2.js');
|
|
14
|
+
require('./chunk-CFJFUVX2.js');
|
|
15
|
+
require('./chunk-2UM3I2MY.js');
|
|
16
|
+
require('./chunk-OG64RBAC.js');
|
|
17
|
+
require('./chunk-COGTRVWW.js');
|
|
18
|
+
|
|
19
|
+
// src/cli/commands/agents.ts
|
|
20
|
+
var _fs = require('fs');
|
|
21
|
+
var _process = require('process');
|
|
22
|
+
var _promises = require('readline/promises');
|
|
23
|
+
var _commander = require('commander');
|
|
24
|
+
var AGENT_FEATURE = "agent";
|
|
25
|
+
var AGENT_PATH = "/api/v2/agent";
|
|
26
|
+
var TEST_TIMEOUT_MS = 3e5;
|
|
27
|
+
var TEST_SPEAKER = /^[A-Za-z0-9][A-Za-z0-9._-]{0,39}$/;
|
|
28
|
+
var PLATFORMS = ["slack", "test"];
|
|
29
|
+
var MODEL_PROVIDERS = ["openai", "anthropic"];
|
|
30
|
+
var MODEL_PROVIDER_NAMES = {
|
|
31
|
+
openai: "OpenAI",
|
|
32
|
+
anthropic: "Anthropic"
|
|
33
|
+
};
|
|
34
|
+
var REPLIES_MAX_LIMIT = 100;
|
|
35
|
+
var REPLIES_INVALID_CURSOR = "DEEPLINE_AGENT_REPLIES_INVALID_CURSOR";
|
|
36
|
+
var FEEDBACK_MAX_LIMIT = 100;
|
|
37
|
+
var FEEDBACK_INVALID_CURSOR = "DEEPLINE_AGENT_FEEDBACK_INVALID_CURSOR";
|
|
38
|
+
var AgentUsageError = (_class = class extends Error {
|
|
39
|
+
__init() {this.code = "AGENT_USAGE_ERROR"}
|
|
40
|
+
__init2() {this.exitCode = 2}
|
|
41
|
+
constructor(message) {
|
|
42
|
+
super(message);_class.prototype.__init.call(this);_class.prototype.__init2.call(this);;
|
|
43
|
+
this.name = "AgentUsageError";
|
|
44
|
+
}
|
|
45
|
+
}, _class);
|
|
46
|
+
var AgentTurnFailedError = (_class2 = class extends Error {
|
|
47
|
+
__init3() {this.code = "AGENT_TURN_FAILED"}
|
|
48
|
+
__init4() {this.exitCode = 5}
|
|
49
|
+
constructor(message) {
|
|
50
|
+
super(message);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);;
|
|
51
|
+
this.name = "AgentTurnFailedError";
|
|
52
|
+
}
|
|
53
|
+
}, _class2);
|
|
54
|
+
function requireArgument(value, what) {
|
|
55
|
+
const trimmed = value.trim();
|
|
56
|
+
if (!trimmed) throw new AgentUsageError(`Pass ${what}.`);
|
|
57
|
+
return trimmed;
|
|
58
|
+
}
|
|
59
|
+
function requirePlatform(value) {
|
|
60
|
+
if (value === void 0) return void 0;
|
|
61
|
+
if (!PLATFORMS.includes(value)) {
|
|
62
|
+
throw new AgentUsageError("--platform is slack or test.");
|
|
63
|
+
}
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
function firstLine(text, max = 100) {
|
|
67
|
+
const line = _nullishCoalesce(text.split("\n")[0], () => ( ""));
|
|
68
|
+
return line.length > max ? `${line.slice(0, max - 1)}\u2026` : line;
|
|
69
|
+
}
|
|
70
|
+
function describeConversation(conversation) {
|
|
71
|
+
const where = conversation.platform === "slack" ? `#${conversation.conversationName}` : `test ${conversation.conversationName}`;
|
|
72
|
+
const settings = [
|
|
73
|
+
...conversation.model ? [`model ${conversation.model}`] : [],
|
|
74
|
+
...conversation.outcome ? [
|
|
75
|
+
`${conversation.outcome.role === "home" ? "home of" : "linked to"} outcome ${conversation.outcome.slug}`
|
|
76
|
+
] : []
|
|
77
|
+
];
|
|
78
|
+
return `${where} (${conversation.conversationId}${settings.length ? `; ${settings.join("; ")}` : ""})`;
|
|
79
|
+
}
|
|
80
|
+
function parseModel(value) {
|
|
81
|
+
if (value === void 0) return void 0;
|
|
82
|
+
const model = value.trim();
|
|
83
|
+
return model === "" || model.toLowerCase() === "default" ? null : model;
|
|
84
|
+
}
|
|
85
|
+
function describeOutcomeChange(change) {
|
|
86
|
+
const { conversation } = change;
|
|
87
|
+
const where = `#${conversation.conversationName}`;
|
|
88
|
+
if (!conversation.outcome) {
|
|
89
|
+
return [
|
|
90
|
+
change.changed ? `${change.agentName} no longer works toward an outcome in ${where}.` : `${change.agentName} works toward no outcome in ${where}.`
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
const { slug, role } = conversation.outcome;
|
|
94
|
+
return [
|
|
95
|
+
role === "home" ? `${where} is the home of outcome ${slug}: ${change.agentName} works toward it there.` : `${where} is linked to outcome ${slug}: ${change.agentName} answers there with it in view.`,
|
|
96
|
+
role === "linked" ? "It is woken in the outcome\u2019s home channel, not here." : change.woken ? "It is woken when something on the outcome concerns it: a schedule firing, a task for it, an answered ask." : "It is not woken between mentions here: this deployment\u2019s app cannot be rung.",
|
|
97
|
+
`See the outcome with: deepline outcomes describe ${slug}`
|
|
98
|
+
];
|
|
99
|
+
}
|
|
100
|
+
function describeAgentLine(agent) {
|
|
101
|
+
const channels = agent.conversations.length ? agent.conversations.map(describeConversation).join(", ") : "no channels";
|
|
102
|
+
const skills = agent.skillNames.length ? `skills: ${agent.skillNames.join(", ")}` : "no skills";
|
|
103
|
+
return `${agent.name} \u2014 ${firstLine(agent.instructions, 60)} [${skills}; ${channels}]`;
|
|
104
|
+
}
|
|
105
|
+
function describeAgent(agent) {
|
|
106
|
+
return [
|
|
107
|
+
`Agent ${agent.name} (created by ${agent.ownerUserId})`,
|
|
108
|
+
"Instructions:",
|
|
109
|
+
...agent.instructions.split("\n").map((line) => ` ${line}`),
|
|
110
|
+
`Skills: ${agent.skillNames.length ? agent.skillNames.join(", ") : "none"}`,
|
|
111
|
+
`Model: ${_nullishCoalesce(agent.model, () => ( "the default (see deepline agents models)"))}`,
|
|
112
|
+
agent.conversations.length ? `Channels: ${agent.conversations.map(describeConversation).join(", ")}` : `Channels: none. Bind one with: deepline agents channels add ${agent.name} <channel-id>`
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
function describeOverview(overview) {
|
|
116
|
+
const { workspace } = overview;
|
|
117
|
+
if (!workspace) {
|
|
118
|
+
return [
|
|
119
|
+
"Agents are not set up. An admin turns them on with: deepline agents enable"
|
|
120
|
+
];
|
|
121
|
+
}
|
|
122
|
+
return [
|
|
123
|
+
`Agents: ${workspace.lifecycle}${workspace.hasServiceAccountKey ? "" : " (service account key missing; an admin runs deepline agents enable)"}`,
|
|
124
|
+
workspace.billing ? `Model billing: your ${MODEL_PROVIDER_NAMES[workspace.billing.provider]} key ending ${workspace.billing.keyLast4}` : "Model billing: not set. An admin runs: deepline agents billing set < key.txt",
|
|
125
|
+
...overview.agents.length ? [
|
|
126
|
+
"Agents:",
|
|
127
|
+
...overview.agents.map((agent) => ` ${describeAgentLine(agent)}`)
|
|
128
|
+
] : [
|
|
129
|
+
'Agents: none. Create one with: deepline agents create <name> --instructions "..."'
|
|
130
|
+
],
|
|
131
|
+
...overview.skills.length ? [
|
|
132
|
+
"Skill library:",
|
|
133
|
+
...overview.skills.map(
|
|
134
|
+
(skill) => ` ${skill.name} \u2014 ${firstLine(skill.description, 80)}`
|
|
135
|
+
)
|
|
136
|
+
] : [
|
|
137
|
+
"Skill library: empty. Add one with: deepline agents skills set <name> --file SKILL.md"
|
|
138
|
+
]
|
|
139
|
+
];
|
|
140
|
+
}
|
|
141
|
+
function print(payload, title, lines, options) {
|
|
142
|
+
_chunkEV3OPDHFjs.printCommandEnvelope.call(void 0,
|
|
143
|
+
{ ...payload, render: { sections: [{ title, lines }] } },
|
|
144
|
+
{ json: options.json }
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
function printDryRun(method, path, body, options) {
|
|
148
|
+
print(
|
|
149
|
+
{ dry_run: true, request: { method, path, body } },
|
|
150
|
+
"dry run",
|
|
151
|
+
[`Would send ${method} ${path}${body ? ` ${JSON.stringify(body)}` : ""}`],
|
|
152
|
+
options
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
function readFileOption(path, flag) {
|
|
156
|
+
try {
|
|
157
|
+
return _fs.readFileSync.call(void 0, path, "utf8");
|
|
158
|
+
} catch (error) {
|
|
159
|
+
throw new AgentUsageError(
|
|
160
|
+
`Could not read ${flag} ${path}: ${error instanceof Error ? error.message : String(error)}`
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function readInstructions(options) {
|
|
165
|
+
if (options.instructions !== void 0 && options.instructionsFile !== void 0) {
|
|
166
|
+
throw new AgentUsageError(
|
|
167
|
+
"Pass --instructions or --instructions-file, not both."
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
if (options.instructionsFile !== void 0) {
|
|
171
|
+
return readFileOption(options.instructionsFile, "--instructions-file");
|
|
172
|
+
}
|
|
173
|
+
return options.instructions;
|
|
174
|
+
}
|
|
175
|
+
function parseSkills(value) {
|
|
176
|
+
if (value === void 0) return void 0;
|
|
177
|
+
return value.split(",").map((name) => name.trim()).filter(Boolean);
|
|
178
|
+
}
|
|
179
|
+
function parseSkillFile(text) {
|
|
180
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text);
|
|
181
|
+
if (!match) return { markdown: text, description: null };
|
|
182
|
+
const line = _nullishCoalesce(_optionalChain([/^description:\s*(.+)$/m, 'access', _ => _.exec, 'call', _2 => _2(match[1]), 'optionalAccess', _3 => _3[1], 'optionalAccess', _4 => _4.trim, 'call', _5 => _5()]), () => ( null));
|
|
183
|
+
const description = line && /^(['"]).*\1$/.test(line) ? line.slice(1, -1) : line;
|
|
184
|
+
return { markdown: text.slice(match[0].length), description };
|
|
185
|
+
}
|
|
186
|
+
async function promptHidden(prompt) {
|
|
187
|
+
_process.stderr.write(prompt);
|
|
188
|
+
_process.stdin.setRawMode(true);
|
|
189
|
+
_process.stdin.resume();
|
|
190
|
+
_process.stdin.setEncoding("utf8");
|
|
191
|
+
try {
|
|
192
|
+
return await new Promise((resolve, reject) => {
|
|
193
|
+
let value = "";
|
|
194
|
+
const onData = (chunk) => {
|
|
195
|
+
for (const char of chunk) {
|
|
196
|
+
if (char === "\r" || char === "\n") {
|
|
197
|
+
_process.stdin.off("data", onData);
|
|
198
|
+
_process.stderr.write("\n");
|
|
199
|
+
resolve(value);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (char === "") {
|
|
203
|
+
_process.stdin.off("data", onData);
|
|
204
|
+
_process.stderr.write("\n");
|
|
205
|
+
reject(new AgentUsageError("Cancelled."));
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (char === "\x7F" || char === "\b") {
|
|
209
|
+
value = value.slice(0, -1);
|
|
210
|
+
} else {
|
|
211
|
+
value += char;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
_process.stdin.on("data", onData);
|
|
216
|
+
});
|
|
217
|
+
} finally {
|
|
218
|
+
_process.stdin.setRawMode(false);
|
|
219
|
+
_process.stdin.pause();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function keyProvider(apiKey) {
|
|
223
|
+
return apiKey.startsWith("sk-ant-") ? "anthropic" : "openai";
|
|
224
|
+
}
|
|
225
|
+
async function readModelKey() {
|
|
226
|
+
if (_process.stdin.isTTY) {
|
|
227
|
+
return (await promptHidden("OpenAI or Anthropic API key (hidden): ")).trim();
|
|
228
|
+
}
|
|
229
|
+
const chunks = [];
|
|
230
|
+
for await (const chunk of _process.stdin) {
|
|
231
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
232
|
+
}
|
|
233
|
+
return Buffer.concat(chunks).toString("utf8").trim();
|
|
234
|
+
}
|
|
235
|
+
async function sendTestMessage(input2) {
|
|
236
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
237
|
+
return http.post(
|
|
238
|
+
`${AGENT_PATH}/test`,
|
|
239
|
+
{
|
|
240
|
+
channel_id: requireArgument(
|
|
241
|
+
input2.channelId,
|
|
242
|
+
"a channel id such as C0123456789"
|
|
243
|
+
),
|
|
244
|
+
message: input2.message,
|
|
245
|
+
...input2.platform ? { platform: input2.platform } : {},
|
|
246
|
+
...input2.threadId ? { thread_id: input2.threadId } : {},
|
|
247
|
+
...input2.speaker ? { speaker: input2.speaker } : {}
|
|
248
|
+
},
|
|
249
|
+
void 0,
|
|
250
|
+
// A resent message would make the agent act twice.
|
|
251
|
+
{ timeout: TEST_TIMEOUT_MS, maxRetries: 0 }
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
function describeReply(channelId, reply, inChat = false) {
|
|
255
|
+
if (reply.status === "awaiting_answer" && reply.question) {
|
|
256
|
+
const { prompt, options } = reply.question;
|
|
257
|
+
return [
|
|
258
|
+
...reply.reply ? [reply.reply] : [],
|
|
259
|
+
`The agent asks: ${prompt}`,
|
|
260
|
+
...options.length > 0 ? [`Options: ${options.join(" | ")}`] : [],
|
|
261
|
+
...inChat ? [] : [
|
|
262
|
+
`Answer: deepline agents test ${channelId} "<answer>" --thread ${reply.threadId}`
|
|
263
|
+
]
|
|
264
|
+
];
|
|
265
|
+
}
|
|
266
|
+
if (reply.status === "failed") {
|
|
267
|
+
return [`The agent failed: ${_nullishCoalesce(reply.error, () => ( "no reason given"))}`];
|
|
268
|
+
}
|
|
269
|
+
return [
|
|
270
|
+
_nullishCoalesce(reply.reply, () => ( "(no reply)")),
|
|
271
|
+
...inChat ? [] : [
|
|
272
|
+
`Continue: deepline agents test ${channelId} "<message>" --thread ${reply.threadId}`
|
|
273
|
+
]
|
|
274
|
+
];
|
|
275
|
+
}
|
|
276
|
+
async function handleTest(channelId, words, options) {
|
|
277
|
+
const message = words.join(" ").trim();
|
|
278
|
+
if (!message) throw new AgentUsageError("Pass a message to send.");
|
|
279
|
+
const speaker = _optionalChain([options, 'access', _6 => _6.as, 'optionalAccess', _7 => _7.trim, 'call', _8 => _8()]);
|
|
280
|
+
if (options.as !== void 0 && !TEST_SPEAKER.test(_nullishCoalesce(speaker, () => ( "")))) {
|
|
281
|
+
throw new AgentUsageError(
|
|
282
|
+
"--as takes a short name: letters, digits, dot, dash or underscore, at most 40 characters."
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
const reply = await sendTestMessage({
|
|
286
|
+
channelId,
|
|
287
|
+
platform: requirePlatform(options.platform),
|
|
288
|
+
message,
|
|
289
|
+
threadId: _nullishCoalesce(options.thread, () => ( null)),
|
|
290
|
+
speaker
|
|
291
|
+
});
|
|
292
|
+
print(reply, "agent reply", describeReply(channelId, reply), options);
|
|
293
|
+
if (reply.status === "failed") {
|
|
294
|
+
throw new AgentTurnFailedError(_nullishCoalesce(reply.error, () => ( "The agent failed.")));
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
async function handleChat(channelId, options) {
|
|
298
|
+
if (!_process.stdin.isTTY) {
|
|
299
|
+
throw new AgentUsageError(
|
|
300
|
+
'chat needs a terminal. In scripts use: deepline agents test <channel-id> "<message>" --thread <id>'
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
const platform = requirePlatform(options.platform);
|
|
304
|
+
const rl = _promises.createInterface.call(void 0, { input: _process.stdin, output: _process.stderr });
|
|
305
|
+
let threadId = null;
|
|
306
|
+
_process.stderr.write(
|
|
307
|
+
"Talking to the agent as an @mention in this channel. Ctrl-D to quit.\n"
|
|
308
|
+
);
|
|
309
|
+
try {
|
|
310
|
+
for (; ; ) {
|
|
311
|
+
let line;
|
|
312
|
+
try {
|
|
313
|
+
line = (await rl.question("you> ")).trim();
|
|
314
|
+
} catch (e) {
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
if (!line) continue;
|
|
318
|
+
const reply = await sendTestMessage({
|
|
319
|
+
channelId,
|
|
320
|
+
platform,
|
|
321
|
+
message: line,
|
|
322
|
+
threadId
|
|
323
|
+
});
|
|
324
|
+
threadId = reply.threadId;
|
|
325
|
+
const text = describeReply(channelId, reply, true).map((line2) => `agent> ${line2}
|
|
326
|
+
`).join("");
|
|
327
|
+
_chunkEV3OPDHFjs.printCommandEnvelope.call(void 0, reply, { json: false, text });
|
|
328
|
+
}
|
|
329
|
+
} finally {
|
|
330
|
+
rl.close();
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
function registerWorkspaceCommands(agents, readKey) {
|
|
334
|
+
agents.command("list").description(
|
|
335
|
+
"Show whether agents are on, their model billing, every agent with its channels, and the skill library."
|
|
336
|
+
).option("--json", "Emit JSON output").action(async (options) => {
|
|
337
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
338
|
+
const overview = await http.get(AGENT_PATH);
|
|
339
|
+
print(overview, "deepline agents", describeOverview(overview), options);
|
|
340
|
+
});
|
|
341
|
+
agents.command("enable").description(
|
|
342
|
+
"Turn agents on for the workspace (admins). The first run creates the deepline-agent service account every agent acts as."
|
|
343
|
+
).option("--dry-run", "Print the request without sending it").option("--json", "Emit JSON output").action(async (options) => {
|
|
344
|
+
if (options.dryRun) {
|
|
345
|
+
printDryRun("POST", `${AGENT_PATH}/enable`, {}, options);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
349
|
+
const result = await http.post(
|
|
350
|
+
`${AGENT_PATH}/enable`,
|
|
351
|
+
{}
|
|
352
|
+
);
|
|
353
|
+
print(
|
|
354
|
+
result,
|
|
355
|
+
"agents enabled",
|
|
356
|
+
[
|
|
357
|
+
result.created ? "Created the deepline-agent service account." : "Already set up.",
|
|
358
|
+
...describeOverview(result.overview)
|
|
359
|
+
],
|
|
360
|
+
options
|
|
361
|
+
);
|
|
362
|
+
});
|
|
363
|
+
agents.command("disable").description(
|
|
364
|
+
"Turn every agent in the workspace off (admins). Agents, skills, channels and keys stay."
|
|
365
|
+
).option("--dry-run", "Print the request without sending it").option("--json", "Emit JSON output").action(async (options) => {
|
|
366
|
+
if (options.dryRun) {
|
|
367
|
+
printDryRun("POST", `${AGENT_PATH}/disable`, {}, options);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
371
|
+
const result = await http.post(
|
|
372
|
+
`${AGENT_PATH}/disable`,
|
|
373
|
+
{}
|
|
374
|
+
);
|
|
375
|
+
print(
|
|
376
|
+
result,
|
|
377
|
+
"agents disabled",
|
|
378
|
+
[
|
|
379
|
+
result.changed ? "Turned off." : "Already off.",
|
|
380
|
+
...describeOverview(result.overview)
|
|
381
|
+
],
|
|
382
|
+
options
|
|
383
|
+
);
|
|
384
|
+
});
|
|
385
|
+
const billing = agents.command("billing").description("Set who pays for every agent\u2019s model calls.");
|
|
386
|
+
billing.command("set").description(
|
|
387
|
+
"Run every agent on your OpenAI or Anthropic key (admins). Reads the key from piped stdin, or a hidden prompt; never from arguments."
|
|
388
|
+
).argument("[forbidden...]", "Do not pass the key here").addOption(
|
|
389
|
+
new (0, _commander.Option)(
|
|
390
|
+
"--provider <provider>",
|
|
391
|
+
"Whose key it is; read from the key when omitted (sk-ant-\u2026 is Anthropic)"
|
|
392
|
+
).choices(MODEL_PROVIDERS)
|
|
393
|
+
).option("--json", "Emit JSON output").action(
|
|
394
|
+
async (forbidden, options) => {
|
|
395
|
+
if ((_nullishCoalesce(forbidden, () => ( []))).length > 0) {
|
|
396
|
+
throw new AgentUsageError(
|
|
397
|
+
"Do not pass the key as an argument. Pipe it in (deepline agents billing set < key.txt) or type it at the hidden prompt."
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
const apiKey = await readKey();
|
|
401
|
+
if (!apiKey) throw new AgentUsageError("No key was given.");
|
|
402
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
403
|
+
const overview = await http.put(`${AGENT_PATH}/billing`, {
|
|
404
|
+
mode: "own_key",
|
|
405
|
+
provider: _nullishCoalesce(options.provider, () => ( keyProvider(apiKey))),
|
|
406
|
+
api_key: apiKey
|
|
407
|
+
});
|
|
408
|
+
print(overview, "agents billing", describeOverview(overview), options);
|
|
409
|
+
}
|
|
410
|
+
);
|
|
411
|
+
agents.command("models").description(
|
|
412
|
+
"List the models an agent or one of its channels can run on, and which your workspace\u2019s key can run."
|
|
413
|
+
).option("--json", "Emit JSON output").action(async (options) => {
|
|
414
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
415
|
+
const result = await http.get(
|
|
416
|
+
`${AGENT_PATH}/models`
|
|
417
|
+
);
|
|
418
|
+
const keySet = result.models.some((model) => model.available);
|
|
419
|
+
print(
|
|
420
|
+
result,
|
|
421
|
+
"agent models",
|
|
422
|
+
[
|
|
423
|
+
...keySet ? [] : [
|
|
424
|
+
"No model key is set, so no model can run yet. An admin runs: deepline agents billing set < key.txt"
|
|
425
|
+
],
|
|
426
|
+
...result.models.map(
|
|
427
|
+
(model) => `${model.id} \u2014 ${model.label}${model.id === result.default ? " (the default)" : ""}; say: ${model.aliases.join(", ")}; ${model.available ? "ready" : keySet ? `runs on an ${MODEL_PROVIDER_NAMES[model.provider]} key, which is not the key your agents run on` : `runs on an ${MODEL_PROVIDER_NAMES[model.provider]} key`}`
|
|
428
|
+
),
|
|
429
|
+
"Set an agent\u2019s model with: deepline agents update <agent> --model <model>",
|
|
430
|
+
"Set one channel\u2019s with: deepline agents channels set <channel-id> --model <model>, or ask the agent there to switch."
|
|
431
|
+
],
|
|
432
|
+
options
|
|
433
|
+
);
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
function registerAgentCommands(agents) {
|
|
437
|
+
agents.command("get").description("Show one agent: its instructions, skills and channels.").argument("<name>", "Agent name").option("--json", "Emit JSON output").action(async (name, options) => {
|
|
438
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
439
|
+
const result = await http.get(
|
|
440
|
+
`${AGENT_PATH}/agents/${encodeURIComponent(requireArgument(name, "an agent name"))}`
|
|
441
|
+
);
|
|
442
|
+
print(result, "agent", describeAgent(result.agent), options);
|
|
443
|
+
});
|
|
444
|
+
agents.command("create").description(
|
|
445
|
+
"Create an agent you own, with instructions and optional skills from the workspace library."
|
|
446
|
+
).argument("<name>", "Agent name: lower-case letters, digits and dashes").option("--instructions <text>", "What the agent does and never does").option("--instructions-file <path>", "Read the instructions from a file").option("--skills <names>", "Comma-separated library skill names").option(
|
|
447
|
+
"--model <model>",
|
|
448
|
+
"The model it runs on, from deepline agents models (for example sonnet)"
|
|
449
|
+
).option("--dry-run", "Print the request without sending it").option("--json", "Emit JSON output").action(
|
|
450
|
+
async (name, options) => {
|
|
451
|
+
const instructions = readInstructions(options);
|
|
452
|
+
const model = parseModel(options.model);
|
|
453
|
+
if (instructions === void 0) {
|
|
454
|
+
throw new AgentUsageError(
|
|
455
|
+
'Pass --instructions "<what the agent does>" or --instructions-file <path>.'
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
const body = {
|
|
459
|
+
name: requireArgument(name, "an agent name"),
|
|
460
|
+
instructions,
|
|
461
|
+
skills: _nullishCoalesce(parseSkills(options.skills), () => ( [])),
|
|
462
|
+
...typeof model === "string" ? { model } : {}
|
|
463
|
+
};
|
|
464
|
+
if (options.dryRun) {
|
|
465
|
+
printDryRun("POST", `${AGENT_PATH}/agents`, body, options);
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
469
|
+
const result = await http.post(
|
|
470
|
+
`${AGENT_PATH}/agents`,
|
|
471
|
+
body
|
|
472
|
+
);
|
|
473
|
+
print(
|
|
474
|
+
result,
|
|
475
|
+
"agent created",
|
|
476
|
+
[
|
|
477
|
+
...describeAgent(result.agent),
|
|
478
|
+
`Next: deepline agents channels add ${result.agent.name} <channel-id>`
|
|
479
|
+
],
|
|
480
|
+
options
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
);
|
|
484
|
+
agents.command("update").description(
|
|
485
|
+
"Replace an agent\u2019s instructions, skills or model (its creator or an admin)."
|
|
486
|
+
).argument("<name>", "Agent name").option("--instructions <text>", "New instructions").option("--instructions-file <path>", "Read new instructions from a file").option(
|
|
487
|
+
"--skills <names>",
|
|
488
|
+
'Comma-separated library skill names; replaces the list ("" clears it)'
|
|
489
|
+
).option(
|
|
490
|
+
"--model <model>",
|
|
491
|
+
'The model it runs on, from deepline agents models ("default" returns it to the default)'
|
|
492
|
+
).option("--dry-run", "Print the request without sending it").option("--json", "Emit JSON output").action(
|
|
493
|
+
async (name, options) => {
|
|
494
|
+
const instructions = readInstructions(options);
|
|
495
|
+
const skills = parseSkills(options.skills);
|
|
496
|
+
const model = parseModel(options.model);
|
|
497
|
+
if (instructions === void 0 && skills === void 0 && model === void 0) {
|
|
498
|
+
throw new AgentUsageError(
|
|
499
|
+
"Pass --instructions, --instructions-file, --skills or --model."
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
const path = `${AGENT_PATH}/agents/${encodeURIComponent(requireArgument(name, "an agent name"))}`;
|
|
503
|
+
const body = {
|
|
504
|
+
...instructions !== void 0 ? { instructions } : {},
|
|
505
|
+
...skills !== void 0 ? { skills } : {},
|
|
506
|
+
...model !== void 0 ? { model } : {}
|
|
507
|
+
};
|
|
508
|
+
if (options.dryRun) {
|
|
509
|
+
printDryRun("PATCH", path, body, options);
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
513
|
+
const result = await http.patch(path, body);
|
|
514
|
+
print(result, "agent updated", describeAgent(result.agent), options);
|
|
515
|
+
}
|
|
516
|
+
);
|
|
517
|
+
agents.command("delete").description(
|
|
518
|
+
"Delete an agent and unbind its channels (its creator or an admin). Unknown agents are a no-op."
|
|
519
|
+
).argument("<name>", "Agent name").option("--dry-run", "Print the request without sending it").option("--json", "Emit JSON output").action(async (name, options) => {
|
|
520
|
+
const path = `${AGENT_PATH}/agents/${encodeURIComponent(requireArgument(name, "an agent name"))}`;
|
|
521
|
+
if (options.dryRun) {
|
|
522
|
+
printDryRun("DELETE", path, null, options);
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
526
|
+
const result = await http.delete(path);
|
|
527
|
+
print(
|
|
528
|
+
result,
|
|
529
|
+
"agent deleted",
|
|
530
|
+
[result.removed ? `Deleted ${name.trim()}.` : "No such agent."],
|
|
531
|
+
options
|
|
532
|
+
);
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
function registerChannelCommands(agents) {
|
|
536
|
+
const channels = agents.command("channels").description(
|
|
537
|
+
"Bind Slack channels to agents, and say what an agent runs on and works toward in each. A channel answers @mentions with one agent."
|
|
538
|
+
);
|
|
539
|
+
channels.command("add").description(
|
|
540
|
+
"Bind a channel the agent\u2019s Slack app was invited to (the agent\u2019s creator or an admin). With --outcome the channel is where the agent works toward that outcome."
|
|
541
|
+
).argument("<agent>", "Agent name").argument("<channel-id>", "Slack channel id, for example C0123456789").option(
|
|
542
|
+
"--outcome <outcome>",
|
|
543
|
+
"The outcome the agent works toward here, as deepline outcomes list names it. The channel becomes the outcome\u2019s home: the agent is woken there."
|
|
544
|
+
).option(
|
|
545
|
+
"--linked",
|
|
546
|
+
"With --outcome: link the channel instead. The agent answers here with the outcome in view; its home channel is another one."
|
|
547
|
+
).addOption(new (0, _commander.Option)("--test-channel").hideHelp()).option("--dry-run", "Print the request without sending it").option("--json", "Emit JSON output").action(
|
|
548
|
+
async (agentName, channelId, options) => {
|
|
549
|
+
if (options.linked && options.outcome === void 0) {
|
|
550
|
+
throw new AgentUsageError("--linked goes with --outcome <outcome>.");
|
|
551
|
+
}
|
|
552
|
+
const body = {
|
|
553
|
+
agent: requireArgument(agentName, "an agent name"),
|
|
554
|
+
channel_id: requireArgument(
|
|
555
|
+
channelId,
|
|
556
|
+
"a channel id such as C0123456789"
|
|
557
|
+
),
|
|
558
|
+
...options.testChannel ? { test_channel: true } : {},
|
|
559
|
+
...options.outcome !== void 0 ? {
|
|
560
|
+
outcome: requireArgument(options.outcome, "an outcome name"),
|
|
561
|
+
outcome_role: options.linked ? "linked" : "home"
|
|
562
|
+
} : {}
|
|
563
|
+
};
|
|
564
|
+
if (options.dryRun) {
|
|
565
|
+
printDryRun("POST", `${AGENT_PATH}/channels`, body, options);
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
569
|
+
const result = await http.post(`${AGENT_PATH}/channels`, body);
|
|
570
|
+
print(
|
|
571
|
+
result,
|
|
572
|
+
"agent channel",
|
|
573
|
+
[
|
|
574
|
+
result.created ? `Bound ${body.channel_id} to ${result.agent.name}.` : `${body.channel_id} already answers with ${result.agent.name}.`,
|
|
575
|
+
...result.outcome ? describeOutcomeChange(result.outcome) : [],
|
|
576
|
+
...describeAgent(result.agent)
|
|
577
|
+
],
|
|
578
|
+
options
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
);
|
|
582
|
+
channels.command("set").description(
|
|
583
|
+
"Change what a bound channel\u2019s agent runs on or works toward there (the agent\u2019s creator or an admin)."
|
|
584
|
+
).argument("<channel-id>", "A bound channel id").option(
|
|
585
|
+
"--model <model>",
|
|
586
|
+
'This channel\u2019s own model, over its agent\u2019s, from deepline agents models ("default" follows the agent again)'
|
|
587
|
+
).option(
|
|
588
|
+
"--outcome <outcome>",
|
|
589
|
+
"The outcome the agent works toward here. The channel becomes the outcome\u2019s home."
|
|
590
|
+
).option(
|
|
591
|
+
"--linked",
|
|
592
|
+
"With --outcome: link the channel instead of making it the home"
|
|
593
|
+
).option("--no-outcome", "The agent works toward no outcome here").option(
|
|
594
|
+
"--platform <platform>",
|
|
595
|
+
"slack or test, when the id is bound on both"
|
|
596
|
+
).option("--dry-run", "Print the request without sending it").option("--json", "Emit JSON output").action(
|
|
597
|
+
async (channelId, options) => {
|
|
598
|
+
const platform = requirePlatform(options.platform);
|
|
599
|
+
const model = parseModel(options.model);
|
|
600
|
+
const outcome = typeof options.outcome === "string" ? requireArgument(options.outcome, "an outcome name") : options.outcome === false ? null : void 0;
|
|
601
|
+
if (model === void 0 && outcome === void 0) {
|
|
602
|
+
throw new AgentUsageError(
|
|
603
|
+
"Pass --model, --outcome <outcome> or --no-outcome."
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
if (options.linked && typeof outcome !== "string") {
|
|
607
|
+
throw new AgentUsageError("--linked goes with --outcome <outcome>.");
|
|
608
|
+
}
|
|
609
|
+
const id = requireArgument(channelId, "a channel id");
|
|
610
|
+
const path = `${AGENT_PATH}/channels/${encodeURIComponent(id)}${platform ? `?platform=${platform}` : ""}`;
|
|
611
|
+
const body = {
|
|
612
|
+
...model !== void 0 ? { model } : {},
|
|
613
|
+
...outcome !== void 0 ? { outcome } : {},
|
|
614
|
+
...typeof outcome === "string" ? { outcome_role: options.linked ? "linked" : "home" } : {}
|
|
615
|
+
};
|
|
616
|
+
if (options.dryRun) {
|
|
617
|
+
printDryRun("PATCH", path, body, options);
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
621
|
+
const result = await http.patch(path, body);
|
|
622
|
+
print(
|
|
623
|
+
result,
|
|
624
|
+
"agent channel",
|
|
625
|
+
[
|
|
626
|
+
...result.model ? [
|
|
627
|
+
result.model.from === "conversation" ? `${id} runs on ${result.model.model.label} (${result.model.model.id}). Its agent\u2019s other channels are unchanged.` : `${id} follows its agent\u2019s model: ${result.model.model.label} (${result.model.model.id}).`
|
|
628
|
+
] : [],
|
|
629
|
+
...result.outcome ? describeOutcomeChange(result.outcome) : []
|
|
630
|
+
],
|
|
631
|
+
options
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
);
|
|
635
|
+
channels.command("remove").description(
|
|
636
|
+
"Unbind a channel from its agent (the agent\u2019s creator or an admin). Unbound channels are a no-op."
|
|
637
|
+
).argument("<channel-id>", "Channel id").option(
|
|
638
|
+
"--platform <platform>",
|
|
639
|
+
"slack or test, when the id is bound on both"
|
|
640
|
+
).option("--dry-run", "Print the request without sending it").option("--json", "Emit JSON output").action(
|
|
641
|
+
async (channelId, options) => {
|
|
642
|
+
const platform = requirePlatform(options.platform);
|
|
643
|
+
const path = `${AGENT_PATH}/channels/${encodeURIComponent(requireArgument(channelId, "a channel id"))}${platform ? `?platform=${platform}` : ""}`;
|
|
644
|
+
if (options.dryRun) {
|
|
645
|
+
printDryRun("DELETE", path, null, options);
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
649
|
+
const result = await http.delete(path);
|
|
650
|
+
print(
|
|
651
|
+
result,
|
|
652
|
+
"agent channel",
|
|
653
|
+
[
|
|
654
|
+
result.removed ? `Unbound ${channelId.trim()} from ${result.agentName}.` : "Was not bound."
|
|
655
|
+
],
|
|
656
|
+
options
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
);
|
|
660
|
+
}
|
|
661
|
+
function describeSlackInstallation(installation) {
|
|
662
|
+
const team = `${installation.teamName} (${installation.teamId})`;
|
|
663
|
+
if (installation.status === "installed") {
|
|
664
|
+
return `${team}: installed ${new Date(installation.installedAt).toISOString()} by ${installation.installedByUserId}`;
|
|
665
|
+
}
|
|
666
|
+
const reason = installation.uninstallReason === "tokens_revoked" ? "its token was revoked" : "removed from Slack";
|
|
667
|
+
return `${team}: not installed since ${new Date(_nullishCoalesce(installation.uninstalledAt, () => ( installation.updatedAt))).toISOString()} (${reason}); install it again to bring its channels back`;
|
|
668
|
+
}
|
|
669
|
+
function slackLinkCode(value) {
|
|
670
|
+
const text = requireArgument(value, "the code from the link");
|
|
671
|
+
try {
|
|
672
|
+
return _nullishCoalesce(new URL(text).searchParams.get("code"), () => ( text));
|
|
673
|
+
} catch (e2) {
|
|
674
|
+
return text;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
function registerSlackCommands(agents) {
|
|
678
|
+
const slack = agents.command("slack").description(
|
|
679
|
+
"Add the agent to Slack workspaces, each with its own bot token, and see where it is installed."
|
|
680
|
+
);
|
|
681
|
+
slack.command("install").description(
|
|
682
|
+
"Print a link that adds the agent to a Slack workspace (owners and admins). Open it, pick the Slack workspace and approve."
|
|
683
|
+
).option("--json", "Emit JSON output").action(async (options) => {
|
|
684
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
685
|
+
const result = await http.post(
|
|
686
|
+
`${AGENT_PATH}/slack/install`,
|
|
687
|
+
{}
|
|
688
|
+
);
|
|
689
|
+
print(
|
|
690
|
+
result,
|
|
691
|
+
"agent slack install",
|
|
692
|
+
[
|
|
693
|
+
"Open this link in a browser signed in to Deepline as you, and approve the install in Slack. It works once, for 15 minutes:",
|
|
694
|
+
result.installUrl,
|
|
695
|
+
"Then check it with: deepline agents slack status"
|
|
696
|
+
],
|
|
697
|
+
options
|
|
698
|
+
);
|
|
699
|
+
});
|
|
700
|
+
slack.command("link").description(
|
|
701
|
+
"Say which Slack user you are, with the code from the link the agent showed you in Slack. Your clicks there (answering an ask, connecting a channel) are then made as you."
|
|
702
|
+
).argument("<code>", "The code from the link, or the whole link").option("--json", "Emit JSON output").action(async (code, options) => {
|
|
703
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
704
|
+
const result = await http.post(`${AGENT_PATH}/slack/link`, { code: slackLinkCode(code) });
|
|
705
|
+
print(
|
|
706
|
+
result,
|
|
707
|
+
"agent slack link",
|
|
708
|
+
[
|
|
709
|
+
`Linked Slack user ${result.slackUserId} in ${result.slackTeamId} to your Deepline account. Click again in Slack.`
|
|
710
|
+
],
|
|
711
|
+
options
|
|
712
|
+
);
|
|
713
|
+
});
|
|
714
|
+
slack.command("unlink").description(
|
|
715
|
+
"Forget which Slack user you are in this workspace. Your clicks in Slack decide nothing until you link again."
|
|
716
|
+
).option("--json", "Emit JSON output").action(async (options) => {
|
|
717
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
718
|
+
const result = await http.delete(
|
|
719
|
+
`${AGENT_PATH}/slack/link`
|
|
720
|
+
);
|
|
721
|
+
print(
|
|
722
|
+
result,
|
|
723
|
+
"agent slack unlink",
|
|
724
|
+
[
|
|
725
|
+
result.removed ? "Unlinked your Slack user." : "No Slack user was linked to your account."
|
|
726
|
+
],
|
|
727
|
+
options
|
|
728
|
+
);
|
|
729
|
+
});
|
|
730
|
+
slack.command("status").description(
|
|
731
|
+
"List the Slack workspaces this workspace installed the agent in."
|
|
732
|
+
).option("--json", "Emit JSON output").action(async (options) => {
|
|
733
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
734
|
+
const result = await http.get(
|
|
735
|
+
`${AGENT_PATH}/slack/installations`
|
|
736
|
+
);
|
|
737
|
+
print(
|
|
738
|
+
result,
|
|
739
|
+
"agent slack status",
|
|
740
|
+
result.installations.length ? result.installations.map(describeSlackInstallation) : [
|
|
741
|
+
"Not installed in any Slack workspace. An admin runs: deepline agents slack install"
|
|
742
|
+
],
|
|
743
|
+
options
|
|
744
|
+
);
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
function registerSkillCommands(agents) {
|
|
748
|
+
const skills = agents.command("skills").description(
|
|
749
|
+
"The workspace\u2019s skill library: markdown an agent loads when its description matches the task."
|
|
750
|
+
);
|
|
751
|
+
skills.command("get").description("Show one library skill with its markdown.").argument("<name>", "Skill name").option("--json", "Emit JSON output").action(async (name, options) => {
|
|
752
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
753
|
+
const result = await http.get(
|
|
754
|
+
`${AGENT_PATH}/skills/${encodeURIComponent(requireArgument(name, "a skill name"))}`
|
|
755
|
+
);
|
|
756
|
+
print(
|
|
757
|
+
result,
|
|
758
|
+
"agent skill",
|
|
759
|
+
[
|
|
760
|
+
`${result.skill.name} \u2014 ${result.skill.description}`,
|
|
761
|
+
"",
|
|
762
|
+
result.skill.markdown
|
|
763
|
+
],
|
|
764
|
+
options
|
|
765
|
+
);
|
|
766
|
+
});
|
|
767
|
+
skills.command("set").description(
|
|
768
|
+
"Add a skill to the library, or replace one (its creator or an admin). Replacing it changes every agent that uses it."
|
|
769
|
+
).argument("<name>", "Skill name: lower-case letters, digits and dashes").requiredOption(
|
|
770
|
+
"--file <path>",
|
|
771
|
+
"A SKILL.md; frontmatter description is read"
|
|
772
|
+
).option(
|
|
773
|
+
"--description <text>",
|
|
774
|
+
"When an agent should load it (overrides the file\u2019s frontmatter)"
|
|
775
|
+
).option("--dry-run", "Print the request without sending it").option("--json", "Emit JSON output").action(
|
|
776
|
+
async (name, options) => {
|
|
777
|
+
const parsed = parseSkillFile(readFileOption(options.file, "--file"));
|
|
778
|
+
const description = _nullishCoalesce(options.description, () => ( parsed.description));
|
|
779
|
+
if (!_optionalChain([description, 'optionalAccess', _9 => _9.trim, 'call', _10 => _10()])) {
|
|
780
|
+
throw new AgentUsageError(
|
|
781
|
+
'Pass --description "<when to load it>", or give the file a frontmatter description.'
|
|
782
|
+
);
|
|
783
|
+
}
|
|
784
|
+
const path = `${AGENT_PATH}/skills/${encodeURIComponent(requireArgument(name, "a skill name"))}`;
|
|
785
|
+
const body = { description, markdown: parsed.markdown };
|
|
786
|
+
if (options.dryRun) {
|
|
787
|
+
printDryRun("PUT", path, body, options);
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
791
|
+
const result = await http.put(path, body);
|
|
792
|
+
print(
|
|
793
|
+
result,
|
|
794
|
+
"agent skill",
|
|
795
|
+
[
|
|
796
|
+
`${result.created ? "Added" : "Replaced"} ${result.skill.name} (${result.skill.markdownLength} characters).`,
|
|
797
|
+
...result.created ? [
|
|
798
|
+
`Attach it: deepline agents update <agent> --skills ${result.skill.name}`
|
|
799
|
+
] : []
|
|
800
|
+
],
|
|
801
|
+
options
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
);
|
|
805
|
+
skills.command("delete").description(
|
|
806
|
+
"Delete a skill from the library (its creator or an admin). Refused while an agent uses it."
|
|
807
|
+
).argument("<name>", "Skill name").option("--dry-run", "Print the request without sending it").option("--json", "Emit JSON output").action(async (name, options) => {
|
|
808
|
+
const path = `${AGENT_PATH}/skills/${encodeURIComponent(requireArgument(name, "a skill name"))}`;
|
|
809
|
+
if (options.dryRun) {
|
|
810
|
+
printDryRun("DELETE", path, null, options);
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
814
|
+
const result = await http.delete(path);
|
|
815
|
+
print(
|
|
816
|
+
result,
|
|
817
|
+
"agent skill",
|
|
818
|
+
[result.removed ? `Deleted ${name.trim()}.` : "No such skill."],
|
|
819
|
+
options
|
|
820
|
+
);
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
function describeFeedback(page, filters) {
|
|
824
|
+
if (page.feedback.length === 0) return ["No ratings yet."];
|
|
825
|
+
const lines = page.feedback.map((row) => {
|
|
826
|
+
const where = row.platform === "slack" ? row.conversationName ? `#${row.conversationName}` : row.conversationId : `test ${_nullishCoalesce(row.conversationName, () => ( row.conversationId))}`;
|
|
827
|
+
const rating = row.rating === "helpful" ? "helpful" : "not helpful";
|
|
828
|
+
return `${new Date(row.updatedAt).toISOString()} ${rating.padEnd(11)} ${_nullishCoalesce(row.agentName, () => ( "(deleted agent)"))} ${where} thread ${row.threadTs} by ${row.raterId}`;
|
|
829
|
+
});
|
|
830
|
+
if (page.cursor) {
|
|
831
|
+
const same = [
|
|
832
|
+
filters.agent === void 0 ? "" : ` --agent ${filters.agent}`,
|
|
833
|
+
filters.limit === void 0 ? "" : ` --limit ${filters.limit}`
|
|
834
|
+
].join("");
|
|
835
|
+
lines.push(`More: deepline agents feedback${same} --cursor ${page.cursor}`);
|
|
836
|
+
}
|
|
837
|
+
return lines;
|
|
838
|
+
}
|
|
839
|
+
function registerFeedbackCommand(agents) {
|
|
840
|
+
agents.command("feedback").description(
|
|
841
|
+
"Show what people said about agent replies with the Helpful / Not helpful buttons under them, newest first."
|
|
842
|
+
).option("--agent <name>", "Only this agent").option(
|
|
843
|
+
"--limit <n>",
|
|
844
|
+
`Ratings per page, 1 to ${FEEDBACK_MAX_LIMIT} (default 50)`
|
|
845
|
+
).option("--cursor <cursor>", "The previous page's cursor").option("--json", "Emit JSON output").action(
|
|
846
|
+
async (options) => {
|
|
847
|
+
const params = new URLSearchParams();
|
|
848
|
+
const filters = {};
|
|
849
|
+
if (options.agent !== void 0) {
|
|
850
|
+
filters.agent = requireArgument(options.agent, "--agent <name>");
|
|
851
|
+
params.set("agent", filters.agent);
|
|
852
|
+
}
|
|
853
|
+
if (options.limit !== void 0) {
|
|
854
|
+
const limit = Number(options.limit);
|
|
855
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > FEEDBACK_MAX_LIMIT) {
|
|
856
|
+
throw new AgentUsageError(
|
|
857
|
+
`--limit is a whole number from 1 to ${FEEDBACK_MAX_LIMIT}.`
|
|
858
|
+
);
|
|
859
|
+
}
|
|
860
|
+
filters.limit = limit;
|
|
861
|
+
params.set("limit", String(limit));
|
|
862
|
+
}
|
|
863
|
+
if (options.cursor !== void 0) {
|
|
864
|
+
params.set("cursor", requireArgument(options.cursor, "--cursor"));
|
|
865
|
+
}
|
|
866
|
+
const query = params.toString();
|
|
867
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
868
|
+
const page = await http.get(
|
|
869
|
+
`${AGENT_PATH}/feedback${query ? `?${query}` : ""}`
|
|
870
|
+
).catch((error) => {
|
|
871
|
+
if (error instanceof _chunkLFQJW4S2js.DeeplineError && error.code === FEEDBACK_INVALID_CURSOR) {
|
|
872
|
+
throw new AgentUsageError(`--cursor: ${error.message}`);
|
|
873
|
+
}
|
|
874
|
+
throw error;
|
|
875
|
+
});
|
|
876
|
+
print(page, "agent feedback", describeFeedback(page, filters), options);
|
|
877
|
+
}
|
|
878
|
+
);
|
|
879
|
+
}
|
|
880
|
+
function conversationLabel(row) {
|
|
881
|
+
return row.platform === "slack" ? row.conversationName ? `#${row.conversationName}` : row.conversationId : `test ${_nullishCoalesce(row.conversationName, () => ( row.conversationId))}`;
|
|
882
|
+
}
|
|
883
|
+
function seconds(ms) {
|
|
884
|
+
return ms === null ? "-" : `${(ms / 1e3).toFixed(1)}s`;
|
|
885
|
+
}
|
|
886
|
+
function describeReplies(page, filters) {
|
|
887
|
+
if (page.replies.length === 0) return ["No replies yet."];
|
|
888
|
+
const lines = page.replies.map((row) => {
|
|
889
|
+
const ratings = row.ratings === null ? "no buttons" : row.ratings.counted ? `${row.ratings.helpful} helpful, ${row.ratings.notHelpful} not` : "too many ratings to count";
|
|
890
|
+
const tokens = row.inputTokens === null && row.outputTokens === null ? "-" : `${_nullishCoalesce(row.inputTokens, () => ( 0))}/${_nullishCoalesce(row.outputTokens, () => ( 0))} tokens`;
|
|
891
|
+
return `${new Date(row.finishedAt).toISOString()} ${row.outcome.padEnd(9)} ${_nullishCoalesce(row.agentName, () => ( "(deleted agent)"))} ${conversationLabel(row)} thread ${row.threadTs} ${seconds(row.durationMs)} ${row.toolCalls} tool calls ${tokens} ${ratings}`;
|
|
892
|
+
});
|
|
893
|
+
if (page.cursor) {
|
|
894
|
+
const same = [
|
|
895
|
+
filters.agent === void 0 ? "" : ` --agent ${filters.agent}`,
|
|
896
|
+
filters.limit === void 0 ? "" : ` --limit ${filters.limit}`
|
|
897
|
+
].join("");
|
|
898
|
+
lines.push(`More: deepline agents replies${same} --cursor ${page.cursor}`);
|
|
899
|
+
}
|
|
900
|
+
return lines;
|
|
901
|
+
}
|
|
902
|
+
function registerRepliesCommand(agents) {
|
|
903
|
+
agents.command("replies").description(
|
|
904
|
+
"Show the replies agents finished, newest first: channel, thread, how it ended, time, tool calls, tokens and ratings."
|
|
905
|
+
).option("--agent <name>", "Only this agent").option(
|
|
906
|
+
"--limit <n>",
|
|
907
|
+
`Replies per page, 1 to ${REPLIES_MAX_LIMIT} (default 50)`
|
|
908
|
+
).option("--cursor <cursor>", "The previous page's cursor").option("--json", "Emit JSON output").action(
|
|
909
|
+
async (options) => {
|
|
910
|
+
const params = new URLSearchParams();
|
|
911
|
+
const filters = {};
|
|
912
|
+
if (options.agent !== void 0) {
|
|
913
|
+
filters.agent = requireArgument(options.agent, "--agent <name>");
|
|
914
|
+
params.set("agent", filters.agent);
|
|
915
|
+
}
|
|
916
|
+
if (options.limit !== void 0) {
|
|
917
|
+
const limit = Number(options.limit);
|
|
918
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > REPLIES_MAX_LIMIT) {
|
|
919
|
+
throw new AgentUsageError(
|
|
920
|
+
`--limit is a whole number from 1 to ${REPLIES_MAX_LIMIT}.`
|
|
921
|
+
);
|
|
922
|
+
}
|
|
923
|
+
filters.limit = limit;
|
|
924
|
+
params.set("limit", String(limit));
|
|
925
|
+
}
|
|
926
|
+
if (options.cursor !== void 0) {
|
|
927
|
+
params.set("cursor", requireArgument(options.cursor, "--cursor"));
|
|
928
|
+
}
|
|
929
|
+
const query = params.toString();
|
|
930
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
931
|
+
const page = await http.get(`${AGENT_PATH}/replies${query ? `?${query}` : ""}`).catch((error) => {
|
|
932
|
+
if (error instanceof _chunkLFQJW4S2js.DeeplineError && error.code === REPLIES_INVALID_CURSOR) {
|
|
933
|
+
throw new AgentUsageError(`--cursor: ${error.message}`);
|
|
934
|
+
}
|
|
935
|
+
throw error;
|
|
936
|
+
});
|
|
937
|
+
print(page, "agent replies", describeReplies(page, filters), options);
|
|
938
|
+
}
|
|
939
|
+
);
|
|
940
|
+
}
|
|
941
|
+
function describeActivity(activity) {
|
|
942
|
+
if (activity.agents.length === 0) return ["No agents yet."];
|
|
943
|
+
return activity.agents.map((agent) => {
|
|
944
|
+
const last = agent.lastReplyAt === null ? "never replied" : `last reply ${new Date(agent.lastReplyAt).toISOString()}`;
|
|
945
|
+
if (agent.window === null) {
|
|
946
|
+
return `${agent.agentName} more than ${activity.readLimit} replies in ${activity.days} days ${last}`;
|
|
947
|
+
}
|
|
948
|
+
const { window } = agent;
|
|
949
|
+
return `${agent.agentName} ${window.replies} replies in ${activity.days} days, ${window.failed} failed, ${window.cancelled} stopped median ${seconds(window.medianDurationMs)} ${window.inputTokens}/${window.outputTokens} tokens ${last}`;
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
function registerActivityCommand(agents) {
|
|
953
|
+
agents.command("activity").description(
|
|
954
|
+
"Sum each agent's replies over the last 7 days: how many, how they ended, median time, tokens and the last reply."
|
|
955
|
+
).option("--json", "Emit JSON output").action(async (options) => {
|
|
956
|
+
const { http } = _chunkEV3OPDHFjs.getAuthedHttpClient.call(void 0, );
|
|
957
|
+
const activity = await http.get(`${AGENT_PATH}/activity`);
|
|
958
|
+
print(activity, "agent activity", describeActivity(activity), options);
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
function registerAgentsCommands(program, readKey = readModelKey) {
|
|
962
|
+
const agents = program.command("agents", { hidden: !_chunkAO56MZ7Djs.cliFeatureEnabled.call(void 0, AGENT_FEATURE) }).description(
|
|
963
|
+
"Deepline agents in Slack: create agents with instructions and skills, bind channels to them, and talk to them."
|
|
964
|
+
);
|
|
965
|
+
registerWorkspaceCommands(agents, readKey);
|
|
966
|
+
registerAgentCommands(agents);
|
|
967
|
+
registerSlackCommands(agents);
|
|
968
|
+
registerChannelCommands(agents);
|
|
969
|
+
registerSkillCommands(agents);
|
|
970
|
+
registerFeedbackCommand(agents);
|
|
971
|
+
registerRepliesCommand(agents);
|
|
972
|
+
registerActivityCommand(agents);
|
|
973
|
+
agents.command("test").description(
|
|
974
|
+
"Send the agent a channel answers with one message, as an @mention there, without Slack."
|
|
975
|
+
).argument("<channel-id>", "A bound channel id").argument("<message...>", "The message").option("--thread <id>", "Continue a thread from an earlier reply").option(
|
|
976
|
+
"--as <name>",
|
|
977
|
+
"Speak as this person, so several people can share one thread (default: tester)"
|
|
978
|
+
).option(
|
|
979
|
+
"--platform <platform>",
|
|
980
|
+
"slack or test, when the id is bound on both"
|
|
981
|
+
).option("--json", "Emit JSON output").action(
|
|
982
|
+
async (channelId, words, options) => handleTest(channelId, words, options)
|
|
983
|
+
);
|
|
984
|
+
agents.command("chat").description(
|
|
985
|
+
"Talk to the agent a channel answers with, in a terminal, one thread."
|
|
986
|
+
).argument("<channel-id>", "A bound channel id").option(
|
|
987
|
+
"--platform <platform>",
|
|
988
|
+
"slack or test, when the id is bound on both"
|
|
989
|
+
).action(
|
|
990
|
+
async (channelId, options) => handleChat(channelId, options)
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
|
|
995
|
+
|
|
996
|
+
exports.parseSkillFile = parseSkillFile; exports.registerAgentsCommands = registerAgentsCommands;
|