@nylorun/harness 0.8.0-beta.1 → 0.11.0-beta

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +5 -38
  3. package/dist/build/assemble.js +1 -0
  4. package/dist/build/bind-tool.js +4 -3
  5. package/dist/build/builder.js +26 -0
  6. package/dist/build/helpers.d.ts +2 -2
  7. package/dist/build/manifest.js +12 -1
  8. package/dist/build/schema.d.ts +11 -16
  9. package/dist/build/schema.js +141 -22
  10. package/dist/errors.d.ts +1 -1
  11. package/dist/index.d.ts +8 -5
  12. package/dist/index.js +2 -0
  13. package/dist/model/adapters.d.ts +160 -0
  14. package/dist/model/adapters.js +545 -0
  15. package/dist/{model-normalize.d.ts → model/normalize.d.ts} +2 -2
  16. package/dist/{model-normalize.js → model/normalize.js} +35 -4
  17. package/dist/model/prepared.d.ts +16 -0
  18. package/dist/model/prepared.js +11 -0
  19. package/dist/session/event-log.d.ts +4 -3
  20. package/dist/session/input-queue.d.ts +7 -4
  21. package/dist/session/input-queue.js +12 -0
  22. package/dist/session/output-contract.d.ts +6 -0
  23. package/dist/session/output-contract.js +12 -0
  24. package/dist/session/scheduler.js +1 -1
  25. package/dist/session/seed.js +79 -5
  26. package/dist/session/session.d.ts +8 -5
  27. package/dist/session/session.js +38 -2
  28. package/dist/session/state.d.ts +1 -1
  29. package/dist/session/submission-stream.d.ts +5 -4
  30. package/dist/step/context-draft.js +1 -7
  31. package/dist/step/model-configuration.js +6 -20
  32. package/dist/step/project.js +25 -3
  33. package/dist/step/resolve.d.ts +1 -0
  34. package/dist/step/resolve.js +1 -0
  35. package/dist/step/run.d.ts +1 -0
  36. package/dist/step/run.js +25 -4
  37. package/dist/step/seal.d.ts +4 -2
  38. package/dist/step/seal.js +64 -13
  39. package/dist/step/step-context.js +1 -1
  40. package/dist/turn/plan-runner.js +38 -3
  41. package/dist/turn/runner.d.ts +6 -4
  42. package/dist/turn/runner.js +6 -4
  43. package/dist/types/manifest.d.ts +5 -4
  44. package/dist/types/middleware.d.ts +10 -1
  45. package/dist/types/model.d.ts +21 -13
  46. package/dist/types/session.d.ts +34 -13
  47. package/dist/types/shared.d.ts +16 -3
  48. package/dist/types/tool.d.ts +54 -17
  49. package/package.json +15 -12
  50. package/dist/utils/digest.d.ts +0 -1
  51. package/dist/utils/digest.js +0 -14
