@volter/twin-togetherai 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/LICENSE +202 -0
- package/README.md +147 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +28 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +79 -0
- package/dist/src/togetherai-budget.d.ts +52 -0
- package/dist/src/togetherai-budget.js +130 -0
- package/dist/src/togetherai-capabilities.d.ts +4 -0
- package/dist/src/togetherai-capabilities.js +1428 -0
- package/dist/src/togetherai-conformance.d.ts +14 -0
- package/dist/src/togetherai-conformance.js +452 -0
- package/dist/src/togetherai-connector.d.ts +164 -0
- package/dist/src/togetherai-connector.js +457 -0
- package/dist/src/togetherai-models.d.ts +19 -0
- package/dist/src/togetherai-models.js +49 -0
- package/dist/src/togetherai-scenario.d.ts +52 -0
- package/dist/src/togetherai-scenario.js +168 -0
- package/dist/src/togetherai-server.d.ts +16 -0
- package/dist/src/togetherai-server.js +187 -0
- package/dist/src/togetherai-stub.d.ts +59 -0
- package/dist/src/togetherai-stub.js +195 -0
- package/dist/src/togetherai-twin.d.ts +83 -0
- package/dist/src/togetherai-twin.js +1419 -0
- package/dist/src/togetherai-types.d.ts +207 -0
- package/dist/src/togetherai-types.js +26 -0
- package/package.json +52 -0
- package/src/cli.ts +27 -0
- package/src/index.ts +118 -0
- package/src/togetherai-budget.ts +156 -0
- package/src/togetherai-capabilities.ts +1315 -0
- package/src/togetherai-conformance.ts +459 -0
- package/src/togetherai-connector.ts +496 -0
- package/src/togetherai-models.ts +74 -0
- package/src/togetherai-scenario.ts +185 -0
- package/src/togetherai-server.ts +199 -0
- package/src/togetherai-stub.ts +197 -0
- package/src/togetherai-twin.ts +1448 -0
- package/src/togetherai-types.ts +222 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type TogetheraiScenarioEngine } from './togetherai-scenario.js';
|
|
2
|
+
import type { TogetheraiChatCompletion, TogetheraiMessageParam, SseSink } from './togetherai-types.js';
|
|
3
|
+
/** The ONE base path Together's inference API serves. Everything the twin routes hangs off this. */
|
|
4
|
+
export declare const TOGETHERAI_API_PREFIX = "/v1";
|
|
5
|
+
export type TogetheraiRequest = {
|
|
6
|
+
/** The scenario engine (kernel grammar + this pack's vocabulary) — scripts chat turns. */
|
|
7
|
+
scenarioEngine?: TogetheraiScenarioEngine;
|
|
8
|
+
method: string;
|
|
9
|
+
path: string;
|
|
10
|
+
body?: string;
|
|
11
|
+
occurredAt?: string;
|
|
12
|
+
root?: string;
|
|
13
|
+
readOnly?: boolean;
|
|
14
|
+
/** The credential the caller presents (the SDK's bearer `Authorization` header). When a request
|
|
15
|
+
* carries an auth SURFACE (this field set, or `headers` present), the twin holds it to the real
|
|
16
|
+
* vendor rule: a credential is required → 401 on missing/invalid. In-process trusted calls
|
|
17
|
+
* (capability verify, connector) omit BOTH and are not auth-gated. */
|
|
18
|
+
apiKey?: string;
|
|
19
|
+
/** Lower-cased request headers the HTTP server passes through so the handler can model auth
|
|
20
|
+
* (401) and the deterministic fault triggers (429 / 402 / 503). */
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
/** When set on a streaming POST, chunks are written here (no sockets). */
|
|
23
|
+
sseSink?: SseSink;
|
|
24
|
+
};
|
|
25
|
+
/** The handler response. `headers` (when present) are response headers the HTTP server should set
|
|
26
|
+
* — e.g. `x-ratelimit-reset` on a modeled 429, or the redirect pair on the SDK's upload flow. */
|
|
27
|
+
export type TogetheraiResponseEnvelope = {
|
|
28
|
+
status: number;
|
|
29
|
+
body: unknown;
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
};
|
|
32
|
+
type ToolChoice = 'auto' | 'none' | 'required' | {
|
|
33
|
+
name: string;
|
|
34
|
+
};
|
|
35
|
+
type ResponseFormat = {
|
|
36
|
+
kind: 'text';
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'json_object';
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'json_schema';
|
|
41
|
+
schema: unknown;
|
|
42
|
+
};
|
|
43
|
+
/** Together's `ChatCompletionRequest.context_length_exceeded_behavior` — a CLOSED documented
|
|
44
|
+
* enum with default `error`. */
|
|
45
|
+
declare const CONTEXT_LENGTH_BEHAVIORS: readonly ["truncate", "error"];
|
|
46
|
+
type ContextLengthBehavior = (typeof CONTEXT_LENGTH_BEHAVIORS)[number];
|
|
47
|
+
/** Together's `reasoning_effort` — a CLOSED documented enum. */
|
|
48
|
+
declare const REASONING_EFFORTS: readonly ["low", "medium", "high"];
|
|
49
|
+
type ReasoningEffort = (typeof REASONING_EFFORTS)[number];
|
|
50
|
+
type ChatArgs = {
|
|
51
|
+
model: string;
|
|
52
|
+
messages: TogetheraiMessageParam[];
|
|
53
|
+
tools?: unknown;
|
|
54
|
+
n: number;
|
|
55
|
+
maxTokens?: number;
|
|
56
|
+
stop?: string[];
|
|
57
|
+
stream: boolean;
|
|
58
|
+
toolChoice?: ToolChoice;
|
|
59
|
+
parallelToolCalls: boolean;
|
|
60
|
+
legacyFunctions: boolean;
|
|
61
|
+
responseFormat: ResponseFormat;
|
|
62
|
+
seed?: number;
|
|
63
|
+
echo: boolean;
|
|
64
|
+
logprobs?: number;
|
|
65
|
+
reasoningEffort?: ReasoningEffort;
|
|
66
|
+
contextBehavior: ContextLengthBehavior;
|
|
67
|
+
};
|
|
68
|
+
export declare function buildChatCompletion(args: ChatArgs, occurredAt?: string, scenarioEngine?: TogetheraiScenarioEngine): TogetheraiChatCompletion | TogetheraiResponseEnvelope;
|
|
69
|
+
/**
|
|
70
|
+
* Emit the vendor-faithful Together streaming sequence into the injected sink (NO sockets, NO
|
|
71
|
+
* setTimeout). Together's order: a first chunk with `delta:{role:'assistant'}`, then
|
|
72
|
+
* `delta:{content}` chunks (or tool_calls deltas), then a chunk carrying `finish_reason`. Every
|
|
73
|
+
* chunk carries Together's nullable `usage` + `warnings` (the schema declares both on
|
|
74
|
+
* ChatCompletionChunk itself — OpenAI puts usage only in an opt-in tail chunk). Ends with
|
|
75
|
+
* `data: [DONE]`. Deterministic + synchronous.
|
|
76
|
+
*/
|
|
77
|
+
export declare function streamChat(args: ChatArgs, sink: SseSink, occurredAt?: string, scenarioEngine?: TogetheraiScenarioEngine): TogetheraiChatCompletion | TogetheraiResponseEnvelope;
|
|
78
|
+
export declare function handleTogetheraiTwinRequest(req: TogetheraiRequest): Promise<TogetheraiResponseEnvelope>;
|
|
79
|
+
/** The twin-only door the SDK redirect flow uploads bytes through (kept OUT of the manifest:
|
|
80
|
+
* twin-only scaffolding, not vendor surface — the same rule the `/twin` doors follow). */
|
|
81
|
+
export declare const TOGETHERAI_UPLOAD_DOOR = "/twin/upload";
|
|
82
|
+
export declare function handleTogetheraiUploadDoor(req: TogetheraiRequest): Promise<TogetheraiResponseEnvelope>;
|
|
83
|
+
export {};
|