@stackfactor/agent-utils 1.2.2 → 1.2.4
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/cjs/langChain.d.ts.map +1 -1
- package/dist/cjs/langChain.js +1 -0
- package/dist/cjs/serve.d.ts.map +1 -1
- package/dist/cjs/serve.js +44 -16
- package/dist/esm/langChain.d.ts.map +1 -1
- package/dist/esm/langChain.js +1 -0
- package/dist/esm/serve.d.ts.map +1 -1
- package/dist/esm/serve.js +44 -16
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";0CAiD6C,GAAG,KAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";0CAiD6C,GAAG,KAAG,IAAI;wBA0hB/C,MAAM,aACD,MAAM,gBACH,MAAM,SACb,GAAG,EAAE,kBACI,GAAG,UACX,GAAG,KACV,GAAG;sBAyBG,GAAG,UACF,MAAM,UACN,GAAG,eACC,QAAQ,GAAG,IAAI,KAC1B,OAAO,CAAC,GAAG,CAAC;oCAqXF,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,eACT,MAAM,eACN,MAAM,wBACG,OAAO,WACpB,GAAG,cACA,MAAM,UACV,GAAG,EAAE,KACX,OAAO,CAAC,GAAG,CAAC;sDAosBF,MAAM,UACT,GAAG,UACH,MAAM,YACL,GAAG,KACX,OAAO,CAAC,GAAG,CAAC;0CAn+B8B,GAAG,KAAG,MAAM;mCAoBxC,MAAM,mBACJ,MAAM,EAAE,KACxB,MAAM;;AAwgCT,wBAQE"}
|
package/dist/cjs/langChain.js
CHANGED
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;AA8LtC;;;;;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;CAC9B;AAkDD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,GAChB,MAAM,SAAS,EACf,UAAS,YAAiB,KACzB,IAAI,CAAC,MAuKP,CAAC"}
|
package/dist/cjs/serve.js
CHANGED
|
@@ -45,9 +45,6 @@ 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
47
|
const runtimeContext_js_1 = require("./runtimeContext.js");
|
|
48
|
-
// The conventional self-check module run on a deep HealthCheck when the caller
|
|
49
|
-
// doesn't specify `check_code`. Resolved relative to the agent's app root.
|
|
50
|
-
const DEFAULT_CHECK_PATH = "src/check.js";
|
|
51
48
|
// Genuine dynamic `import()` that survives TypeScript's CJS downlevelling (which
|
|
52
49
|
// would otherwise turn `import()` into `require()` and break file:// URLs and
|
|
53
50
|
// ESM check modules). Built once; see the call site in runSelfCheck.
|
|
@@ -60,9 +57,8 @@ const SELF_CHECK_TIMEOUT_MS = 20_000;
|
|
|
60
57
|
* path that escapes it or is absolute (the path may originate from the
|
|
61
58
|
* integration config, so treat it as untrusted). Returns null when unsafe.
|
|
62
59
|
*/
|
|
63
|
-
const resolveCheckPath = (
|
|
60
|
+
const resolveCheckPath = (rel) => {
|
|
64
61
|
const root = process.cwd();
|
|
65
|
-
const rel = (checkCode || "").trim() || DEFAULT_CHECK_PATH;
|
|
66
62
|
const dest = (0, node_path_1.resolve)(root, rel);
|
|
67
63
|
const back = (0, node_path_1.relative)(root, dest);
|
|
68
64
|
if (back === "" || back.startsWith("..") || (0, node_path_1.isAbsolute)(back)) {
|
|
@@ -85,19 +81,51 @@ const normalizeChecks = (raw) => {
|
|
|
85
81
|
}));
|
|
86
82
|
};
|
|
87
83
|
/**
|
|
88
|
-
* Loads and runs the agent's self-check module
|
|
89
|
-
* `
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
84
|
+
* Loads and runs the agent's self-check module named by `check_code`. There is
|
|
85
|
+
* NO default path — if `check_code` is unset, synthetic testing is reported as
|
|
86
|
+
* not enabled (we never guess at `src/check.js`). The check follows the same
|
|
87
|
+
* programming model as `main`: it receives the request {@link AbortSignal} and
|
|
88
|
+
* reads `config` / `request` (incl. `request.session`) from the per-request
|
|
89
|
+
* globals (bound here via {@link runWithContext}); the logger is imported. The
|
|
90
|
+
* agent owns only its own checks — reachability/version rows are synthesised
|
|
91
|
+
* backend-side. Never throws: a load error, bad export, thrown error, or timeout
|
|
92
|
+
* collapses to a single failed `synthetic_check` row.
|
|
96
93
|
*/
|
|
97
94
|
const runSelfCheck = async (checkCode, config, session) => {
|
|
98
|
-
const
|
|
99
|
-
if (!
|
|
100
|
-
|
|
95
|
+
const rel = (checkCode || "").trim();
|
|
96
|
+
if (!rel) {
|
|
97
|
+
// No self-check configured. Don't assume a default module — surface that
|
|
98
|
+
// synthetic testing simply isn't enabled for this integration.
|
|
99
|
+
logger_js_1.default.log(null, logger_js_1.default.levels.info, "Self-check skipped: no checkCode configured (synthetic testing not enabled).");
|
|
100
|
+
return [
|
|
101
|
+
{
|
|
102
|
+
name: "synthetic_check",
|
|
103
|
+
ok: false,
|
|
104
|
+
detail: "synthetic testing not enabled — no checkCode configured for this integration",
|
|
105
|
+
severity: "warn",
|
|
106
|
+
},
|
|
107
|
+
];
|
|
108
|
+
}
|
|
109
|
+
const modulePath = resolveCheckPath(rel);
|
|
110
|
+
if (!modulePath) {
|
|
111
|
+
return [
|
|
112
|
+
{
|
|
113
|
+
name: "synthetic_check",
|
|
114
|
+
ok: false,
|
|
115
|
+
detail: `invalid checkCode path "${rel}"`,
|
|
116
|
+
severity: "warn",
|
|
117
|
+
},
|
|
118
|
+
];
|
|
119
|
+
}
|
|
120
|
+
if (!(0, node_fs_1.existsSync)(modulePath)) {
|
|
121
|
+
return [
|
|
122
|
+
{
|
|
123
|
+
name: "synthetic_check",
|
|
124
|
+
ok: false,
|
|
125
|
+
detail: `checkCode "${rel}" is configured but the module was not found in the agent image`,
|
|
126
|
+
severity: "warn",
|
|
127
|
+
},
|
|
128
|
+
];
|
|
101
129
|
}
|
|
102
130
|
let checkFn;
|
|
103
131
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";0CAiD6C,GAAG,KAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";0CAiD6C,GAAG,KAAG,IAAI;wBA0hB/C,MAAM,aACD,MAAM,gBACH,MAAM,SACb,GAAG,EAAE,kBACI,GAAG,UACX,GAAG,KACV,GAAG;sBAyBG,GAAG,UACF,MAAM,UACN,GAAG,eACC,QAAQ,GAAG,IAAI,KAC1B,OAAO,CAAC,GAAG,CAAC;oCAqXF,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,eACT,MAAM,eACN,MAAM,wBACG,OAAO,WACpB,GAAG,cACA,MAAM,UACV,GAAG,EAAE,KACX,OAAO,CAAC,GAAG,CAAC;sDAosBF,MAAM,UACT,GAAG,UACH,MAAM,YACL,GAAG,KACX,OAAO,CAAC,GAAG,CAAC;0CAn+B8B,GAAG,KAAG,MAAM;mCAoBxC,MAAM,mBACJ,MAAM,EAAE,KACxB,MAAM;;AAwgCT,wBAQE"}
|
package/dist/esm/langChain.js
CHANGED
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;AA8LtC;;;;;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;CAC9B;AAkDD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,GAChB,MAAM,SAAS,EACf,UAAS,YAAiB,KACzB,IAAI,CAAC,MAuKP,CAAC"}
|
package/dist/esm/serve.js
CHANGED
|
@@ -6,9 +6,6 @@ import { session as clientSession } from "@stackfactor/client-api";
|
|
|
6
6
|
import logger from "./logger.js";
|
|
7
7
|
import { loadAgentService } from "./agentProto.js";
|
|
8
8
|
import { runWithContext, installGlobals } from "./runtimeContext.js";
|
|
9
|
-
// The conventional self-check module run on a deep HealthCheck when the caller
|
|
10
|
-
// doesn't specify `check_code`. Resolved relative to the agent's app root.
|
|
11
|
-
const DEFAULT_CHECK_PATH = "src/check.js";
|
|
12
9
|
// Genuine dynamic `import()` that survives TypeScript's CJS downlevelling (which
|
|
13
10
|
// would otherwise turn `import()` into `require()` and break file:// URLs and
|
|
14
11
|
// ESM check modules). Built once; see the call site in runSelfCheck.
|
|
@@ -21,9 +18,8 @@ const SELF_CHECK_TIMEOUT_MS = 20_000;
|
|
|
21
18
|
* path that escapes it or is absolute (the path may originate from the
|
|
22
19
|
* integration config, so treat it as untrusted). Returns null when unsafe.
|
|
23
20
|
*/
|
|
24
|
-
const resolveCheckPath = (
|
|
21
|
+
const resolveCheckPath = (rel) => {
|
|
25
22
|
const root = process.cwd();
|
|
26
|
-
const rel = (checkCode || "").trim() || DEFAULT_CHECK_PATH;
|
|
27
23
|
const dest = resolve(root, rel);
|
|
28
24
|
const back = relative(root, dest);
|
|
29
25
|
if (back === "" || back.startsWith("..") || isAbsolute(back)) {
|
|
@@ -46,19 +42,51 @@ const normalizeChecks = (raw) => {
|
|
|
46
42
|
}));
|
|
47
43
|
};
|
|
48
44
|
/**
|
|
49
|
-
* Loads and runs the agent's self-check module
|
|
50
|
-
* `
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
45
|
+
* Loads and runs the agent's self-check module named by `check_code`. There is
|
|
46
|
+
* NO default path — if `check_code` is unset, synthetic testing is reported as
|
|
47
|
+
* not enabled (we never guess at `src/check.js`). The check follows the same
|
|
48
|
+
* programming model as `main`: it receives the request {@link AbortSignal} and
|
|
49
|
+
* reads `config` / `request` (incl. `request.session`) from the per-request
|
|
50
|
+
* globals (bound here via {@link runWithContext}); the logger is imported. The
|
|
51
|
+
* agent owns only its own checks — reachability/version rows are synthesised
|
|
52
|
+
* backend-side. Never throws: a load error, bad export, thrown error, or timeout
|
|
53
|
+
* collapses to a single failed `synthetic_check` row.
|
|
57
54
|
*/
|
|
58
55
|
const runSelfCheck = async (checkCode, config, session) => {
|
|
59
|
-
const
|
|
60
|
-
if (!
|
|
61
|
-
|
|
56
|
+
const rel = (checkCode || "").trim();
|
|
57
|
+
if (!rel) {
|
|
58
|
+
// No self-check configured. Don't assume a default module — surface that
|
|
59
|
+
// synthetic testing simply isn't enabled for this integration.
|
|
60
|
+
logger.log(null, logger.levels.info, "Self-check skipped: no checkCode configured (synthetic testing not enabled).");
|
|
61
|
+
return [
|
|
62
|
+
{
|
|
63
|
+
name: "synthetic_check",
|
|
64
|
+
ok: false,
|
|
65
|
+
detail: "synthetic testing not enabled — no checkCode configured for this integration",
|
|
66
|
+
severity: "warn",
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
const modulePath = resolveCheckPath(rel);
|
|
71
|
+
if (!modulePath) {
|
|
72
|
+
return [
|
|
73
|
+
{
|
|
74
|
+
name: "synthetic_check",
|
|
75
|
+
ok: false,
|
|
76
|
+
detail: `invalid checkCode path "${rel}"`,
|
|
77
|
+
severity: "warn",
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
if (!existsSync(modulePath)) {
|
|
82
|
+
return [
|
|
83
|
+
{
|
|
84
|
+
name: "synthetic_check",
|
|
85
|
+
ok: false,
|
|
86
|
+
detail: `checkCode "${rel}" is configured but the module was not found in the agent image`,
|
|
87
|
+
severity: "warn",
|
|
88
|
+
},
|
|
89
|
+
];
|
|
62
90
|
}
|
|
63
91
|
let checkFn;
|
|
64
92
|
try {
|