@nones/agentflow-opencode 0.0.0-stage → 0.6.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 +21 -0
- package/README.md +194 -2
- package/package.json +43 -4
- package/src/adapter.ts +1114 -0
- package/src/config.ts +268 -0
- package/src/errors.ts +95 -0
- package/src/http.ts +169 -0
- package/src/index.ts +49 -0
- package/src/normalize.ts +1199 -0
- package/src/provider-history.ts +342 -0
- package/src/sse.ts +105 -0
- package/src/transcript.ts +930 -0
- package/src/types.ts +128 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { Profile, ProviderModel } from "@nones/agentflow-core/types";
|
|
2
|
+
|
|
3
|
+
export type {
|
|
4
|
+
AgentSpec,
|
|
5
|
+
CancelRequest,
|
|
6
|
+
Profile,
|
|
7
|
+
ProviderAdapter,
|
|
8
|
+
ProviderEvent,
|
|
9
|
+
RateLimitInfo,
|
|
10
|
+
SendRequest,
|
|
11
|
+
SessionConfiguration,
|
|
12
|
+
SessionPermission,
|
|
13
|
+
TurnRequest,
|
|
14
|
+
TurnResult,
|
|
15
|
+
TurnStatus,
|
|
16
|
+
} from "@nones/agentflow-core/types";
|
|
17
|
+
|
|
18
|
+
export interface ModelRef {
|
|
19
|
+
providerID: string;
|
|
20
|
+
id: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* One model the connected local endpoint exposes. `id` is the exact
|
|
25
|
+
* `provider/model` string usable verbatim in agent or profile configuration.
|
|
26
|
+
* `provider` is the separate provider id when it is known.
|
|
27
|
+
*/
|
|
28
|
+
export type ActiveModel = ProviderModel;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Authentication is always supplied as a reference. The HTTP client asks the
|
|
32
|
+
* trusted host application to resolve the reference; it never reads token
|
|
33
|
+
* files, environment variables, or credential stores itself.
|
|
34
|
+
*/
|
|
35
|
+
export interface AuthReferenceObject {
|
|
36
|
+
type?: "bearer" | "header";
|
|
37
|
+
/** Header name when `type` is `header`. */
|
|
38
|
+
name?: string;
|
|
39
|
+
/** Alias for the header name. */
|
|
40
|
+
header?: string;
|
|
41
|
+
/** Literal value supplied by the trusted host, not read from a store. */
|
|
42
|
+
value?: string;
|
|
43
|
+
/** Alias for a literal value. */
|
|
44
|
+
token?: string;
|
|
45
|
+
/** Credential reference resolved by `OpenCodeAdapterOptions.resolveCredential`. */
|
|
46
|
+
ref?: string;
|
|
47
|
+
/** Alias for a credential reference. */
|
|
48
|
+
tokenRef?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** A bare string is treated as a bearer credential reference. */
|
|
52
|
+
export type AuthReference = string | AuthReferenceObject;
|
|
53
|
+
|
|
54
|
+
export interface OpenCodeTimeouts {
|
|
55
|
+
/** Individual JSON request deadline. */
|
|
56
|
+
requestMs?: number;
|
|
57
|
+
/** How long to poll for the native session's concrete model. */
|
|
58
|
+
sessionReadyMs?: number;
|
|
59
|
+
/** Maximum observed turn duration. */
|
|
60
|
+
turnMs?: number;
|
|
61
|
+
/** Deadline for one `session/wait` attempt. */
|
|
62
|
+
waitMs?: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface OpenCodeProfileSettings {
|
|
66
|
+
/** Direct loopback endpoint, for example `http://127.0.0.1:4096`. */
|
|
67
|
+
endpoint?: string;
|
|
68
|
+
/** Named endpoint resolved by `OpenCodeAdapterOptions.resolveEndpoint`. */
|
|
69
|
+
endpointName?: string;
|
|
70
|
+
/** Authentication reference, resolved by the host application. */
|
|
71
|
+
auth?: AuthReference;
|
|
72
|
+
/** Default model for the profile, either `provider/id` or an object. */
|
|
73
|
+
model?: string | ModelRef;
|
|
74
|
+
/** Native location directory (passed as `location[directory]` when relevant). */
|
|
75
|
+
directory?: string;
|
|
76
|
+
/** Alias for `directory`. */
|
|
77
|
+
cwd?: string;
|
|
78
|
+
/** Delivery mode used by `turn`; defaults to `queue`. */
|
|
79
|
+
turnDelivery?: "queue" | "steer";
|
|
80
|
+
timeouts?: OpenCodeTimeouts;
|
|
81
|
+
/** Non-secret headers merged into every request. */
|
|
82
|
+
headers?: Record<string, string>;
|
|
83
|
+
/** Disable SSE observation (message/wait polling is still used). */
|
|
84
|
+
eventStream?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Opt in to mirroring normalized visible history into the host store. Off by
|
|
87
|
+
* default; `true` or `"enabled"` enable it, anything else leaves it off.
|
|
88
|
+
*/
|
|
89
|
+
historyIntake?: boolean | "enabled" | "disabled";
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface OpenCodeAdapterOptions {
|
|
93
|
+
/** Adapter id exposed on `ProviderAdapter.id`. */
|
|
94
|
+
id?: string;
|
|
95
|
+
/** Injectable fetch, typed so tests never touch the network. */
|
|
96
|
+
fetch?: (input: string, init: RequestInit) => Promise<Response>;
|
|
97
|
+
/** Injectable clock, in milliseconds. */
|
|
98
|
+
now?: () => number;
|
|
99
|
+
/** Injectable delay used while polling. */
|
|
100
|
+
sleep?: (ms: number) => Promise<void>;
|
|
101
|
+
/** Resolve `settings.endpointName` to a deliberate local endpoint. */
|
|
102
|
+
resolveEndpoint?: (name: string) => string | undefined;
|
|
103
|
+
/** Optional static named endpoints. */
|
|
104
|
+
endpoints?: Record<string, string>;
|
|
105
|
+
/**
|
|
106
|
+
* Resolve an authentication reference. The function receives only the
|
|
107
|
+
* reference string; credential contents are never inspected by the adapter.
|
|
108
|
+
*/
|
|
109
|
+
resolveCredential?: (
|
|
110
|
+
ref: string,
|
|
111
|
+
profile: Profile,
|
|
112
|
+
) => string | undefined | Promise<string | undefined>;
|
|
113
|
+
/** Non-secret headers merged into every request. */
|
|
114
|
+
headers?: Record<string, string>;
|
|
115
|
+
/** Allow non-loopback endpoints. Off by default; local-only is the norm. */
|
|
116
|
+
allowNonLoopback?: boolean;
|
|
117
|
+
/** Poll interval for session readiness and turn observation. */
|
|
118
|
+
pollIntervalMs?: number;
|
|
119
|
+
/** Default profile timeouts. */
|
|
120
|
+
timeouts?: OpenCodeTimeouts;
|
|
121
|
+
/** Use the experimental wait endpoint as a completion hint. */
|
|
122
|
+
useWaitEndpoint?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Fallback execution-context directory for profile-level operations such as
|
|
125
|
+
* `doctor`. Explicit profile `settings.directory` / `settings.cwd` wins.
|
|
126
|
+
*/
|
|
127
|
+
defaultCwd?: string;
|
|
128
|
+
}
|