@north-light/sdk 0.3.693 → 0.3.695

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 (54) hide show
  1. package/README.md +5 -72
  2. package/dist/client.d.ts +12 -80
  3. package/dist/client.js +7 -255
  4. package/dist/index.d.ts +3 -7
  5. package/dist/index.js +1 -3
  6. package/dist/oauth/index.d.ts +3 -6
  7. package/dist/oauth/index.js +6 -11
  8. package/dist/resources/canvas.d.ts +2 -9
  9. package/dist/resources/canvas.js +1 -26
  10. package/dist/resources/files.d.ts +0 -10
  11. package/dist/resources/files.js +0 -14
  12. package/dist/resources/identifiers.d.ts +0 -5
  13. package/dist/resources/identifiers.js +3 -23
  14. package/dist/resources/models/credentials.d.ts +1 -3
  15. package/dist/resources/models/credentials.js +0 -6
  16. package/dist/resources/models.d.ts +0 -2
  17. package/dist/resources/models.js +0 -3
  18. package/dist/resources/run-stream.d.ts +3 -29
  19. package/dist/resources/run-stream.js +4 -44
  20. package/dist/resources/runs.d.ts +0 -3
  21. package/dist/resources/runs.js +0 -9
  22. package/dist/skill/northlight/SKILL.md +2 -2
  23. package/dist/types.d.ts +0 -50
  24. package/dist/version.d.ts +1 -1
  25. package/dist/version.js +1 -1
  26. package/package.json +5 -5
  27. package/dist/resources/activity.d.ts +0 -22
  28. package/dist/resources/activity.js +0 -43
  29. package/dist/resources/bash.d.ts +0 -9
  30. package/dist/resources/bash.js +0 -15
  31. package/dist/resources/canvas/history.d.ts +0 -11
  32. package/dist/resources/canvas/history.js +0 -20
  33. package/dist/resources/crons.d.ts +0 -15
  34. package/dist/resources/crons.js +0 -33
  35. package/dist/resources/human/inbox.d.ts +0 -14
  36. package/dist/resources/human/inbox.js +0 -30
  37. package/dist/resources/human/requests.d.ts +0 -13
  38. package/dist/resources/human/requests.js +0 -26
  39. package/dist/resources/human.d.ts +0 -8
  40. package/dist/resources/human.js +0 -10
  41. package/dist/resources/models/config.d.ts +0 -8
  42. package/dist/resources/models/config.js +0 -9
  43. package/dist/resources/node-stream.d.ts +0 -34
  44. package/dist/resources/node-stream.js +0 -176
  45. package/dist/resources/nodes/jobs.d.ts +0 -9
  46. package/dist/resources/nodes/jobs.js +0 -14
  47. package/dist/resources/nodes/result.d.ts +0 -8
  48. package/dist/resources/nodes/result.js +0 -11
  49. package/dist/resources/nodes/worktree.d.ts +0 -9
  50. package/dist/resources/nodes/worktree.js +0 -14
  51. package/dist/resources/nodes.d.ts +0 -23
  52. package/dist/resources/nodes.js +0 -47
  53. package/dist/resources/structured-requests.d.ts +0 -14
  54. package/dist/resources/structured-requests.js +0 -19
