@stackfactor/agent-utils 1.13.0 → 1.13.2
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 -1
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +2 -19
- package/dist/cjs/langChain.d.ts.map +1 -1
- package/dist/cjs/langChain.js +31 -2
- package/dist/cjs/messageLimits.d.ts +21 -0
- package/dist/cjs/messageLimits.d.ts.map +1 -0
- package/dist/cjs/messageLimits.js +29 -0
- package/dist/cjs/serve.d.ts.map +1 -1
- package/dist/cjs/serve.js +4 -1
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +2 -19
- package/dist/esm/langChain.d.ts.map +1 -1
- package/dist/esm/langChain.js +31 -2
- package/dist/esm/messageLimits.d.ts +21 -0
- package/dist/esm/messageLimits.d.ts.map +1 -0
- package/dist/esm/messageLimits.js +26 -0
- package/dist/esm/serve.d.ts.map +1 -1
- package/dist/esm/serve.js +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -103,7 +103,9 @@ Constructs a LangChain agent with a model, system prompt, and tools. When `onRep
|
|
|
103
103
|
|
|
104
104
|
### `langChain.runAIAgent(agent, prompt, config, onProgress?)`
|
|
105
105
|
|
|
106
|
-
Executes a LangChain agent with a user prompt. Registers callbacks for `tool_start`, `
|
|
106
|
+
Executes a LangChain agent with a user prompt. Registers callbacks for `tool_start`, `agent_action`, and error events when `onProgress` is provided. Logs execution time on completion.
|
|
107
|
+
|
|
108
|
+
A tool event's `message` is plain language for the progress bar: the web tools read "Searching the web", "Reading web pages", "Listing the pages of a site" and "Reading the pages of a site", and any other tool reads as its name in words (`lookup_record` → "Using lookup record"). It never carries the model's reasoning or the tool's input; the raw name and input stay on the event's `tool` and `input`.
|
|
107
109
|
|
|
108
110
|
| Parameter | Type | Default | Description |
|
|
109
111
|
| ------------ | ------------------ | ------- | -------------------------------- |
|
package/dist/cjs/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACrE,gFAAgF;IAChF,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,gFAAgF;IAChF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AA2CD;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,GACpB,UAAU,MAAM,EAChB,SAAS,mBAAmB,EAC5B,UAAS,gBAAqB,KAC7B,OAAO,CAAC,GAAG,CA0DV,CAAC;AAEL,MAAM,WAAW,iBAAiB;IAChC,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,+DAA+D;AAC/D,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,2EAA2E;IAC3E,EAAE,EAAE,OAAO,CAAC;IACZ,gFAAgF;IAChF,gBAAgB,EAAE,OAAO,CAAC;IAC1B,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB;AAID;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GACrB,UAAU,MAAM,EAChB,UAAS,iBAAsB,KAC9B,OAAO,CAAC,WAAW,CA8ClB,CAAC"}
|
package/dist/cjs/client.js
CHANGED
|
@@ -36,30 +36,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.checkAgent = exports.callAgent = void 0;
|
|
37
37
|
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
38
38
|
const agentProto_js_1 = require("./agentProto.js");
|
|
39
|
+
const messageLimits_js_1 = require("./messageLimits.js");
|
|
39
40
|
const DEFAULT_DEADLINE_MS = 900_000;
|
|
40
|
-
/**
|
|
41
|
-
* gRPC-js defaults `grpc.max_receive_message_length` to 4 MiB. Agents stream
|
|
42
|
-
* their result inline in `result_json`, and image/avatar agents (GIA) routinely
|
|
43
|
-
* return payloads well above 4 MiB — a single PNG can be 5 MiB+ before the
|
|
44
|
-
* ~33% base64 inflation of embedding it in JSON — which trips
|
|
45
|
-
* `RESOURCE_EXHAUSTED: Received message larger than max`. Raise both limits to
|
|
46
|
-
* 64 MiB so large media responses pass. Override via the
|
|
47
|
-
* `STACKFACTOR_AGENT_MAX_MESSAGE_BYTES` env var if an even larger ceiling is
|
|
48
|
-
* needed. (-1 in gRPC-js means "unlimited", which we deliberately avoid so a
|
|
49
|
-
* runaway response can't exhaust memory.)
|
|
50
|
-
*/
|
|
51
|
-
const MAX_MESSAGE_BYTES = (() => {
|
|
52
|
-
const fromEnv = Number(process.env.STACKFACTOR_AGENT_MAX_MESSAGE_BYTES);
|
|
53
|
-
return Number.isFinite(fromEnv) && fromEnv > 0 ? fromEnv : 64 * 1024 * 1024;
|
|
54
|
-
})();
|
|
55
41
|
/**
|
|
56
42
|
* Channel options applied to every agent gRPC client. Lifts the send/receive
|
|
57
43
|
* message-size caps off their 4 MiB defaults (see `MAX_MESSAGE_BYTES`).
|
|
58
44
|
*/
|
|
59
|
-
const CHANNEL_OPTIONS =
|
|
60
|
-
"grpc.max_receive_message_length": MAX_MESSAGE_BYTES,
|
|
61
|
-
"grpc.max_send_message_length": MAX_MESSAGE_BYTES,
|
|
62
|
-
};
|
|
45
|
+
const CHANNEL_OPTIONS = messageLimits_js_1.MESSAGE_SIZE_OPTIONS;
|
|
63
46
|
const safeParse = (value, fallback) => {
|
|
64
47
|
if (!value)
|
|
65
48
|
return fallback;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":"AAoGA,KAAK,UAAU,GAAG;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IAKtB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACvC;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACrD;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,MAAM,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,eACC,QAAQ,GAAG,IAAI,iBACb,YAAY,GAAG,IAAI,aACvB,MAAM,KACf,OAAO,CAAC,GAAG,CAAC;oCAohBF,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,eACT,MAAM,eACN,MAAM,wBACG,OAAO,WACpB,GAAG,cACA,MAAM,UACV,GAAG,EAAE,iBACE,YAAY,GAAG,IAAI,KAChC,OAAO,CAAC,GAAG,CAAC;sDA2sBF,MAAM,UACT,GAAG,UACH,MAAM,YACL,GAAG,iBACE,YAAY,GAAG,IAAI,KAChC,OAAO,CAAC,GAAG,CAAC;sDAmTF,MAAM,UACT,GAAG,UACH,MAAM,YACL,GAAG,iBACE,YAAY,GAAG,IAAI,KAChC,OAAO,CAAC,GAAG,CAAC;0CAz6C8B,GAAG,KAAG,MAAM;uCAt0B9C,YAAY,GAAG,IAAI,GAAG,SAAS,aAC7B,MAAM,YACP,GAAG,WACJ,GAAG,YACF,QAAQ,GAAG,QAAQ,KAC5B,IAAI;kCA5CI,YAAY,GAAG,IAAI,GAAG,SAAS,aAC7B,MAAM,SACV,UAAU,GAAG,IAAI,YACd,GAAG,KACZ,IAAI;+CA0FI,YAAY,GAAG,IAAI,GAAG,SAAS,aAC7B,MAAM,kBACD,MAAM,YACZ,GAAG,KACZ,IAAI;uCAoBI,YAAY,GAAG,IAAI,GAAG,SAAS,aAC7B,MAAM,WACR,MAAM,YACL,GAAG,KACZ,IAAI;mCAuwBU,MAAM,mBACJ,MAAM,EAAE,KACxB,MAAM;;AA48CT,wBAkBE"}
|
package/dist/cjs/langChain.js
CHANGED
|
@@ -765,10 +765,36 @@ const createAgent = (name, modelName, systemPrompt, tools = [], responseFormat,
|
|
|
765
765
|
});
|
|
766
766
|
return agent;
|
|
767
767
|
};
|
|
768
|
+
// What the progress bar says while each tool agent-utils registers (the
|
|
769
|
+
// Tavily tools in tavily.ts) runs. A Map, so a tool named after an
|
|
770
|
+
// Object.prototype key ("constructor") is not mistaken for a label.
|
|
771
|
+
const TOOL_PROGRESS_LABELS = new Map([
|
|
772
|
+
["web_search", "Searching the web"],
|
|
773
|
+
["web_extract", "Reading web pages"],
|
|
774
|
+
["web_map", "Listing the pages of a site"],
|
|
775
|
+
["web_crawl", "Reading the pages of a site"],
|
|
776
|
+
]);
|
|
777
|
+
/**
|
|
778
|
+
* The progress message for a tool call, in words the person watching the run
|
|
779
|
+
* can read. A tool without a label (an agent's own) reads as its name with
|
|
780
|
+
* underscores as spaces: `lookup_record` → "Using lookup record".
|
|
781
|
+
* @param name - The tool's registered name
|
|
782
|
+
* @returns A plain-language message; never the raw name in quotes
|
|
783
|
+
*/
|
|
784
|
+
const toolProgressLabel = (name) => {
|
|
785
|
+
const text = String(name ?? "");
|
|
786
|
+
const label = TOOL_PROGRESS_LABELS.get(text);
|
|
787
|
+
if (label)
|
|
788
|
+
return label;
|
|
789
|
+
const words = text.replace(/_+/g, " ").trim();
|
|
790
|
+
return words ? `Using ${words}` : "Using a tool";
|
|
791
|
+
};
|
|
768
792
|
/**
|
|
769
793
|
* Executes a LangChain agent with a single user prompt and returns the raw agent
|
|
770
794
|
* response. When an `onProgress` callback is provided, LangChain callbacks are
|
|
771
795
|
* registered to forward `tool_start`, `agent_action`, and error events to the caller.
|
|
796
|
+
* A tool event's `message` is plain language (see `toolProgressLabel`); the raw tool
|
|
797
|
+
* name and input stay on its `tool` and `input` fields.
|
|
772
798
|
* Execution time is logged at the info level on completion.
|
|
773
799
|
* @param agent - A LangChain agent instance created by `createAgent`
|
|
774
800
|
* @param prompt - The user message string to send to the agent
|
|
@@ -798,15 +824,18 @@ const runAgent = async (agent, prompt, config, onProgress = null, usageTracker =
|
|
|
798
824
|
if (name)
|
|
799
825
|
onProgress({
|
|
800
826
|
type: "tool_start",
|
|
801
|
-
message:
|
|
827
|
+
message: toolProgressLabel(name),
|
|
802
828
|
tool: name,
|
|
803
829
|
progress,
|
|
804
830
|
});
|
|
805
831
|
},
|
|
832
|
+
// `action.log` is the model's own text (LangChain's default reads
|
|
833
|
+
// "Invoking: `web_extract` with `{...}`", the raw tool input), so it
|
|
834
|
+
// never reaches the progress bar.
|
|
806
835
|
handleAgentAction: (action) => {
|
|
807
836
|
onProgress({
|
|
808
837
|
type: "agent_action",
|
|
809
|
-
message: action.
|
|
838
|
+
message: toolProgressLabel(action.tool),
|
|
810
839
|
tool: action.tool,
|
|
811
840
|
input: action.toolInput,
|
|
812
841
|
progress,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gRPC-js defaults `grpc.max_receive_message_length` to 4 MiB. Agents stream
|
|
3
|
+
* their result inline in `result_json`, and image/avatar agents (GIA) routinely
|
|
4
|
+
* return payloads well above 4 MiB — a single PNG can be 5 MiB+ before the
|
|
5
|
+
* ~33% base64 inflation of embedding it in JSON — which trips
|
|
6
|
+
* `RESOURCE_EXHAUSTED: Received message larger than max`. Raise both limits to
|
|
7
|
+
* 64 MiB so large media responses pass — on the client channel AND on the
|
|
8
|
+
* agent's own gRPC server (`serve`), which would otherwise reject a large
|
|
9
|
+
* request before the handler runs. Override via the
|
|
10
|
+
* `STACKFACTOR_AGENT_MAX_MESSAGE_BYTES` env var if an even larger ceiling is
|
|
11
|
+
* needed. (-1 in gRPC-js means "unlimited", which we deliberately avoid so a
|
|
12
|
+
* runaway response can't exhaust memory.)
|
|
13
|
+
*/
|
|
14
|
+
export declare const MAX_MESSAGE_BYTES: number;
|
|
15
|
+
/**
|
|
16
|
+
* gRPC options that lift the send/receive message-size caps off their 4 MiB
|
|
17
|
+
* defaults (see `MAX_MESSAGE_BYTES`). Used for the agent clients and for the
|
|
18
|
+
* agent's gRPC server.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MESSAGE_SIZE_OPTIONS: Record<string, number>;
|
|
21
|
+
//# sourceMappingURL=messageLimits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageLimits.d.ts","sourceRoot":"","sources":["../../src/messageLimits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,QAG1B,CAAC;AAEL;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGvD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MESSAGE_SIZE_OPTIONS = exports.MAX_MESSAGE_BYTES = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* gRPC-js defaults `grpc.max_receive_message_length` to 4 MiB. Agents stream
|
|
6
|
+
* their result inline in `result_json`, and image/avatar agents (GIA) routinely
|
|
7
|
+
* return payloads well above 4 MiB — a single PNG can be 5 MiB+ before the
|
|
8
|
+
* ~33% base64 inflation of embedding it in JSON — which trips
|
|
9
|
+
* `RESOURCE_EXHAUSTED: Received message larger than max`. Raise both limits to
|
|
10
|
+
* 64 MiB so large media responses pass — on the client channel AND on the
|
|
11
|
+
* agent's own gRPC server (`serve`), which would otherwise reject a large
|
|
12
|
+
* request before the handler runs. Override via the
|
|
13
|
+
* `STACKFACTOR_AGENT_MAX_MESSAGE_BYTES` env var if an even larger ceiling is
|
|
14
|
+
* needed. (-1 in gRPC-js means "unlimited", which we deliberately avoid so a
|
|
15
|
+
* runaway response can't exhaust memory.)
|
|
16
|
+
*/
|
|
17
|
+
exports.MAX_MESSAGE_BYTES = (() => {
|
|
18
|
+
const fromEnv = Number(process.env.STACKFACTOR_AGENT_MAX_MESSAGE_BYTES);
|
|
19
|
+
return Number.isFinite(fromEnv) && fromEnv > 0 ? fromEnv : 64 * 1024 * 1024;
|
|
20
|
+
})();
|
|
21
|
+
/**
|
|
22
|
+
* gRPC options that lift the send/receive message-size caps off their 4 MiB
|
|
23
|
+
* defaults (see `MAX_MESSAGE_BYTES`). Used for the agent clients and for the
|
|
24
|
+
* agent's gRPC server.
|
|
25
|
+
*/
|
|
26
|
+
exports.MESSAGE_SIZE_OPTIONS = {
|
|
27
|
+
"grpc.max_receive_message_length": exports.MAX_MESSAGE_BYTES,
|
|
28
|
+
"grpc.max_send_message_length": exports.MAX_MESSAGE_BYTES,
|
|
29
|
+
};
|
package/dist/cjs/serve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/serve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/serve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAYtC,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AAwPpB;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,OAAO,EAAE,GAAG,KACT,OAAO,CAAC;IAAE,IAAI,EAAE,GAAG,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,CAAC,CAAC;AAEzC,MAAM,WAAW,YAAY;IAC3B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wFAAwF;IACxF,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,uEAAuE;IACvE,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACpE,sEAAsE;IACtE,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,iEAAiE;IACjE,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,mFAAmF;IACnF,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,mFAAmF;IACnF,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACxD,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,EAAE,CACN,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,KACV,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACpC;AAKD;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAEX,mFAAmF;AACnF,eAAO,MAAM,kBAAkB,GAAI,MAAK,MAAM,CAAC,UAAwB,KAAG,OACJ,CAAC;AAKvE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,GAAG,EAAE,SAAS,GAAG,KAAG,OAEhB,CAAC;AAKlD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,GAAG,EAAE,SAAS,GAAG,KAAG,OAGN,CAAC;AAmKrD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,OAAO,GAClB,MAAM,SAAS,EACf,UAAS,YAAiB,KACzB,OAAO,CAAC,IAAI,CA8Id,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,GAChB,MAAM,SAAS,EACf,UAAS,YAAiB,KACzB,IAAI,CAAC,MA2OP,CAAC"}
|
package/dist/cjs/serve.js
CHANGED
|
@@ -44,6 +44,7 @@ const node_url_1 = require("node:url");
|
|
|
44
44
|
const client_api_1 = require("@stackfactor/client-api");
|
|
45
45
|
const logger_js_1 = __importDefault(require("./logger.js"));
|
|
46
46
|
const agentProto_js_1 = require("./agentProto.js");
|
|
47
|
+
const messageLimits_js_1 = require("./messageLimits.js");
|
|
47
48
|
const runtimeContext_js_1 = require("./runtimeContext.js");
|
|
48
49
|
const usage_js_1 = require("./usage.js");
|
|
49
50
|
// Genuine dynamic `import()` that survives TypeScript's CJS downlevelling (which
|
|
@@ -723,7 +724,9 @@ const serve = (main, options = {}) => {
|
|
|
723
724
|
respond(ok, backendReachable, message, checks);
|
|
724
725
|
})();
|
|
725
726
|
};
|
|
726
|
-
|
|
727
|
+
// Without options grpc-js rejects any request over 4 MiB (RESOURCE_EXHAUSTED)
|
|
728
|
+
// before the handler runs; use the same ceiling as the clients.
|
|
729
|
+
const server = new grpc.Server(messageLimits_js_1.MESSAGE_SIZE_OPTIONS);
|
|
727
730
|
server.addService((0, agentProto_js_1.loadAgentService)(), {
|
|
728
731
|
Execute: execute,
|
|
729
732
|
HealthCheck: healthCheck,
|
package/dist/esm/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACrE,gFA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
import { loadAgentPackage } from "./agentProto.js";
|
|
3
|
+
import { MESSAGE_SIZE_OPTIONS } from "./messageLimits.js";
|
|
3
4
|
const DEFAULT_DEADLINE_MS = 900_000;
|
|
4
|
-
/**
|
|
5
|
-
* gRPC-js defaults `grpc.max_receive_message_length` to 4 MiB. Agents stream
|
|
6
|
-
* their result inline in `result_json`, and image/avatar agents (GIA) routinely
|
|
7
|
-
* return payloads well above 4 MiB — a single PNG can be 5 MiB+ before the
|
|
8
|
-
* ~33% base64 inflation of embedding it in JSON — which trips
|
|
9
|
-
* `RESOURCE_EXHAUSTED: Received message larger than max`. Raise both limits to
|
|
10
|
-
* 64 MiB so large media responses pass. Override via the
|
|
11
|
-
* `STACKFACTOR_AGENT_MAX_MESSAGE_BYTES` env var if an even larger ceiling is
|
|
12
|
-
* needed. (-1 in gRPC-js means "unlimited", which we deliberately avoid so a
|
|
13
|
-
* runaway response can't exhaust memory.)
|
|
14
|
-
*/
|
|
15
|
-
const MAX_MESSAGE_BYTES = (() => {
|
|
16
|
-
const fromEnv = Number(process.env.STACKFACTOR_AGENT_MAX_MESSAGE_BYTES);
|
|
17
|
-
return Number.isFinite(fromEnv) && fromEnv > 0 ? fromEnv : 64 * 1024 * 1024;
|
|
18
|
-
})();
|
|
19
5
|
/**
|
|
20
6
|
* Channel options applied to every agent gRPC client. Lifts the send/receive
|
|
21
7
|
* message-size caps off their 4 MiB defaults (see `MAX_MESSAGE_BYTES`).
|
|
22
8
|
*/
|
|
23
|
-
const CHANNEL_OPTIONS =
|
|
24
|
-
"grpc.max_receive_message_length": MAX_MESSAGE_BYTES,
|
|
25
|
-
"grpc.max_send_message_length": MAX_MESSAGE_BYTES,
|
|
26
|
-
};
|
|
9
|
+
const CHANNEL_OPTIONS = MESSAGE_SIZE_OPTIONS;
|
|
27
10
|
const safeParse = (value, fallback) => {
|
|
28
11
|
if (!value)
|
|
29
12
|
return fallback;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":"AAoGA,KAAK,UAAU,GAAG;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IAKtB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACvC;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACrD;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B,CAAC;AA0iBF;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,eAAO,MAAM,WAAW,GACtB,WAAW,MAAM,EACjB,QAAQ,GAAG,EACX,SAAQ,GAAU,KACjB,GAwHF,CAAC;;
|
|
1
|
+
{"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":"AAoGA,KAAK,UAAU,GAAG;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IAKtB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACvC;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACrD;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;C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AAY,GAAG,IAAI,GAAG,SAAS,aAC7B,MAAM,kBACD,MAAM,YACZ,GAAG,KACZ,IAAI;uCAoBI,YAAY,GAAG,IAAI,GAAG,SAAS,aAC7B,MAAM,WACR,MAAM,YACL,GAAG,KACZ,IAAI;mCAuwBU,MAAM,mBACJ,MAAM,EAAE,KACxB,MAAM;;AA48CT,wBAkBE"}
|
package/dist/esm/langChain.js
CHANGED
|
@@ -758,10 +758,36 @@ const createAgent = (name, modelName, systemPrompt, tools = [], responseFormat,
|
|
|
758
758
|
});
|
|
759
759
|
return agent;
|
|
760
760
|
};
|
|
761
|
+
// What the progress bar says while each tool agent-utils registers (the
|
|
762
|
+
// Tavily tools in tavily.ts) runs. A Map, so a tool named after an
|
|
763
|
+
// Object.prototype key ("constructor") is not mistaken for a label.
|
|
764
|
+
const TOOL_PROGRESS_LABELS = new Map([
|
|
765
|
+
["web_search", "Searching the web"],
|
|
766
|
+
["web_extract", "Reading web pages"],
|
|
767
|
+
["web_map", "Listing the pages of a site"],
|
|
768
|
+
["web_crawl", "Reading the pages of a site"],
|
|
769
|
+
]);
|
|
770
|
+
/**
|
|
771
|
+
* The progress message for a tool call, in words the person watching the run
|
|
772
|
+
* can read. A tool without a label (an agent's own) reads as its name with
|
|
773
|
+
* underscores as spaces: `lookup_record` → "Using lookup record".
|
|
774
|
+
* @param name - The tool's registered name
|
|
775
|
+
* @returns A plain-language message; never the raw name in quotes
|
|
776
|
+
*/
|
|
777
|
+
const toolProgressLabel = (name) => {
|
|
778
|
+
const text = String(name ?? "");
|
|
779
|
+
const label = TOOL_PROGRESS_LABELS.get(text);
|
|
780
|
+
if (label)
|
|
781
|
+
return label;
|
|
782
|
+
const words = text.replace(/_+/g, " ").trim();
|
|
783
|
+
return words ? `Using ${words}` : "Using a tool";
|
|
784
|
+
};
|
|
761
785
|
/**
|
|
762
786
|
* Executes a LangChain agent with a single user prompt and returns the raw agent
|
|
763
787
|
* response. When an `onProgress` callback is provided, LangChain callbacks are
|
|
764
788
|
* registered to forward `tool_start`, `agent_action`, and error events to the caller.
|
|
789
|
+
* A tool event's `message` is plain language (see `toolProgressLabel`); the raw tool
|
|
790
|
+
* name and input stay on its `tool` and `input` fields.
|
|
765
791
|
* Execution time is logged at the info level on completion.
|
|
766
792
|
* @param agent - A LangChain agent instance created by `createAgent`
|
|
767
793
|
* @param prompt - The user message string to send to the agent
|
|
@@ -791,15 +817,18 @@ const runAgent = async (agent, prompt, config, onProgress = null, usageTracker =
|
|
|
791
817
|
if (name)
|
|
792
818
|
onProgress({
|
|
793
819
|
type: "tool_start",
|
|
794
|
-
message:
|
|
820
|
+
message: toolProgressLabel(name),
|
|
795
821
|
tool: name,
|
|
796
822
|
progress,
|
|
797
823
|
});
|
|
798
824
|
},
|
|
825
|
+
// `action.log` is the model's own text (LangChain's default reads
|
|
826
|
+
// "Invoking: `web_extract` with `{...}`", the raw tool input), so it
|
|
827
|
+
// never reaches the progress bar.
|
|
799
828
|
handleAgentAction: (action) => {
|
|
800
829
|
onProgress({
|
|
801
830
|
type: "agent_action",
|
|
802
|
-
message: action.
|
|
831
|
+
message: toolProgressLabel(action.tool),
|
|
803
832
|
tool: action.tool,
|
|
804
833
|
input: action.toolInput,
|
|
805
834
|
progress,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gRPC-js defaults `grpc.max_receive_message_length` to 4 MiB. Agents stream
|
|
3
|
+
* their result inline in `result_json`, and image/avatar agents (GIA) routinely
|
|
4
|
+
* return payloads well above 4 MiB — a single PNG can be 5 MiB+ before the
|
|
5
|
+
* ~33% base64 inflation of embedding it in JSON — which trips
|
|
6
|
+
* `RESOURCE_EXHAUSTED: Received message larger than max`. Raise both limits to
|
|
7
|
+
* 64 MiB so large media responses pass — on the client channel AND on the
|
|
8
|
+
* agent's own gRPC server (`serve`), which would otherwise reject a large
|
|
9
|
+
* request before the handler runs. Override via the
|
|
10
|
+
* `STACKFACTOR_AGENT_MAX_MESSAGE_BYTES` env var if an even larger ceiling is
|
|
11
|
+
* needed. (-1 in gRPC-js means "unlimited", which we deliberately avoid so a
|
|
12
|
+
* runaway response can't exhaust memory.)
|
|
13
|
+
*/
|
|
14
|
+
export declare const MAX_MESSAGE_BYTES: number;
|
|
15
|
+
/**
|
|
16
|
+
* gRPC options that lift the send/receive message-size caps off their 4 MiB
|
|
17
|
+
* defaults (see `MAX_MESSAGE_BYTES`). Used for the agent clients and for the
|
|
18
|
+
* agent's gRPC server.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MESSAGE_SIZE_OPTIONS: Record<string, number>;
|
|
21
|
+
//# sourceMappingURL=messageLimits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageLimits.d.ts","sourceRoot":"","sources":["../../src/messageLimits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,QAG1B,CAAC;AAEL;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGvD,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gRPC-js defaults `grpc.max_receive_message_length` to 4 MiB. Agents stream
|
|
3
|
+
* their result inline in `result_json`, and image/avatar agents (GIA) routinely
|
|
4
|
+
* return payloads well above 4 MiB — a single PNG can be 5 MiB+ before the
|
|
5
|
+
* ~33% base64 inflation of embedding it in JSON — which trips
|
|
6
|
+
* `RESOURCE_EXHAUSTED: Received message larger than max`. Raise both limits to
|
|
7
|
+
* 64 MiB so large media responses pass — on the client channel AND on the
|
|
8
|
+
* agent's own gRPC server (`serve`), which would otherwise reject a large
|
|
9
|
+
* request before the handler runs. Override via the
|
|
10
|
+
* `STACKFACTOR_AGENT_MAX_MESSAGE_BYTES` env var if an even larger ceiling is
|
|
11
|
+
* needed. (-1 in gRPC-js means "unlimited", which we deliberately avoid so a
|
|
12
|
+
* runaway response can't exhaust memory.)
|
|
13
|
+
*/
|
|
14
|
+
export const MAX_MESSAGE_BYTES = (() => {
|
|
15
|
+
const fromEnv = Number(process.env.STACKFACTOR_AGENT_MAX_MESSAGE_BYTES);
|
|
16
|
+
return Number.isFinite(fromEnv) && fromEnv > 0 ? fromEnv : 64 * 1024 * 1024;
|
|
17
|
+
})();
|
|
18
|
+
/**
|
|
19
|
+
* gRPC options that lift the send/receive message-size caps off their 4 MiB
|
|
20
|
+
* defaults (see `MAX_MESSAGE_BYTES`). Used for the agent clients and for the
|
|
21
|
+
* agent's gRPC server.
|
|
22
|
+
*/
|
|
23
|
+
export const MESSAGE_SIZE_OPTIONS = {
|
|
24
|
+
"grpc.max_receive_message_length": MAX_MESSAGE_BYTES,
|
|
25
|
+
"grpc.max_send_message_length": MAX_MESSAGE_BYTES,
|
|
26
|
+
};
|
package/dist/esm/serve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/serve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/serve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAYtC,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AAwPpB;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,OAAO,EAAE,GAAG,KACT,OAAO,CAAC;IAAE,IAAI,EAAE,GAAG,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,CAAC,CAAC;AAEzC,MAAM,WAAW,YAAY;IAC3B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,IAAI,C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AM,OAAO,GAClB,MAAM,SAAS,EACf,UAAS,YAAiB,KACzB,OAAO,CAAC,IAAI,CA8Id,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,GAChB,MAAM,SAAS,EACf,UAAS,YAAiB,KACzB,IAAI,CAAC,MA2OP,CAAC"}
|
package/dist/esm/serve.js
CHANGED
|
@@ -5,6 +5,7 @@ import { pathToFileURL } from "node:url";
|
|
|
5
5
|
import { integration as clientIntegration, session as clientSession, } from "@stackfactor/client-api";
|
|
6
6
|
import logger from "./logger.js";
|
|
7
7
|
import { loadAgentService } from "./agentProto.js";
|
|
8
|
+
import { MESSAGE_SIZE_OPTIONS } from "./messageLimits.js";
|
|
8
9
|
import { runWithContext, installGlobals } from "./runtimeContext.js";
|
|
9
10
|
import { UsageLedger, reportUsage, reportUsageWhileRunning, } from "./usage.js";
|
|
10
11
|
// Genuine dynamic `import()` that survives TypeScript's CJS downlevelling (which
|
|
@@ -680,7 +681,9 @@ export const serve = (main, options = {}) => {
|
|
|
680
681
|
respond(ok, backendReachable, message, checks);
|
|
681
682
|
})();
|
|
682
683
|
};
|
|
683
|
-
|
|
684
|
+
// Without options grpc-js rejects any request over 4 MiB (RESOURCE_EXHAUSTED)
|
|
685
|
+
// before the handler runs; use the same ceiling as the clients.
|
|
686
|
+
const server = new grpc.Server(MESSAGE_SIZE_OPTIONS);
|
|
684
687
|
server.addService(loadAgentService(), {
|
|
685
688
|
Execute: execute,
|
|
686
689
|
HealthCheck: healthCheck,
|