@acentric/llm 0.0.0-stage → 0.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/README.md +128 -2
- package/dist/catalog/anthropic.d.ts +77 -0
- package/dist/catalog/anthropic.d.ts.map +1 -0
- package/dist/catalog/anthropic.js +73 -0
- package/dist/catalog/anthropic.js.map +1 -0
- package/dist/catalog/fireworks.d.ts +93 -0
- package/dist/catalog/fireworks.d.ts.map +1 -0
- package/dist/catalog/fireworks.js +117 -0
- package/dist/catalog/fireworks.js.map +1 -0
- package/dist/catalog/openai.d.ts +103 -0
- package/dist/catalog/openai.d.ts.map +1 -0
- package/dist/catalog/openai.js +102 -0
- package/dist/catalog/openai.js.map +1 -0
- package/dist/client/anthropic/errors.d.ts +4 -0
- package/dist/client/anthropic/errors.d.ts.map +1 -0
- package/dist/client/anthropic/errors.js +80 -0
- package/dist/client/anthropic/errors.js.map +1 -0
- package/dist/client/anthropic/request.d.ts +9 -0
- package/dist/client/anthropic/request.d.ts.map +1 -0
- package/dist/client/anthropic/request.js +232 -0
- package/dist/client/anthropic/request.js.map +1 -0
- package/dist/client/anthropic/response.d.ts +13 -0
- package/dist/client/anthropic/response.d.ts.map +1 -0
- package/dist/client/anthropic/response.js +207 -0
- package/dist/client/anthropic/response.js.map +1 -0
- package/dist/client/direct.d.ts +18 -0
- package/dist/client/direct.d.ts.map +1 -0
- package/dist/client/direct.js +104 -0
- package/dist/client/direct.js.map +1 -0
- package/dist/client/gateway.d.ts +43 -0
- package/dist/client/gateway.d.ts.map +1 -0
- package/dist/client/gateway.js +72 -0
- package/dist/client/gateway.js.map +1 -0
- package/dist/client/http.d.ts +41 -0
- package/dist/client/http.d.ts.map +1 -0
- package/dist/client/http.js +190 -0
- package/dist/client/http.js.map +1 -0
- package/dist/client/llm.d.ts +41 -0
- package/dist/client/llm.d.ts.map +1 -0
- package/dist/client/llm.js +100 -0
- package/dist/client/llm.js.map +1 -0
- package/dist/client/responses/errors.d.ts +13 -0
- package/dist/client/responses/errors.d.ts.map +1 -0
- package/dist/client/responses/errors.js +144 -0
- package/dist/client/responses/errors.js.map +1 -0
- package/dist/client/responses/profile.d.ts +50 -0
- package/dist/client/responses/profile.d.ts.map +1 -0
- package/dist/client/responses/profile.js +4 -0
- package/dist/client/responses/profile.js.map +1 -0
- package/dist/client/responses/providers.d.ts +4 -0
- package/dist/client/responses/providers.d.ts.map +1 -0
- package/dist/client/responses/providers.js +75 -0
- package/dist/client/responses/providers.js.map +1 -0
- package/dist/client/responses/request.d.ts +5 -0
- package/dist/client/responses/request.d.ts.map +1 -0
- package/dist/client/responses/request.js +248 -0
- package/dist/client/responses/request.js.map +1 -0
- package/dist/client/responses/response.d.ts +10 -0
- package/dist/client/responses/response.d.ts.map +1 -0
- package/dist/client/responses/response.js +176 -0
- package/dist/client/responses/response.js.map +1 -0
- package/dist/client/util.d.ts +21 -0
- package/dist/client/util.d.ts.map +1 -0
- package/dist/client/util.js +63 -0
- package/dist/client/util.js.map +1 -0
- package/dist/client.d.ts +9 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +10 -0
- package/dist/client.js.map +1 -0
- package/dist/content.d.ts +38 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/content.js +5 -0
- package/dist/content.js.map +1 -0
- package/dist/convert/anthropic.d.ts +3 -0
- package/dist/convert/anthropic.d.ts.map +1 -0
- package/dist/convert/anthropic.js +114 -0
- package/dist/convert/anthropic.js.map +1 -0
- package/dist/convert/index.d.ts +12 -0
- package/dist/convert/index.d.ts.map +1 -0
- package/dist/convert/index.js +221 -0
- package/dist/convert/index.js.map +1 -0
- package/dist/convert/responses.d.ts +3 -0
- package/dist/convert/responses.d.ts.map +1 -0
- package/dist/convert/responses.js +197 -0
- package/dist/convert/responses.js.map +1 -0
- package/dist/convert/types.d.ts +88 -0
- package/dist/convert/types.d.ts.map +1 -0
- package/dist/convert/types.js +3 -0
- package/dist/convert/types.js.map +1 -0
- package/dist/cost.d.ts +18 -0
- package/dist/cost.d.ts.map +1 -0
- package/dist/cost.js +49 -0
- package/dist/cost.js.map +1 -0
- package/dist/failure.d.ts +90 -0
- package/dist/failure.d.ts.map +1 -0
- package/dist/failure.js +111 -0
- package/dist/failure.js.map +1 -0
- package/dist/fields.d.ts +14 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +3 -0
- package/dist/fields.js.map +1 -0
- package/dist/formats/anthropic.d.ts +152 -0
- package/dist/formats/anthropic.d.ts.map +1 -0
- package/dist/formats/anthropic.js +7 -0
- package/dist/formats/anthropic.js.map +1 -0
- package/dist/formats/responses.d.ts +179 -0
- package/dist/formats/responses.d.ts.map +1 -0
- package/dist/formats/responses.js +9 -0
- package/dist/formats/responses.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/json.d.ts +6 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +10 -0
- package/dist/json.js.map +1 -0
- package/dist/messages.d.ts +82 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +4 -0
- package/dist/messages.js.map +1 -0
- package/dist/model.d.ts +36 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +4 -0
- package/dist/model.js.map +1 -0
- package/dist/models.d.ts +9 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +19 -0
- package/dist/models.js.map +1 -0
- package/dist/providers/anthropic.d.ts +130 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +5 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/fireworks.d.ts +108 -0
- package/dist/providers/fireworks.d.ts.map +1 -0
- package/dist/providers/fireworks.js +6 -0
- package/dist/providers/fireworks.js.map +1 -0
- package/dist/providers/openai.d.ts +193 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +4 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers.d.ts +50 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +5 -0
- package/dist/providers.js.map +1 -0
- package/dist/read/anthropic.d.ts +15 -0
- package/dist/read/anthropic.d.ts.map +1 -0
- package/dist/read/anthropic.js +56 -0
- package/dist/read/anthropic.js.map +1 -0
- package/dist/read/responses.d.ts +26 -0
- package/dist/read/responses.d.ts.map +1 -0
- package/dist/read/responses.js +121 -0
- package/dist/read/responses.js.map +1 -0
- package/dist/read.d.ts +32 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +73 -0
- package/dist/read.js.map +1 -0
- package/dist/request.d.ts +23 -0
- package/dist/request.d.ts.map +1 -0
- package/dist/request.js +4 -0
- package/dist/request.js.map +1 -0
- package/dist/response.d.ts +38 -0
- package/dist/response.d.ts.map +1 -0
- package/dist/response.js +4 -0
- package/dist/response.js.map +1 -0
- package/dist/secrets.d.ts +22 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +35 -0
- package/dist/secrets.js.map +1 -0
- package/dist/tool-calls.d.ts +28 -0
- package/dist/tool-calls.d.ts.map +1 -0
- package/dist/tool-calls.js +4 -0
- package/dist/tool-calls.js.map +1 -0
- package/dist/tools.d.ts +33 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +4 -0
- package/dist/tools.js.map +1 -0
- package/dist/usage.d.ts +31 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +3 -0
- package/dist/usage.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +33 -3
- package/src/catalog/anthropic.ts +83 -0
- package/src/catalog/fireworks.ts +121 -0
- package/src/catalog/openai.ts +133 -0
- package/src/client/anthropic/errors.ts +88 -0
- package/src/client/anthropic/request.ts +272 -0
- package/src/client/anthropic/response.ts +236 -0
- package/src/client/direct.ts +157 -0
- package/src/client/gateway.ts +120 -0
- package/src/client/http.ts +231 -0
- package/src/client/llm.ts +151 -0
- package/src/client/responses/errors.ts +166 -0
- package/src/client/responses/profile.ts +55 -0
- package/src/client/responses/providers.ts +87 -0
- package/src/client/responses/request.ts +326 -0
- package/src/client/responses/response.ts +203 -0
- package/src/client/util.ts +81 -0
- package/src/client.ts +20 -0
- package/src/content.ts +46 -0
- package/src/convert/anthropic.ts +115 -0
- package/src/convert/index.ts +275 -0
- package/src/convert/responses.ts +203 -0
- package/src/convert/types.ts +104 -0
- package/src/cost.ts +71 -0
- package/src/failure.ts +164 -0
- package/src/fields.ts +13 -0
- package/src/formats/anthropic.ts +191 -0
- package/src/formats/responses.ts +207 -0
- package/src/index.ts +44 -0
- package/src/json.ts +13 -0
- package/src/messages.ts +99 -0
- package/src/model.ts +41 -0
- package/src/models.ts +23 -0
- package/src/providers/anthropic.ts +137 -0
- package/src/providers/fireworks.ts +140 -0
- package/src/providers/openai.ts +275 -0
- package/src/providers.ts +59 -0
- package/src/read/anthropic.ts +64 -0
- package/src/read/responses.ts +159 -0
- package/src/read.ts +108 -0
- package/src/request.ts +28 -0
- package/src/response.ts +44 -0
- package/src/secrets.ts +40 -0
- package/src/tool-calls.ts +33 -0
- package/src/tools.ts +38 -0
- package/src/usage.ts +33 -0
- package/src/version.ts +6 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { Json } from '@acentric/types';
|
|
2
|
+
/** A prompt-cache breakpoint on a block, tool or system text. */
|
|
3
|
+
export type AnthropicCacheControl = {
|
|
4
|
+
readonly type: 'ephemeral';
|
|
5
|
+
/** `5m`, the default, or `1h`, which costs twice the input price to write. */
|
|
6
|
+
readonly ttl?: '5m' | '1h';
|
|
7
|
+
};
|
|
8
|
+
/** A block typed loosely: only the fields the readers use are named, and the rest pass through. */
|
|
9
|
+
export type AnthropicBlock<T extends string, Fields = unknown> = {
|
|
10
|
+
readonly type: T;
|
|
11
|
+
readonly [key: string]: Json;
|
|
12
|
+
} & Fields;
|
|
13
|
+
export type AnthropicTextBlock = {
|
|
14
|
+
readonly type: 'text';
|
|
15
|
+
readonly text: string;
|
|
16
|
+
/** Where the text comes from, with documents or search results that allow citations. */
|
|
17
|
+
readonly citations?: readonly Json[] | null;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The model's reasoning. `thinking` is a summary, or empty when `display` is
|
|
21
|
+
* `omitted`, the default on Claude 5 models; the reasoning itself travels in
|
|
22
|
+
* the `signature`, which is checked every time it is sent back. Send it back
|
|
23
|
+
* unchanged.
|
|
24
|
+
*/
|
|
25
|
+
export type AnthropicThinkingBlock = {
|
|
26
|
+
readonly type: 'thinking';
|
|
27
|
+
readonly thinking: string;
|
|
28
|
+
readonly signature: string;
|
|
29
|
+
};
|
|
30
|
+
/** Reasoning the safety systems flagged, encrypted. Send it back unchanged. */
|
|
31
|
+
export type AnthropicRedactedThinkingBlock = {
|
|
32
|
+
readonly type: 'redacted_thinking';
|
|
33
|
+
readonly data: string;
|
|
34
|
+
};
|
|
35
|
+
/** Who made a call: `direct`, or code execution for programmatic tool calling. */
|
|
36
|
+
export type AnthropicCaller = {
|
|
37
|
+
readonly type: string;
|
|
38
|
+
readonly [key: string]: Json;
|
|
39
|
+
};
|
|
40
|
+
/** A call to one of the caller's tools, answered with a `tool_result`. */
|
|
41
|
+
export type AnthropicToolUseBlock = {
|
|
42
|
+
readonly type: 'tool_use';
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly name: string;
|
|
45
|
+
/** The arguments, parsed. */
|
|
46
|
+
readonly input: Json;
|
|
47
|
+
readonly caller?: AnthropicCaller;
|
|
48
|
+
/** Set on a member of an Anthropic toolset; its result must name the toolset. */
|
|
49
|
+
readonly toolset_name?: string;
|
|
50
|
+
};
|
|
51
|
+
/** A call to a server tool: web search, web fetch, code execution, tool search. */
|
|
52
|
+
export type AnthropicServerToolUseBlock = AnthropicBlock<'server_tool_use', {
|
|
53
|
+
readonly id: string;
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly input: Json;
|
|
56
|
+
}>;
|
|
57
|
+
/** A server tool's result, in the same message. Some hold encrypted content: send them back unchanged. */
|
|
58
|
+
export type AnthropicServerToolResultBlock = AnthropicBlock<'web_search_tool_result' | 'web_fetch_tool_result' | 'code_execution_tool_result' | 'bash_code_execution_tool_result' | 'text_editor_code_execution_tool_result' | 'tool_search_tool_result', {
|
|
59
|
+
readonly tool_use_id: string;
|
|
60
|
+
}>;
|
|
61
|
+
/** A call to a remote MCP server, and its result. */
|
|
62
|
+
export type AnthropicMcpToolUseBlock = AnthropicBlock<'mcp_tool_use', {
|
|
63
|
+
readonly id: string;
|
|
64
|
+
}>;
|
|
65
|
+
export type AnthropicMcpToolResultBlock = AnthropicBlock<'mcp_tool_result', {
|
|
66
|
+
readonly tool_use_id: string;
|
|
67
|
+
}>;
|
|
68
|
+
/** Earlier context, summarized. Send it back unchanged. */
|
|
69
|
+
export type AnthropicCompactionBlock = AnthropicBlock<'compaction'>;
|
|
70
|
+
/** A file uploaded to the code execution container. */
|
|
71
|
+
export type AnthropicContainerUploadBlock = AnthropicBlock<'container_upload', {
|
|
72
|
+
readonly file_id: string;
|
|
73
|
+
}>;
|
|
74
|
+
export type AnthropicOutputBlock = AnthropicTextBlock | AnthropicThinkingBlock | AnthropicRedactedThinkingBlock | AnthropicToolUseBlock | AnthropicServerToolUseBlock | AnthropicServerToolResultBlock | AnthropicMcpToolUseBlock | AnthropicMcpToolResultBlock | AnthropicCompactionBlock | AnthropicContainerUploadBlock;
|
|
75
|
+
export type AnthropicMediaSource = {
|
|
76
|
+
readonly type: 'base64';
|
|
77
|
+
readonly media_type: string;
|
|
78
|
+
readonly data: string;
|
|
79
|
+
} | {
|
|
80
|
+
readonly type: 'url';
|
|
81
|
+
readonly url: string;
|
|
82
|
+
} | {
|
|
83
|
+
readonly type: 'file';
|
|
84
|
+
readonly file_id: string;
|
|
85
|
+
} | {
|
|
86
|
+
readonly type: 'text';
|
|
87
|
+
readonly media_type: 'text/plain';
|
|
88
|
+
readonly data: string;
|
|
89
|
+
} | {
|
|
90
|
+
readonly type: 'content';
|
|
91
|
+
readonly content: Json;
|
|
92
|
+
};
|
|
93
|
+
export type AnthropicImageBlock = AnthropicBlock<'image', {
|
|
94
|
+
readonly source: AnthropicMediaSource;
|
|
95
|
+
}>;
|
|
96
|
+
export type AnthropicDocumentBlock = AnthropicBlock<'document', {
|
|
97
|
+
readonly source: AnthropicMediaSource;
|
|
98
|
+
}>;
|
|
99
|
+
/** A search result the model may cite. */
|
|
100
|
+
export type AnthropicSearchResultBlock = AnthropicBlock<'search_result', {
|
|
101
|
+
readonly source: string;
|
|
102
|
+
readonly title: string;
|
|
103
|
+
readonly content: readonly Json[];
|
|
104
|
+
}>;
|
|
105
|
+
export type AnthropicToolResultBlock = AnthropicBlock<'tool_result', {
|
|
106
|
+
readonly tool_use_id: string;
|
|
107
|
+
readonly is_error?: boolean;
|
|
108
|
+
}>;
|
|
109
|
+
/** A block a `native` message may carry. */
|
|
110
|
+
export type AnthropicInputBlock = AnthropicBlock<'text', {
|
|
111
|
+
readonly text: string;
|
|
112
|
+
}> | AnthropicImageBlock | AnthropicDocumentBlock | AnthropicSearchResultBlock | AnthropicToolResultBlock | AnthropicContainerUploadBlock;
|
|
113
|
+
/** Why generation stopped. */
|
|
114
|
+
export type AnthropicStopReason = 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | 'pause_turn' | 'refusal' | 'model_context_window_exceeded' | 'compaction' | (string & {});
|
|
115
|
+
/** Token usage as the format reports it. */
|
|
116
|
+
export type AnthropicUsage = {
|
|
117
|
+
/** Uncached input only. */
|
|
118
|
+
readonly input_tokens: number;
|
|
119
|
+
readonly cache_creation_input_tokens?: number | null;
|
|
120
|
+
readonly cache_read_input_tokens?: number | null;
|
|
121
|
+
/** Cache writes by time to live. */
|
|
122
|
+
readonly cache_creation?: {
|
|
123
|
+
readonly ephemeral_5m_input_tokens?: number;
|
|
124
|
+
readonly ephemeral_1h_input_tokens?: number;
|
|
125
|
+
} | null;
|
|
126
|
+
/** Output tokens, thinking included. */
|
|
127
|
+
readonly output_tokens: number;
|
|
128
|
+
readonly output_tokens_details?: {
|
|
129
|
+
readonly thinking_tokens?: number;
|
|
130
|
+
} | null;
|
|
131
|
+
readonly server_tool_use?: {
|
|
132
|
+
readonly [tool: string]: number;
|
|
133
|
+
} | null;
|
|
134
|
+
/** The tier that served the request: `standard`, `priority` or `batch`. */
|
|
135
|
+
readonly service_tier?: string | null;
|
|
136
|
+
/** Where inference ran: `global`, or `us` at 1.1 times the price. */
|
|
137
|
+
readonly inference_geo?: string | null;
|
|
138
|
+
/** `standard` or `fast`. */
|
|
139
|
+
readonly speed?: string | null;
|
|
140
|
+
/** The whole bill per sampling iteration, each with its own model. */
|
|
141
|
+
readonly iterations?: readonly AnthropicUsageIteration[] | null;
|
|
142
|
+
};
|
|
143
|
+
export type AnthropicUsageIteration = {
|
|
144
|
+
readonly type: 'message' | 'compaction' | 'advisor_message' | 'fallback_message' | (string & {});
|
|
145
|
+
readonly model?: string | null;
|
|
146
|
+
readonly input_tokens?: number;
|
|
147
|
+
readonly output_tokens?: number;
|
|
148
|
+
readonly cache_creation_input_tokens?: number | null;
|
|
149
|
+
readonly cache_read_input_tokens?: number | null;
|
|
150
|
+
readonly cache_creation?: AnthropicUsage['cache_creation'];
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=anthropic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/formats/anthropic.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,iEAAiE;AACjE,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,8EAA8E;IAC9E,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF,mGAAmG;AACnG,MAA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AAG,IAAI,CAAC;IAC/B,sEAAsE;IACtE,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,uBAAuB,EAAE,GAAG,IAAI,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IACjG,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,2BAA2B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrD,QAAQ,CAAC,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjD,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;CAC5D,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// The Anthropic Messages format (`POST /v1/messages`): the content blocks the
|
|
2
|
+
// client writes and reads.
|
|
3
|
+
//
|
|
4
|
+
// Blocks are typed for what the client and the readers interpret. Anthropic
|
|
5
|
+
// adds block types and fields often, and those pass through as they are.
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=anthropic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/formats/anthropic.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2BAA2B;AAC3B,EAAE;AACF,4EAA4E;AAC5E,yEAAyE"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import type { Json } from '@acentric/types';
|
|
2
|
+
/** An explicit prompt-cache breakpoint on a content part. */
|
|
3
|
+
export type ResponsesCacheBreakpoint = {
|
|
4
|
+
readonly mode: 'explicit';
|
|
5
|
+
};
|
|
6
|
+
export type ResponsesInputText = {
|
|
7
|
+
readonly type: 'input_text';
|
|
8
|
+
readonly text: string;
|
|
9
|
+
readonly prompt_cache_breakpoint?: ResponsesCacheBreakpoint;
|
|
10
|
+
};
|
|
11
|
+
export type ResponsesInputImage = {
|
|
12
|
+
readonly type: 'input_image';
|
|
13
|
+
/** A URL or a `data:` URL. */
|
|
14
|
+
readonly image_url?: string;
|
|
15
|
+
readonly file_id?: string;
|
|
16
|
+
readonly detail?: 'auto' | 'low' | 'high' | 'original';
|
|
17
|
+
readonly prompt_cache_breakpoint?: ResponsesCacheBreakpoint;
|
|
18
|
+
};
|
|
19
|
+
export type ResponsesInputFile = {
|
|
20
|
+
readonly type: 'input_file';
|
|
21
|
+
readonly file_id?: string;
|
|
22
|
+
readonly file_url?: string;
|
|
23
|
+
/** The file's bytes, as a `data:` URL. */
|
|
24
|
+
readonly file_data?: string;
|
|
25
|
+
readonly filename?: string;
|
|
26
|
+
readonly detail?: 'auto' | 'low' | 'high';
|
|
27
|
+
readonly prompt_cache_breakpoint?: ResponsesCacheBreakpoint;
|
|
28
|
+
};
|
|
29
|
+
export type ResponsesInputContent = ResponsesInputText | ResponsesInputImage | ResponsesInputFile;
|
|
30
|
+
/** A user, system or developer message in the input. */
|
|
31
|
+
export type ResponsesInputMessage = {
|
|
32
|
+
readonly type: 'message';
|
|
33
|
+
readonly role: 'user' | 'system' | 'developer';
|
|
34
|
+
readonly content: readonly ResponsesInputContent[];
|
|
35
|
+
};
|
|
36
|
+
export type ResponsesAnnotation = {
|
|
37
|
+
readonly type: 'url_citation';
|
|
38
|
+
readonly url: string;
|
|
39
|
+
readonly title: string;
|
|
40
|
+
readonly start_index: number;
|
|
41
|
+
readonly end_index: number;
|
|
42
|
+
} | {
|
|
43
|
+
readonly type: 'file_citation';
|
|
44
|
+
readonly file_id: string;
|
|
45
|
+
readonly filename: string;
|
|
46
|
+
readonly index: number;
|
|
47
|
+
} | {
|
|
48
|
+
readonly type: 'container_file_citation';
|
|
49
|
+
readonly container_id: string;
|
|
50
|
+
readonly file_id: string;
|
|
51
|
+
readonly filename: string;
|
|
52
|
+
readonly start_index: number;
|
|
53
|
+
readonly end_index: number;
|
|
54
|
+
} | {
|
|
55
|
+
readonly type: 'file_path';
|
|
56
|
+
readonly file_id: string;
|
|
57
|
+
readonly index: number;
|
|
58
|
+
};
|
|
59
|
+
export type ResponsesOutputText = {
|
|
60
|
+
readonly type: 'output_text';
|
|
61
|
+
readonly text: string;
|
|
62
|
+
readonly annotations: readonly ResponsesAnnotation[];
|
|
63
|
+
readonly logprobs?: readonly Json[];
|
|
64
|
+
};
|
|
65
|
+
export type ResponsesRefusal = {
|
|
66
|
+
readonly type: 'refusal';
|
|
67
|
+
readonly refusal: string;
|
|
68
|
+
};
|
|
69
|
+
/** An assistant message in the output. */
|
|
70
|
+
export type ResponsesOutputMessage = {
|
|
71
|
+
readonly type: 'message';
|
|
72
|
+
readonly id: string;
|
|
73
|
+
readonly role: 'assistant';
|
|
74
|
+
readonly status: 'in_progress' | 'completed' | 'incomplete';
|
|
75
|
+
/** `commentary` is a progress update, not the answer. Keep it when sending back. */
|
|
76
|
+
readonly phase?: 'commentary' | 'final_answer' | null;
|
|
77
|
+
readonly content: readonly (ResponsesOutputText | ResponsesRefusal)[];
|
|
78
|
+
};
|
|
79
|
+
export type ResponsesReasoning = {
|
|
80
|
+
readonly type: 'reasoning';
|
|
81
|
+
readonly id: string;
|
|
82
|
+
readonly summary: readonly {
|
|
83
|
+
readonly type: 'summary_text';
|
|
84
|
+
readonly text: string;
|
|
85
|
+
}[];
|
|
86
|
+
readonly content?: readonly {
|
|
87
|
+
readonly type: 'reasoning_text';
|
|
88
|
+
readonly text: string;
|
|
89
|
+
}[];
|
|
90
|
+
/** Opaque: send it back unchanged. */
|
|
91
|
+
readonly encrypted_content?: string | null;
|
|
92
|
+
readonly status?: 'in_progress' | 'completed' | 'incomplete';
|
|
93
|
+
};
|
|
94
|
+
/** Who made a call, such as `{ type: "program", caller_id }` for programmatic tool calling. */
|
|
95
|
+
export type ResponsesCaller = {
|
|
96
|
+
readonly type: string;
|
|
97
|
+
readonly [key: string]: Json;
|
|
98
|
+
};
|
|
99
|
+
export type ResponsesFunctionCall = {
|
|
100
|
+
readonly type: 'function_call';
|
|
101
|
+
readonly id?: string;
|
|
102
|
+
/** The ID a result answers; `id` is only the item's. */
|
|
103
|
+
readonly call_id: string;
|
|
104
|
+
readonly name: string;
|
|
105
|
+
/** A JSON string, as the model wrote it. */
|
|
106
|
+
readonly arguments: string;
|
|
107
|
+
readonly namespace?: string;
|
|
108
|
+
readonly caller?: ResponsesCaller;
|
|
109
|
+
readonly async?: boolean;
|
|
110
|
+
readonly status?: 'in_progress' | 'completed' | 'incomplete';
|
|
111
|
+
};
|
|
112
|
+
export type ResponsesCustomToolCall = {
|
|
113
|
+
readonly type: 'custom_tool_call';
|
|
114
|
+
readonly id?: string;
|
|
115
|
+
readonly call_id: string;
|
|
116
|
+
readonly name: string;
|
|
117
|
+
readonly input: string;
|
|
118
|
+
readonly namespace?: string;
|
|
119
|
+
readonly caller?: ResponsesCaller;
|
|
120
|
+
readonly async?: boolean;
|
|
121
|
+
};
|
|
122
|
+
export type ResponsesFunctionCallOutput = {
|
|
123
|
+
readonly type: 'function_call_output';
|
|
124
|
+
readonly call_id: string;
|
|
125
|
+
readonly output: string | readonly ResponsesInputContent[];
|
|
126
|
+
readonly id?: string;
|
|
127
|
+
readonly name?: string;
|
|
128
|
+
readonly namespace?: string;
|
|
129
|
+
readonly caller?: ResponsesCaller;
|
|
130
|
+
readonly status?: 'in_progress' | 'completed' | 'incomplete';
|
|
131
|
+
};
|
|
132
|
+
export type ResponsesCustomToolCallOutput = {
|
|
133
|
+
readonly type: 'custom_tool_call_output';
|
|
134
|
+
readonly call_id: string;
|
|
135
|
+
readonly output: string | readonly ResponsesInputContent[];
|
|
136
|
+
readonly id?: string;
|
|
137
|
+
readonly caller?: ResponsesCaller;
|
|
138
|
+
};
|
|
139
|
+
/** Earlier context, compacted. Opaque: send it back unchanged. */
|
|
140
|
+
export type ResponsesCompaction = {
|
|
141
|
+
readonly type: 'compaction';
|
|
142
|
+
readonly id?: string;
|
|
143
|
+
readonly encrypted_content: string;
|
|
144
|
+
};
|
|
145
|
+
/** An item the provider stored, by ID. */
|
|
146
|
+
export type ResponsesItemReference = {
|
|
147
|
+
readonly type: 'item_reference';
|
|
148
|
+
readonly id: string;
|
|
149
|
+
};
|
|
150
|
+
/** Output items every Responses provider shares. */
|
|
151
|
+
export type ResponsesOutputItem = ResponsesOutputMessage | ResponsesReasoning | ResponsesFunctionCall | ResponsesCustomToolCall | ResponsesCompaction;
|
|
152
|
+
/** Input items every Responses provider shares, besides output items sent back. */
|
|
153
|
+
export type ResponsesInputItem = ResponsesInputMessage | ResponsesFunctionCallOutput | ResponsesCustomToolCallOutput | ResponsesItemReference | ResponsesOutputItem;
|
|
154
|
+
/**
|
|
155
|
+
* An item a provider adds to the format, typed loosely: only the fields the
|
|
156
|
+
* readers use are named, and the rest pass through.
|
|
157
|
+
*/
|
|
158
|
+
export type ResponsesItem<T extends string, Fields = unknown> = {
|
|
159
|
+
readonly type: T;
|
|
160
|
+
readonly id?: string;
|
|
161
|
+
readonly [key: string]: Json;
|
|
162
|
+
} & Fields;
|
|
163
|
+
/** Token usage as the format reports it. */
|
|
164
|
+
export type ResponsesUsage = {
|
|
165
|
+
/** Every input token, cached or not. */
|
|
166
|
+
readonly input_tokens: number;
|
|
167
|
+
readonly input_tokens_details?: {
|
|
168
|
+
readonly cached_tokens?: number;
|
|
169
|
+
readonly cache_write_tokens?: number;
|
|
170
|
+
} | null;
|
|
171
|
+
/** Output tokens, reasoning included. */
|
|
172
|
+
readonly output_tokens: number;
|
|
173
|
+
readonly output_tokens_details?: {
|
|
174
|
+
readonly reasoning_tokens?: number;
|
|
175
|
+
} | null;
|
|
176
|
+
readonly total_tokens?: number;
|
|
177
|
+
};
|
|
178
|
+
export type ResponsesStatus = 'completed' | 'incomplete' | 'failed' | 'cancelled' | 'queued' | 'in_progress';
|
|
179
|
+
//# sourceMappingURL=responses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/formats/responses.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,6DAA6D;AAC7D,MAAM,MAAM,wBAAwB,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;AAErE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,uBAAuB,CAAC,EAAE,wBAAwB,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,8BAA8B;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,UAAU,CAAC;IACvD,QAAQ,CAAC,uBAAuB,CAAC,EAAE,wBAAwB,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG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M,mBAAmB,GAC3B,sBAAsB,GACtB,kBAAkB,GAClB,qBAAqB,GACrB,uBAAuB,GACvB,mBAAmB,CAAC;AAExB,mFAAmF;AACnF,MAAM,MAAM,kBAAkB,GAC1B,qBAAqB,GACrB,2BAA2B,GAC3B,6BAA6B,GAC7B,sBAAsB,GACtB,mBAAmB,CAAC;AAExB;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,GAAG,OAAO,IAAI;IAC9D,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,GAAG,MAAM,CAAC;AAEX,4CAA4C;AAC5C,MAAM,MAAM,cAAc,GAAG;IAC3B,wCAAwC;IACxC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,oBAAoB,CAAC,EAAE;QAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;QAChC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;KACtC,GAAG,IAAI,CAAC;IACT,yCAAyC;IACzC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,qBAAqB,CAAC,EAAE;QAAE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC/E,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,eAAe,GACzB,WAAW,GAAG,YAAY,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,aAAa,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// The Responses format: OpenAI's Responses API and the Open Responses
|
|
2
|
+
// specification other providers implement, here Fireworks. These are the
|
|
3
|
+
// shapes every Responses provider shares; each provider adds its own items in
|
|
4
|
+
// providers/.
|
|
5
|
+
//
|
|
6
|
+
// Items are typed for what the client and the readers interpret. Providers add
|
|
7
|
+
// fields and item types often, and those pass through as they are.
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=responses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses.js","sourceRoot":"","sources":["../../src/formats/responses.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,yEAAyE;AACzE,8EAA8E;AAC9E,cAAc;AACd,EAAE;AACF,+EAA+E;AAC/E,mEAAmE"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type * from './content.js';
|
|
2
|
+
export type * from './fields.js';
|
|
3
|
+
export type * from './messages.js';
|
|
4
|
+
export type * from './providers.js';
|
|
5
|
+
export type * from './request.js';
|
|
6
|
+
export type * from './response.js';
|
|
7
|
+
export type * from './tool-calls.js';
|
|
8
|
+
export type * from './tools.js';
|
|
9
|
+
export type * from './usage.js';
|
|
10
|
+
export type * from './formats/anthropic.js';
|
|
11
|
+
export type * from './formats/responses.js';
|
|
12
|
+
export type * from './providers/anthropic.js';
|
|
13
|
+
export type * from './providers/fireworks.js';
|
|
14
|
+
export type * from './providers/openai.js';
|
|
15
|
+
export { convert } from './convert/index.js';
|
|
16
|
+
export type { Conversion, ConversionChange, ConvertOptions, ConvertTarget, } from './convert/index.js';
|
|
17
|
+
export { estimateCost } from './cost.js';
|
|
18
|
+
export type { CostOptions } from './cost.js';
|
|
19
|
+
export { isLlmFailure, LLM_FAILURE_KINDS, LlmError, llmFailure } from './failure.js';
|
|
20
|
+
export type { LlmErrorOptions, LlmFailure, LlmFailureKind } from './failure.js';
|
|
21
|
+
export { outputText, pendingToolCalls, reasoningSummary, refusals, requestMessages, toolCalls, toolResult, } from './read.js';
|
|
22
|
+
export type { TextOptions, ToolResultOptions } from './read.js';
|
|
23
|
+
export type * from './model.js';
|
|
24
|
+
export { findModel, MODELS } from './models.js';
|
|
25
|
+
export { GATEWAY_SECRETS, llmSecrets, PROVIDER_SECRETS } from './secrets.js';
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,aAAa,CAAC;AACjC,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,iBAAiB,CAAC;AACrC,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,wBAAwB,CAAC;AAC5C,mBAAmB,wBAAwB,CAAC;AAC5C,mBAAmB,0BAA0B,CAAC;AAC9C,mBAAmB,0BAA0B,CAAC;AAC9C,mBAAmB,uBAAuB,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrF,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,SAAS,EACT,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAChE,mBAAmB,YAAY,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// The pure half of @acentric/llm: what an agent's step, effects and view may
|
|
2
|
+
// import. Nothing here uses fetch, timers, the clock or randomness, so it
|
|
3
|
+
// bundles into agent.js. The calls themselves are in @acentric/llm/client,
|
|
4
|
+
// for handlers.
|
|
5
|
+
export { convert } from './convert/index.js';
|
|
6
|
+
export { estimateCost } from './cost.js';
|
|
7
|
+
export { isLlmFailure, LLM_FAILURE_KINDS, LlmError, llmFailure } from './failure.js';
|
|
8
|
+
export { outputText, pendingToolCalls, reasoningSummary, refusals, requestMessages, toolCalls, toolResult, } from './read.js';
|
|
9
|
+
export { findModel, MODELS } from './models.js';
|
|
10
|
+
export { GATEWAY_SECRETS, llmSecrets, PROVIDER_SECRETS } from './secrets.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,0EAA0E;AAC1E,2EAA2E;AAC3E,gBAAgB;AAiBhB,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAO7C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAErF,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,SAAS,EACT,UAAU,GACX,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/json.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Json, JsonObject } from '@acentric/types';
|
|
2
|
+
/** Whether a value is a Json object. `Array.isArray` alone does not narrow a readonly array out. */
|
|
3
|
+
export declare function isObject(value: Json | undefined): value is JsonObject;
|
|
4
|
+
/** Whether a value is a Json array. */
|
|
5
|
+
export declare function isArray(value: Json | undefined): value is readonly Json[];
|
|
6
|
+
//# sourceMappingURL=json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAExD,oGAAoG;AACpG,wBAAgB,QAAQ,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,GAAG,KAAK,IAAI,UAAU,CAErE;AAED,uCAAuC;AACvC,wBAAgB,OAAO,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,GAAG,KAAK,IAAI,SAAS,IAAI,EAAE,CAEzE"}
|
package/dist/json.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Reading Json whose shape is not known in advance, such as a provider's items.
|
|
2
|
+
/** Whether a value is a Json object. `Array.isArray` alone does not narrow a readonly array out. */
|
|
3
|
+
export function isObject(value) {
|
|
4
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
5
|
+
}
|
|
6
|
+
/** Whether a value is a Json array. */
|
|
7
|
+
export function isArray(value) {
|
|
8
|
+
return Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=json.js.map
|
package/dist/json.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAIhF,oGAAoG;AACpG,MAAM,UAAU,QAAQ,CAAC,KAAuB;IAC9C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,OAAO,CAAC,KAAuB;IAC7C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Json } from '@acentric/types';
|
|
2
|
+
import type { ContentPart, TextPart } from './content.js';
|
|
3
|
+
import type { Metadata, ProviderFields } from './fields.js';
|
|
4
|
+
import type { ApiOf, NativeInputItem, NativeOutputItem, Provider } from './providers.js';
|
|
5
|
+
import type { ToolType } from './tools.js';
|
|
6
|
+
type MessageBase = {
|
|
7
|
+
/** For an assistant message, the provider's response ID. Otherwise the application's. */
|
|
8
|
+
readonly id?: string;
|
|
9
|
+
/** Milliseconds since the Unix epoch. */
|
|
10
|
+
readonly timestamp?: number;
|
|
11
|
+
/** The application's own attributes. Never sent to a provider. */
|
|
12
|
+
readonly metadata?: Metadata;
|
|
13
|
+
};
|
|
14
|
+
export type UserMessage = MessageBase & {
|
|
15
|
+
readonly role: 'user';
|
|
16
|
+
readonly content: readonly ContentPart[];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* An instruction in the middle of the conversation. The request's
|
|
20
|
+
* `instructions` are the top-level ones. A provider with no such messages
|
|
21
|
+
* refuses a request that has one.
|
|
22
|
+
*/
|
|
23
|
+
export type SystemMessage = MessageBase & {
|
|
24
|
+
readonly role: 'system';
|
|
25
|
+
readonly content: readonly TextPart[];
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The provider's output, as it is, for sending back: reasoning, signatures and
|
|
29
|
+
* compaction items included. Read it with `outputText`, `toolCalls` and the
|
|
30
|
+
* other readers. Sending it back is safe to the same provider, format and model.
|
|
31
|
+
*/
|
|
32
|
+
export type AssistantMessage<P extends Provider = Provider> = P extends Provider ? MessageBase & {
|
|
33
|
+
readonly role: 'assistant';
|
|
34
|
+
readonly provider: P;
|
|
35
|
+
readonly api: ApiOf<P>;
|
|
36
|
+
/** The model ID the request asked for. */
|
|
37
|
+
readonly model: string;
|
|
38
|
+
readonly content: readonly NativeOutputItem<P>[];
|
|
39
|
+
} : never;
|
|
40
|
+
/** The result of a tool call the caller ran. */
|
|
41
|
+
export type ToolResultMessage = MessageBase & {
|
|
42
|
+
readonly role: 'tool_result';
|
|
43
|
+
readonly toolCallId: string;
|
|
44
|
+
readonly toolName: string;
|
|
45
|
+
/** The type of the tool that was called. Defaults to `function`. */
|
|
46
|
+
readonly toolType?: ToolType;
|
|
47
|
+
readonly content: readonly ContentPart[];
|
|
48
|
+
/**
|
|
49
|
+
* The tool failed. Sent only where the provider has a field for it, so
|
|
50
|
+
* `content` must say what failed either way.
|
|
51
|
+
*/
|
|
52
|
+
readonly isError?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Merged into the provider's result item, for fields it requires on results,
|
|
55
|
+
* such as OpenAI's `caller`. `toolResult(call, content)` copies them from the call.
|
|
56
|
+
*/
|
|
57
|
+
readonly providerOptions?: ProviderFields;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Input only provider `P` takes, sent as it is: a compaction trigger, the
|
|
61
|
+
* output of a computer-use call, an approval.
|
|
62
|
+
*/
|
|
63
|
+
export type NativeMessage<P extends Provider = Provider> = P extends Provider ? MessageBase & {
|
|
64
|
+
readonly role: 'native';
|
|
65
|
+
readonly provider: P;
|
|
66
|
+
readonly api: ApiOf<P>;
|
|
67
|
+
readonly content: readonly NativeInputItem<P>[];
|
|
68
|
+
} : never;
|
|
69
|
+
/** The application's own entry in a conversation. Never sent to a provider. */
|
|
70
|
+
export type CustomMessage = MessageBase & {
|
|
71
|
+
readonly role: 'custom';
|
|
72
|
+
/** Says how the application reads `data`. */
|
|
73
|
+
readonly tag: string;
|
|
74
|
+
readonly data: Json;
|
|
75
|
+
};
|
|
76
|
+
/** A message a request to provider `P` sends. */
|
|
77
|
+
export type RequestMessage<P extends Provider = Provider> = UserMessage | SystemMessage | ToolResultMessage | AssistantMessage<P> | NativeMessage<P>;
|
|
78
|
+
/** Any message in a conversation, the application's own included. */
|
|
79
|
+
export type Message<P extends Provider = Provider> = RequestMessage<P> | CustomMessage;
|
|
80
|
+
export type Role = Message['role'];
|
|
81
|
+
export {};
|
|
82
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACzF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,KAAK,WAAW,GAAG;IACjB,yFAAyF;IACzF,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;CAC1C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG;IACxC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,Q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,CAAC,OAAO,EAAE,SAAS,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;CACjD,GACD,KAAK,CAAC;AAEV,+EAA+E;AAC/E,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG;IACxC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,6CAA6C;IAC7C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACrB,CAAC;AAEF,iDAAiD;AACjD,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,IACtD,WAAW,GAAG,aAAa,GAAG,iBAAiB,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAE3F,qEAAqE;AACrE,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC;AAEvF,MAAM,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/messages.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,oEAAoE"}
|
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { KnownModelId, Provider } from './providers.js';
|
|
2
|
+
export type Modality = 'text' | 'image' | 'file';
|
|
3
|
+
/** US dollars per million tokens. */
|
|
4
|
+
export type ModelCost = {
|
|
5
|
+
readonly input: number;
|
|
6
|
+
readonly output: number;
|
|
7
|
+
readonly cacheRead?: number;
|
|
8
|
+
/** Writing to the cache, for the provider's default time to live. */
|
|
9
|
+
readonly cacheWrite?: number;
|
|
10
|
+
/** Writing to the cache for an hour, where a provider prices it apart (Anthropic). */
|
|
11
|
+
readonly cacheWrite1h?: number;
|
|
12
|
+
};
|
|
13
|
+
export type ModelPricing = {
|
|
14
|
+
readonly base: ModelCost;
|
|
15
|
+
/**
|
|
16
|
+
* Prices for the whole request once its prompt is over a number of tokens,
|
|
17
|
+
* in ascending order.
|
|
18
|
+
*/
|
|
19
|
+
readonly tiers?: readonly {
|
|
20
|
+
readonly aboveInputTokens: number;
|
|
21
|
+
readonly cost: ModelCost;
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
24
|
+
/** One model. */
|
|
25
|
+
export type ModelInfo<P extends Provider = Provider> = P extends Provider ? {
|
|
26
|
+
readonly provider: P;
|
|
27
|
+
readonly id: KnownModelId<P>;
|
|
28
|
+
readonly name: string;
|
|
29
|
+
/** The most tokens it reads, prompt and output together. */
|
|
30
|
+
readonly contextWindow?: number;
|
|
31
|
+
/** The most tokens it writes in one reply. */
|
|
32
|
+
readonly maxOutputTokens?: number;
|
|
33
|
+
readonly input?: readonly Modality[];
|
|
34
|
+
readonly pricing?: ModelPricing;
|
|
35
|
+
} : never;
|
|
36
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE7D,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjD,qCAAqC;AACrC,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,sFAAsF;IACtF,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS;QAAE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;KAAE,EAAE,CAAC;CAC7F,CAAC;AAEF,iBAAiB;AACjB,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,IAAI,CAAC,SAAS,QAAQ,GACrE;IACE,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,8CAA8C;IAC9C,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC;CACjC,GACD,KAAK,CAAC"}
|
package/dist/model.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,4CAA4C"}
|
package/dist/models.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ModelInfo } from './model.js';
|
|
2
|
+
import type { Provider } from './providers.js';
|
|
3
|
+
/** Every model, by provider. */
|
|
4
|
+
export declare const MODELS: {
|
|
5
|
+
readonly [P in Provider]: readonly ModelInfo<P>[];
|
|
6
|
+
};
|
|
7
|
+
/** The model, or undefined for one not listed, which still works. */
|
|
8
|
+
export declare function findModel<P extends Provider>(provider: P, id: string): ModelInfo<P> | undefined;
|
|
9
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,gCAAgC;AAChC,eAAO,MAAM,MAAM,EAAE;IAAE,QAAQ,EAAE,CAAC,IAAI,QAAQ,GAAG,SAAS,SAAS,CAAC,CAAC,CAAC,EAAE;CAIvE,CAAC;AAEF,qEAAqE;AACrE,wBAAgB,SAAS,CAAC,CAAC,SAAS,QAAQ,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAI/F"}
|
package/dist/models.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// What is known about each model: its limits, what it takes as input and its
|
|
2
|
+
// prices. A model need not be here to be used; one that is gets cost
|
|
3
|
+
// estimates, and a step can read its context window.
|
|
4
|
+
import { ANTHROPIC_MODELS } from './catalog/anthropic.js';
|
|
5
|
+
import { FIREWORKS_MODELS } from './catalog/fireworks.js';
|
|
6
|
+
import { OPENAI_MODELS } from './catalog/openai.js';
|
|
7
|
+
/** Every model, by provider. */
|
|
8
|
+
export const MODELS = {
|
|
9
|
+
anthropic: ANTHROPIC_MODELS,
|
|
10
|
+
openai: OPENAI_MODELS,
|
|
11
|
+
fireworks: FIREWORKS_MODELS,
|
|
12
|
+
};
|
|
13
|
+
/** The model, or undefined for one not listed, which still works. */
|
|
14
|
+
export function findModel(provider, id) {
|
|
15
|
+
const models = MODELS[provider];
|
|
16
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion
|
|
17
|
+
return models.find((model) => model.id === id);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=models.js.map
|