@@ -0,0 +1,160 @@
1
+ import type { ModelAdapter, ModelAdapterContext, ModelCall, ModelCandidate } from "../types/model.js";
2
+ import type { JsonObject } from "../types/shared.js";
3
+ export type ChatCompletionsMessage = {
4
+ readonly role: "system";
5
+ readonly content: string;
6
+ } | {
7
+ readonly role: "user";
8
+ readonly content: string | readonly ChatCompletionsContentPart[];
9
+ } | {
10
+ readonly role: "assistant";
11
+ readonly content: string | null;
12
+ readonly tool_calls?: readonly ChatCompletionsToolCall[];
13
+ } | {
14
+ readonly role: "tool";
15
+ readonly tool_call_id: string;
16
+ readonly content: string;
17
+ };
18
+ export type ChatCompletionsContentPart = {
19
+ readonly type: "text";
20
+ readonly text: string;
21
+ } | {
22
+ readonly type: "image_url";
23
+ readonly image_url: Readonly<{
24
+ url: string;
25
+ }>;
26
+ };
27
+ export interface ChatCompletionsToolCall {
28
+ readonly id: string;
29
+ readonly type: "function";
30
+ readonly function: Readonly<{
31
+ name: string;
32
+ arguments: string;
33
+ }>;
34
+ }
35
+ export interface ChatCompletionsRequest {
36
+ readonly messages: readonly ChatCompletionsMessage[];
37
+ readonly tools?: readonly Readonly<{
38
+ type: "function";
39
+ function: Readonly<{
40
+ name: string;
41
+ description?: string;
42
+ parameters: JsonObject;
43
+ }>;
44
+ }>[];
45
+ readonly temperature?: number;
46
+ readonly max_completion_tokens?: number;
47
+ readonly response_format?: Readonly<{
48
+ type: "json_schema";
49
+ json_schema: Readonly<{
50
+ name: string;
51
+ schema: JsonObject;
52
+ }>;
53
+ }>;
54
+ }
55
+ export interface ResponsesRequest {
56
+ readonly instructions?: string;
57
+ readonly input: readonly ResponsesInputItem[];
58
+ readonly tools?: readonly Readonly<{
59
+ type: "function";
60
+ name: string;
61
+ description?: string;
62
+ parameters: JsonObject;
63
+ }>[];
64
+ readonly temperature?: number;
65
+ readonly max_output_tokens?: number;
66
+ readonly text?: Readonly<{
67
+ format: Readonly<{
68
+ type: "json_schema";
69
+ name: string;
70
+ schema: JsonObject;
71
+ }>;
72
+ }>;
73
+ }
74
+ export type ResponsesInputItem = {
75
+ readonly type: "message";
76
+ readonly role: "user" | "assistant";
77
+ readonly content: string | readonly ResponsesContentPart[];
78
+ } | {
79
+ readonly type: "function_call";
80
+ readonly call_id: string;
81
+ readonly name: string;
82
+ readonly arguments: string;
83
+ } | {
84
+ readonly type: "function_call_output";
85
+ readonly call_id: string;
86
+ readonly output: string;
87
+ };
88
+ export type ResponsesContentPart = {
89
+ readonly type: "input_text";
90
+ readonly text: string;
91
+ } | {
92
+ readonly type: "input_image";
93
+ readonly image_url: string;
94
+ };
95
+ export interface MessagesRequest {
96
+ readonly system?: string;
97
+ readonly messages: readonly MessagesMessage[];
98
+ readonly tools?: readonly Readonly<{
99
+ name: string;
100
+ description?: string;
101
+ input_schema: JsonObject;
102
+ }>[];
103
+ readonly temperature?: number;
104
+ readonly max_tokens: number;
105
+ }
106
+ export type MessagesMessage = {
107
+ readonly role: "user";
108
+ readonly content: string | readonly (MessagesToolResult | MessagesUserContentPart)[];
109
+ } | {
110
+ readonly role: "assistant";
111
+ readonly content: readonly MessagesAssistantPart[];
112
+ };
113
+ export type MessagesAssistantPart = {
114
+ readonly type: "text";
115
+ readonly text: string;
116
+ } | {
117
+ readonly type: "tool_use";
118
+ readonly id: string;
119
+ readonly name: string;
120
+ readonly input: JsonObject;
121
+ };
122
+ export interface MessagesToolResult {
123
+ readonly type: "tool_result";
124
+ readonly tool_use_id: string;
125
+ readonly content: string;
126
+ readonly is_error?: boolean;
127
+ }
128
+ export type MessagesUserContentPart = {
129
+ readonly type: "text";
130
+ readonly text: string;
131
+ } | {
132
+ readonly type: "image";
133
+ readonly source: Readonly<{
134
+ type: "url";
135
+ url: string;
136
+ }>;
137
+ };
138
+ export type AdapterSend<Request> = (request: Request, call: ModelCall, context: ModelAdapterContext) => Promise<unknown>;
139
+ export interface AnthropicAdapterOptions {
140
+ readonly defaultMaxOutputTokens: number;
141
+ readonly send: AdapterSend<MessagesRequest>;
142
+ }
143
+ /** Translate a Harness call to the OpenAI Chat Completions request shape. */
144
+ export declare function toChatCompletions(call: ModelCall): ChatCompletionsRequest;
145
+ /** Translate a Chat Completions response into a Harness candidate. */
146
+ export declare function fromChatCompletions(value: unknown, call?: Pick<ModelCall, "outputSchema">): ModelCandidate;
147
+ /** Return a Harness adapter backed by an application-owned Chat Completions send function. */
148
+ export declare function chatCompletionsAdapter(send: AdapterSend<ChatCompletionsRequest>): ModelAdapter;
149
+ /** Translate a Harness call to the OpenAI Responses request shape. */
150
+ export declare function toResponses(call: ModelCall): ResponsesRequest;
151
+ /** Translate an OpenAI Responses response into a Harness candidate. */
152
+ export declare function fromResponses(value: unknown, call?: Pick<ModelCall, "outputSchema">): ModelCandidate;
153
+ /** Return a Harness adapter backed by an application-owned Responses send function. */
154
+ export declare function responsesAdapter(send: AdapterSend<ResponsesRequest>): ModelAdapter;
155
+ /** Translate a Harness call to the Anthropic Messages request shape. */
156
+ export declare function toMessages(call: ModelCall, defaultMaxOutputTokens: number): MessagesRequest;
157
+ /** Translate an Anthropic Messages response into a Harness candidate. */
158
+ export declare function fromMessages(value: unknown): ModelCandidate;
159
+ /** Return a Harness adapter backed by an application-owned Anthropic Messages send function. */
160
+ export declare function anthropicAdapter(options: AnthropicAdapterOptions): ModelAdapter;