agent-framework-js 0.1.1
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/AGENT_USAGE.md +207 -0
- package/LICENSE +21 -0
- package/README.md +99 -0
- package/dist/agents/index.cjs +35 -0
- package/dist/agents/index.cjs.map +1 -0
- package/dist/agents/index.d.cts +8 -0
- package/dist/agents/index.d.ts +8 -0
- package/dist/agents/index.js +10 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/chunk-5M6ER4ZX.cjs +4 -0
- package/dist/chunk-5M6ER4ZX.cjs.map +1 -0
- package/dist/chunk-5PDJOBTD.js +38 -0
- package/dist/chunk-5PDJOBTD.js.map +1 -0
- package/dist/chunk-7ZXUIHLH.js +18 -0
- package/dist/chunk-7ZXUIHLH.js.map +1 -0
- package/dist/chunk-ACBIHS5H.js +30 -0
- package/dist/chunk-ACBIHS5H.js.map +1 -0
- package/dist/chunk-DEABART4.js +54 -0
- package/dist/chunk-DEABART4.js.map +1 -0
- package/dist/chunk-FOTCUNP5.cjs +34 -0
- package/dist/chunk-FOTCUNP5.cjs.map +1 -0
- package/dist/chunk-FSDMBWQV.cjs +20 -0
- package/dist/chunk-FSDMBWQV.cjs.map +1 -0
- package/dist/chunk-GYDY3KX5.cjs +72 -0
- package/dist/chunk-GYDY3KX5.cjs.map +1 -0
- package/dist/chunk-HGEPXJDG.js +129 -0
- package/dist/chunk-HGEPXJDG.js.map +1 -0
- package/dist/chunk-IJASUMIQ.cjs +57 -0
- package/dist/chunk-IJASUMIQ.cjs.map +1 -0
- package/dist/chunk-IU3LS5FC.cjs +10 -0
- package/dist/chunk-IU3LS5FC.cjs.map +1 -0
- package/dist/chunk-IUKD54F7.js +8 -0
- package/dist/chunk-IUKD54F7.js.map +1 -0
- package/dist/chunk-IXV4UIF5.js +79 -0
- package/dist/chunk-IXV4UIF5.js.map +1 -0
- package/dist/chunk-KEI3EALJ.cjs +10 -0
- package/dist/chunk-KEI3EALJ.cjs.map +1 -0
- package/dist/chunk-LMN75W3W.cjs +87 -0
- package/dist/chunk-LMN75W3W.cjs.map +1 -0
- package/dist/chunk-MCLVWCOB.js +3 -0
- package/dist/chunk-MCLVWCOB.js.map +1 -0
- package/dist/chunk-MQ2XTH3S.cjs +87 -0
- package/dist/chunk-MQ2XTH3S.cjs.map +1 -0
- package/dist/chunk-QJ5XHA6S.cjs +95 -0
- package/dist/chunk-QJ5XHA6S.cjs.map +1 -0
- package/dist/chunk-RD5YUB2E.js +190 -0
- package/dist/chunk-RD5YUB2E.js.map +1 -0
- package/dist/chunk-RZ43WNHR.js +8 -0
- package/dist/chunk-RZ43WNHR.js.map +1 -0
- package/dist/chunk-RZP2ZUUX.cjs +252 -0
- package/dist/chunk-RZP2ZUUX.cjs.map +1 -0
- package/dist/chunk-T2GHJ5R4.js +241 -0
- package/dist/chunk-T2GHJ5R4.js.map +1 -0
- package/dist/chunk-TAMJ5HSR.cjs +137 -0
- package/dist/chunk-TAMJ5HSR.cjs.map +1 -0
- package/dist/chunk-TLACSVEZ.cjs +201 -0
- package/dist/chunk-TLACSVEZ.cjs.map +1 -0
- package/dist/chunk-UVWQWOLO.js +196 -0
- package/dist/chunk-UVWQWOLO.js.map +1 -0
- package/dist/chunk-V472N2PK.js +91 -0
- package/dist/chunk-V472N2PK.js.map +1 -0
- package/dist/chunk-V6O6SYAN.cjs +43 -0
- package/dist/chunk-V6O6SYAN.cjs.map +1 -0
- package/dist/chunk-VLSVL5N2.js +48 -0
- package/dist/chunk-VLSVL5N2.js.map +1 -0
- package/dist/chunk-WSMYH2IN.cjs +86 -0
- package/dist/chunk-WSMYH2IN.cjs.map +1 -0
- package/dist/chunk-XPXTXOYQ.js +81 -0
- package/dist/chunk-XPXTXOYQ.js.map +1 -0
- package/dist/chunk-YBFLWRO5.cjs +194 -0
- package/dist/chunk-YBFLWRO5.cjs.map +1 -0
- package/dist/chunk-YCBDEEAV.js +82 -0
- package/dist/chunk-YCBDEEAV.js.map +1 -0
- package/dist/chunk-YH5746OF.js +69 -0
- package/dist/chunk-YH5746OF.js.map +1 -0
- package/dist/chunk-YKZJRE32.cjs +50 -0
- package/dist/chunk-YKZJRE32.cjs.map +1 -0
- package/dist/declarative/index.cjs +19 -0
- package/dist/declarative/index.cjs.map +1 -0
- package/dist/declarative/index.d.cts +60 -0
- package/dist/declarative/index.d.ts +60 -0
- package/dist/declarative/index.js +10 -0
- package/dist/declarative/index.js.map +1 -0
- package/dist/errors-CjVz4W_5.d.cts +68 -0
- package/dist/errors-CjVz4W_5.d.ts +68 -0
- package/dist/index-C2vzfbBz.d.cts +57 -0
- package/dist/index-C2vzfbBz.d.ts +57 -0
- package/dist/index-D7-znzrc.d.ts +153 -0
- package/dist/index-DdYZeNIu.d.cts +153 -0
- package/dist/index.cjs +236 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +51 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/index.cjs +19 -0
- package/dist/mcp/index.cjs.map +1 -0
- package/dist/mcp/index.d.cts +72 -0
- package/dist/mcp/index.d.ts +72 -0
- package/dist/mcp/index.js +6 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/middleware/index.cjs +17 -0
- package/dist/middleware/index.cjs.map +1 -0
- package/dist/middleware/index.d.cts +29 -0
- package/dist/middleware/index.d.ts +29 -0
- package/dist/middleware/index.js +4 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/observability/index.cjs +29 -0
- package/dist/observability/index.cjs.map +1 -0
- package/dist/observability/index.d.cts +1 -0
- package/dist/observability/index.d.ts +1 -0
- package/dist/observability/index.js +4 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/persistence/index.cjs +24 -0
- package/dist/persistence/index.cjs.map +1 -0
- package/dist/persistence/index.d.cts +51 -0
- package/dist/persistence/index.d.ts +51 -0
- package/dist/persistence/index.js +7 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/provider-CMAymr1b.d.cts +82 -0
- package/dist/provider-osAtfZ7x.d.ts +82 -0
- package/dist/providers/index.cjs +26 -0
- package/dist/providers/index.cjs.map +1 -0
- package/dist/providers/index.d.cts +107 -0
- package/dist/providers/index.d.ts +107 -0
- package/dist/providers/index.js +5 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/registry-CpO0yH5v.d.ts +57 -0
- package/dist/registry-D4fThGiN.d.cts +57 -0
- package/dist/skill-DfNChtJN.d.cts +45 -0
- package/dist/skill-DfNChtJN.d.ts +45 -0
- package/dist/skills/index.cjs +20 -0
- package/dist/skills/index.cjs.map +1 -0
- package/dist/skills/index.d.cts +30 -0
- package/dist/skills/index.d.ts +30 -0
- package/dist/skills/index.js +3 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/thread-CWVzTyti.d.ts +51 -0
- package/dist/thread-Dfo9LLf7.d.cts +51 -0
- package/dist/tool-BZg_znMZ.d.cts +50 -0
- package/dist/tool-CSCC87OD.d.ts +50 -0
- package/dist/tools/index.cjs +27 -0
- package/dist/tools/index.cjs.map +1 -0
- package/dist/tools/index.d.cts +21 -0
- package/dist/tools/index.d.ts +21 -0
- package/dist/tools/index.js +6 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types-Cn1g9Tg4.d.cts +63 -0
- package/dist/types-Cn1g9Tg4.d.ts +63 -0
- package/dist/workflows/index.cjs +50 -0
- package/dist/workflows/index.cjs.map +1 -0
- package/dist/workflows/index.d.cts +182 -0
- package/dist/workflows/index.d.ts +182 -0
- package/dist/workflows/index.js +5 -0
- package/dist/workflows/index.js.map +1 -0
- package/package.json +145 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { a as ModelCapabilities, M as Message } from './types-Cn1g9Tg4.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* LLM provider abstraction. Agents and workflows depend only on this interface,
|
|
5
|
+
* never on a concrete provider, so new providers can be added without changing
|
|
6
|
+
* agent/workflow code. (FR-007)
|
|
7
|
+
*
|
|
8
|
+
* Credentials are always obtained via a caller-supplied callback and are never
|
|
9
|
+
* bundled, persisted, or logged by the framework. (FR-005a, FR-008)
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** A caller-supplied source of credentials. The framework never stores the value. */
|
|
15
|
+
interface CredentialSource {
|
|
16
|
+
/** Return the current credential (token/api key). May be async. */
|
|
17
|
+
getCredential(): string | Promise<string>;
|
|
18
|
+
}
|
|
19
|
+
/** A tool description passed to the provider so the model can decide to call it. */
|
|
20
|
+
interface ToolSpec {
|
|
21
|
+
name: string;
|
|
22
|
+
description: string;
|
|
23
|
+
inputSchema: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
/** A request to generate a model response. */
|
|
26
|
+
interface GenerateRequest {
|
|
27
|
+
messages: Message[];
|
|
28
|
+
tools?: ToolSpec[];
|
|
29
|
+
/** Abort signal to cancel an in-flight request. */
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
}
|
|
32
|
+
/** A tool call requested by the model. */
|
|
33
|
+
interface ToolCall {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
/** Raw JSON arguments (validated by the tools module before invocation). */
|
|
37
|
+
arguments: unknown;
|
|
38
|
+
}
|
|
39
|
+
/** A complete (non-streaming) model response. */
|
|
40
|
+
interface GenerateResponse {
|
|
41
|
+
/** Final answer text. */
|
|
42
|
+
text: string;
|
|
43
|
+
/** Reasoning/thinking content — only present for reasoning-capable models. (FR-003a) */
|
|
44
|
+
reasoning?: string;
|
|
45
|
+
/** Tool calls the model wants to make, if any. */
|
|
46
|
+
toolCalls?: ToolCall[];
|
|
47
|
+
/** Approximate token usage if reported by the provider. */
|
|
48
|
+
usage?: {
|
|
49
|
+
inputTokens?: number;
|
|
50
|
+
outputTokens?: number;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** An incremental streaming chunk. */
|
|
54
|
+
type GenerateChunk = {
|
|
55
|
+
type: "text";
|
|
56
|
+
text: string;
|
|
57
|
+
} | {
|
|
58
|
+
type: "reasoning";
|
|
59
|
+
text: string;
|
|
60
|
+
} | {
|
|
61
|
+
type: "tool-call";
|
|
62
|
+
toolCall: ToolCall;
|
|
63
|
+
} | {
|
|
64
|
+
type: "done";
|
|
65
|
+
response: GenerateResponse;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* An LLM backend. Implementations adapt a concrete API (Copilot, OpenAI-compatible)
|
|
69
|
+
* onto this uniform surface.
|
|
70
|
+
*/
|
|
71
|
+
interface Provider {
|
|
72
|
+
/** Stable provider identifier, e.g. `"openai-compatible"`. */
|
|
73
|
+
readonly name: string;
|
|
74
|
+
/** Per-model capability configuration supplied by the caller. (FR-007a) */
|
|
75
|
+
readonly capabilities: ModelCapabilities;
|
|
76
|
+
/** Generate a complete response. */
|
|
77
|
+
generate(req: GenerateRequest): Promise<GenerateResponse>;
|
|
78
|
+
/** Generate a streamed response. */
|
|
79
|
+
generateStream(req: GenerateRequest): AsyncIterable<GenerateChunk>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export type { CredentialSource as C, GenerateChunk as G, Provider as P, ToolCall as T, GenerateRequest as a, GenerateResponse as b, ToolSpec as c };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { a as ModelCapabilities, M as Message } from './types-Cn1g9Tg4.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* LLM provider abstraction. Agents and workflows depend only on this interface,
|
|
5
|
+
* never on a concrete provider, so new providers can be added without changing
|
|
6
|
+
* agent/workflow code. (FR-007)
|
|
7
|
+
*
|
|
8
|
+
* Credentials are always obtained via a caller-supplied callback and are never
|
|
9
|
+
* bundled, persisted, or logged by the framework. (FR-005a, FR-008)
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** A caller-supplied source of credentials. The framework never stores the value. */
|
|
15
|
+
interface CredentialSource {
|
|
16
|
+
/** Return the current credential (token/api key). May be async. */
|
|
17
|
+
getCredential(): string | Promise<string>;
|
|
18
|
+
}
|
|
19
|
+
/** A tool description passed to the provider so the model can decide to call it. */
|
|
20
|
+
interface ToolSpec {
|
|
21
|
+
name: string;
|
|
22
|
+
description: string;
|
|
23
|
+
inputSchema: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
/** A request to generate a model response. */
|
|
26
|
+
interface GenerateRequest {
|
|
27
|
+
messages: Message[];
|
|
28
|
+
tools?: ToolSpec[];
|
|
29
|
+
/** Abort signal to cancel an in-flight request. */
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
}
|
|
32
|
+
/** A tool call requested by the model. */
|
|
33
|
+
interface ToolCall {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
/** Raw JSON arguments (validated by the tools module before invocation). */
|
|
37
|
+
arguments: unknown;
|
|
38
|
+
}
|
|
39
|
+
/** A complete (non-streaming) model response. */
|
|
40
|
+
interface GenerateResponse {
|
|
41
|
+
/** Final answer text. */
|
|
42
|
+
text: string;
|
|
43
|
+
/** Reasoning/thinking content — only present for reasoning-capable models. (FR-003a) */
|
|
44
|
+
reasoning?: string;
|
|
45
|
+
/** Tool calls the model wants to make, if any. */
|
|
46
|
+
toolCalls?: ToolCall[];
|
|
47
|
+
/** Approximate token usage if reported by the provider. */
|
|
48
|
+
usage?: {
|
|
49
|
+
inputTokens?: number;
|
|
50
|
+
outputTokens?: number;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** An incremental streaming chunk. */
|
|
54
|
+
type GenerateChunk = {
|
|
55
|
+
type: "text";
|
|
56
|
+
text: string;
|
|
57
|
+
} | {
|
|
58
|
+
type: "reasoning";
|
|
59
|
+
text: string;
|
|
60
|
+
} | {
|
|
61
|
+
type: "tool-call";
|
|
62
|
+
toolCall: ToolCall;
|
|
63
|
+
} | {
|
|
64
|
+
type: "done";
|
|
65
|
+
response: GenerateResponse;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* An LLM backend. Implementations adapt a concrete API (Copilot, OpenAI-compatible)
|
|
69
|
+
* onto this uniform surface.
|
|
70
|
+
*/
|
|
71
|
+
interface Provider {
|
|
72
|
+
/** Stable provider identifier, e.g. `"openai-compatible"`. */
|
|
73
|
+
readonly name: string;
|
|
74
|
+
/** Per-model capability configuration supplied by the caller. (FR-007a) */
|
|
75
|
+
readonly capabilities: ModelCapabilities;
|
|
76
|
+
/** Generate a complete response. */
|
|
77
|
+
generate(req: GenerateRequest): Promise<GenerateResponse>;
|
|
78
|
+
/** Generate a streamed response. */
|
|
79
|
+
generateStream(req: GenerateRequest): AsyncIterable<GenerateChunk>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export type { CredentialSource as C, GenerateChunk as G, Provider as P, ToolCall as T, GenerateRequest as a, GenerateResponse as b, ToolSpec as c };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkTLACSVEZ_cjs = require('../chunk-TLACSVEZ.cjs');
|
|
4
|
+
require('../chunk-MQ2XTH3S.cjs');
|
|
5
|
+
require('../chunk-IJASUMIQ.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "createCopilotProvider", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunkTLACSVEZ_cjs.createCopilotProvider; }
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "createOpenAICompatibleProvider", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return chunkTLACSVEZ_cjs.createOpenAICompatibleProvider; }
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "providerErrorFromStatus", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return chunkTLACSVEZ_cjs.providerErrorFromStatus; }
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, "withRetry", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return chunkTLACSVEZ_cjs.withRetry; }
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=index.cjs.map
|
|
26
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { C as CredentialSource, P as Provider } from '../provider-CMAymr1b.cjs';
|
|
2
|
+
export { G as GenerateChunk, a as GenerateRequest, b as GenerateResponse, T as ToolCall, c as ToolSpec } from '../provider-CMAymr1b.cjs';
|
|
3
|
+
import { P as ProviderError } from '../errors-CjVz4W_5.cjs';
|
|
4
|
+
import { a as ModelCapabilities } from '../types-Cn1g9Tg4.cjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Exponential-backoff retry for transient provider failures. Transient errors
|
|
8
|
+
* (429 with Retry-After, 5xx, network/timeout) are retried; auth/4xx fail fast.
|
|
9
|
+
* (FR-008a)
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** Retry tuning. All fields have safe defaults. */
|
|
15
|
+
interface RetryOptions {
|
|
16
|
+
/** Maximum retry attempts after the first try. Default 3. */
|
|
17
|
+
maxRetries?: number;
|
|
18
|
+
/** Base delay in ms for backoff. Default 250. */
|
|
19
|
+
baseDelayMs?: number;
|
|
20
|
+
/** Maximum delay cap in ms. Default 8000. */
|
|
21
|
+
maxDelayMs?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Run `fn`, retrying transient {@link ProviderError}s with exponential backoff
|
|
25
|
+
* and jitter. Non-transient errors are rethrown immediately (fail fast).
|
|
26
|
+
*
|
|
27
|
+
* @param fn - The operation to attempt. It should throw a {@link ProviderError}.
|
|
28
|
+
* @param opts - Retry tuning.
|
|
29
|
+
* @param retryAfterMs - Optional hook returning a server-specified delay (Retry-After).
|
|
30
|
+
*/
|
|
31
|
+
declare function withRetry<T>(fn: () => Promise<T>, opts?: RetryOptions, retryAfterMs?: (err: ProviderError) => number | undefined): Promise<T>;
|
|
32
|
+
/** Map an HTTP status to a {@link ProviderError} with the right retry semantics. */
|
|
33
|
+
declare function providerErrorFromStatus(status: number, message: string): ProviderError;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* OpenAI-compatible provider. Targets any endpoint speaking the OpenAI
|
|
37
|
+
* `/chat/completions` API, including local servers such as LM Studio via a custom
|
|
38
|
+
* `baseUrl`. (FR-006)
|
|
39
|
+
*
|
|
40
|
+
* @packageDocumentation
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/** Options for {@link createOpenAICompatibleProvider}. */
|
|
44
|
+
interface OpenAICompatibleProviderOptions extends CredentialSource {
|
|
45
|
+
/** Base URL of the OpenAI-compatible API, e.g. `http://localhost:1234/v1`. */
|
|
46
|
+
baseUrl: string;
|
|
47
|
+
/** Per-model capability configuration. */
|
|
48
|
+
capabilities: ModelCapabilities;
|
|
49
|
+
/** Retry tuning for transient failures. */
|
|
50
|
+
retry?: RetryOptions;
|
|
51
|
+
/** Optional custom fetch (for testing or non-standard runtimes). */
|
|
52
|
+
fetchImpl?: typeof fetch;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create an OpenAI-compatible provider (works with LM Studio, vLLM, etc.).
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const provider = createOpenAICompatibleProvider({
|
|
60
|
+
* baseUrl: "http://localhost:1234/v1",
|
|
61
|
+
* getCredential: () => process.env.LMSTUDIO_KEY ?? "",
|
|
62
|
+
* capabilities: { model: "local", maxInputTokens: 262144, maxOutputTokens: 32000 },
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
declare function createOpenAICompatibleProvider(options: OpenAICompatibleProviderOptions): Provider;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* GitHub Copilot provider. (FR-005)
|
|
70
|
+
*
|
|
71
|
+
* Copilot's chat API is OpenAI-compatible, so this provider configures the shared
|
|
72
|
+
* OpenAI-compatible transport with Copilot's endpoint and the caller-supplied
|
|
73
|
+
* credential (a Copilot/GitHub token). The token is obtained via callback and is
|
|
74
|
+
* never bundled, persisted, or logged. (FR-005a)
|
|
75
|
+
*
|
|
76
|
+
* In a frontend-only deployment the end user supplies their own token (it stays
|
|
77
|
+
* client-side); in a backend deployment the developer may supply it, or the user
|
|
78
|
+
* sends it per request over SSL/TLS and the backend must not log or persist it.
|
|
79
|
+
*
|
|
80
|
+
* @packageDocumentation
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/** Options for {@link createCopilotProvider}. */
|
|
84
|
+
interface CopilotProviderOptions extends CredentialSource {
|
|
85
|
+
/** Per-model capability configuration. */
|
|
86
|
+
capabilities: ModelCapabilities;
|
|
87
|
+
/** Override the Copilot base URL if needed. */
|
|
88
|
+
baseUrl?: string;
|
|
89
|
+
/** Retry tuning for transient failures. */
|
|
90
|
+
retry?: RetryOptions;
|
|
91
|
+
/** Optional custom fetch (for testing or non-standard runtimes). */
|
|
92
|
+
fetchImpl?: typeof fetch;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Create a GitHub Copilot provider.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* const provider = createCopilotProvider({
|
|
100
|
+
* getCredential: () => myCopilotToken, // never logged or persisted
|
|
101
|
+
* capabilities: { model: "gpt-4o", maxInputTokens: 128000, maxOutputTokens: 16000 },
|
|
102
|
+
* });
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
declare function createCopilotProvider(options: CopilotProviderOptions): Provider;
|
|
106
|
+
|
|
107
|
+
export { type CopilotProviderOptions, CredentialSource, type OpenAICompatibleProviderOptions, Provider, type RetryOptions, createCopilotProvider, createOpenAICompatibleProvider, providerErrorFromStatus, withRetry };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { C as CredentialSource, P as Provider } from '../provider-osAtfZ7x.js';
|
|
2
|
+
export { G as GenerateChunk, a as GenerateRequest, b as GenerateResponse, T as ToolCall, c as ToolSpec } from '../provider-osAtfZ7x.js';
|
|
3
|
+
import { P as ProviderError } from '../errors-CjVz4W_5.js';
|
|
4
|
+
import { a as ModelCapabilities } from '../types-Cn1g9Tg4.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Exponential-backoff retry for transient provider failures. Transient errors
|
|
8
|
+
* (429 with Retry-After, 5xx, network/timeout) are retried; auth/4xx fail fast.
|
|
9
|
+
* (FR-008a)
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** Retry tuning. All fields have safe defaults. */
|
|
15
|
+
interface RetryOptions {
|
|
16
|
+
/** Maximum retry attempts after the first try. Default 3. */
|
|
17
|
+
maxRetries?: number;
|
|
18
|
+
/** Base delay in ms for backoff. Default 250. */
|
|
19
|
+
baseDelayMs?: number;
|
|
20
|
+
/** Maximum delay cap in ms. Default 8000. */
|
|
21
|
+
maxDelayMs?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Run `fn`, retrying transient {@link ProviderError}s with exponential backoff
|
|
25
|
+
* and jitter. Non-transient errors are rethrown immediately (fail fast).
|
|
26
|
+
*
|
|
27
|
+
* @param fn - The operation to attempt. It should throw a {@link ProviderError}.
|
|
28
|
+
* @param opts - Retry tuning.
|
|
29
|
+
* @param retryAfterMs - Optional hook returning a server-specified delay (Retry-After).
|
|
30
|
+
*/
|
|
31
|
+
declare function withRetry<T>(fn: () => Promise<T>, opts?: RetryOptions, retryAfterMs?: (err: ProviderError) => number | undefined): Promise<T>;
|
|
32
|
+
/** Map an HTTP status to a {@link ProviderError} with the right retry semantics. */
|
|
33
|
+
declare function providerErrorFromStatus(status: number, message: string): ProviderError;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* OpenAI-compatible provider. Targets any endpoint speaking the OpenAI
|
|
37
|
+
* `/chat/completions` API, including local servers such as LM Studio via a custom
|
|
38
|
+
* `baseUrl`. (FR-006)
|
|
39
|
+
*
|
|
40
|
+
* @packageDocumentation
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/** Options for {@link createOpenAICompatibleProvider}. */
|
|
44
|
+
interface OpenAICompatibleProviderOptions extends CredentialSource {
|
|
45
|
+
/** Base URL of the OpenAI-compatible API, e.g. `http://localhost:1234/v1`. */
|
|
46
|
+
baseUrl: string;
|
|
47
|
+
/** Per-model capability configuration. */
|
|
48
|
+
capabilities: ModelCapabilities;
|
|
49
|
+
/** Retry tuning for transient failures. */
|
|
50
|
+
retry?: RetryOptions;
|
|
51
|
+
/** Optional custom fetch (for testing or non-standard runtimes). */
|
|
52
|
+
fetchImpl?: typeof fetch;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create an OpenAI-compatible provider (works with LM Studio, vLLM, etc.).
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const provider = createOpenAICompatibleProvider({
|
|
60
|
+
* baseUrl: "http://localhost:1234/v1",
|
|
61
|
+
* getCredential: () => process.env.LMSTUDIO_KEY ?? "",
|
|
62
|
+
* capabilities: { model: "local", maxInputTokens: 262144, maxOutputTokens: 32000 },
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
declare function createOpenAICompatibleProvider(options: OpenAICompatibleProviderOptions): Provider;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* GitHub Copilot provider. (FR-005)
|
|
70
|
+
*
|
|
71
|
+
* Copilot's chat API is OpenAI-compatible, so this provider configures the shared
|
|
72
|
+
* OpenAI-compatible transport with Copilot's endpoint and the caller-supplied
|
|
73
|
+
* credential (a Copilot/GitHub token). The token is obtained via callback and is
|
|
74
|
+
* never bundled, persisted, or logged. (FR-005a)
|
|
75
|
+
*
|
|
76
|
+
* In a frontend-only deployment the end user supplies their own token (it stays
|
|
77
|
+
* client-side); in a backend deployment the developer may supply it, or the user
|
|
78
|
+
* sends it per request over SSL/TLS and the backend must not log or persist it.
|
|
79
|
+
*
|
|
80
|
+
* @packageDocumentation
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/** Options for {@link createCopilotProvider}. */
|
|
84
|
+
interface CopilotProviderOptions extends CredentialSource {
|
|
85
|
+
/** Per-model capability configuration. */
|
|
86
|
+
capabilities: ModelCapabilities;
|
|
87
|
+
/** Override the Copilot base URL if needed. */
|
|
88
|
+
baseUrl?: string;
|
|
89
|
+
/** Retry tuning for transient failures. */
|
|
90
|
+
retry?: RetryOptions;
|
|
91
|
+
/** Optional custom fetch (for testing or non-standard runtimes). */
|
|
92
|
+
fetchImpl?: typeof fetch;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Create a GitHub Copilot provider.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* const provider = createCopilotProvider({
|
|
100
|
+
* getCredential: () => myCopilotToken, // never logged or persisted
|
|
101
|
+
* capabilities: { model: "gpt-4o", maxInputTokens: 128000, maxOutputTokens: 16000 },
|
|
102
|
+
* });
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
declare function createCopilotProvider(options: CopilotProviderOptions): Provider;
|
|
106
|
+
|
|
107
|
+
export { type CopilotProviderOptions, CredentialSource, type OpenAICompatibleProviderOptions, Provider, type RetryOptions, createCopilotProvider, createOpenAICompatibleProvider, providerErrorFromStatus, withRetry };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { T as Tool } from './tool-CSCC87OD.js';
|
|
2
|
+
import { c as ToolSpec } from './provider-osAtfZ7x.js';
|
|
3
|
+
import { T as ToolError } from './errors-CjVz4W_5.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Tool registry: registration, namespacing, granular enable/disable, and
|
|
7
|
+
* validated invocation. Tools are addressed namespaced by source (`server.tool`)
|
|
8
|
+
* so collisions across MCP servers and local code are impossible. (FR-012a, FR-014a)
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Result of invoking a tool. */
|
|
14
|
+
interface ToolResult {
|
|
15
|
+
/** The tool's (namespaced) name. */
|
|
16
|
+
name: string;
|
|
17
|
+
/** The returned value on success. */
|
|
18
|
+
value?: unknown;
|
|
19
|
+
/** A typed error on failure (fed back to the model for self-correction). */
|
|
20
|
+
error?: ToolError;
|
|
21
|
+
}
|
|
22
|
+
/** Compute the namespaced address for a tool. */
|
|
23
|
+
declare function namespacedName(tool: Pick<Tool, "name" | "source">): string;
|
|
24
|
+
/** A registry of tools available to an agent. */
|
|
25
|
+
declare class ToolRegistry {
|
|
26
|
+
private readonly tools;
|
|
27
|
+
private readonly disabled;
|
|
28
|
+
private readonly disabledServers;
|
|
29
|
+
constructor(tools?: Tool[]);
|
|
30
|
+
/** Register a tool under its namespaced name. */
|
|
31
|
+
register(tool: Tool): void;
|
|
32
|
+
/** Enable a tool by namespaced name. */
|
|
33
|
+
enable(name: string): void;
|
|
34
|
+
/** Disable a single tool by namespaced name. (FR-012a) */
|
|
35
|
+
disable(name: string): void;
|
|
36
|
+
/** Disable every tool from an MCP server id. (FR-012a) */
|
|
37
|
+
disableServer(serverId: string): void;
|
|
38
|
+
/** Re-enable every tool from an MCP server id. */
|
|
39
|
+
enableServer(serverId: string): void;
|
|
40
|
+
private isEnabled;
|
|
41
|
+
/** List currently enabled tools (those presented to the agent). */
|
|
42
|
+
list(): Tool[];
|
|
43
|
+
/** Provider-facing specs for enabled tools. */
|
|
44
|
+
specs(): ToolSpec[];
|
|
45
|
+
/**
|
|
46
|
+
* Validate and invoke a tool. Never throws for tool-level failures; instead
|
|
47
|
+
* returns a {@link ToolResult} with a typed error so the agent can self-correct.
|
|
48
|
+
* (FR-011a, FR-012, FR-012c)
|
|
49
|
+
*
|
|
50
|
+
* @param name - Namespaced tool name.
|
|
51
|
+
* @param args - Raw arguments from the model.
|
|
52
|
+
* @param timeoutMs - Optional per-call timeout.
|
|
53
|
+
*/
|
|
54
|
+
invoke(name: string, args: unknown, timeoutMs?: number): Promise<ToolResult>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { ToolRegistry as T, type ToolResult as a, namespacedName as n };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { T as Tool } from './tool-BZg_znMZ.cjs';
|
|
2
|
+
import { c as ToolSpec } from './provider-CMAymr1b.cjs';
|
|
3
|
+
import { T as ToolError } from './errors-CjVz4W_5.cjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Tool registry: registration, namespacing, granular enable/disable, and
|
|
7
|
+
* validated invocation. Tools are addressed namespaced by source (`server.tool`)
|
|
8
|
+
* so collisions across MCP servers and local code are impossible. (FR-012a, FR-014a)
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Result of invoking a tool. */
|
|
14
|
+
interface ToolResult {
|
|
15
|
+
/** The tool's (namespaced) name. */
|
|
16
|
+
name: string;
|
|
17
|
+
/** The returned value on success. */
|
|
18
|
+
value?: unknown;
|
|
19
|
+
/** A typed error on failure (fed back to the model for self-correction). */
|
|
20
|
+
error?: ToolError;
|
|
21
|
+
}
|
|
22
|
+
/** Compute the namespaced address for a tool. */
|
|
23
|
+
declare function namespacedName(tool: Pick<Tool, "name" | "source">): string;
|
|
24
|
+
/** A registry of tools available to an agent. */
|
|
25
|
+
declare class ToolRegistry {
|
|
26
|
+
private readonly tools;
|
|
27
|
+
private readonly disabled;
|
|
28
|
+
private readonly disabledServers;
|
|
29
|
+
constructor(tools?: Tool[]);
|
|
30
|
+
/** Register a tool under its namespaced name. */
|
|
31
|
+
register(tool: Tool): void;
|
|
32
|
+
/** Enable a tool by namespaced name. */
|
|
33
|
+
enable(name: string): void;
|
|
34
|
+
/** Disable a single tool by namespaced name. (FR-012a) */
|
|
35
|
+
disable(name: string): void;
|
|
36
|
+
/** Disable every tool from an MCP server id. (FR-012a) */
|
|
37
|
+
disableServer(serverId: string): void;
|
|
38
|
+
/** Re-enable every tool from an MCP server id. */
|
|
39
|
+
enableServer(serverId: string): void;
|
|
40
|
+
private isEnabled;
|
|
41
|
+
/** List currently enabled tools (those presented to the agent). */
|
|
42
|
+
list(): Tool[];
|
|
43
|
+
/** Provider-facing specs for enabled tools. */
|
|
44
|
+
specs(): ToolSpec[];
|
|
45
|
+
/**
|
|
46
|
+
* Validate and invoke a tool. Never throws for tool-level failures; instead
|
|
47
|
+
* returns a {@link ToolResult} with a typed error so the agent can self-correct.
|
|
48
|
+
* (FR-011a, FR-012, FR-012c)
|
|
49
|
+
*
|
|
50
|
+
* @param name - Namespaced tool name.
|
|
51
|
+
* @param args - Raw arguments from the model.
|
|
52
|
+
* @param timeoutMs - Optional per-call timeout.
|
|
53
|
+
*/
|
|
54
|
+
invoke(name: string, args: unknown, timeoutMs?: number): Promise<ToolResult>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { ToolRegistry as T, type ToolResult as a, namespacedName as n };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skills: domain-specific knowledge bundles attached to agents. Skills use
|
|
3
|
+
* progressive disclosure — only a skill's short description is used to decide
|
|
4
|
+
* relevance, and its full content is loaded only when the skill is deemed needed.
|
|
5
|
+
* (FR-016, FR-017)
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/** A source of skill content, loaded on demand. */
|
|
10
|
+
type SkillSource = {
|
|
11
|
+
kind: "inline";
|
|
12
|
+
content: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "file";
|
|
15
|
+
path: string;
|
|
16
|
+
} | {
|
|
17
|
+
kind: "code";
|
|
18
|
+
load: () => Promise<string>;
|
|
19
|
+
};
|
|
20
|
+
/** A domain knowledge bundle. */
|
|
21
|
+
interface Skill {
|
|
22
|
+
/** Unique skill name. */
|
|
23
|
+
name: string;
|
|
24
|
+
/** Short description — the ONLY text used to decide relevance. (FR-017) */
|
|
25
|
+
description: string;
|
|
26
|
+
/** Content sources, read only when the skill is selected. */
|
|
27
|
+
sources: SkillSource[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Define a skill.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const refund = defineSkill({
|
|
35
|
+
* name: "refund-policy",
|
|
36
|
+
* description: "Company refund and return rules.",
|
|
37
|
+
* sources: [{ kind: "inline", content: "Refunds allowed within 30 days..." }],
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare function defineSkill(skill: Skill): Skill;
|
|
42
|
+
/** Read a single source's content. File sources require a Node runtime. */
|
|
43
|
+
declare function loadSource(source: SkillSource): Promise<string>;
|
|
44
|
+
|
|
45
|
+
export { type Skill as S, type SkillSource as a, defineSkill as d, loadSource as l };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skills: domain-specific knowledge bundles attached to agents. Skills use
|
|
3
|
+
* progressive disclosure — only a skill's short description is used to decide
|
|
4
|
+
* relevance, and its full content is loaded only when the skill is deemed needed.
|
|
5
|
+
* (FR-016, FR-017)
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/** A source of skill content, loaded on demand. */
|
|
10
|
+
type SkillSource = {
|
|
11
|
+
kind: "inline";
|
|
12
|
+
content: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "file";
|
|
15
|
+
path: string;
|
|
16
|
+
} | {
|
|
17
|
+
kind: "code";
|
|
18
|
+
load: () => Promise<string>;
|
|
19
|
+
};
|
|
20
|
+
/** A domain knowledge bundle. */
|
|
21
|
+
interface Skill {
|
|
22
|
+
/** Unique skill name. */
|
|
23
|
+
name: string;
|
|
24
|
+
/** Short description — the ONLY text used to decide relevance. (FR-017) */
|
|
25
|
+
description: string;
|
|
26
|
+
/** Content sources, read only when the skill is selected. */
|
|
27
|
+
sources: SkillSource[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Define a skill.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const refund = defineSkill({
|
|
35
|
+
* name: "refund-policy",
|
|
36
|
+
* description: "Company refund and return rules.",
|
|
37
|
+
* sources: [{ kind: "inline", content: "Refunds allowed within 30 days..." }],
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare function defineSkill(skill: Skill): Skill;
|
|
42
|
+
/** Read a single source's content. File sources require a Node runtime. */
|
|
43
|
+
declare function loadSource(source: SkillSource): Promise<string>;
|
|
44
|
+
|
|
45
|
+
export { type Skill as S, type SkillSource as a, defineSkill as d, loadSource as l };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkWSMYH2IN_cjs = require('../chunk-WSMYH2IN.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "SkillIndex", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkWSMYH2IN_cjs.SkillIndex; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "defineSkill", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkWSMYH2IN_cjs.defineSkill; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "loadSource", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkWSMYH2IN_cjs.loadSource; }
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=index.cjs.map
|
|
20
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { S as Skill } from '../skill-DfNChtJN.cjs';
|
|
2
|
+
export { a as SkillSource, d as defineSkill, l as loadSource } from '../skill-DfNChtJN.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Client-side keyword/text index over skill descriptions. No embeddings and no
|
|
6
|
+
* extra provider — relevance is decided by simple token overlap so it runs fully
|
|
7
|
+
* in the browser/edge. Full content is loaded only after a skill is selected.
|
|
8
|
+
* (FR-017, FR-017a)
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Indexes skills by description and selects relevant ones for a prompt. */
|
|
14
|
+
declare class SkillIndex {
|
|
15
|
+
private readonly entries;
|
|
16
|
+
constructor(skills?: Skill[]);
|
|
17
|
+
/** Add a skill to the index (description-only). */
|
|
18
|
+
add(skill: Skill): void;
|
|
19
|
+
/**
|
|
20
|
+
* Select skills relevant to `prompt` by keyword overlap with their descriptions.
|
|
21
|
+
*
|
|
22
|
+
* @param prompt - The user prompt.
|
|
23
|
+
* @param minOverlap - Minimum overlapping tokens to count as relevant. Default 1.
|
|
24
|
+
*/
|
|
25
|
+
select(prompt: string, minOverlap?: number): Skill[];
|
|
26
|
+
/** Load the full content of a selected skill (concatenated sources). (FR-017) */
|
|
27
|
+
load(skill: Skill): Promise<string>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { Skill, SkillIndex };
|