@oxap/sdk 0.0.0 → 0.1.0-alpha.34
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 +572 -6
- package/dist/src/abort_signal.d.ts +5 -0
- package/dist/src/abort_signal.js +52 -0
- package/dist/src/auth_protocol.d.ts +67 -0
- package/dist/src/auth_protocol.js +113 -0
- package/dist/src/binary_resolver.d.ts +29 -0
- package/dist/src/binary_resolver.js +207 -0
- package/dist/src/execution_client.d.ts +23 -0
- package/dist/src/execution_client.js +7 -0
- package/dist/src/execution_types.d.ts +204 -0
- package/dist/src/execution_types.js +28 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/index.js +30 -0
- package/dist/src/logger.d.ts +8 -0
- package/dist/src/logger.js +16 -0
- package/dist/src/models_types.d.ts +75 -0
- package/dist/src/models_types.js +14 -0
- package/dist/src/oap_client.d.ts +64 -0
- package/dist/src/oap_client.js +1023 -0
- package/dist/src/timeout_diagnostics.d.ts +22 -0
- package/dist/src/timeout_diagnostics.js +44 -0
- package/package.json +40 -4
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { checkAbort, isAbortError, raceWithAbort, } from "./abort_signal";
|
|
2
|
+
export { resolveMakaiBinary, type BinaryResolverOptions, type ModuleResolver } from "./binary_resolver";
|
|
3
|
+
export { MakaiAuthError, flattenAuthEvent, type AuthFlowHandlers, type AuthStatus, type MakaiAuthApi, type MakaiAuthErrorKind, type MakaiAuthEvent, type ProviderAuthInfo, type AuthKind, type ProviderId, } from "./auth_protocol";
|
|
4
|
+
export { createMakaiClient, type CreateMakaiClientOptions, type MakaiAgentModelsApi, type MakaiClient, } from "./execution_client";
|
|
5
|
+
export { createOapClient, OapStdioTransport, OapUnsupportedFeatureError, OAP_PROTOCOL, OAP_VERSION, OAP_AGENT_PROFILE, OAP_PROVIDER_PROFILE, type OapEnvelope, } from "./oap_client";
|
|
6
|
+
export { MakaiAuthRequiredError, MakaiStreamError, type AgentRunRequest, type AgentRunResponse, type AgentStreamEvent, type AuthRetryPolicy, type ChatMessage, type CompletionResponse, type ContentPart, type ImageContentPart, type MakaiAgentApi, type MakaiClientOptions, type MakaiProviderApi, type MakaiStreamErrorKind, type ProviderCompleteRequest, type ProviderCompleteResponse, type ProviderStreamEvent, type RunOptions, type StopReason, type TextContentPart, type ThinkingContentPart, type ToolCallContentPart, type ToolDefinition, type ToolResultContentPart, type UsageSummary, type UsageCountField, type UnrepresentableUsageCount, } from "./execution_types";
|
|
7
|
+
export { type TimeoutDiagnosticContext, type TimeoutDiagnostics, } from "./timeout_diagnostics";
|
|
8
|
+
export { type MakaiLogger, getNoopLogger, isNoopLogger, } from "./logger";
|
|
9
|
+
export { MakaiProtocolError, type ApiId, type ListModelsRequest, type ListModelsResponse, type MakaiModelsApi, type Modality, type ModelCapability, type ModelCatalog, type ModelCost, type ModelDescriptor, type ModelLifecycle, type ModelSource, type ReasoningLevel, type ResolveModelRequest, type ResolveModelResponse, } from "./models_types";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MakaiProtocolError = exports.isNoopLogger = exports.getNoopLogger = exports.MakaiStreamError = exports.MakaiAuthRequiredError = exports.OAP_PROVIDER_PROFILE = exports.OAP_AGENT_PROFILE = exports.OAP_VERSION = exports.OAP_PROTOCOL = exports.OapUnsupportedFeatureError = exports.OapStdioTransport = exports.createOapClient = exports.createMakaiClient = exports.flattenAuthEvent = exports.MakaiAuthError = exports.resolveMakaiBinary = exports.raceWithAbort = exports.isAbortError = exports.checkAbort = void 0;
|
|
4
|
+
var abort_signal_1 = require("./abort_signal");
|
|
5
|
+
Object.defineProperty(exports, "checkAbort", { enumerable: true, get: function () { return abort_signal_1.checkAbort; } });
|
|
6
|
+
Object.defineProperty(exports, "isAbortError", { enumerable: true, get: function () { return abort_signal_1.isAbortError; } });
|
|
7
|
+
Object.defineProperty(exports, "raceWithAbort", { enumerable: true, get: function () { return abort_signal_1.raceWithAbort; } });
|
|
8
|
+
var binary_resolver_1 = require("./binary_resolver");
|
|
9
|
+
Object.defineProperty(exports, "resolveMakaiBinary", { enumerable: true, get: function () { return binary_resolver_1.resolveMakaiBinary; } });
|
|
10
|
+
var auth_protocol_1 = require("./auth_protocol");
|
|
11
|
+
Object.defineProperty(exports, "MakaiAuthError", { enumerable: true, get: function () { return auth_protocol_1.MakaiAuthError; } });
|
|
12
|
+
Object.defineProperty(exports, "flattenAuthEvent", { enumerable: true, get: function () { return auth_protocol_1.flattenAuthEvent; } });
|
|
13
|
+
var execution_client_1 = require("./execution_client");
|
|
14
|
+
Object.defineProperty(exports, "createMakaiClient", { enumerable: true, get: function () { return execution_client_1.createMakaiClient; } });
|
|
15
|
+
var oap_client_1 = require("./oap_client");
|
|
16
|
+
Object.defineProperty(exports, "createOapClient", { enumerable: true, get: function () { return oap_client_1.createOapClient; } });
|
|
17
|
+
Object.defineProperty(exports, "OapStdioTransport", { enumerable: true, get: function () { return oap_client_1.OapStdioTransport; } });
|
|
18
|
+
Object.defineProperty(exports, "OapUnsupportedFeatureError", { enumerable: true, get: function () { return oap_client_1.OapUnsupportedFeatureError; } });
|
|
19
|
+
Object.defineProperty(exports, "OAP_PROTOCOL", { enumerable: true, get: function () { return oap_client_1.OAP_PROTOCOL; } });
|
|
20
|
+
Object.defineProperty(exports, "OAP_VERSION", { enumerable: true, get: function () { return oap_client_1.OAP_VERSION; } });
|
|
21
|
+
Object.defineProperty(exports, "OAP_AGENT_PROFILE", { enumerable: true, get: function () { return oap_client_1.OAP_AGENT_PROFILE; } });
|
|
22
|
+
Object.defineProperty(exports, "OAP_PROVIDER_PROFILE", { enumerable: true, get: function () { return oap_client_1.OAP_PROVIDER_PROFILE; } });
|
|
23
|
+
var execution_types_1 = require("./execution_types");
|
|
24
|
+
Object.defineProperty(exports, "MakaiAuthRequiredError", { enumerable: true, get: function () { return execution_types_1.MakaiAuthRequiredError; } });
|
|
25
|
+
Object.defineProperty(exports, "MakaiStreamError", { enumerable: true, get: function () { return execution_types_1.MakaiStreamError; } });
|
|
26
|
+
var logger_1 = require("./logger");
|
|
27
|
+
Object.defineProperty(exports, "getNoopLogger", { enumerable: true, get: function () { return logger_1.getNoopLogger; } });
|
|
28
|
+
Object.defineProperty(exports, "isNoopLogger", { enumerable: true, get: function () { return logger_1.isNoopLogger; } });
|
|
29
|
+
var models_types_1 = require("./models_types");
|
|
30
|
+
Object.defineProperty(exports, "MakaiProtocolError", { enumerable: true, get: function () { return models_types_1.MakaiProtocolError; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface MakaiLogger {
|
|
2
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
3
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
4
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
5
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function getNoopLogger(): MakaiLogger;
|
|
8
|
+
export declare function isNoopLogger(logger: MakaiLogger): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNoopLogger = getNoopLogger;
|
|
4
|
+
exports.isNoopLogger = isNoopLogger;
|
|
5
|
+
const noopLogger = {
|
|
6
|
+
debug() { },
|
|
7
|
+
info() { },
|
|
8
|
+
warn() { },
|
|
9
|
+
error() { },
|
|
10
|
+
};
|
|
11
|
+
function getNoopLogger() {
|
|
12
|
+
return noopLogger;
|
|
13
|
+
}
|
|
14
|
+
function isNoopLogger(logger) {
|
|
15
|
+
return logger === noopLogger;
|
|
16
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { TimeoutDiagnostics } from "./timeout_diagnostics";
|
|
2
|
+
export type ProviderId = string;
|
|
3
|
+
export type ApiId = "anthropic-messages" | "openai-completions" | "openai-responses" | "azure-openai-responses" | "google-generative-ai" | "google-gemini-cli" | "ollama" | (string & {});
|
|
4
|
+
export type AuthStatus = "authenticated" | "login_required" | "expired" | "refreshing" | "login_in_progress" | "failed" | "unknown";
|
|
5
|
+
export type ModelLifecycle = "stable" | "preview" | "deprecated";
|
|
6
|
+
export type ModelCapability = "chat" | "streaming" | "tools" | "vision" | "reasoning" | "prompt_cache" | "audio_input" | "audio_output";
|
|
7
|
+
export type Modality = "text" | "image" | "audio" | "video" | "document";
|
|
8
|
+
export type ModelSource = "dynamic" | "static_fallback";
|
|
9
|
+
export type ReasoningLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
10
|
+
export interface ModelDescriptor {
|
|
11
|
+
model_ref: string;
|
|
12
|
+
model_id: string;
|
|
13
|
+
display_name: string;
|
|
14
|
+
provider_id: ProviderId;
|
|
15
|
+
api: ApiId;
|
|
16
|
+
base_url?: string;
|
|
17
|
+
auth_status: AuthStatus;
|
|
18
|
+
lifecycle?: ModelLifecycle;
|
|
19
|
+
capabilities: ModelCapability[];
|
|
20
|
+
source?: ModelSource;
|
|
21
|
+
context_window?: number;
|
|
22
|
+
max_output_tokens?: number;
|
|
23
|
+
reasoning_default?: ReasoningLevel;
|
|
24
|
+
cost?: ModelCost;
|
|
25
|
+
input_modalities?: Modality[];
|
|
26
|
+
output_modalities?: Modality[];
|
|
27
|
+
reasoning_levels?: ReasoningLevel[];
|
|
28
|
+
release_date?: string;
|
|
29
|
+
family?: string;
|
|
30
|
+
metadata?: Record<string, string>;
|
|
31
|
+
}
|
|
32
|
+
export interface ModelCost {
|
|
33
|
+
input?: number;
|
|
34
|
+
output?: number;
|
|
35
|
+
cache_read?: number;
|
|
36
|
+
cache_write?: number;
|
|
37
|
+
}
|
|
38
|
+
export interface ModelCatalog {
|
|
39
|
+
observed_at_ms?: number;
|
|
40
|
+
complete?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface ListModelsRequest {
|
|
43
|
+
provider_id?: ProviderId;
|
|
44
|
+
api?: ApiId;
|
|
45
|
+
model_id?: string;
|
|
46
|
+
include_deprecated?: boolean;
|
|
47
|
+
include_login_required?: boolean;
|
|
48
|
+
signal?: AbortSignal;
|
|
49
|
+
}
|
|
50
|
+
export interface ListModelsResponse {
|
|
51
|
+
models: ModelDescriptor[];
|
|
52
|
+
catalog?: ModelCatalog;
|
|
53
|
+
fetched_at_ms: number;
|
|
54
|
+
cache_max_age_ms: number;
|
|
55
|
+
}
|
|
56
|
+
export interface ResolveModelRequest {
|
|
57
|
+
provider_id: ProviderId;
|
|
58
|
+
api?: ApiId;
|
|
59
|
+
model_id: string;
|
|
60
|
+
signal?: AbortSignal;
|
|
61
|
+
}
|
|
62
|
+
export interface ResolveModelResponse {
|
|
63
|
+
model: ModelDescriptor;
|
|
64
|
+
}
|
|
65
|
+
export interface MakaiModelsApi {
|
|
66
|
+
list(request?: ListModelsRequest): Promise<ListModelsResponse>;
|
|
67
|
+
resolve(request: ResolveModelRequest): Promise<ResolveModelResponse>;
|
|
68
|
+
}
|
|
69
|
+
export declare class MakaiProtocolError extends Error {
|
|
70
|
+
readonly code?: string | undefined;
|
|
71
|
+
readonly diagnostics?: TimeoutDiagnostics;
|
|
72
|
+
constructor(message: string, code?: string | undefined, options?: {
|
|
73
|
+
diagnostics?: TimeoutDiagnostics;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MakaiProtocolError = void 0;
|
|
4
|
+
class MakaiProtocolError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
diagnostics;
|
|
7
|
+
constructor(message, code, options = {}) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.name = "MakaiProtocolError";
|
|
11
|
+
this.diagnostics = options.diagnostics;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.MakaiProtocolError = MakaiProtocolError;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { CreateMakaiClientOptions, MakaiClient } from "./execution_client";
|
|
2
|
+
export declare const OAP_PROTOCOL = "open-agent-protocol";
|
|
3
|
+
export declare const OAP_VERSION = "0.1";
|
|
4
|
+
export declare const OAP_AGENT_PROFILE = "open-agent-protocol.agent-control-core";
|
|
5
|
+
export declare const OAP_PROVIDER_PROFILE = "open-agent-protocol.model-provider-core";
|
|
6
|
+
export type OapEnvelope = {
|
|
7
|
+
protocol: typeof OAP_PROTOCOL;
|
|
8
|
+
version: typeof OAP_VERSION;
|
|
9
|
+
profile: string;
|
|
10
|
+
type: string;
|
|
11
|
+
id: string;
|
|
12
|
+
payload: Record<string, unknown>;
|
|
13
|
+
in_reply_to?: string;
|
|
14
|
+
session_id?: string;
|
|
15
|
+
run_id?: string;
|
|
16
|
+
inference_id?: string;
|
|
17
|
+
sequence?: number;
|
|
18
|
+
capability_revision?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare class OapUnsupportedFeatureError extends Error {
|
|
21
|
+
readonly feature: string;
|
|
22
|
+
readonly code = "unsupported_feature";
|
|
23
|
+
constructor(feature: string);
|
|
24
|
+
}
|
|
25
|
+
declare class FrameQueue {
|
|
26
|
+
private frames;
|
|
27
|
+
private waiting;
|
|
28
|
+
private closed?;
|
|
29
|
+
push(frame: OapEnvelope): void;
|
|
30
|
+
next(timeoutMs: number | undefined, signal?: AbortSignal): Promise<OapEnvelope>;
|
|
31
|
+
close(error: Error): void;
|
|
32
|
+
}
|
|
33
|
+
export declare class OapStdioTransport {
|
|
34
|
+
private readonly command;
|
|
35
|
+
private readonly args;
|
|
36
|
+
private readonly options;
|
|
37
|
+
private child?;
|
|
38
|
+
private reader?;
|
|
39
|
+
private pending;
|
|
40
|
+
private subscriptions;
|
|
41
|
+
private orphaned;
|
|
42
|
+
private closed?;
|
|
43
|
+
agentRevision?: string;
|
|
44
|
+
agentEndpoint: string;
|
|
45
|
+
agentFeatures: ReadonlySet<string>;
|
|
46
|
+
agentSource: string;
|
|
47
|
+
servesProvider: boolean;
|
|
48
|
+
constructor(command: string, args: string[], options: {
|
|
49
|
+
cwd?: string;
|
|
50
|
+
env?: NodeJS.ProcessEnv;
|
|
51
|
+
timeoutMs: number;
|
|
52
|
+
handshakeTimeoutMs?: number;
|
|
53
|
+
});
|
|
54
|
+
connect(): Promise<void>;
|
|
55
|
+
request(profile: string, type: string, payload: Record<string, unknown>, scope?: Partial<OapEnvelope>, timeoutMs?: number): Promise<OapEnvelope>;
|
|
56
|
+
send(profile: string, type: string, payload: Record<string, unknown>, scope?: Partial<OapEnvelope>): string;
|
|
57
|
+
subscribe(profile: string, kind: "session" | "inference" | "flow", id: string): FrameQueue;
|
|
58
|
+
unsubscribe(profile: string, kind: "session" | "inference" | "flow", id: string): void;
|
|
59
|
+
private receive;
|
|
60
|
+
private fail;
|
|
61
|
+
close(): Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
export declare function createOapClient(options?: CreateMakaiClientOptions): Promise<MakaiClient>;
|
|
64
|
+
export {};
|