@knpkv/relay 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/LICENSE-THIRD-PARTY.md +29 -0
- package/README.md +90 -2
- package/dist/backends.d.ts +26 -0
- package/dist/backends.d.ts.map +1 -0
- package/dist/harness.d.ts +128 -0
- package/dist/harness.d.ts.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12099 -0
- package/dist/index.js.map +7 -0
- package/dist/model.d.ts +188 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/registry.d.ts +47 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/turn.d.ts +68 -0
- package/dist/turn.d.ts.map +1 -0
- package/package.json +69 -3
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/** The products Relay can be about. */
|
|
3
|
+
export declare const RelayProduct: Schema.Literals<readonly ["codecommit", "jcf", "agent-usage", "control-center", "herdr"]>;
|
|
4
|
+
export type RelayProduct = typeof RelayProduct.Type;
|
|
5
|
+
/** A product object a Relay session is about. Relay keeps sessions only for the products it knows. */
|
|
6
|
+
export declare const ObjectRef: Schema.Struct<{
|
|
7
|
+
readonly product: Schema.Literals<readonly ["codecommit", "jcf", "agent-usage", "control-center", "herdr"]>;
|
|
8
|
+
readonly kind: Schema.String;
|
|
9
|
+
readonly id: Schema.String;
|
|
10
|
+
}>;
|
|
11
|
+
export interface ObjectRef extends Schema.Schema.Type<typeof ObjectRef> {
|
|
12
|
+
}
|
|
13
|
+
/** The key a session is stored under. Unique per product, kind and id: JSON-encoded, so no field can contain the separator. */
|
|
14
|
+
export declare const objectRefKey: (ref: ObjectRef) => string;
|
|
15
|
+
/** Who must agree before a capability runs, as the dock lists it. */
|
|
16
|
+
export declare const CapabilityAccess: Schema.Literals<readonly ["read", "write", "host"]>;
|
|
17
|
+
export type CapabilityAccess = typeof CapabilityAccess.Type;
|
|
18
|
+
/** Why a backend can't answer yet, and the one action that fixes it. */
|
|
19
|
+
export declare const BackendUnavailableCause: Schema.Literals<readonly ["NotInstalled", "SignedOut", "Misconfigured", "NoCapability"]>;
|
|
20
|
+
export type BackendUnavailableCause = typeof BackendUnavailableCause.Type;
|
|
21
|
+
/** The backends Relay supports: each runs on the user's own CLI login, never on a token Relay holds. */
|
|
22
|
+
export declare const RelayBackendId: Schema.Literals<readonly ["claude-code", "codex-cli"]>;
|
|
23
|
+
export type RelayBackendId = typeof RelayBackendId.Type;
|
|
24
|
+
/**
|
|
25
|
+
* What setup shows for one backend. `Unverified` (installed, version known, never answered yet) until a turn
|
|
26
|
+
* answers (`Ready`) or is refused for sign-in (`Unavailable` with `SignedOut`). Not persisted: every start is
|
|
27
|
+
* `Unverified` or `Unavailable` again. `fix` is one line the person can act on.
|
|
28
|
+
*/
|
|
29
|
+
export declare const BackendStatus: Schema.TaggedUnion<{
|
|
30
|
+
readonly Ready: Schema.TaggedStruct<"Ready", {
|
|
31
|
+
readonly backend: Schema.Literals<readonly ["claude-code", "codex-cli"]>;
|
|
32
|
+
readonly label: Schema.String;
|
|
33
|
+
readonly version: Schema.String;
|
|
34
|
+
}>;
|
|
35
|
+
readonly Unavailable: Schema.TaggedStruct<"Unavailable", {
|
|
36
|
+
readonly backend: Schema.Literals<readonly ["claude-code", "codex-cli"]>;
|
|
37
|
+
readonly label: Schema.String;
|
|
38
|
+
readonly version: Schema.optionalKey<Schema.String>;
|
|
39
|
+
readonly cause: Schema.Literals<readonly ["NotInstalled", "SignedOut", "Misconfigured", "NoCapability"]>;
|
|
40
|
+
readonly fix: Schema.String;
|
|
41
|
+
}>;
|
|
42
|
+
readonly Unverified: Schema.TaggedStruct<"Unverified", {
|
|
43
|
+
readonly backend: Schema.Literals<readonly ["claude-code", "codex-cli"]>;
|
|
44
|
+
readonly label: Schema.String;
|
|
45
|
+
readonly version: Schema.String;
|
|
46
|
+
}>;
|
|
47
|
+
}>;
|
|
48
|
+
export type BackendStatus = typeof BackendStatus.Type;
|
|
49
|
+
/** Why a confirmation can't be answered: answered already, withdrawn with its run, or never asked. */
|
|
50
|
+
export declare const DecisionState: Schema.TaggedUnion<{
|
|
51
|
+
readonly Decided: Schema.TaggedStruct<"Decided", {
|
|
52
|
+
readonly allow: Schema.Boolean;
|
|
53
|
+
}>;
|
|
54
|
+
readonly Expired: Schema.TaggedStruct<"Expired", {}>;
|
|
55
|
+
readonly Unknown: Schema.TaggedStruct<"Unknown", {}>;
|
|
56
|
+
}>;
|
|
57
|
+
export type DecisionState = typeof DecisionState.Type;
|
|
58
|
+
/** One tool as the dock lists it for a session. */
|
|
59
|
+
export declare const SessionTool: Schema.Struct<{
|
|
60
|
+
readonly name: Schema.String;
|
|
61
|
+
readonly access: Schema.Literals<readonly ["read", "write", "host"]>;
|
|
62
|
+
readonly available: Schema.Boolean;
|
|
63
|
+
readonly unavailableReason: Schema.optional<Schema.String>;
|
|
64
|
+
}>;
|
|
65
|
+
export interface SessionTool extends Schema.Schema.Type<typeof SessionTool> {
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* What the dock shows for a session: its tools, the backend its next turn runs on, and whether a run can
|
|
69
|
+
* be stopped (the dock offers Stop only when `cancel` is true).
|
|
70
|
+
*/
|
|
71
|
+
export declare const SessionInfo: Schema.Struct<{
|
|
72
|
+
readonly tools: Schema.$Array<Schema.Struct<{
|
|
73
|
+
readonly name: Schema.String;
|
|
74
|
+
readonly access: Schema.Literals<readonly ["read", "write", "host"]>;
|
|
75
|
+
readonly available: Schema.Boolean;
|
|
76
|
+
readonly unavailableReason: Schema.optional<Schema.String>;
|
|
77
|
+
}>>;
|
|
78
|
+
readonly backend: Schema.Literals<readonly ["claude-code", "codex-cli"]>;
|
|
79
|
+
readonly cancel: Schema.Boolean;
|
|
80
|
+
}>;
|
|
81
|
+
export interface SessionInfo extends Schema.Schema.Type<typeof SessionInfo> {
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* What a confirmed write did, as the product projects it: a display-safe line, the provider's id for what
|
|
85
|
+
* was made, and where to see it.
|
|
86
|
+
*/
|
|
87
|
+
export declare const WriteReceipt: Schema.Struct<{
|
|
88
|
+
readonly summary: Schema.String;
|
|
89
|
+
readonly providerId: Schema.String;
|
|
90
|
+
readonly link: Schema.optionalKey<Schema.String>;
|
|
91
|
+
}>;
|
|
92
|
+
export interface WriteReceipt extends Schema.Schema.Type<typeof WriteReceipt> {
|
|
93
|
+
}
|
|
94
|
+
/** Everything the dock renders. `seq` counts up within one subscription; a reconnect starts from a `Snapshot`. */
|
|
95
|
+
export declare const RelayEvent: Schema.TaggedUnion<{
|
|
96
|
+
readonly ApprovalPending: Schema.TaggedStruct<"ApprovalPending", {
|
|
97
|
+
readonly session: Schema.String;
|
|
98
|
+
readonly seq: Schema.Int;
|
|
99
|
+
readonly call: Schema.String;
|
|
100
|
+
readonly approvalId: Schema.String;
|
|
101
|
+
}>;
|
|
102
|
+
readonly Cancelled: Schema.TaggedStruct<"Cancelled", {
|
|
103
|
+
readonly session: Schema.String;
|
|
104
|
+
readonly seq: Schema.Int;
|
|
105
|
+
readonly runIds: Schema.$Array<Schema.String>;
|
|
106
|
+
}>;
|
|
107
|
+
readonly ConfirmationRequired: Schema.TaggedStruct<"ConfirmationRequired", {
|
|
108
|
+
readonly session: Schema.String;
|
|
109
|
+
readonly seq: Schema.Int;
|
|
110
|
+
readonly call: Schema.String;
|
|
111
|
+
readonly action: Schema.Struct<{
|
|
112
|
+
readonly verb: Schema.String;
|
|
113
|
+
readonly target: Schema.Struct<{
|
|
114
|
+
readonly product: Schema.String;
|
|
115
|
+
readonly kind: Schema.String;
|
|
116
|
+
readonly id: Schema.String;
|
|
117
|
+
}>;
|
|
118
|
+
readonly args: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
119
|
+
}>;
|
|
120
|
+
readonly reversible: Schema.Boolean;
|
|
121
|
+
}>;
|
|
122
|
+
readonly ConfirmationResolved: Schema.TaggedStruct<"ConfirmationResolved", {
|
|
123
|
+
readonly session: Schema.String;
|
|
124
|
+
readonly seq: Schema.Int;
|
|
125
|
+
readonly call: Schema.String;
|
|
126
|
+
readonly decision: Schema.Literals<readonly ["confirmed", "declined", "expired"]>;
|
|
127
|
+
}>;
|
|
128
|
+
readonly RunFailed: Schema.TaggedStruct<"RunFailed", {
|
|
129
|
+
readonly session: Schema.String;
|
|
130
|
+
readonly seq: Schema.Int;
|
|
131
|
+
readonly runIds: Schema.$Array<Schema.String>;
|
|
132
|
+
readonly cause: Schema.String;
|
|
133
|
+
readonly fix: Schema.String;
|
|
134
|
+
}>;
|
|
135
|
+
readonly RunFinished: Schema.TaggedStruct<"RunFinished", {
|
|
136
|
+
readonly session: Schema.String;
|
|
137
|
+
readonly seq: Schema.Int;
|
|
138
|
+
readonly runIds: Schema.$Array<Schema.String>;
|
|
139
|
+
}>;
|
|
140
|
+
readonly RunStarted: Schema.TaggedStruct<"RunStarted", {
|
|
141
|
+
readonly session: Schema.String;
|
|
142
|
+
readonly seq: Schema.Int;
|
|
143
|
+
readonly runIds: Schema.$Array<Schema.String>;
|
|
144
|
+
}>;
|
|
145
|
+
readonly Snapshot: Schema.TaggedStruct<"Snapshot", {
|
|
146
|
+
readonly session: Schema.String;
|
|
147
|
+
readonly seq: Schema.Int;
|
|
148
|
+
readonly messages: Schema.$Array<Schema.Struct<{
|
|
149
|
+
readonly id: Schema.String;
|
|
150
|
+
readonly role: Schema.Literals<readonly ["user", "relay"]>;
|
|
151
|
+
readonly text: Schema.String;
|
|
152
|
+
}>>;
|
|
153
|
+
/** The run in flight, empty when idle. */
|
|
154
|
+
readonly runIds: Schema.$Array<Schema.String>;
|
|
155
|
+
}>;
|
|
156
|
+
readonly TextDelta: Schema.TaggedStruct<"TextDelta", {
|
|
157
|
+
readonly session: Schema.String;
|
|
158
|
+
readonly seq: Schema.Int;
|
|
159
|
+
readonly text: Schema.String;
|
|
160
|
+
}>;
|
|
161
|
+
readonly ToolFinished: Schema.TaggedStruct<"ToolFinished", {
|
|
162
|
+
readonly session: Schema.String;
|
|
163
|
+
readonly seq: Schema.Int;
|
|
164
|
+
readonly call: Schema.String;
|
|
165
|
+
readonly ok: Schema.Boolean;
|
|
166
|
+
readonly summary: Schema.String;
|
|
167
|
+
readonly cites: Schema.$Array<Schema.Struct<{
|
|
168
|
+
readonly product: Schema.String;
|
|
169
|
+
readonly kind: Schema.String;
|
|
170
|
+
readonly id: Schema.String;
|
|
171
|
+
}>>;
|
|
172
|
+
readonly receipt: Schema.optionalKey<Schema.Struct<{
|
|
173
|
+
readonly summary: Schema.String;
|
|
174
|
+
readonly providerId: Schema.String;
|
|
175
|
+
readonly link: Schema.optionalKey<Schema.String>;
|
|
176
|
+
}>>;
|
|
177
|
+
}>;
|
|
178
|
+
readonly ToolStarted: Schema.TaggedStruct<"ToolStarted", {
|
|
179
|
+
readonly session: Schema.String;
|
|
180
|
+
readonly seq: Schema.Int;
|
|
181
|
+
readonly call: Schema.String;
|
|
182
|
+
readonly capability: Schema.String;
|
|
183
|
+
readonly summary: Schema.String;
|
|
184
|
+
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
185
|
+
}>;
|
|
186
|
+
}>;
|
|
187
|
+
export type RelayEvent = typeof RelayEvent.Type;
|
|
188
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAI/B,uCAAuC;AACvC,eAAO,MAAM,YAAY,2FAAmF,CAAA;AAC5G,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AAEnD,sGAAsG;AACtG,eAAO,MAAM,SAAS;;;;EAIpB,CAAA;AACF,MAAM,WAAW,SAAU,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,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;;;;;;;;;;;;;;;;;;;;;;;QAMnB,0CAA0C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2B5C,CAAA;AACF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capabilities as the harness holds them: one list of `@knpkv/capability` capabilities with their
|
|
3
|
+
* types closed over, so the harness can run any of them from the model's JSON without `any`.
|
|
4
|
+
*
|
|
5
|
+
* Decoding, encoding and failure handling are the capability package's (`invoke`, `describeCall`);
|
|
6
|
+
* this module only erases types and records what the gate needs.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { type Capability, type CapabilityEncodingFailed, type CapabilityFailed, type CapabilityInputInvalid, type FailureSchema, type InputSchema, type InvocationResult, type PendingAction, type PlainSchema } from "@knpkv/capability";
|
|
11
|
+
import { Schema } from "effect";
|
|
12
|
+
import type { Effect } from "effect";
|
|
13
|
+
import type * as JsonSchema from "effect/JsonSchema";
|
|
14
|
+
import type { WriteReceipt } from "./model.js";
|
|
15
|
+
/** What a person must agree to before a gated capability runs. */
|
|
16
|
+
export interface Gate {
|
|
17
|
+
readonly access: "write" | "host";
|
|
18
|
+
readonly reversible: boolean;
|
|
19
|
+
readonly describe: (args: Schema.Json) => Effect.Effect<PendingAction, CapabilityInputInvalid | CapabilityEncodingFailed>;
|
|
20
|
+
}
|
|
21
|
+
/** One registered capability, its types erased behind closures. */
|
|
22
|
+
export interface RegisteredCapability<Requirements> {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly description: string;
|
|
25
|
+
/** `undefined` for a read: it runs without anyone agreeing first. */
|
|
26
|
+
readonly gate: Gate | undefined;
|
|
27
|
+
/** A short display name, for activity rows. */
|
|
28
|
+
readonly label: string;
|
|
29
|
+
/** A display-safe line for one call: a write's action verb, or the label. */
|
|
30
|
+
readonly summarize: (args: Schema.Json) => string;
|
|
31
|
+
/** What a completed call made, for writes whose product projects a receipt. */
|
|
32
|
+
readonly receipt: (result: InvocationResult) => WriteReceipt | undefined;
|
|
33
|
+
/** JSON Schema of the input, for the model's tool list and argument validation. */
|
|
34
|
+
readonly parameters: JsonSchema.JsonSchema;
|
|
35
|
+
/** `args` is the model's JSON for this call; the capability decodes it at the boundary. */
|
|
36
|
+
readonly run: (args: Schema.Json) => Effect.Effect<InvocationResult, CapabilityInputInvalid | CapabilityFailed | CapabilityEncodingFailed, Requirements>;
|
|
37
|
+
}
|
|
38
|
+
/** How the dock shows a capability's calls. Every field has a default. */
|
|
39
|
+
export interface DisplayOptions<Output extends PlainSchema> {
|
|
40
|
+
/** Defaults to the capability name with spaces: `get_pull_request` is "get pull request". */
|
|
41
|
+
readonly label?: string;
|
|
42
|
+
/** A write's receipt, from its decoded output: a display-safe line, the provider's id, a link. */
|
|
43
|
+
readonly receipt?: (output: Output["Type"]) => WriteReceipt;
|
|
44
|
+
}
|
|
45
|
+
/** Register a capability for Relay, with how the dock shows its calls. */
|
|
46
|
+
export declare const register: <Name extends string, Input extends InputSchema, Output extends PlainSchema, Failure extends FailureSchema, Requirements>(capability: Capability<Name, Input, Output, Failure, Requirements>, display?: DisplayOptions<Output>) => RegisteredCapability<Requirements>;
|
|
47
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,KAAK,UAAU,EACf,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAElB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EAErB,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,KAAK,EAAE,MAAM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F;IAC7F,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,kGAAkG;IAClG,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,YAAY,CAAA;CAC5D;AAED,0EAA0E;AAC1E,eAAO,MAAM,QAAQ,GACnB,IAAI,SAAS,MAAM,EACnB,KAAK,SAAS,WAAW,EACzB,MAAM,SAAS,WAAW,EAC1B,OAAO,SAAS,aAAa,EAC7B,YAAY,cAEA,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,YACzD,cAAc,CAAC,MAAM,CAAC,KAC9B,oBAAoB,CAAC,YAAY,CA0BnC,CAAA"}
|
package/dist/turn.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One model turn over a CLI-backed `LanguageModel`, with tool calls carried in a JSON schema.
|
|
3
|
+
*
|
|
4
|
+
* **Mental model**
|
|
5
|
+
*
|
|
6
|
+
* - **The CLI never runs tools.** `claude --print` and `codex exec` are asked for one structured
|
|
7
|
+
* answer: either tool calls or a final reply. The harness runs the tools, behind its gate, and the
|
|
8
|
+
* next turn sees their results. That keeps the user's own CLI login as the only credential and the
|
|
9
|
+
* permission gate as the only path to a product.
|
|
10
|
+
* - **The transcript is rendered, not replayed into provider sessions.** Each turn gets the whole
|
|
11
|
+
* visible transcript, so switching backends mid-session needs no provider state.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import { Effect, Schema } from "effect";
|
|
16
|
+
import { LanguageModel } from "effect/ai";
|
|
17
|
+
/** A tool as the model is told about it. */
|
|
18
|
+
export interface TurnTool {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly description: string;
|
|
21
|
+
readonly parameters: Schema.Json;
|
|
22
|
+
}
|
|
23
|
+
/** One transcript line as the model reads it. */
|
|
24
|
+
export type TurnLine = {
|
|
25
|
+
readonly _tag: "User";
|
|
26
|
+
readonly text: string;
|
|
27
|
+
} | {
|
|
28
|
+
readonly _tag: "Relay";
|
|
29
|
+
readonly text: string;
|
|
30
|
+
} | {
|
|
31
|
+
readonly _tag: "ToolCall";
|
|
32
|
+
readonly id: string;
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly arguments: Schema.Json;
|
|
35
|
+
} | {
|
|
36
|
+
readonly _tag: "ToolResult";
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly text: string;
|
|
40
|
+
readonly isError: boolean;
|
|
41
|
+
};
|
|
42
|
+
export interface TurnRequest {
|
|
43
|
+
readonly instructions: string;
|
|
44
|
+
readonly tools: ReadonlyArray<TurnTool>;
|
|
45
|
+
readonly transcript: ReadonlyArray<TurnLine>;
|
|
46
|
+
}
|
|
47
|
+
/** What the model returns for one turn. An empty `toolCalls` means `reply` is the final answer. */
|
|
48
|
+
export declare const Turn: Schema.Struct<{
|
|
49
|
+
readonly reply: Schema.String;
|
|
50
|
+
readonly toolCalls: Schema.$Array<Schema.Struct<{
|
|
51
|
+
readonly name: Schema.String;
|
|
52
|
+
readonly arguments: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
53
|
+
}>>;
|
|
54
|
+
}>;
|
|
55
|
+
export type Turn = typeof Turn.Type;
|
|
56
|
+
/** The prompt one turn sends: instructions, the tool list with schemas, the transcript, the answer rule. */
|
|
57
|
+
export declare const renderTurnPrompt: (request: TurnRequest) => string;
|
|
58
|
+
/** Run one turn on whatever `LanguageModel` is provided: the user's Claude Code or Codex CLI. */
|
|
59
|
+
export declare const runTurn: (request: TurnRequest) => Effect.Effect<{
|
|
60
|
+
readonly reply: string;
|
|
61
|
+
readonly toolCalls: readonly {
|
|
62
|
+
readonly name: string;
|
|
63
|
+
readonly arguments: {
|
|
64
|
+
readonly [x: string]: Schema.Json;
|
|
65
|
+
};
|
|
66
|
+
}[];
|
|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EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;IACvC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;CAC7C;AAED,mGAAmG;AACnG,eAAO,MAAM,IAAI;;;;;;EAGf,CAAA;AACF,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,CAAA;AAenC,4GAA4G;AAC5G,eAAO,MAAM,gBAAgB,YAAa,WAAW,KAAG,MAmB1C,CAAA;AAEd,iGAAiG;AACjG,eAAO,MAAM,OAAO;;;;;;;;oEAOlB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knpkv/relay",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Relay agent harness: durable sessions per product object, typed capabilities, a central permission gate, and model turns through the user's own Claude Code or Codex CLI login",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "knpkv",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/knpkv/npm.git",
|
|
10
|
+
"directory": "packages/relay"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE-THIRD-PARTY.md"
|
|
26
|
+
],
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=26"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"effect": "4.0.0"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@libsql/client": "^0.18.0",
|
|
38
|
+
"typebox": "1.3.27",
|
|
39
|
+
"@knpkv/ai-claude": "^0.4.3",
|
|
40
|
+
"@knpkv/ai-codex": "^0.5.3",
|
|
41
|
+
"@knpkv/ai-runtime": "^0.5.2",
|
|
42
|
+
"@knpkv/capability": "^0.1.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@earendil-works/chord": "1.0.4",
|
|
46
|
+
"@earendil-works/pi-ai": "1.0.4",
|
|
47
|
+
"@earendil-works/pi-durable": "1.0.4",
|
|
48
|
+
"@effect/platform-node": "4.0.0",
|
|
49
|
+
"@effect/vitest": "4.0.0",
|
|
50
|
+
"effect": "4.0.0",
|
|
51
|
+
"esbuild": "0.28.2",
|
|
52
|
+
"rimraf": "^6.1.3",
|
|
53
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
54
|
+
"vitest": "^5.0.3"
|
|
55
|
+
},
|
|
56
|
+
"keywords": [
|
|
57
|
+
"effect",
|
|
58
|
+
"agent",
|
|
59
|
+
"relay",
|
|
60
|
+
"durable",
|
|
61
|
+
"claude",
|
|
62
|
+
"codex"
|
|
63
|
+
],
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "rimraf dist && tsc && node scripts/bundle.mjs",
|
|
66
|
+
"check": "tsc --noEmit && tsc --noEmit -p test/tsconfig.json",
|
|
67
|
+
"clean": "rimraf dist *.tsbuildinfo",
|
|
68
|
+
"lint": "eslint \"{src,test}/**/*.ts\"",
|
|
69
|
+
"test": "vitest run",
|
|
70
|
+
"test:pack": "pnpm --filter \"@knpkv/relay...\" --sort run build && node scripts/test-packed-package.mjs"
|
|
71
|
+
}
|
|
6
72
|
}
|