@acosmi/sdk-ts 1.0.2 → 1.1.0
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 +34 -0
- package/README.md +72 -5
- package/dist/browser/index.mjs +501 -3
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.mjs +501 -3
- package/dist/index.mjs.map +1 -1
- package/dist/node/adapters/anthropic.d.cts +1 -1
- package/dist/node/adapters/anthropic.d.ts +1 -1
- package/dist/node/adapters/openai.d.cts +1 -1
- package/dist/node/adapters/openai.d.ts +1 -1
- package/dist/node/{index-C3Z_84Bv.d.cts → index-BI8EgBXu.d.cts} +1 -1
- package/dist/node/{index-C3Z_84Bv.d.ts → index-BI8EgBXu.d.ts} +1 -1
- package/dist/node/index.cjs +502 -2
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +210 -7
- package/dist/node/index.d.ts +210 -7
- package/dist/node/index.mjs +501 -3
- package/dist/node/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/node/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as ServerMetadata, T as TokenResponse, a as TokenSet, C as ClientRegistration, M as
|
|
2
|
-
export { I as APIResponse, J as AnthropicContentBlock, K as AnthropicUsage, L as BucketClassCommercial, R as BucketClassGeneric, U as BucketInfo, V as BucketRow, X as BusinessError, Y as ChatContentBlock, Z as ChatMessage, _ as ChatUsage, $ as ConsumeRecord, a0 as EffortConfig, a1 as GeoLoc, a2 as HTTPError, a3 as ModelNotFoundError, a4 as NetworkError, a5 as Notification, a6 as NotificationUnreadCount, a7 as OpenAIChatChoice, a8 as OpenAIChatMessage, a9 as OpenAIChatResponse, aa as OpenAIFunctionCall, ab as OpenAIStreamChoice, ac as OpenAIStreamChunk, ad as OpenAIStreamDelta, ae as OpenAIStreamToolCall, af as OpenAIToolCall, ag as OpenAIUsage, ah as OrderTerminalError, ai as OutputConfig, aj as ProviderFormat, ak as RateLimitError, al as ServerTool, am as ServerToolTypeWebSearch, an as SkillStoreListItem, ao as StreamError, ap as ThinkingConfig, aq as ThinkingHigh, ar as ThinkingHighMinMaxTokens, as as ThinkingMax, at as ThinkingMaxFallbackMaxTokens, au as ThinkingOff, av as ToolListResponse, aw as ToolProvider, ax as WebSearchConfig, ay as WebSearchSource, az as YudaoPageResult, aA as anthropicResponseTextContent, aB as anthropicResponseThinkingContent, aC as anthropicResponseToolUseBlocks, aD as apiResponseBusinessError, aE as apiResponseGetMessage, aF as bucketInfoIsCommercial, aG as bucketRowIsCommercial, aH as getAdapter, aI as getAdapterForModel, aJ as newThinkingConfig, aK as newWebSearchTool, aL as parseNotificationEvent, aM as parseSettlement, aN as parseSourcesEvent, aO as tokenSetIsExpired } from './index-
|
|
1
|
+
import { S as ServerMetadata, T as TokenResponse, a as TokenSet, C as ClientRegistration, M as ManagedModel, b as ModelCoefficient, Q as QuotaSummary, c as ModelCapabilities, d as ChatRequest, P as ProviderAdapter, e as ChatResponse, A as AnthropicResponse, f as StreamEvent, g as SourcesEvent, h as StreamSettlement, E as EntitlementBalance, B as BalanceDetail, i as EntitlementItem, j as ConsumeRecordPage, k as ModelByQuotaResponse, l as ModelBucket, m as TokenPackage, n as PayPayload, O as Order, o as OrderStatus, W as WalletStats, p as Transaction, q as SkillStoreQuery, r as SkillStoreItem, s as SkillBrowseResponse, t as SkillBrowseListResponse, u as SkillSummary, v as CertificationStatus, G as GenerateSkillRequest, w as GenerateSkillResult, x as OptimizeSkillRequest, y as OptimizeSkillResult, z as ToolView, N as NotificationList, D as DeviceRegistration, F as NotificationPreference, H as WSEvent } from './index-BI8EgBXu.cjs';
|
|
2
|
+
export { I as APIResponse, J as AnthropicContentBlock, K as AnthropicUsage, L as BucketClassCommercial, R as BucketClassGeneric, U as BucketInfo, V as BucketRow, X as BusinessError, Y as ChatContentBlock, Z as ChatMessage, _ as ChatUsage, $ as ConsumeRecord, a0 as EffortConfig, a1 as GeoLoc, a2 as HTTPError, a3 as ModelNotFoundError, a4 as NetworkError, a5 as Notification, a6 as NotificationUnreadCount, a7 as OpenAIChatChoice, a8 as OpenAIChatMessage, a9 as OpenAIChatResponse, aa as OpenAIFunctionCall, ab as OpenAIStreamChoice, ac as OpenAIStreamChunk, ad as OpenAIStreamDelta, ae as OpenAIStreamToolCall, af as OpenAIToolCall, ag as OpenAIUsage, ah as OrderTerminalError, ai as OutputConfig, aj as ProviderFormat, ak as RateLimitError, al as ServerTool, am as ServerToolTypeWebSearch, an as SkillStoreListItem, ao as StreamError, ap as ThinkingConfig, aq as ThinkingHigh, ar as ThinkingHighMinMaxTokens, as as ThinkingMax, at as ThinkingMaxFallbackMaxTokens, au as ThinkingOff, av as ToolListResponse, aw as ToolProvider, ax as WebSearchConfig, ay as WebSearchSource, az as YudaoPageResult, aA as anthropicResponseTextContent, aB as anthropicResponseThinkingContent, aC as anthropicResponseToolUseBlocks, aD as apiResponseBusinessError, aE as apiResponseGetMessage, aF as bucketInfoIsCommercial, aG as bucketRowIsCommercial, aH as getAdapter, aI as getAdapterForModel, aJ as newThinkingConfig, aK as newWebSearchTool, aL as parseNotificationEvent, aM as parseSettlement, aN as parseSourcesEvent, aO as tokenSetIsExpired } from './index-BI8EgBXu.cjs';
|
|
3
3
|
import { M as MinimalSanitizeConfig } from './index-nvLKgCm9.cjs';
|
|
4
4
|
export { i as sanitize } from './index-nvLKgCm9.cjs';
|
|
5
5
|
export { AnthropicAdapter } from './adapters/anthropic.cjs';
|
|
@@ -297,10 +297,182 @@ interface BlockMeta {
|
|
|
297
297
|
*/
|
|
298
298
|
declare function extractAnthropicBlockMeta(eventType: string, data: string, blockTypeMap: Map<number, BlockMeta>): [number, string, boolean];
|
|
299
299
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
300
|
+
type AgentRunStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
301
|
+
interface AgentRunLocalContextPolicy {
|
|
302
|
+
enabled?: boolean;
|
|
303
|
+
readonly?: boolean;
|
|
304
|
+
maxBytes?: number;
|
|
305
|
+
allowedTools?: string[];
|
|
306
|
+
}
|
|
307
|
+
interface AgentRunArtifactPolicy {
|
|
308
|
+
enabled?: boolean;
|
|
309
|
+
maxFiles?: number;
|
|
310
|
+
}
|
|
311
|
+
interface AgentRunCreateRequest {
|
|
312
|
+
appId: string;
|
|
313
|
+
mode?: string;
|
|
314
|
+
sessionId?: string;
|
|
315
|
+
input: string;
|
|
316
|
+
messages?: unknown[];
|
|
317
|
+
model?: string;
|
|
318
|
+
activeSkillIds?: string[];
|
|
319
|
+
knowledgeBaseIds?: string[];
|
|
320
|
+
metadata?: Record<string, string>;
|
|
321
|
+
localContextPolicy?: AgentRunLocalContextPolicy;
|
|
322
|
+
artifactPolicy?: AgentRunArtifactPolicy;
|
|
323
|
+
}
|
|
324
|
+
interface AgentRun {
|
|
325
|
+
runId: string;
|
|
326
|
+
sessionId: string;
|
|
327
|
+
appId?: string;
|
|
328
|
+
mode?: string;
|
|
329
|
+
status: AgentRunStatus;
|
|
330
|
+
createdAt?: string;
|
|
331
|
+
startedAt?: string;
|
|
332
|
+
completedAt?: string;
|
|
333
|
+
error?: AgentRunErrorPayload;
|
|
334
|
+
metadata?: Record<string, string>;
|
|
335
|
+
}
|
|
336
|
+
interface AgentRunCreateResponse {
|
|
337
|
+
runId: string;
|
|
338
|
+
sessionId: string;
|
|
339
|
+
status: AgentRunStatus;
|
|
340
|
+
}
|
|
341
|
+
interface AgentRunArtifact {
|
|
342
|
+
id: string;
|
|
343
|
+
filename: string;
|
|
344
|
+
contentType?: string;
|
|
345
|
+
size?: number;
|
|
346
|
+
type?: string;
|
|
347
|
+
metadata?: Record<string, string>;
|
|
348
|
+
}
|
|
349
|
+
interface AgentRunArtifactList {
|
|
350
|
+
artifacts: AgentRunArtifact[];
|
|
351
|
+
}
|
|
352
|
+
interface AgentRunDownload {
|
|
353
|
+
data: Uint8Array;
|
|
354
|
+
filename: string;
|
|
355
|
+
contentType?: string;
|
|
356
|
+
}
|
|
357
|
+
interface AgentRunUsage {
|
|
358
|
+
inputTokens?: number;
|
|
359
|
+
outputTokens?: number;
|
|
360
|
+
totalTokens?: number;
|
|
361
|
+
cacheReadTokens?: number;
|
|
362
|
+
cacheCreateTokens?: number;
|
|
363
|
+
exact?: boolean;
|
|
364
|
+
source?: string;
|
|
365
|
+
[key: string]: unknown;
|
|
366
|
+
}
|
|
367
|
+
interface AgentRunSettlement {
|
|
368
|
+
requestId?: string;
|
|
369
|
+
status?: string;
|
|
370
|
+
consumeStatus?: string;
|
|
371
|
+
inputTokens?: number;
|
|
372
|
+
outputTokens?: number;
|
|
373
|
+
totalTokens?: number;
|
|
374
|
+
cacheReadTokens?: number;
|
|
375
|
+
cacheCreateTokens?: number;
|
|
376
|
+
tokenRemaining?: number;
|
|
377
|
+
callRemaining?: number;
|
|
378
|
+
retryQueued?: boolean;
|
|
379
|
+
exact?: boolean;
|
|
380
|
+
[key: string]: unknown;
|
|
381
|
+
}
|
|
382
|
+
interface AgentRunErrorPayload {
|
|
383
|
+
code?: string;
|
|
384
|
+
message: string;
|
|
385
|
+
stage?: string;
|
|
386
|
+
retryable?: boolean;
|
|
387
|
+
raw?: unknown;
|
|
388
|
+
}
|
|
389
|
+
interface AgentRunLocalToolResult {
|
|
390
|
+
requestId: string;
|
|
391
|
+
ok: boolean;
|
|
392
|
+
content?: unknown;
|
|
393
|
+
error?: string;
|
|
394
|
+
}
|
|
395
|
+
interface AgentRunLocalToolHandlerContext {
|
|
396
|
+
runId: string;
|
|
397
|
+
requestId: string;
|
|
398
|
+
name: string;
|
|
399
|
+
signal: AbortSignal;
|
|
400
|
+
}
|
|
401
|
+
type AgentRunLocalToolHandler = (input: unknown, context: AgentRunLocalToolHandlerContext) => Promise<unknown> | unknown;
|
|
402
|
+
interface AgentRunStreamOptions {
|
|
403
|
+
/**
|
|
404
|
+
* true by default. When enabled, an error event is converted into
|
|
405
|
+
* AgentRunStreamError after the event has been parsed.
|
|
406
|
+
*/
|
|
407
|
+
throwOnError?: boolean;
|
|
408
|
+
}
|
|
409
|
+
interface AgentRunRunOptions extends AgentRunStreamOptions {
|
|
410
|
+
}
|
|
411
|
+
interface AgentRunWithLocalToolsOptions extends AgentRunRunOptions {
|
|
412
|
+
timeoutMs?: number;
|
|
413
|
+
onEvent?: (event: AgentRunStreamEvent) => void | Promise<void>;
|
|
414
|
+
}
|
|
415
|
+
type AgentRunStreamEvent = {
|
|
416
|
+
type: 'run_started';
|
|
417
|
+
runId: string;
|
|
418
|
+
sessionId: string;
|
|
419
|
+
} | {
|
|
420
|
+
type: 'status';
|
|
421
|
+
status: AgentRunStatus | string;
|
|
422
|
+
message?: string;
|
|
423
|
+
} | {
|
|
424
|
+
type: 'text_delta';
|
|
425
|
+
text: string;
|
|
426
|
+
} | {
|
|
427
|
+
type: 'reasoning_delta';
|
|
428
|
+
text: string;
|
|
429
|
+
} | {
|
|
430
|
+
type: 'tool_call';
|
|
431
|
+
id: string;
|
|
432
|
+
name: string;
|
|
433
|
+
input?: unknown;
|
|
434
|
+
} | {
|
|
435
|
+
type: 'tool_result';
|
|
436
|
+
id: string;
|
|
437
|
+
name?: string;
|
|
438
|
+
result?: unknown;
|
|
439
|
+
error?: string;
|
|
440
|
+
} | {
|
|
441
|
+
type: 'local_tool_request';
|
|
442
|
+
requestId: string;
|
|
443
|
+
name: string;
|
|
444
|
+
input: unknown;
|
|
445
|
+
} | {
|
|
446
|
+
type: 'artifact';
|
|
447
|
+
artifact: AgentRunArtifact;
|
|
448
|
+
} | {
|
|
449
|
+
type: 'sources';
|
|
450
|
+
sources: unknown;
|
|
451
|
+
} | {
|
|
452
|
+
type: 'usage';
|
|
453
|
+
usage: AgentRunUsage;
|
|
454
|
+
} | {
|
|
455
|
+
type: 'settle';
|
|
456
|
+
settlement: AgentRunSettlement;
|
|
457
|
+
} | {
|
|
458
|
+
type: 'error';
|
|
459
|
+
error: AgentRunErrorPayload;
|
|
460
|
+
} | {
|
|
461
|
+
type: 'done';
|
|
462
|
+
runId: string;
|
|
463
|
+
status: AgentRunStatus | string;
|
|
464
|
+
};
|
|
465
|
+
declare class AgentRunStreamError extends Error {
|
|
466
|
+
event: Extract<AgentRunStreamEvent, {
|
|
467
|
+
type: 'error';
|
|
468
|
+
}>;
|
|
469
|
+
code: string;
|
|
470
|
+
stage: string;
|
|
471
|
+
retryable: boolean;
|
|
472
|
+
constructor(event: Extract<AgentRunStreamEvent, {
|
|
473
|
+
type: 'error';
|
|
474
|
+
}>);
|
|
475
|
+
}
|
|
304
476
|
|
|
305
477
|
type FilterStatus = 'ok' | 'admin-bypass' | 'internal-bypass' | 'disabled-by-flag' | 'fallback-tkdist-error' | 'fallback-tkdist-deployment-skew' | 'fallback-no-buckets' | 'fallback-missing-userid' | '';
|
|
306
478
|
declare const FilterStatusOK: FilterStatus;
|
|
@@ -590,6 +762,37 @@ declare class Client {
|
|
|
590
762
|
}, signal?: AbortSignal): Promise<Response>;
|
|
591
763
|
}
|
|
592
764
|
|
|
765
|
+
declare module '@acosmi/sdk-ts' {
|
|
766
|
+
interface Client {
|
|
767
|
+
/** SDK-facing cloud agent run gateway. */
|
|
768
|
+
readonly agentRuns: AgentRunsClient;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
declare class AgentRunsClient {
|
|
772
|
+
private readonly client;
|
|
773
|
+
constructor(client: Client);
|
|
774
|
+
create(req: AgentRunCreateRequest, signal?: AbortSignal): Promise<AgentRunCreateResponse>;
|
|
775
|
+
get(runId: string, signal?: AbortSignal): Promise<AgentRun>;
|
|
776
|
+
stream(runId: string, opts?: AgentRunStreamOptions, signal?: AbortSignal): AsyncIterable<AgentRunStreamEvent>;
|
|
777
|
+
cancel(runId: string, signal?: AbortSignal): Promise<AgentRun>;
|
|
778
|
+
listArtifacts(runId: string, signal?: AbortSignal): Promise<AgentRunArtifact[]>;
|
|
779
|
+
downloadArtifact(runId: string, artifactId: string, signal?: AbortSignal): Promise<AgentRunDownload>;
|
|
780
|
+
submitLocalToolResult(runId: string, result: AgentRunLocalToolResult, signal?: AbortSignal): Promise<AgentRun>;
|
|
781
|
+
run(req: AgentRunCreateRequest, opts?: AgentRunRunOptions, signal?: AbortSignal): AsyncIterable<AgentRunStreamEvent>;
|
|
782
|
+
runWithLocalTools(req: AgentRunCreateRequest, handlers: Record<string, AgentRunLocalToolHandler>, opts?: AgentRunWithLocalToolsOptions, signal?: AbortSignal): AsyncIterable<AgentRunStreamEvent>;
|
|
783
|
+
private runGen;
|
|
784
|
+
private runWithLocalToolsGen;
|
|
785
|
+
private invokeLocalTool;
|
|
786
|
+
private streamGen;
|
|
787
|
+
private requestAPI;
|
|
788
|
+
private requestRaw;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/** 根据模型能力和请求参数自动组装 beta header 列表 */
|
|
792
|
+
declare function buildBetas(caps: ModelCapabilities, req: ChatRequest): string[];
|
|
793
|
+
/** 合并两个字符串数组并去重, 保留顺序 */
|
|
794
|
+
declare function uniqueMerge(base: string[], extra: string[]): string[];
|
|
795
|
+
|
|
593
796
|
declare module '@acosmi/sdk-ts' {
|
|
594
797
|
interface Client {
|
|
595
798
|
/** 查询当前用户的权益余额 (聚合) */
|
|
@@ -833,4 +1036,4 @@ declare module '@acosmi/sdk-ts' {
|
|
|
833
1036
|
}
|
|
834
1037
|
}
|
|
835
1038
|
|
|
836
|
-
export { AnthropicResponse, type AuthorizeResult, BalanceDetail, type BlockMeta, type BugReportResult, type BugView, CertificationStatus, ChatRequest, ChatResponse, Client, ClientRegistration, type Config, ConsumeRecordPage, DefaultRetryPolicy, DeviceRegistration, EntitlementBalance, EntitlementItem, ErrAuthDenied, ErrBrowserOpen, ErrDiscovery, ErrRegistration, ErrSSLProxy, ErrTimeout, ErrTokenExchange, EventAuthURL, EventComplete, EventError, FileTokenStore, type FilterStatus, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, GenerateSkillRequest, GenerateSkillResult, InMemoryTokenStore, LocalStorageTokenStore, type LoginErrCode, type LoginEvent, type LoginEventType, type LoginOptions, ManagedModel, ModelBucket, ModelByQuotaResponse, ModelCapabilities, ModelCoefficient, NotificationList, NotificationPreference, OptimizeSkillRequest, OptimizeSkillResult, Order, OrderStatus, PayPayload, ProviderAdapter, QuotaSummary, type RetryPolicy, type RetryRequestInfo, ScopeAI, ScopeAccount, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, ServerMetadata, SkillBrowseListResponse, SkillBrowseResponse, SkillStoreItem, SkillStoreQuery, SkillSummary, SourcesEvent, StreamEvent, StreamSettlement, TokenPackage, TokenResponse, TokenSet, type TokenStore, ToolView, Transaction, type WSConfig, WSEvent, WalletStats, allScopes, authorize, buildBetas, commerceScopes, computeBackoff, defaultRetryable, defaultSafeToRetry, discover, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, isSSLError, modelScopes, newFileTokenStore, newTokenSet, refreshToken, register, revokeToken, skillScopes, uniqueMerge };
|
|
1039
|
+
export { type AgentRun, type AgentRunArtifact, type AgentRunArtifactList, type AgentRunArtifactPolicy, type AgentRunCreateRequest, type AgentRunCreateResponse, type AgentRunDownload, type AgentRunErrorPayload, type AgentRunLocalContextPolicy, type AgentRunLocalToolHandler, type AgentRunLocalToolHandlerContext, type AgentRunLocalToolResult, type AgentRunRunOptions, type AgentRunSettlement, type AgentRunStatus, AgentRunStreamError, type AgentRunStreamEvent, type AgentRunStreamOptions, type AgentRunUsage, type AgentRunWithLocalToolsOptions, AgentRunsClient, AnthropicResponse, type AuthorizeResult, BalanceDetail, type BlockMeta, type BugReportResult, type BugView, CertificationStatus, ChatRequest, ChatResponse, Client, ClientRegistration, type Config, ConsumeRecordPage, DefaultRetryPolicy, DeviceRegistration, EntitlementBalance, EntitlementItem, ErrAuthDenied, ErrBrowserOpen, ErrDiscovery, ErrRegistration, ErrSSLProxy, ErrTimeout, ErrTokenExchange, EventAuthURL, EventComplete, EventError, FileTokenStore, type FilterStatus, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, GenerateSkillRequest, GenerateSkillResult, InMemoryTokenStore, LocalStorageTokenStore, type LoginErrCode, type LoginEvent, type LoginEventType, type LoginOptions, ManagedModel, ModelBucket, ModelByQuotaResponse, ModelCapabilities, ModelCoefficient, NotificationList, NotificationPreference, OptimizeSkillRequest, OptimizeSkillResult, Order, OrderStatus, PayPayload, ProviderAdapter, QuotaSummary, type RetryPolicy, type RetryRequestInfo, ScopeAI, ScopeAccount, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, ServerMetadata, SkillBrowseListResponse, SkillBrowseResponse, SkillStoreItem, SkillStoreQuery, SkillSummary, SourcesEvent, StreamEvent, StreamSettlement, TokenPackage, TokenResponse, TokenSet, type TokenStore, ToolView, Transaction, type WSConfig, WSEvent, WalletStats, allScopes, authorize, buildBetas, commerceScopes, computeBackoff, defaultRetryable, defaultSafeToRetry, discover, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, isSSLError, modelScopes, newFileTokenStore, newTokenSet, refreshToken, register, revokeToken, skillScopes, uniqueMerge };
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as ServerMetadata, T as TokenResponse, a as TokenSet, C as ClientRegistration, M as
|
|
2
|
-
export { I as APIResponse, J as AnthropicContentBlock, K as AnthropicUsage, L as BucketClassCommercial, R as BucketClassGeneric, U as BucketInfo, V as BucketRow, X as BusinessError, Y as ChatContentBlock, Z as ChatMessage, _ as ChatUsage, $ as ConsumeRecord, a0 as EffortConfig, a1 as GeoLoc, a2 as HTTPError, a3 as ModelNotFoundError, a4 as NetworkError, a5 as Notification, a6 as NotificationUnreadCount, a7 as OpenAIChatChoice, a8 as OpenAIChatMessage, a9 as OpenAIChatResponse, aa as OpenAIFunctionCall, ab as OpenAIStreamChoice, ac as OpenAIStreamChunk, ad as OpenAIStreamDelta, ae as OpenAIStreamToolCall, af as OpenAIToolCall, ag as OpenAIUsage, ah as OrderTerminalError, ai as OutputConfig, aj as ProviderFormat, ak as RateLimitError, al as ServerTool, am as ServerToolTypeWebSearch, an as SkillStoreListItem, ao as StreamError, ap as ThinkingConfig, aq as ThinkingHigh, ar as ThinkingHighMinMaxTokens, as as ThinkingMax, at as ThinkingMaxFallbackMaxTokens, au as ThinkingOff, av as ToolListResponse, aw as ToolProvider, ax as WebSearchConfig, ay as WebSearchSource, az as YudaoPageResult, aA as anthropicResponseTextContent, aB as anthropicResponseThinkingContent, aC as anthropicResponseToolUseBlocks, aD as apiResponseBusinessError, aE as apiResponseGetMessage, aF as bucketInfoIsCommercial, aG as bucketRowIsCommercial, aH as getAdapter, aI as getAdapterForModel, aJ as newThinkingConfig, aK as newWebSearchTool, aL as parseNotificationEvent, aM as parseSettlement, aN as parseSourcesEvent, aO as tokenSetIsExpired } from './index-
|
|
1
|
+
import { S as ServerMetadata, T as TokenResponse, a as TokenSet, C as ClientRegistration, M as ManagedModel, b as ModelCoefficient, Q as QuotaSummary, c as ModelCapabilities, d as ChatRequest, P as ProviderAdapter, e as ChatResponse, A as AnthropicResponse, f as StreamEvent, g as SourcesEvent, h as StreamSettlement, E as EntitlementBalance, B as BalanceDetail, i as EntitlementItem, j as ConsumeRecordPage, k as ModelByQuotaResponse, l as ModelBucket, m as TokenPackage, n as PayPayload, O as Order, o as OrderStatus, W as WalletStats, p as Transaction, q as SkillStoreQuery, r as SkillStoreItem, s as SkillBrowseResponse, t as SkillBrowseListResponse, u as SkillSummary, v as CertificationStatus, G as GenerateSkillRequest, w as GenerateSkillResult, x as OptimizeSkillRequest, y as OptimizeSkillResult, z as ToolView, N as NotificationList, D as DeviceRegistration, F as NotificationPreference, H as WSEvent } from './index-BI8EgBXu.js';
|
|
2
|
+
export { I as APIResponse, J as AnthropicContentBlock, K as AnthropicUsage, L as BucketClassCommercial, R as BucketClassGeneric, U as BucketInfo, V as BucketRow, X as BusinessError, Y as ChatContentBlock, Z as ChatMessage, _ as ChatUsage, $ as ConsumeRecord, a0 as EffortConfig, a1 as GeoLoc, a2 as HTTPError, a3 as ModelNotFoundError, a4 as NetworkError, a5 as Notification, a6 as NotificationUnreadCount, a7 as OpenAIChatChoice, a8 as OpenAIChatMessage, a9 as OpenAIChatResponse, aa as OpenAIFunctionCall, ab as OpenAIStreamChoice, ac as OpenAIStreamChunk, ad as OpenAIStreamDelta, ae as OpenAIStreamToolCall, af as OpenAIToolCall, ag as OpenAIUsage, ah as OrderTerminalError, ai as OutputConfig, aj as ProviderFormat, ak as RateLimitError, al as ServerTool, am as ServerToolTypeWebSearch, an as SkillStoreListItem, ao as StreamError, ap as ThinkingConfig, aq as ThinkingHigh, ar as ThinkingHighMinMaxTokens, as as ThinkingMax, at as ThinkingMaxFallbackMaxTokens, au as ThinkingOff, av as ToolListResponse, aw as ToolProvider, ax as WebSearchConfig, ay as WebSearchSource, az as YudaoPageResult, aA as anthropicResponseTextContent, aB as anthropicResponseThinkingContent, aC as anthropicResponseToolUseBlocks, aD as apiResponseBusinessError, aE as apiResponseGetMessage, aF as bucketInfoIsCommercial, aG as bucketRowIsCommercial, aH as getAdapter, aI as getAdapterForModel, aJ as newThinkingConfig, aK as newWebSearchTool, aL as parseNotificationEvent, aM as parseSettlement, aN as parseSourcesEvent, aO as tokenSetIsExpired } from './index-BI8EgBXu.js';
|
|
3
3
|
import { M as MinimalSanitizeConfig } from './index-nvLKgCm9.js';
|
|
4
4
|
export { i as sanitize } from './index-nvLKgCm9.js';
|
|
5
5
|
export { AnthropicAdapter } from './adapters/anthropic.js';
|
|
@@ -297,10 +297,182 @@ interface BlockMeta {
|
|
|
297
297
|
*/
|
|
298
298
|
declare function extractAnthropicBlockMeta(eventType: string, data: string, blockTypeMap: Map<number, BlockMeta>): [number, string, boolean];
|
|
299
299
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
300
|
+
type AgentRunStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
301
|
+
interface AgentRunLocalContextPolicy {
|
|
302
|
+
enabled?: boolean;
|
|
303
|
+
readonly?: boolean;
|
|
304
|
+
maxBytes?: number;
|
|
305
|
+
allowedTools?: string[];
|
|
306
|
+
}
|
|
307
|
+
interface AgentRunArtifactPolicy {
|
|
308
|
+
enabled?: boolean;
|
|
309
|
+
maxFiles?: number;
|
|
310
|
+
}
|
|
311
|
+
interface AgentRunCreateRequest {
|
|
312
|
+
appId: string;
|
|
313
|
+
mode?: string;
|
|
314
|
+
sessionId?: string;
|
|
315
|
+
input: string;
|
|
316
|
+
messages?: unknown[];
|
|
317
|
+
model?: string;
|
|
318
|
+
activeSkillIds?: string[];
|
|
319
|
+
knowledgeBaseIds?: string[];
|
|
320
|
+
metadata?: Record<string, string>;
|
|
321
|
+
localContextPolicy?: AgentRunLocalContextPolicy;
|
|
322
|
+
artifactPolicy?: AgentRunArtifactPolicy;
|
|
323
|
+
}
|
|
324
|
+
interface AgentRun {
|
|
325
|
+
runId: string;
|
|
326
|
+
sessionId: string;
|
|
327
|
+
appId?: string;
|
|
328
|
+
mode?: string;
|
|
329
|
+
status: AgentRunStatus;
|
|
330
|
+
createdAt?: string;
|
|
331
|
+
startedAt?: string;
|
|
332
|
+
completedAt?: string;
|
|
333
|
+
error?: AgentRunErrorPayload;
|
|
334
|
+
metadata?: Record<string, string>;
|
|
335
|
+
}
|
|
336
|
+
interface AgentRunCreateResponse {
|
|
337
|
+
runId: string;
|
|
338
|
+
sessionId: string;
|
|
339
|
+
status: AgentRunStatus;
|
|
340
|
+
}
|
|
341
|
+
interface AgentRunArtifact {
|
|
342
|
+
id: string;
|
|
343
|
+
filename: string;
|
|
344
|
+
contentType?: string;
|
|
345
|
+
size?: number;
|
|
346
|
+
type?: string;
|
|
347
|
+
metadata?: Record<string, string>;
|
|
348
|
+
}
|
|
349
|
+
interface AgentRunArtifactList {
|
|
350
|
+
artifacts: AgentRunArtifact[];
|
|
351
|
+
}
|
|
352
|
+
interface AgentRunDownload {
|
|
353
|
+
data: Uint8Array;
|
|
354
|
+
filename: string;
|
|
355
|
+
contentType?: string;
|
|
356
|
+
}
|
|
357
|
+
interface AgentRunUsage {
|
|
358
|
+
inputTokens?: number;
|
|
359
|
+
outputTokens?: number;
|
|
360
|
+
totalTokens?: number;
|
|
361
|
+
cacheReadTokens?: number;
|
|
362
|
+
cacheCreateTokens?: number;
|
|
363
|
+
exact?: boolean;
|
|
364
|
+
source?: string;
|
|
365
|
+
[key: string]: unknown;
|
|
366
|
+
}
|
|
367
|
+
interface AgentRunSettlement {
|
|
368
|
+
requestId?: string;
|
|
369
|
+
status?: string;
|
|
370
|
+
consumeStatus?: string;
|
|
371
|
+
inputTokens?: number;
|
|
372
|
+
outputTokens?: number;
|
|
373
|
+
totalTokens?: number;
|
|
374
|
+
cacheReadTokens?: number;
|
|
375
|
+
cacheCreateTokens?: number;
|
|
376
|
+
tokenRemaining?: number;
|
|
377
|
+
callRemaining?: number;
|
|
378
|
+
retryQueued?: boolean;
|
|
379
|
+
exact?: boolean;
|
|
380
|
+
[key: string]: unknown;
|
|
381
|
+
}
|
|
382
|
+
interface AgentRunErrorPayload {
|
|
383
|
+
code?: string;
|
|
384
|
+
message: string;
|
|
385
|
+
stage?: string;
|
|
386
|
+
retryable?: boolean;
|
|
387
|
+
raw?: unknown;
|
|
388
|
+
}
|
|
389
|
+
interface AgentRunLocalToolResult {
|
|
390
|
+
requestId: string;
|
|
391
|
+
ok: boolean;
|
|
392
|
+
content?: unknown;
|
|
393
|
+
error?: string;
|
|
394
|
+
}
|
|
395
|
+
interface AgentRunLocalToolHandlerContext {
|
|
396
|
+
runId: string;
|
|
397
|
+
requestId: string;
|
|
398
|
+
name: string;
|
|
399
|
+
signal: AbortSignal;
|
|
400
|
+
}
|
|
401
|
+
type AgentRunLocalToolHandler = (input: unknown, context: AgentRunLocalToolHandlerContext) => Promise<unknown> | unknown;
|
|
402
|
+
interface AgentRunStreamOptions {
|
|
403
|
+
/**
|
|
404
|
+
* true by default. When enabled, an error event is converted into
|
|
405
|
+
* AgentRunStreamError after the event has been parsed.
|
|
406
|
+
*/
|
|
407
|
+
throwOnError?: boolean;
|
|
408
|
+
}
|
|
409
|
+
interface AgentRunRunOptions extends AgentRunStreamOptions {
|
|
410
|
+
}
|
|
411
|
+
interface AgentRunWithLocalToolsOptions extends AgentRunRunOptions {
|
|
412
|
+
timeoutMs?: number;
|
|
413
|
+
onEvent?: (event: AgentRunStreamEvent) => void | Promise<void>;
|
|
414
|
+
}
|
|
415
|
+
type AgentRunStreamEvent = {
|
|
416
|
+
type: 'run_started';
|
|
417
|
+
runId: string;
|
|
418
|
+
sessionId: string;
|
|
419
|
+
} | {
|
|
420
|
+
type: 'status';
|
|
421
|
+
status: AgentRunStatus | string;
|
|
422
|
+
message?: string;
|
|
423
|
+
} | {
|
|
424
|
+
type: 'text_delta';
|
|
425
|
+
text: string;
|
|
426
|
+
} | {
|
|
427
|
+
type: 'reasoning_delta';
|
|
428
|
+
text: string;
|
|
429
|
+
} | {
|
|
430
|
+
type: 'tool_call';
|
|
431
|
+
id: string;
|
|
432
|
+
name: string;
|
|
433
|
+
input?: unknown;
|
|
434
|
+
} | {
|
|
435
|
+
type: 'tool_result';
|
|
436
|
+
id: string;
|
|
437
|
+
name?: string;
|
|
438
|
+
result?: unknown;
|
|
439
|
+
error?: string;
|
|
440
|
+
} | {
|
|
441
|
+
type: 'local_tool_request';
|
|
442
|
+
requestId: string;
|
|
443
|
+
name: string;
|
|
444
|
+
input: unknown;
|
|
445
|
+
} | {
|
|
446
|
+
type: 'artifact';
|
|
447
|
+
artifact: AgentRunArtifact;
|
|
448
|
+
} | {
|
|
449
|
+
type: 'sources';
|
|
450
|
+
sources: unknown;
|
|
451
|
+
} | {
|
|
452
|
+
type: 'usage';
|
|
453
|
+
usage: AgentRunUsage;
|
|
454
|
+
} | {
|
|
455
|
+
type: 'settle';
|
|
456
|
+
settlement: AgentRunSettlement;
|
|
457
|
+
} | {
|
|
458
|
+
type: 'error';
|
|
459
|
+
error: AgentRunErrorPayload;
|
|
460
|
+
} | {
|
|
461
|
+
type: 'done';
|
|
462
|
+
runId: string;
|
|
463
|
+
status: AgentRunStatus | string;
|
|
464
|
+
};
|
|
465
|
+
declare class AgentRunStreamError extends Error {
|
|
466
|
+
event: Extract<AgentRunStreamEvent, {
|
|
467
|
+
type: 'error';
|
|
468
|
+
}>;
|
|
469
|
+
code: string;
|
|
470
|
+
stage: string;
|
|
471
|
+
retryable: boolean;
|
|
472
|
+
constructor(event: Extract<AgentRunStreamEvent, {
|
|
473
|
+
type: 'error';
|
|
474
|
+
}>);
|
|
475
|
+
}
|
|
304
476
|
|
|
305
477
|
type FilterStatus = 'ok' | 'admin-bypass' | 'internal-bypass' | 'disabled-by-flag' | 'fallback-tkdist-error' | 'fallback-tkdist-deployment-skew' | 'fallback-no-buckets' | 'fallback-missing-userid' | '';
|
|
306
478
|
declare const FilterStatusOK: FilterStatus;
|
|
@@ -590,6 +762,37 @@ declare class Client {
|
|
|
590
762
|
}, signal?: AbortSignal): Promise<Response>;
|
|
591
763
|
}
|
|
592
764
|
|
|
765
|
+
declare module '@acosmi/sdk-ts' {
|
|
766
|
+
interface Client {
|
|
767
|
+
/** SDK-facing cloud agent run gateway. */
|
|
768
|
+
readonly agentRuns: AgentRunsClient;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
declare class AgentRunsClient {
|
|
772
|
+
private readonly client;
|
|
773
|
+
constructor(client: Client);
|
|
774
|
+
create(req: AgentRunCreateRequest, signal?: AbortSignal): Promise<AgentRunCreateResponse>;
|
|
775
|
+
get(runId: string, signal?: AbortSignal): Promise<AgentRun>;
|
|
776
|
+
stream(runId: string, opts?: AgentRunStreamOptions, signal?: AbortSignal): AsyncIterable<AgentRunStreamEvent>;
|
|
777
|
+
cancel(runId: string, signal?: AbortSignal): Promise<AgentRun>;
|
|
778
|
+
listArtifacts(runId: string, signal?: AbortSignal): Promise<AgentRunArtifact[]>;
|
|
779
|
+
downloadArtifact(runId: string, artifactId: string, signal?: AbortSignal): Promise<AgentRunDownload>;
|
|
780
|
+
submitLocalToolResult(runId: string, result: AgentRunLocalToolResult, signal?: AbortSignal): Promise<AgentRun>;
|
|
781
|
+
run(req: AgentRunCreateRequest, opts?: AgentRunRunOptions, signal?: AbortSignal): AsyncIterable<AgentRunStreamEvent>;
|
|
782
|
+
runWithLocalTools(req: AgentRunCreateRequest, handlers: Record<string, AgentRunLocalToolHandler>, opts?: AgentRunWithLocalToolsOptions, signal?: AbortSignal): AsyncIterable<AgentRunStreamEvent>;
|
|
783
|
+
private runGen;
|
|
784
|
+
private runWithLocalToolsGen;
|
|
785
|
+
private invokeLocalTool;
|
|
786
|
+
private streamGen;
|
|
787
|
+
private requestAPI;
|
|
788
|
+
private requestRaw;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/** 根据模型能力和请求参数自动组装 beta header 列表 */
|
|
792
|
+
declare function buildBetas(caps: ModelCapabilities, req: ChatRequest): string[];
|
|
793
|
+
/** 合并两个字符串数组并去重, 保留顺序 */
|
|
794
|
+
declare function uniqueMerge(base: string[], extra: string[]): string[];
|
|
795
|
+
|
|
593
796
|
declare module '@acosmi/sdk-ts' {
|
|
594
797
|
interface Client {
|
|
595
798
|
/** 查询当前用户的权益余额 (聚合) */
|
|
@@ -833,4 +1036,4 @@ declare module '@acosmi/sdk-ts' {
|
|
|
833
1036
|
}
|
|
834
1037
|
}
|
|
835
1038
|
|
|
836
|
-
export { AnthropicResponse, type AuthorizeResult, BalanceDetail, type BlockMeta, type BugReportResult, type BugView, CertificationStatus, ChatRequest, ChatResponse, Client, ClientRegistration, type Config, ConsumeRecordPage, DefaultRetryPolicy, DeviceRegistration, EntitlementBalance, EntitlementItem, ErrAuthDenied, ErrBrowserOpen, ErrDiscovery, ErrRegistration, ErrSSLProxy, ErrTimeout, ErrTokenExchange, EventAuthURL, EventComplete, EventError, FileTokenStore, type FilterStatus, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, GenerateSkillRequest, GenerateSkillResult, InMemoryTokenStore, LocalStorageTokenStore, type LoginErrCode, type LoginEvent, type LoginEventType, type LoginOptions, ManagedModel, ModelBucket, ModelByQuotaResponse, ModelCapabilities, ModelCoefficient, NotificationList, NotificationPreference, OptimizeSkillRequest, OptimizeSkillResult, Order, OrderStatus, PayPayload, ProviderAdapter, QuotaSummary, type RetryPolicy, type RetryRequestInfo, ScopeAI, ScopeAccount, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, ServerMetadata, SkillBrowseListResponse, SkillBrowseResponse, SkillStoreItem, SkillStoreQuery, SkillSummary, SourcesEvent, StreamEvent, StreamSettlement, TokenPackage, TokenResponse, TokenSet, type TokenStore, ToolView, Transaction, type WSConfig, WSEvent, WalletStats, allScopes, authorize, buildBetas, commerceScopes, computeBackoff, defaultRetryable, defaultSafeToRetry, discover, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, isSSLError, modelScopes, newFileTokenStore, newTokenSet, refreshToken, register, revokeToken, skillScopes, uniqueMerge };
|
|
1039
|
+
export { type AgentRun, type AgentRunArtifact, type AgentRunArtifactList, type AgentRunArtifactPolicy, type AgentRunCreateRequest, type AgentRunCreateResponse, type AgentRunDownload, type AgentRunErrorPayload, type AgentRunLocalContextPolicy, type AgentRunLocalToolHandler, type AgentRunLocalToolHandlerContext, type AgentRunLocalToolResult, type AgentRunRunOptions, type AgentRunSettlement, type AgentRunStatus, AgentRunStreamError, type AgentRunStreamEvent, type AgentRunStreamOptions, type AgentRunUsage, type AgentRunWithLocalToolsOptions, AgentRunsClient, AnthropicResponse, type AuthorizeResult, BalanceDetail, type BlockMeta, type BugReportResult, type BugView, CertificationStatus, ChatRequest, ChatResponse, Client, ClientRegistration, type Config, ConsumeRecordPage, DefaultRetryPolicy, DeviceRegistration, EntitlementBalance, EntitlementItem, ErrAuthDenied, ErrBrowserOpen, ErrDiscovery, ErrRegistration, ErrSSLProxy, ErrTimeout, ErrTokenExchange, EventAuthURL, EventComplete, EventError, FileTokenStore, type FilterStatus, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, GenerateSkillRequest, GenerateSkillResult, InMemoryTokenStore, LocalStorageTokenStore, type LoginErrCode, type LoginEvent, type LoginEventType, type LoginOptions, ManagedModel, ModelBucket, ModelByQuotaResponse, ModelCapabilities, ModelCoefficient, NotificationList, NotificationPreference, OptimizeSkillRequest, OptimizeSkillResult, Order, OrderStatus, PayPayload, ProviderAdapter, QuotaSummary, type RetryPolicy, type RetryRequestInfo, ScopeAI, ScopeAccount, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, ServerMetadata, SkillBrowseListResponse, SkillBrowseResponse, SkillStoreItem, SkillStoreQuery, SkillSummary, SourcesEvent, StreamEvent, StreamSettlement, TokenPackage, TokenResponse, TokenSet, type TokenStore, ToolView, Transaction, type WSConfig, WSEvent, WalletStats, allScopes, authorize, buildBetas, commerceScopes, computeBackoff, defaultRetryable, defaultSafeToRetry, discover, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, isSSLError, modelScopes, newFileTokenStore, newTokenSet, refreshToken, register, revokeToken, skillScopes, uniqueMerge };
|