@@ -1,22 +0,0 @@
1
- import type { NodeStreamEvent } from './node-stream.js';
2
- /** One tool call rendered as an activity step. */
3
- export interface ActivityStep {
4
- /** The tool call's id, stable across its status changes. */
5
- id: string;
6
- /** Tool name, e.g. `bash` or `read`. */
7
- tool: string;
8
- /** The daemon's one-line summary of the call. */
9
- summary: string;
10
- /** What `describe` returned for this call, for display. */
11
- label: string;
12
- /** Where the call stands. */
13
- status: 'running' | 'done' | 'failed';
14
- }
15
- /** Turn a streamed tool call into a label, or return null to omit it. */
16
- export type DescribeTool = (tool: string, summary: string) => string | null;
17
- /** Plain labels for the tools every node can use. */
18
- export declare const describeToolDefault: DescribeTool;
19
- /** Yield an immutable activity snapshot after every streamed tool-call change. */
20
- export declare function followActivity(stream: AsyncIterable<NodeStreamEvent>, options?: {
21
- describe?: DescribeTool;
22
- }): AsyncGenerator<ActivityStep[]>;
@@ -1,43 +0,0 @@
1
- /** Plain labels for the tools every node can use. */
2
- export const describeToolDefault = (tool) => {
3
- switch (tool) {
4
- case 'bash': return 'running bash';
5
- case 'read': return 'reading';
6
- case 'write': return 'writing';
7
- case 'edit': return 'editing';
8
- default: return tool;
9
- }
10
- };
11
- /** Yield an immutable activity snapshot after every streamed tool-call change. */
12
- export async function* followActivity(stream, options = {}) {
13
- const describe = options.describe ?? describeToolDefault;
14
- const steps = [];
15
- const byId = new Map();
16
- for await (const event of stream) {
17
- if (event.type === 'node.tool_call.started') {
18
- const label = describe(event.tool, event.summary);
19
- if (label === null || byId.has(event.tool_call_id))
20
- continue;
21
- const step = {
22
- id: event.tool_call_id,
23
- tool: event.tool,
24
- summary: event.summary,
25
- label,
26
- status: 'running',
27
- };
28
- byId.set(step.id, step);
29
- steps.push(step);
30
- yield snapshot(steps);
31
- }
32
- else if (event.type === 'node.tool_call.completed') {
33
- const step = byId.get(event.tool_call_id);
34
- if (step === undefined || step.status !== 'running')
35
- continue;
36
- step.status = event.status === 'ok' ? 'done' : 'failed';
37
- yield snapshot(steps);
38
- }
39
- }
40
- }
41
- function snapshot(steps) {
42
- return steps.map((step) => ({ ...step }));
43
- }
@@ -1,9 +0,0 @@
1
- import { type BashRunDTO, type BashRunParams } from '@north-light/api';
2
- import type { RequestOptions } from '../types.js';
3
- import type { Request } from './request.js';
4
- export declare class Bash {
5
- private readonly request;
6
- private readonly defaultTimeout;
7
- constructor(request: Request, defaultTimeout: number);
8
- run(params: BashRunParams, options?: RequestOptions): Promise<BashRunDTO>;
9
- }
@@ -1,15 +0,0 @@
1
- import { routes } from '@north-light/api';
2
- const DEFAULT_TIMEOUT_SECONDS = 60;
3
- const TIMEOUT_ALLOWANCE_MS = 15_000;
4
- export class Bash {
5
- request;
6
- defaultTimeout;
7
- constructor(request, defaultTimeout) {
8
- this.request = request;
9
- this.defaultTimeout = defaultTimeout;
10
- }
11
- run(params, options) {
12
- const requiredTimeout = (params.timeout_s ?? DEFAULT_TIMEOUT_SECONDS) * 1000 + TIMEOUT_ALLOWANCE_MS;
13
- return this.request('POST', routes.bash(), params, { ...options, timeout: Math.max(options?.timeout ?? this.defaultTimeout, requiredTimeout) });
14
- }
15
- }
@@ -1,11 +0,0 @@
1
- import { type HistoryGrepQuery, type HistoryGrepResultDTO, type HistoryReadQuery, type HistoryReadResultDTO, type HistorySearchQuery, type HistorySearchResultDTO, type HistoryStatsQuery, type HistoryStatsResultDTO } from '@north-light/api';
2
- import type { RequestOptions } from '../../types.js';
3
- import type { Request } from '../request.js';
4
- export declare class CanvasHistory {
5
- private readonly request;
6
- constructor(request: Request);
7
- search(body: HistorySearchQuery, options?: RequestOptions): Promise<HistorySearchResultDTO>;
8
- grep(body: HistoryGrepQuery, options?: RequestOptions): Promise<HistoryGrepResultDTO>;
9
- read(query: HistoryReadQuery, options?: RequestOptions): Promise<HistoryReadResultDTO>;
10
- stats(body: HistoryStatsQuery, options?: RequestOptions): Promise<HistoryStatsResultDTO>;
11
- }
@@ -1,20 +0,0 @@
1
- import { routes, } from '@north-light/api';
2
- import { withQuery } from '../request.js';
3
- export class CanvasHistory {
4
- request;
5
- constructor(request) {
6
- this.request = request;
7
- }
8
- search(body, options) {
9
- return this.request('POST', routes.canvasHistorySearch(), body, options);
10
- }
11
- grep(body, options) {
12
- return this.request('POST', routes.canvasHistoryGrep(), body, options);
13
- }
14
- read(query, options) {
15
- return this.request('GET', withQuery(routes.canvasHistoryRead(), query), undefined, options);
16
- }
17
- stats(body, options) {
18
- return this.request('POST', routes.canvasHistoryStats(), body, options);
19
- }
20
- }
@@ -1,15 +0,0 @@
1
- import { type ArmCronRequest, type CancelCronQuery, type CronDTO, type CronRunDTO, type CronScopeQuery, type CronShowDTO, type ListCronsQuery, type PokeCronsResult } from '@north-light/api';
2
- import type { RequestOptions } from '../types.js';
3
- import type { Request } from './request.js';
4
- export declare class Crons {
5
- private readonly request;
6
- constructor(request: Request);
7
- create(body: ArmCronRequest, options?: RequestOptions): Promise<CronDTO>;
8
- retrieve(id: string, query?: CronScopeQuery, options?: RequestOptions): Promise<CronShowDTO>;
9
- list(query?: ListCronsQuery, options?: RequestOptions): Promise<CronDTO[]>;
10
- pause(id: string, query?: CronScopeQuery, options?: RequestOptions): Promise<CronDTO>;
11
- resume(id: string, query?: CronScopeQuery, options?: RequestOptions): Promise<CronDTO>;
12
- run(id: string, query?: CronScopeQuery, options?: RequestOptions): Promise<CronRunDTO>;
13
- delete(id: string, query?: CancelCronQuery, options?: RequestOptions): Promise<void>;
14
- poke(options?: RequestOptions): Promise<PokeCronsResult>;
15
- }
@@ -1,33 +0,0 @@
1
- import { routes, } from '@north-light/api';
2
- import { cronId } from './identifiers.js';
3
- import { withQuery } from './request.js';
4
- export class Crons {
5
- request;
6
- constructor(request) {
7
- this.request = request;
8
- }
9
- create(body, options) {
10
- return this.request('POST', routes.crons(), body, options);
11
- }
12
- async retrieve(id, query, options) {
13
- return this.request('GET', withQuery(routes.cron(cronId(id)), query), undefined, options);
14
- }
15
- list(query, options) {
16
- return this.request('GET', withQuery(routes.crons(), query), undefined, options);
17
- }
18
- async pause(id, query, options) {
19
- return this.request('POST', withQuery(routes.cronPause(cronId(id)), query), {}, options);
20
- }
21
- async resume(id, query, options) {
22
- return this.request('POST', withQuery(routes.cronResume(cronId(id)), query), {}, options);
23
- }
24
- async run(id, query, options) {
25
- return this.request('POST', withQuery(routes.cronRun(cronId(id)), query), {}, options);
26
- }
27
- async delete(id, query, options) {
28
- return this.request('DELETE', withQuery(routes.cron(cronId(id)), query), undefined, options);
29
- }
30
- poke(options) {
31
- return this.request('POST', routes.cronsPoke(), {}, options);
32
- }
33
- }
@@ -1,14 +0,0 @@
1
- import { type CancelInboxTicketRequest, type CanceledTicketResultDTO, type InboxListDTO, type InboxPageDTO, type InboxPageHistoryDTO, type InboxPageProgressDTO, type InboxPageResponseDTO, type PageTicketResultDTO, type RespondInboxPageRequest } from '@north-light/api';
2
- import type { RequestOptions } from '../../types.js';
3
- import type { Request } from '../request.js';
4
- export declare class HumanInbox {
5
- private readonly request;
6
- constructor(request: Request);
7
- list(options?: RequestOptions): Promise<InboxListDTO>;
8
- retrieve(ticketId: string, options?: RequestOptions): Promise<InboxPageDTO>;
9
- respond(ticketId: string, body: RespondInboxPageRequest, options?: RequestOptions): Promise<PageTicketResultDTO>;
10
- progress(ticketId: string, body: InboxPageProgressDTO, options?: RequestOptions): Promise<Record<string, unknown>>;
11
- cancel(ticketId: string, body?: CancelInboxTicketRequest, options?: RequestOptions): Promise<CanceledTicketResultDTO>;
12
- history(nodeId?: string, options?: RequestOptions): Promise<InboxPageHistoryDTO>;
13
- response(ticketId: string, options?: RequestOptions): Promise<InboxPageResponseDTO>;
14
- }
@@ -1,30 +0,0 @@
1
- import { routes, } from '@north-light/api';
2
- import { inboxTicketId } from '../identifiers.js';
3
- import { withQuery } from '../request.js';
4
- export class HumanInbox {
5
- request;
6
- constructor(request) {
7
- this.request = request;
8
- }
9
- list(options) {
10
- return this.request('GET', routes.humanInbox(), undefined, options);
11
- }
12
- async retrieve(ticketId, options) {
13
- return this.request('GET', routes.humanInboxTicket(inboxTicketId(ticketId)), undefined, options);
14
- }
15
- async respond(ticketId, body, options) {
16
- return this.request('POST', routes.humanInboxRespond(inboxTicketId(ticketId)), body, options);
17
- }
18
- async progress(ticketId, body, options) {
19
- return this.request('POST', routes.humanInboxProgress(inboxTicketId(ticketId)), body, options);
20
- }
21
- async cancel(ticketId, body, options) {
22
- return this.request('POST', routes.humanInboxCancel(inboxTicketId(ticketId)), body ?? {}, options);
23
- }
24
- history(nodeId, options) {
25
- return this.request('GET', withQuery('/v1/human/inbox/history', nodeId === undefined ? undefined : { node_id: nodeId }), undefined, options);
26
- }
27
- async response(ticketId, options) {
28
- return this.request('GET', routes.humanInboxResponse(inboxTicketId(ticketId)), undefined, options);
29
- }
30
- }
@@ -1,13 +0,0 @@
1
- import { type CreateHumanRequestDTO, type CreateHumanRequestRequest, type HumanRequestDTO, type ReplaceHumanRequestRequest, type RespondHumanRequestRequest, type SettleHumanRequestRequest } from '@north-light/api';
2
- import type { RequestOptions } from '../../types.js';
3
- import type { Request } from '../request.js';
4
- export declare class HumanRequests {
5
- private readonly request;
6
- constructor(request: Request);
7
- create(body: CreateHumanRequestRequest, options?: RequestOptions): Promise<CreateHumanRequestDTO>;
8
- retrieve(id: string, options?: RequestOptions): Promise<HumanRequestDTO>;
9
- replace(id: string, body: ReplaceHumanRequestRequest, options?: RequestOptions): Promise<HumanRequestDTO>;
10
- respond(id: string, body: RespondHumanRequestRequest, options?: RequestOptions): Promise<HumanRequestDTO>;
11
- dismiss(id: string, body?: SettleHumanRequestRequest, options?: RequestOptions): Promise<HumanRequestDTO>;
12
- cancel(id: string, body?: SettleHumanRequestRequest, options?: RequestOptions): Promise<HumanRequestDTO>;
13
- }
@@ -1,26 +0,0 @@
1
- import { routes, } from '@north-light/api';
2
- import { requestId } from '../identifiers.js';
3
- export class HumanRequests {
4
- request;
5
- constructor(request) {
6
- this.request = request;
7
- }
8
- create(body, options) {
9
- return this.request('POST', routes.humanRequests(), body, options);
10
- }
11
- async retrieve(id, options) {
12
- return this.request('GET', routes.humanRequest(requestId(id)), undefined, options);
13
- }
14
- async replace(id, body, options) {
15
- return this.request('POST', routes.humanRequestReplace(requestId(id)), body, options);
16
- }
17
- async respond(id, body, options) {
18
- return this.request('POST', routes.humanRequestRespond(requestId(id)), body, options);
19
- }
20
- async dismiss(id, body, options) {
21
- return this.request('POST', routes.humanRequestDismiss(requestId(id)), body ?? {}, options);
22
- }
23
- async cancel(id, body, options) {
24
- return this.request('POST', routes.humanRequestCancel(requestId(id)), body ?? {}, options);
25
- }
26
- }
@@ -1,8 +0,0 @@
1
- import { HumanInbox } from './human/inbox.js';
2
- import { HumanRequests } from './human/requests.js';
3
- import type { Request } from './request.js';
4
- export declare class Human {
5
- readonly requests: HumanRequests;
6
- readonly inbox: HumanInbox;
7
- constructor(request: Request);
8
- }
@@ -1,10 +0,0 @@
1
- import { HumanInbox } from './human/inbox.js';
2
- import { HumanRequests } from './human/requests.js';
3
- export class Human {
4
- requests;
5
- inbox;
6
- constructor(request) {
7
- this.requests = new HumanRequests(request);
8
- this.inbox = new HumanInbox(request);
9
- }
10
- }
@@ -1,8 +0,0 @@
1
- import { type PutModelConfigRequest, type PutModelConfigResponse } from '@north-light/api';
2
- import type { RequestOptions } from '../../types.js';
3
- import type { Request } from '../request.js';
4
- export declare class ModelConfig {
5
- private readonly request;
6
- constructor(request: Request);
7
- update(body: PutModelConfigRequest, options?: RequestOptions): Promise<PutModelConfigResponse>;
8
- }
@@ -1,9 +0,0 @@
1
- export class ModelConfig {
2
- request;
3
- constructor(request) {
4
- this.request = request;
5
- }
6
- update(body, options) {
7
- return this.request('PUT', '/v1/model-config', body, options);
8
- }
9
- }
@@ -1,34 +0,0 @@
1
- import { type NodeDetailDTO, type NodeEventDTO, type NodeOutcomeDTO } from '@north-light/api';
2
- /** One event from a node's stream. */
3
- export type NodeStreamEvent = NodeEventDTO;
4
- /** The `type` discriminant of a stream event, and the name `on` and `off` take. */
5
- export type NodeStreamEventType = NodeStreamEvent['type'];
6
- /** A listener for one event type, receiving only that type's event. */
7
- export type NodeStreamEventListener<T extends NodeStreamEventType> = (event: Extract<NodeStreamEvent, {
8
- type: T;
9
- }>) => void;
10
- /** A parsed node event stream. Aborting it disconnects this observer, not the node. */
11
- export declare class NodeStream implements AsyncIterable<NodeStreamEvent> {
12
- /** The node this stream follows; resolves once the daemon has created it. */
13
- readonly node: Promise<NodeDetailDTO>;
14
- private readonly controller;
15
- private readonly listeners;
16
- private readonly settled;
17
- private resolveOutcome;
18
- private rejectOutcome;
19
- private finished;
20
- constructor(node: Promise<NodeDetailDTO>, open: (signal: AbortSignal) => Promise<Response>, signal?: AbortSignal);
21
- /** Adds a listener for one event type. */
22
- on<T extends NodeStreamEventType>(type: T, listener: NodeStreamEventListener<T>): this;
23
- /** Removes a listener added with `on`. */
24
- off<T extends NodeStreamEventType>(type: T, listener: NodeStreamEventListener<T>): this;
25
- /** Disconnects this observer. The node keeps running. */
26
- abort(): void;
27
- /** The node's settled outcome. Rejects with `APIError` on a terminal stream error. */
28
- finalOutcome(): Promise<NodeOutcomeDTO>;
29
- [Symbol.asyncIterator](): AsyncIterator<NodeStreamEvent>;
30
- private consume;
31
- private handleRecord;
32
- private emit;
33
- private fail;
34
- }
@@ -1,176 +0,0 @@
1
- import { isErrorBody } from '@north-light/api';
2
- import { ResourceIdentifierError } from './identifiers.js';
3
- import { APIConnectionError, APIError, APIUserAbortError, mapError } from '../errors.js';
4
- /** A parsed node event stream. Aborting it disconnects this observer, not the node. */
5
- export class NodeStream {
6
- /** The node this stream follows; resolves once the daemon has created it. */
7
- node;
8
- controller = new AbortController();
9
- listeners = new Map();
10
- settled;
11
- resolveOutcome;
12
- rejectOutcome;
13
- finished = false;
14
- constructor(node, open, signal) {
15
- this.node = node;
16
- this.settled = new Promise((resolve, reject) => {
17
- this.resolveOutcome = resolve;
18
- this.rejectOutcome = reject;
19
- });
20
- void this.settled.catch(() => undefined);
21
- if (signal !== undefined) {
22
- if (signal.aborted)
23
- this.controller.abort(signal.reason);
24
- else
25
- signal.addEventListener('abort', () => this.controller.abort(signal.reason), { once: true });
26
- }
27
- void this.consume(open);
28
- }
29
- /** Adds a listener for one event type. */
30
- on(type, listener) {
31
- const listeners = this.listeners.get(type) ?? new Set();
32
- listeners.add(listener);
33
- this.listeners.set(type, listeners);
34
- return this;
35
- }
36
- /** Removes a listener added with `on`. */
37
- off(type, listener) {
38
- this.listeners.get(type)?.delete(listener);
39
- return this;
40
- }
41
- /** Disconnects this observer. The node keeps running. */
42
- abort() {
43
- this.controller.abort();
44
- }
45
- /** The node's settled outcome. Rejects with `APIError` on a terminal stream error. */
46
- finalOutcome() {
47
- return this.settled;
48
- }
49
- async *[Symbol.asyncIterator]() {
50
- const events = [];
51
- let wake;
52
- const listener = (event) => {
53
- events.push(event);
54
- wake?.();
55
- wake = undefined;
56
- };
57
- void this.settled.then(() => { wake?.(); wake = undefined; }, () => { wake?.(); wake = undefined; });
58
- for (const type of eventTypes)
59
- this.on(type, listener);
60
- try {
61
- for (;;) {
62
- const event = events.shift();
63
- if (event !== undefined) {
64
- yield event;
65
- continue;
66
- }
67
- if (this.finished) {
68
- await this.settled;
69
- return;
70
- }
71
- await new Promise((resolve) => { wake = resolve; });
72
- }
73
- }
74
- finally {
75
- for (const type of eventTypes)
76
- this.off(type, listener);
77
- }
78
- }
79
- async consume(open) {
80
- try {
81
- const response = await open(this.controller.signal);
82
- if (!response.ok)
83
- throw await responseError(response);
84
- if (response.body === null)
85
- throw new APIConnectionError(0, 'stream_ended', 'node event stream had no response body');
86
- const reader = response.body.getReader();
87
- const decoder = new TextDecoder();
88
- let buffer = '';
89
- for (;;) {
90
- const { done, value } = await reader.read();
91
- buffer += decoder.decode(value, { stream: !done });
92
- const records = buffer.split(/\r\n\r\n|\n\n|\r\r/);
93
- buffer = records.pop() ?? '';
94
- for (const record of records)
95
- this.handleRecord(record);
96
- if (done) {
97
- if (buffer !== '')
98
- this.handleRecord(buffer);
99
- break;
100
- }
101
- }
102
- if (!this.finished)
103
- this.fail(new APIConnectionError(0, 'stream_ended', 'node event stream ended before node.settled'));
104
- }
105
- catch (error) {
106
- this.fail(this.controller.signal.aborted
107
- ? new APIUserAbortError(0, 'request_aborted', 'request aborted by caller signal')
108
- : error instanceof ResourceIdentifierError
109
- ? error
110
- : error instanceof APIError ? mapError(error) : error);
111
- }
112
- }
113
- handleRecord(record) {
114
- let type;
115
- const data = [];
116
- for (const line of record.split(/\r\n|\r|\n/)) {
117
- if (line.startsWith(':'))
118
- continue;
119
- const separator = line.indexOf(':');
120
- const field = separator === -1 ? line : line.slice(0, separator);
121
- const value = separator === -1 ? '' : line.slice(separator + 1).replace(/^ /, '');
122
- if (field === 'event')
123
- type = value;
124
- if (field === 'data')
125
- data.push(value);
126
- }
127
- if (type === undefined || data.length === 0)
128
- return;
129
- const parsed = JSON.parse(data.join('\n'));
130
- const event = { ...parsed, type };
131
- this.emit(event);
132
- if (event.type === 'node.settled') {
133
- this.finished = true;
134
- this.resolveOutcome(event.outcome);
135
- }
136
- else if (event.type === 'error' && event.error.code !== 'stream_gap') {
137
- this.fail(new APIError(0, event.error.code, event.error.message, event.error.details));
138
- }
139
- }
140
- emit(event) {
141
- for (const listener of this.listeners.get(event.type) ?? [])
142
- listener(event);
143
- }
144
- fail(error) {
145
- if (this.finished)
146
- return;
147
- this.finished = true;
148
- this.rejectOutcome(error);
149
- }
150
- }
151
- async function responseError(response) {
152
- const text = (await response.text()).trim();
153
- let body;
154
- try {
155
- body = text === '' ? undefined : JSON.parse(text);
156
- }
157
- catch {
158
- return new APIError(response.status, 'invalid_response', text.slice(0, 500), undefined, response.headers);
159
- }
160
- if (isErrorBody(body)) {
161
- return new APIError(response.status, body.error.code, body.error.message, body.error.details, response.headers);
162
- }
163
- return new APIError(response.status, 'internal', `request failed with status ${response.status}`, undefined, response.headers);
164
- }
165
- const eventTypes = [
166
- 'node.output_text.delta',
167
- 'node.output_text.done',
168
- 'node.tool_call.started',
169
- 'node.tool_call.completed',
170
- 'node.turn.started',
171
- 'node.turn.completed',
172
- 'node.report.pushed',
173
- 'node.status.changed',
174
- 'node.settled',
175
- 'error',
176
- ];
@@ -1,9 +0,0 @@
1
- import { type BashJobStatusDTO, type BashJobStopResultDTO } from '@north-light/api';
2
- import type { RequestOptions } from '../../types.js';
3
- import type { Request } from '../request.js';
4
- export declare class NodeJobs {
5
- private readonly request;
6
- constructor(request: Request);
7
- list(id: string, options?: RequestOptions): Promise<BashJobStatusDTO[]>;
8
- cancel(id: string, jobId: string, options?: RequestOptions): Promise<BashJobStopResultDTO>;
9
- }
@@ -1,14 +0,0 @@
1
- import { routes } from '@north-light/api';
2
- import { jobId as validatedJobId, nodeId } from '../identifiers.js';
3
- export class NodeJobs {
4
- request;
5
- constructor(request) {
6
- this.request = request;
7
- }
8
- async list(id, options) {
9
- return this.request('GET', routes.nodeJobs(nodeId(id)), undefined, options);
10
- }
11
- async cancel(id, jobId, options) {
12
- return this.request('DELETE', routes.nodeJob(nodeId(id), validatedJobId(jobId)), undefined, options);
13
- }
14
- }
@@ -1,8 +0,0 @@
1
- import { type SubmitResultDTO, type SubmitResultRequest } from '@north-light/api';
2
- import type { RequestOptions } from '../../types.js';
3
- import type { Request } from '../request.js';
4
- export declare class NodeResult {
5
- private readonly request;
6
- constructor(request: Request);
7
- submit(id: string, body: SubmitResultRequest, options?: RequestOptions): Promise<SubmitResultDTO>;
8
- }
@@ -1,11 +0,0 @@
1
- import { routes } from '@north-light/api';
2
- import { nodeId } from '../identifiers.js';
3
- export class NodeResult {
4
- request;
5
- constructor(request) {
6
- this.request = request;
7
- }
8
- async submit(id, body, options) {
9
- return this.request('POST', routes.nodeResult(nodeId(id)), body, options);
10
- }
11
- }
@@ -1,9 +0,0 @@
1
- import { type AbandonWorktreeRequest, type AbandonWorktreeResultDTO, type CloseWorktreeResultDTO } from '@north-light/api';
2
- import type { RequestOptions } from '../../types.js';
3
- import type { Request } from '../request.js';
4
- export declare class NodeWorktree {
5
- private readonly request;
6
- constructor(request: Request);
7
- close(id: string, options?: RequestOptions): Promise<CloseWorktreeResultDTO>;
8
- abandon(id: string, body: AbandonWorktreeRequest, options?: RequestOptions): Promise<AbandonWorktreeResultDTO>;
9
- }
@@ -1,14 +0,0 @@
1
- import { routes, } from '@north-light/api';
2
- import { nodeId } from '../identifiers.js';
3
- export class NodeWorktree {
4
- request;
5
- constructor(request) {
6
- this.request = request;
7
- }
8
- async close(id, options) {
9
- return this.request('POST', routes.nodeWorktreeClose(nodeId(id)), {}, options);
10
- }
11
- async abandon(id, body, options) {
12
- return this.request('POST', routes.nodeWorktreeAbandon(nodeId(id)), body, options);
13
- }
14
- }
@@ -1,23 +0,0 @@
1
- import { type NodeConfigPatch, type NodeDetailDTO, type RelaunchRootResultDTO, type ReviveAllResultDTO, type ReviveRequest, type ReviveResultDTO, type PromoteRequest, type WaitRequest, type YieldRequest } from '@north-light/api';
2
- import type { RequestOptions } from '../types.js';
3
- import { NodeJobs } from './nodes/jobs.js';
4
- import { NodeResult } from './nodes/result.js';
5
- import { NodeWorktree } from './nodes/worktree.js';
6
- import type { Request } from './request.js';
7
- export declare class NodesResource {
8
- private readonly request;
9
- readonly jobs: NodeJobs;
10
- readonly worktree: NodeWorktree;
11
- readonly result: NodeResult;
12
- constructor(request: Request);
13
- update(id: string, patch: NodeConfigPatch, options?: RequestOptions): Promise<NodeDetailDTO>;
14
- fork(id: string, options?: RequestOptions): Promise<NodeDetailDTO>;
15
- revive(id: string, body?: ReviveRequest, options?: RequestOptions): Promise<ReviveResultDTO>;
16
- reviveAll(options?: RequestOptions): Promise<ReviveAllResultDTO>;
17
- promote(id: string, body?: PromoteRequest, options?: RequestOptions): Promise<NodeDetailDTO>;
18
- demote(id: string, options?: RequestOptions): Promise<NodeDetailDTO>;
19
- recycle(id: string, options?: RequestOptions): Promise<NodeDetailDTO>;
20
- yield(id: string, body?: YieldRequest, options?: RequestOptions): Promise<NodeDetailDTO>;
21
- wait(id: string, body: WaitRequest, options?: RequestOptions): Promise<NodeDetailDTO>;
22
- relaunchRoot(id: string, options?: RequestOptions): Promise<RelaunchRootResultDTO>;
23
- }