@jini-ai/agent-runtime 0.6.22 → 0.6.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/diagnostics.d.ts +16 -1
- package/dist/diagnostics.js +44 -1
- package/dist/native-tool-policy.js +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
package/dist/diagnostics.d.ts
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module diagnostics
|
|
3
|
-
* Explain
|
|
3
|
+
* Explain executable/authentication detection failures and preserve safe startup evidence.
|
|
4
4
|
*/
|
|
5
5
|
import { type ExecutableResolutionOptions } from './executables.js';
|
|
6
6
|
import type { AgentLaunchResolution } from './launch.js';
|
|
7
7
|
import type { AgentAuthProbeResult } from './auth.js';
|
|
8
8
|
import type { AgentDiagnostic, RuntimeAgentDef } from './types.js';
|
|
9
|
+
/** Pasteable startup evidence, redacted before a UTF-8 byte cap is applied. No stack or input
|
|
10
|
+
* envelope is copied; deepest causes come first so a long wrapper cannot hide the cause.
|
|
11
|
+
* @param required Stage owned by the caller and the thrown startup value.
|
|
12
|
+
* @param options Exact host secrets and caller wording for an unconfirmed start response.
|
|
13
|
+
* @returns At most 2 KiB of actionable text; hostile diagnostic getters never escape.
|
|
14
|
+
* @complexity O(n) time/space in the messages read, with at most four causes; no I/O.
|
|
15
|
+
* @example startupFailureMessage({ stage: 'session binding', error }, {});
|
|
16
|
+
*/
|
|
17
|
+
export declare function startupFailureMessage({ stage, error }: {
|
|
18
|
+
stage: string;
|
|
19
|
+
error: unknown;
|
|
20
|
+
}, { exactSecrets, notice }?: {
|
|
21
|
+
exactSecrets?: readonly string[];
|
|
22
|
+
notice?: string;
|
|
23
|
+
}): string;
|
|
9
24
|
export declare function buildExecutableDiagnostic({ def }: {
|
|
10
25
|
def: Pick<RuntimeAgentDef, 'id' | 'name' | 'bin'>;
|
|
11
26
|
}, { configuredEnv, ...options }?: ExecutableResolutionOptions & {
|
package/dist/diagnostics.js
CHANGED
|
@@ -1,8 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module diagnostics
|
|
3
|
-
* Explain
|
|
3
|
+
* Explain executable/authentication detection failures and preserve safe startup evidence.
|
|
4
4
|
*/
|
|
5
5
|
import { agentBinEnvKey, agentSearchDirs } from './executables.js';
|
|
6
|
+
import { formatErrorForLog } from '@jini-ai/core';
|
|
7
|
+
/** Pasteable startup evidence, redacted before a UTF-8 byte cap is applied. No stack or input
|
|
8
|
+
* envelope is copied; deepest causes come first so a long wrapper cannot hide the cause.
|
|
9
|
+
* @param required Stage owned by the caller and the thrown startup value.
|
|
10
|
+
* @param options Exact host secrets and caller wording for an unconfirmed start response.
|
|
11
|
+
* @returns At most 2 KiB of actionable text; hostile diagnostic getters never escape.
|
|
12
|
+
* @complexity O(n) time/space in the messages read, with at most four causes; no I/O.
|
|
13
|
+
* @example startupFailureMessage({ stage: 'session binding', error }, {});
|
|
14
|
+
*/
|
|
15
|
+
export function startupFailureMessage({ stage, error }, { exactSecrets = [], notice = 'The assistant could not start. Correct the reported cause, then send again.' } = {}) {
|
|
16
|
+
let cause;
|
|
17
|
+
try {
|
|
18
|
+
cause = startupCauseText({ error });
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
cause = 'The error details could not be read.';
|
|
22
|
+
}
|
|
23
|
+
const safe = formatErrorForLog({ error: `${notice}\nStartup stage: ${stage}\nCause: ${cause}` }, { exactSecrets });
|
|
24
|
+
const bytes = new TextEncoder().encode(safe);
|
|
25
|
+
if (bytes.length <= 2048)
|
|
26
|
+
return safe;
|
|
27
|
+
// Streaming decode drops an incomplete trailing code point rather than inserting U+FFFD.
|
|
28
|
+
return new TextDecoder().decode(bytes.subarray(0, 2045), { stream: true }) + '…';
|
|
29
|
+
}
|
|
30
|
+
/** Bound cause traversal (including cycles); copy diagnostic fields only, never environment data. */
|
|
31
|
+
function startupCauseText({ error }) {
|
|
32
|
+
const parts = [];
|
|
33
|
+
const seen = new Set();
|
|
34
|
+
let current = error;
|
|
35
|
+
while (current != null && !seen.has(current) && parts.length < 4) {
|
|
36
|
+
seen.add(current);
|
|
37
|
+
parts.push(startupErrorPart({ error: current }));
|
|
38
|
+
current = typeof current === 'object' ? current.cause : undefined;
|
|
39
|
+
}
|
|
40
|
+
return parts.reverse().join('\nCaused by: ') || 'No startup cause was supplied.';
|
|
41
|
+
}
|
|
42
|
+
/** Retain plain messages and OS/provider codes without serializing arbitrary object fields. */
|
|
43
|
+
function startupErrorPart({ error }) {
|
|
44
|
+
if (typeof error !== 'object' || error === null)
|
|
45
|
+
return String(error);
|
|
46
|
+
const { message, code } = error;
|
|
47
|
+
return [code, message].filter(value => typeof value === 'string' || typeof value === 'number').join(': ') || 'Startup error without a message';
|
|
48
|
+
}
|
|
6
49
|
// Cap on how many searched dirs we attach to a `not-on-path` diagnostic.
|
|
7
50
|
// The resolver walks PATH + the user-toolchain whitelist, which can run to
|
|
8
51
|
// dozens of entries; the UI only needs enough to make "we looked here"
|
|
@@ -58,7 +58,7 @@ function nativeToolPolicyRefusal({ cliName, offSwitches }, _options = {}) {
|
|
|
58
58
|
const blocked = switches.length > 0 ? `with ${new Intl.ListFormat('en', { type: 'conjunction' }).format(switches)} off` : `with this chat's CLI tool limits`;
|
|
59
59
|
const pronoun = switches.length === 1 ? 'it' : 'them';
|
|
60
60
|
const action = switches.length === 0 ? `Turn on 'Full CLI access'` : `Turn ${pronoun} on`;
|
|
61
|
-
return `${cliName} can't run ${blocked}. ${action} in
|
|
61
|
+
return `${cliName} can't run ${blocked}. ${action} in gear → More settings → Agent permissions, or choose an available agent that supports these limits.`;
|
|
62
62
|
}
|
|
63
63
|
/** The same fail-closed assessment at selection and spawn; no CLI-name allowlist.
|
|
64
64
|
* Unknown explicit OFF switches stay blocked. O(c) over declared limits, without effects.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jini-ai/agent-runtime",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.23",
|
|
4
4
|
"description": "Coding-agent runtime adapters: runtime registry, detection, launch, stream parsers, and the ACP/pi-rpc subprocess transport.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -120,15 +120,15 @@
|
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@vitest/coverage-v8": "^2.1.9",
|
|
122
122
|
"@jini-ai/core": "^0.6.13",
|
|
123
|
-
"@jini-ai/
|
|
124
|
-
"@jini-ai/
|
|
123
|
+
"@jini-ai/platform": "^0.6.23",
|
|
124
|
+
"@jini-ai/integrations": "^0.6.19"
|
|
125
125
|
},
|
|
126
126
|
"dependencies": {
|
|
127
|
-
"@jini-ai/core": "^0.6.
|
|
128
|
-
"@jini-ai/protocol": "^0.6.19",
|
|
129
|
-
"@jini-ai/platform": "^0.6.22",
|
|
127
|
+
"@jini-ai/core": "^0.6.23",
|
|
130
128
|
"@jini-ai/integrations": "^0.6.19",
|
|
131
|
-
"@jini-ai/
|
|
129
|
+
"@jini-ai/platform": "^0.6.23",
|
|
130
|
+
"@jini-ai/oauth": "^0.6.19",
|
|
131
|
+
"@jini-ai/protocol": "^0.6.19"
|
|
132
132
|
},
|
|
133
133
|
"scripts": {
|
|
134
134
|
"build": "tsc -p tsconfig.json",
|