@north-light/sdk 0.3.852 → 0.3.854
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/dist/client.d.ts +3 -0
- package/dist/client.js +4 -0
- package/dist/index.d.ts +2 -1
- package/dist/resources/providers.d.ts +7 -0
- package/dist/resources/providers.js +4 -0
- package/dist/resources/questions.d.ts +38 -3
- package/dist/resources/questions.js +20 -3
- package/dist/resources/reviews.d.ts +37 -0
- package/dist/resources/reviews.js +38 -0
- package/dist/resources/runs.d.ts +6 -0
- package/dist/skill/northlight/SKILL.md +2 -2
- package/dist/testing/cloud.d.ts +1 -1
- package/dist/testing/cloud.js +28 -2
- package/dist/testing/run.d.ts +5 -1
- package/dist/testing/run.js +17 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
package/dist/client.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { Attachments } from './resources/attachments.js';
|
|
|
12
12
|
import { Files } from './resources/files.js';
|
|
13
13
|
import { Models } from './resources/models.js';
|
|
14
14
|
import { Questions } from './resources/questions.js';
|
|
15
|
+
import { Reviews } from './resources/reviews.js';
|
|
15
16
|
import { Providers } from './resources/providers.js';
|
|
16
17
|
import { Runs } from './resources/runs.js';
|
|
17
18
|
import { Shares } from './resources/shares.js';
|
|
@@ -88,6 +89,8 @@ export declare class Crouter {
|
|
|
88
89
|
readonly shares: Shares;
|
|
89
90
|
/** Questions agents in runs ask the user (app listener only). */
|
|
90
91
|
readonly questions: Questions;
|
|
92
|
+
/** Reviews of documents agents in runs asked the person to review (app listener only). */
|
|
93
|
+
readonly reviews: Reviews;
|
|
91
94
|
/** Read the documents the person owns (`store: 'user'`): an app sees their `public` documents, `private` ones too while the grant holds
|
|
92
95
|
* `crtr:memory:read_private:user` (read-only), and `crtr:memory:manage:user` covers both. */
|
|
93
96
|
readonly memory: Memory;
|
package/dist/client.js
CHANGED
|
@@ -13,6 +13,7 @@ import { Attachments } from './resources/attachments.js';
|
|
|
13
13
|
import { Files } from './resources/files.js';
|
|
14
14
|
import { Models } from './resources/models.js';
|
|
15
15
|
import { Questions } from './resources/questions.js';
|
|
16
|
+
import { Reviews } from './resources/reviews.js';
|
|
16
17
|
import { Providers } from './resources/providers.js';
|
|
17
18
|
import { CAUSED_BY_HEADER, Runs } from './resources/runs.js';
|
|
18
19
|
import { Shares } from './resources/shares.js';
|
|
@@ -48,6 +49,8 @@ export class Crouter {
|
|
|
48
49
|
shares;
|
|
49
50
|
/** Questions agents in runs ask the user (app listener only). */
|
|
50
51
|
questions;
|
|
52
|
+
/** Reviews of documents agents in runs asked the person to review (app listener only). */
|
|
53
|
+
reviews;
|
|
51
54
|
/** Read the documents the person owns (`store: 'user'`): an app sees their `public` documents, `private` ones too while the grant holds
|
|
52
55
|
* `crtr:memory:read_private:user` (read-only), and `crtr:memory:manage:user` covers both. */
|
|
53
56
|
memory;
|
|
@@ -169,6 +172,7 @@ export class Crouter {
|
|
|
169
172
|
this.attachments = new Attachments(request);
|
|
170
173
|
this.shares = new Shares(request);
|
|
171
174
|
this.questions = new Questions(request);
|
|
175
|
+
this.reviews = new Reviews(request);
|
|
172
176
|
this.memory = new Memory(request);
|
|
173
177
|
this.docs = new Docs(request);
|
|
174
178
|
this.crons = new Crons(request);
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,8 @@ export type { Charges, ChargeListParams } from './resources/charges.js';
|
|
|
18
18
|
export type { Environments } from './resources/environments.js';
|
|
19
19
|
export type { SpendLimits } from './resources/spend-limits.js';
|
|
20
20
|
export type { MemoryDocument, MemoryGetParams, MemoryListItem, MemoryListPage, MemoryListParams } from './resources/memory.js';
|
|
21
|
-
export type { Question, QuestionAnswered, QuestionCanceled, QuestionFields, QuestionKind, QuestionResponses, QuestionSlot, QuestionStatus } from './resources/questions.js';
|
|
21
|
+
export type { Question, QuestionAnswered, QuestionCanceled, QuestionFields, QuestionHistory, QuestionHistoryItem, QuestionKind, QuestionResponses, QuestionSettledBy, QuestionSlot, QuestionStatus } from './resources/questions.js';
|
|
22
|
+
export type { ReviewListQuery, SubmitReviewRequest } from './resources/reviews.js';
|
|
22
23
|
export type { ProviderToolEntry } from './resources/providers.js';
|
|
23
24
|
export { OAuth2Client, ConnectedCrouter, MemoryConnectionStore, profileFromClaims } from './oauth/index.js';
|
|
24
25
|
export { authorizationRefusalOf, refusalOf } from './oauth/index.js';
|
|
@@ -67,4 +67,11 @@ export declare class Providers {
|
|
|
67
67
|
name: string;
|
|
68
68
|
chosen_by: 'named' | 'account' | 'only_device' | 'newest';
|
|
69
69
|
}>;
|
|
70
|
+
/** For a provider's own app, while serving a request: which of its own broker runs is sending that live request. `jti` is the `jti` of the bearer token the request carries. A request that is not live, or not from a run of this app, is `not_found`. */
|
|
71
|
+
caller(provider: string, requestId: string, jti: string, options?: RequestOptions): Promise<{
|
|
72
|
+
run_id: string;
|
|
73
|
+
node_id: string;
|
|
74
|
+
sub: string;
|
|
75
|
+
tool: string;
|
|
76
|
+
}>;
|
|
70
77
|
}
|
|
@@ -24,4 +24,8 @@ export class Providers {
|
|
|
24
24
|
machine(input, options) {
|
|
25
25
|
return this.request('POST', '/v1/provider/machine', input, options);
|
|
26
26
|
}
|
|
27
|
+
/** For a provider's own app, while serving a request: which of its own broker runs is sending that live request. `jti` is the `jti` of the bearer token the request carries. A request that is not live, or not from a run of this app, is `not_found`. */
|
|
28
|
+
caller(provider, requestId, jti, options) {
|
|
29
|
+
return this.request('GET', `/v1/providers/${pathSegment(provider, 'provider')}/calls/${pathSegment(requestId, 'request_id')}?jti=${encodeURIComponent(jti)}`, undefined, options);
|
|
30
|
+
}
|
|
27
31
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { DiscussDTO, PostDiscussMessageDTO } from '@north-light/api';
|
|
1
2
|
import type { RequestOptions } from '../types.js';
|
|
2
|
-
import type
|
|
3
|
+
import { type Request } from './request.js';
|
|
3
4
|
/** One input or display element of a question. `id` is absent on a slot that takes no response. */
|
|
4
5
|
export interface QuestionSlot {
|
|
5
6
|
id?: string;
|
|
@@ -43,6 +44,29 @@ export interface QuestionAnswered {
|
|
|
43
44
|
status: 'answered';
|
|
44
45
|
answer: QuestionResponses;
|
|
45
46
|
}
|
|
47
|
+
/** Who settled a question: the person, the asking agent withdrawing it, or a companion acting on the person's word. */
|
|
48
|
+
export type QuestionSettledBy = 'person' | 'asker' | 'companion';
|
|
49
|
+
/** One settled question or notice in `questions.history`. */
|
|
50
|
+
export interface QuestionHistoryItem {
|
|
51
|
+
question_id: string;
|
|
52
|
+
run_id: string;
|
|
53
|
+
title: string;
|
|
54
|
+
kind: QuestionKind;
|
|
55
|
+
/** ISO time it was settled. */
|
|
56
|
+
settled_at: string;
|
|
57
|
+
state: 'answered' | 'canceled';
|
|
58
|
+
settled_by: QuestionSettledBy;
|
|
59
|
+
/** Labels of the options chosen, when answered. */
|
|
60
|
+
selected_labels?: string[];
|
|
61
|
+
/** The written answer, when answered in writing. */
|
|
62
|
+
written_answer?: string;
|
|
63
|
+
/** The reason given, when canceled with one. */
|
|
64
|
+
cancel_reason?: string;
|
|
65
|
+
}
|
|
66
|
+
/** `questions.history`'s result, newest settlement first. */
|
|
67
|
+
export interface QuestionHistory {
|
|
68
|
+
questions: QuestionHistoryItem[];
|
|
69
|
+
}
|
|
46
70
|
/** Questions from agents in runs (app listener only). */
|
|
47
71
|
export declare class Questions {
|
|
48
72
|
private readonly request;
|
|
@@ -54,7 +78,18 @@ export declare class Questions {
|
|
|
54
78
|
* canceled — including the loser of a race — is 409 `run_settled` with `details.state` and `details.result`. */
|
|
55
79
|
answer(questionId: string, responses: QuestionResponses, options?: RequestOptions): Promise<QuestionAnswered>;
|
|
56
80
|
/** Cancel an open question of the caller's own run (or the caller's own runless provider approval): the person
|
|
57
|
-
* dismissed it, and the asking agent is told so. A question already answered or canceled is 409 `run_settled`
|
|
81
|
+
* dismissed it, and the asking agent is told so. With `reason` the cancellation carries it to the asking agent as the person's words instead. A question already answered or canceled is 409 `run_settled`
|
|
58
82
|
* with `details.state` and `details.result`; another app's run is `other_app_run`. A notice is canceled the same way. */
|
|
59
|
-
cancel(questionId: string, options?: RequestOptions
|
|
83
|
+
cancel(questionId: string, { reason, ...options }?: RequestOptions & {
|
|
84
|
+
reason?: string;
|
|
85
|
+
}): Promise<QuestionCanceled>;
|
|
86
|
+
/** The caller's run-bound questions and notices settled at or after `settled_since` (an ISO timestamp), newest first,
|
|
87
|
+
* including ones settled while the app was not looking. */
|
|
88
|
+
history(query: {
|
|
89
|
+
settled_since: string;
|
|
90
|
+
}, options?: RequestOptions): Promise<QuestionHistory>;
|
|
91
|
+
/** The person's Discuss conversation about an open question with a copy of the asking agent, from its first message on. Empty before one is posted. The ticket id is the question id. */
|
|
92
|
+
discuss(questionId: string, options?: RequestOptions): Promise<DiscussDTO>;
|
|
93
|
+
/** Post a Discuss message. The first one forks the asking agent at that moment. The message never reaches the question's result. */
|
|
94
|
+
postDiscuss(questionId: string, text: string, options?: RequestOptions): Promise<PostDiscussMessageDTO>;
|
|
60
95
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { pathSegment } from './identifiers.js';
|
|
2
|
+
import { withQuery } from './request.js';
|
|
2
3
|
/** Questions from agents in runs (app listener only). */
|
|
3
4
|
export class Questions {
|
|
4
5
|
request;
|
|
@@ -16,11 +17,27 @@ export class Questions {
|
|
|
16
17
|
return this.request('POST', `${questionPath(questionId)}/answer`, { responses }, { ...options, maxRetries: 0 });
|
|
17
18
|
}
|
|
18
19
|
/** Cancel an open question of the caller's own run (or the caller's own runless provider approval): the person
|
|
19
|
-
* dismissed it, and the asking agent is told so. A question already answered or canceled is 409 `run_settled`
|
|
20
|
+
* dismissed it, and the asking agent is told so. With `reason` the cancellation carries it to the asking agent as the person's words instead. A question already answered or canceled is 409 `run_settled`
|
|
20
21
|
* with `details.state` and `details.result`; another app's run is `other_app_run`. A notice is canceled the same way. */
|
|
21
|
-
cancel(questionId, options = {}) {
|
|
22
|
-
return this.request('POST', `${questionPath(questionId)}/cancel`, undefined, { ...options, maxRetries: 0 });
|
|
22
|
+
cancel(questionId, { reason, ...options } = {}) {
|
|
23
|
+
return this.request('POST', `${questionPath(questionId)}/cancel`, reason === undefined ? undefined : { reason }, { ...options, maxRetries: 0 });
|
|
23
24
|
}
|
|
25
|
+
/** The caller's run-bound questions and notices settled at or after `settled_since` (an ISO timestamp), newest first,
|
|
26
|
+
* including ones settled while the app was not looking. */
|
|
27
|
+
history(query, options) {
|
|
28
|
+
return this.request('GET', withQuery('/v1/questions', query), undefined, options);
|
|
29
|
+
}
|
|
30
|
+
/** The person's Discuss conversation about an open question with a copy of the asking agent, from its first message on. Empty before one is posted. The ticket id is the question id. */
|
|
31
|
+
discuss(questionId, options) {
|
|
32
|
+
return this.request('GET', discussPath(questionId), undefined, options);
|
|
33
|
+
}
|
|
34
|
+
/** Post a Discuss message. The first one forks the asking agent at that moment. The message never reaches the question's result. */
|
|
35
|
+
postDiscuss(questionId, text, options = {}) {
|
|
36
|
+
return this.request('POST', discussPath(questionId), { text }, { ...options, maxRetries: 0 });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function discussPath(id) {
|
|
40
|
+
return `/v1/human/inbox/tickets/${encodeURIComponent(pathSegment(id, 'question id'))}/discuss`;
|
|
24
41
|
}
|
|
25
42
|
function questionPath(id) {
|
|
26
43
|
return `/v1/questions/${encodeURIComponent(pathSegment(id, 'question id'))}`;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { DiscussDTO, PostDiscussMessageDTO, ReviewCancelResultDTO, ReviewDTO, ReviewDocumentBaseDTO, ReviewListDTO, ReviewStateDTO, ReviewSubmitResultDTO } from '@north-light/api';
|
|
2
|
+
import type { RequestOptions } from '../types.js';
|
|
3
|
+
import { type Request } from './request.js';
|
|
4
|
+
export type { ReviewCancelResultDTO, ReviewDTO, ReviewDocumentBaseDTO, ReviewListDTO, ReviewStateDTO, ReviewSubmitResultDTO };
|
|
5
|
+
/** Filters for `reviews.list`. `run_id` keeps the reviews whose asking node belongs to that run. */
|
|
6
|
+
export interface ReviewListQuery {
|
|
7
|
+
state?: ReviewStateDTO;
|
|
8
|
+
run_id?: string;
|
|
9
|
+
origin_node_id?: string;
|
|
10
|
+
file?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Body of `reviews.submit`. */
|
|
13
|
+
export interface SubmitReviewRequest {
|
|
14
|
+
/** A note with the approval, at most 8,000 characters; the asking agent receives it. */
|
|
15
|
+
note?: string;
|
|
16
|
+
/** SHA-256 hex of the document text the person approved. A different current text refuses with 409 `document_changed` and leaves the review open. */
|
|
17
|
+
seen_sha256?: string;
|
|
18
|
+
}
|
|
19
|
+
/** Reviews of documents that agents in the caller's runs asked the person to review (app listener only).
|
|
20
|
+
* A review whose run the caller may not read is `not_found`; one of another app's run is `other_app_run` when acting. */
|
|
21
|
+
export declare class Reviews {
|
|
22
|
+
private readonly request;
|
|
23
|
+
constructor(request: Request);
|
|
24
|
+
list(query?: ReviewListQuery, options?: RequestOptions): Promise<ReviewListDTO>;
|
|
25
|
+
get(reviewId: string, options?: RequestOptions): Promise<ReviewDTO>;
|
|
26
|
+
/** The text the review's comments are anchored to. */
|
|
27
|
+
document(reviewId: string, options?: RequestOptions): Promise<ReviewDocumentBaseDTO>;
|
|
28
|
+
/** Approve. `note` goes to the asking agent with the approval; `seen_sha256` refuses with 409 `document_changed` when the text differs. */
|
|
29
|
+
submit(reviewId: string, { note, seen_sha256, ...options }?: RequestOptions & SubmitReviewRequest): Promise<ReviewSubmitResultDTO>;
|
|
30
|
+
cancel(reviewId: string, body?: {
|
|
31
|
+
reason?: string;
|
|
32
|
+
}, options?: RequestOptions): Promise<ReviewCancelResultDTO>;
|
|
33
|
+
/** The Discuss conversation with the review's companion, from its boundary marker on. */
|
|
34
|
+
discuss(reviewId: string, options?: RequestOptions): Promise<DiscussDTO>;
|
|
35
|
+
/** Post a Discuss message to the review's companion. It is not a review comment. */
|
|
36
|
+
postDiscuss(reviewId: string, text: string, options?: RequestOptions): Promise<PostDiscussMessageDTO>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { pathSegment } from './identifiers.js';
|
|
2
|
+
import { withQuery } from './request.js';
|
|
3
|
+
/** Reviews of documents that agents in the caller's runs asked the person to review (app listener only).
|
|
4
|
+
* A review whose run the caller may not read is `not_found`; one of another app's run is `other_app_run` when acting. */
|
|
5
|
+
export class Reviews {
|
|
6
|
+
request;
|
|
7
|
+
constructor(request) {
|
|
8
|
+
this.request = request;
|
|
9
|
+
}
|
|
10
|
+
list(query, options) {
|
|
11
|
+
return this.request('GET', withQuery('/v1/human/reviews', query), undefined, options);
|
|
12
|
+
}
|
|
13
|
+
get(reviewId, options) {
|
|
14
|
+
return this.request('GET', reviewPath(reviewId), undefined, options);
|
|
15
|
+
}
|
|
16
|
+
/** The text the review's comments are anchored to. */
|
|
17
|
+
document(reviewId, options) {
|
|
18
|
+
return this.request('GET', `${reviewPath(reviewId)}/document`, undefined, options);
|
|
19
|
+
}
|
|
20
|
+
/** Approve. `note` goes to the asking agent with the approval; `seen_sha256` refuses with 409 `document_changed` when the text differs. */
|
|
21
|
+
submit(reviewId, { note, seen_sha256, ...options } = {}) {
|
|
22
|
+
return this.request('POST', `${reviewPath(reviewId)}/submit`, { ...(note === undefined ? {} : { note }), ...(seen_sha256 === undefined ? {} : { seen_sha256 }) }, { ...options, maxRetries: 0 });
|
|
23
|
+
}
|
|
24
|
+
cancel(reviewId, body = {}, options = {}) {
|
|
25
|
+
return this.request('POST', `${reviewPath(reviewId)}/cancel`, body, { ...options, maxRetries: 0 });
|
|
26
|
+
}
|
|
27
|
+
/** The Discuss conversation with the review's companion, from its boundary marker on. */
|
|
28
|
+
discuss(reviewId, options) {
|
|
29
|
+
return this.request('GET', `${reviewPath(reviewId)}/discuss`, undefined, options);
|
|
30
|
+
}
|
|
31
|
+
/** Post a Discuss message to the review's companion. It is not a review comment. */
|
|
32
|
+
postDiscuss(reviewId, text, options = {}) {
|
|
33
|
+
return this.request('POST', `${reviewPath(reviewId)}/discuss`, { text }, { ...options, maxRetries: 0 });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function reviewPath(id) {
|
|
37
|
+
return `/v1/human/reviews/${encodeURIComponent(pathSegment(id, 'review id'))}`;
|
|
38
|
+
}
|
package/dist/resources/runs.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export interface RunStartParams {
|
|
|
11
11
|
metadata?: Record<string, unknown>;
|
|
12
12
|
/** Launch every node without network or the app's files mount. Descendants cannot disable it. */
|
|
13
13
|
isolated?: boolean;
|
|
14
|
+
/** Fix the run to the person whose verified call starts it: no other principal is acted for, and no node is born from or of the run. Needs an explicit `scopes` list without `crtr:schedule`. Refusals are `subject_fixed`. */
|
|
15
|
+
fixed_subject?: boolean;
|
|
14
16
|
/** Profile id (`profile_id` from `profiles.list()`) the run's agent uses; absent uses the app's default profile. */
|
|
15
17
|
profile?: string;
|
|
16
18
|
/** The model the run's root agent runs on: a bare strength (`medium`, resolved against the default provider), `family/strength` (`anthropic/medium`), or a concrete registered model id. Absent uses the run kind's default. Applies to the root only; its child nodes choose their own. An unknown or unregistered value is refused (`invalid_request`, `param: model`). */
|
|
@@ -45,6 +47,8 @@ export interface RunStartResult {
|
|
|
45
47
|
created_at: string;
|
|
46
48
|
metadata: Record<string, unknown>;
|
|
47
49
|
sequence_number: number;
|
|
50
|
+
/** Whether the run was started with `fixed_subject`. */
|
|
51
|
+
fixed_subject: boolean;
|
|
48
52
|
/** Present when `RunStartParams.message` was sent: pass it to `runs.reply(run.run_id, run.message)`. */
|
|
49
53
|
message?: SentRunMessage;
|
|
50
54
|
}
|
|
@@ -80,6 +84,8 @@ export interface RunObject {
|
|
|
80
84
|
scopes: string[] | null;
|
|
81
85
|
metadata: Record<string, unknown>;
|
|
82
86
|
created_at: string;
|
|
87
|
+
/** Whether the run was started with `fixed_subject`. */
|
|
88
|
+
fixed_subject: boolean;
|
|
83
89
|
settled_at?: string;
|
|
84
90
|
latest_sequence: number;
|
|
85
91
|
last_activity_at: string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: northlight
|
|
3
3
|
description: "Use when building, debugging or shipping an app that signs people in with Northlight, starts runs on their Northlight runtime, or calls Northlight providers (sms, search, integrations, context, device) with @north-light/sdk."
|
|
4
4
|
metadata:
|
|
5
|
-
sdk-version: "0.3.
|
|
5
|
+
sdk-version: "0.3.854"
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Building a Northlight app
|
|
@@ -27,7 +27,7 @@ Never text a person first: Comms refuses a send to anyone who has not texted you
|
|
|
27
27
|
|
|
28
28
|
## First: check this skill matches the SDK
|
|
29
29
|
|
|
30
|
-
This skill is for SDK version `0.3.
|
|
30
|
+
This skill is for SDK version `0.3.854`. If the project has `node_modules/@north-light/sdk/package.json`, compare its `version` with that number. If they differ, run `npx @north-light/sdk skill` in the project, then read the rewritten `.agents/skills/northlight/SKILL.md` (or `.claude/skills/northlight/SKILL.md`) instead of this copy. It needs no account. A project that has no SDK yet starts with `npx @north-light/sdk@latest init <dir>`.
|
|
31
31
|
|
|
32
32
|
## Where things run
|
|
33
33
|
|
package/dist/testing/cloud.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { type SpaceOp } from './space.js';
|
|
|
7
7
|
import { type FakeRefusalCode, type FakeScope, type FakeUser, type Responder } from './users.js';
|
|
8
8
|
import { type FakeError } from './wire.js';
|
|
9
9
|
/** A runtime operation, named as the daemon's `OPERATIONS` table names it. */
|
|
10
|
-
export type FakeOp = 'grant.get' | 'run.start' | 'run.list' | 'run.get' | 'run.message' | 'run.events' | 'run.interrupt' | 'run.cancel' | 'run.delete' | 'run.rename' | 'question.get' | 'question.answer' | 'question.cancel' | 'trace.get' | 'memory.list' | 'memory.get' | 'provider.tools' | 'provider.call' | 'provider.machine' | 'profile.list' | 'exec' | SpaceOp;
|
|
10
|
+
export type FakeOp = 'grant.get' | 'run.start' | 'run.list' | 'run.get' | 'run.message' | 'run.events' | 'run.interrupt' | 'run.cancel' | 'run.delete' | 'run.rename' | 'question.get' | 'question.answer' | 'question.cancel' | 'question.history' | 'review.list' | 'review.get' | 'review.submit' | 'review.cancel' | 'discuss.ticket.get' | 'discuss.ticket.post' | 'discuss.review.get' | 'discuss.review.post' | 'trace.get' | 'memory.list' | 'memory.get' | 'provider.tools' | 'provider.call' | 'provider.machine' | 'profile.list' | 'exec' | SpaceOp;
|
|
11
11
|
/** A directory operation. */
|
|
12
12
|
export type FakeDirectoryOp = 'directory.discovery' | 'directory.token' | 'directory.jwks';
|
|
13
13
|
/** What `intercept` / `failNext` / `gate` match: a runtime operation, `'*'` (every runtime operation), or a directory operation. */
|
package/dist/testing/cloud.js
CHANGED
|
@@ -27,9 +27,18 @@ const ROUTES = [
|
|
|
27
27
|
['POST', /^\/v1\/runs\/([^/]+)\/cancel$/, 'run.cancel'],
|
|
28
28
|
['POST', /^\/v1\/runs\/([^/]+)\/rename$/, 'run.rename'],
|
|
29
29
|
['GET', /^\/v1\/runs\/([^/]+)\/trace$/, 'trace.get'],
|
|
30
|
+
['GET', /^\/v1\/questions$/, 'question.history'],
|
|
30
31
|
['GET', /^\/v1\/questions\/([^/]+)$/, 'question.get'],
|
|
31
32
|
['POST', /^\/v1\/questions\/([^/]+)\/answer$/, 'question.answer'],
|
|
32
33
|
['POST', /^\/v1\/questions\/([^/]+)\/cancel$/, 'question.cancel'],
|
|
34
|
+
['GET', /^\/v1\/human\/reviews$/, 'review.list'],
|
|
35
|
+
['GET', /^\/v1\/human\/reviews\/([^/]+)$/, 'review.get'],
|
|
36
|
+
['POST', /^\/v1\/human\/reviews\/([^/]+)\/submit$/, 'review.submit'],
|
|
37
|
+
['POST', /^\/v1\/human\/reviews\/([^/]+)\/cancel$/, 'review.cancel'],
|
|
38
|
+
['GET', /^\/v1\/human\/inbox\/tickets\/([^/]+)\/discuss$/, 'discuss.ticket.get'],
|
|
39
|
+
['POST', /^\/v1\/human\/inbox\/tickets\/([^/]+)\/discuss$/, 'discuss.ticket.post'],
|
|
40
|
+
['GET', /^\/v1\/human\/reviews\/([^/]+)\/discuss$/, 'discuss.review.get'],
|
|
41
|
+
['POST', /^\/v1\/human\/reviews\/([^/]+)\/discuss$/, 'discuss.review.post'],
|
|
33
42
|
['GET', /^\/v1\/memory$/, 'memory.list'],
|
|
34
43
|
['GET', /^\/v1\/memory\/document$/, 'memory.get'],
|
|
35
44
|
['GET', /^\/v1\/providers\/tools$/, 'provider.tools'],
|
|
@@ -808,9 +817,18 @@ export class FakeCloud {
|
|
|
808
817
|
const current = run.questionObject(question);
|
|
809
818
|
if (current['status'] !== 'open')
|
|
810
819
|
throw refuse(409, 'run_settled', `question ${question} is already ${String(current['status'])}`, { details: { state: current['status'] } });
|
|
811
|
-
|
|
820
|
+
const reason = body !== null && typeof body === 'object' ? body['reason'] : undefined;
|
|
821
|
+
run.cancelQuestion(question, typeof reason === 'string' ? reason : undefined);
|
|
812
822
|
return { status: 200, body: run.questionObject(question) };
|
|
813
823
|
}
|
|
824
|
+
case 'question.history': {
|
|
825
|
+
const since = Date.parse(query.get('settled_since') ?? '');
|
|
826
|
+
if (Number.isNaN(since))
|
|
827
|
+
throw invalid('settled_since must be an ISO timestamp', 'settled_since');
|
|
828
|
+
const questions = user.runs.filter((run) => !run.deleted).flatMap((run) => run.questionHistory(since))
|
|
829
|
+
.sort((a, b) => String(b['settled_at']).localeCompare(String(a['settled_at'])));
|
|
830
|
+
return { status: 200, body: { questions } };
|
|
831
|
+
}
|
|
814
832
|
case 'memory.list': return { status: 200, body: this.memoryList(user, query) };
|
|
815
833
|
case 'memory.get': {
|
|
816
834
|
this.memoryStore(query);
|
|
@@ -829,6 +847,14 @@ export class FakeCloud {
|
|
|
829
847
|
end--;
|
|
830
848
|
return { status: 200, body: { ...memoryItem(doc), body: full.subarray(0, end).toString('utf8'), size: full.length, truncated: end < full.length } };
|
|
831
849
|
}
|
|
850
|
+
case 'review.list': return { status: 200, body: { reviews: [] } };
|
|
851
|
+
case 'review.get':
|
|
852
|
+
case 'review.submit':
|
|
853
|
+
case 'review.cancel':
|
|
854
|
+
case 'discuss.review.get':
|
|
855
|
+
case 'discuss.review.post': throw refuse(404, 'not_found', 'review not found');
|
|
856
|
+
case 'discuss.ticket.get':
|
|
857
|
+
case 'discuss.ticket.post': throw refuse(404, 'not_found', 'question not found');
|
|
832
858
|
case 'provider.tools': return this.providerTools(user, id);
|
|
833
859
|
case 'provider.call': return this.providerCall(user, body, signal);
|
|
834
860
|
case 'provider.machine': return this.providerMachine(user, body);
|
|
@@ -951,7 +977,7 @@ export class FakeCloud {
|
|
|
951
977
|
const accepted = message === undefined ? undefined : run.accept(message, false, key);
|
|
952
978
|
const response = {
|
|
953
979
|
run_id: run.id, node_id: run.id, grantee: this.host.grantee, grant: user.grantId, rev: user.rev, scopes, payer: 'user',
|
|
954
|
-
status: 'running', created_at: run.createdAt, metadata, sequence_number: 0,
|
|
980
|
+
status: 'running', created_at: run.createdAt, metadata, sequence_number: 0, fixed_subject: false,
|
|
955
981
|
...(accepted ? { message: { run_id: run.id, message_id: accepted.message_id, sequence_number: accepted.sequence_number } } : {}),
|
|
956
982
|
};
|
|
957
983
|
if (key !== null)
|
package/dist/testing/run.d.ts
CHANGED
|
@@ -67,6 +67,8 @@ interface OpenQuestion {
|
|
|
67
67
|
slots: RunQuestionSlotDTO[];
|
|
68
68
|
status: 'open' | 'answered' | 'canceled';
|
|
69
69
|
answer?: Record<string, unknown>;
|
|
70
|
+
settledAt?: string;
|
|
71
|
+
cancelReason?: string;
|
|
70
72
|
}
|
|
71
73
|
/** `activity.tool.summary` as the daemon writes it: a command's first line, else a path; null otherwise. */
|
|
72
74
|
export declare function toolCallSummary(args: unknown): string | null;
|
|
@@ -166,7 +168,9 @@ export declare class FakeRun {
|
|
|
166
168
|
/** The app answered a question. */
|
|
167
169
|
answer(questionId: string, responses: Record<string, unknown>): void;
|
|
168
170
|
/** The app canceled a question: the person dismissed it. */
|
|
169
|
-
cancelQuestion(questionId: string): void;
|
|
171
|
+
cancelQuestion(questionId: string, reason?: string): void;
|
|
172
|
+
/** The settled questions of this run as `questions.history` lists them. */
|
|
173
|
+
questionHistory(since: number): Array<Record<string, unknown>>;
|
|
170
174
|
questionObject(questionId: string): Record<string, unknown> | undefined;
|
|
171
175
|
/** Resolves when the run rests (`idle`, `waiting_on_user`, `settled`), is deleted, `seconds` pass, or `signal` aborts. */
|
|
172
176
|
waitResting(seconds: number, signal?: AbortSignal | null): Promise<void>;
|
package/dist/testing/run.js
CHANGED
|
@@ -119,7 +119,7 @@ export class FakeRun {
|
|
|
119
119
|
pending_question_ids: status === 'settled' ? [] : this.pendingQuestionIds,
|
|
120
120
|
open_notice_ids: status === 'settled' ? [] : this.openNoticeIds,
|
|
121
121
|
...(this.turnError ? { last_turn_error: this.turnError } : {}),
|
|
122
|
-
usage: usage(), payer: 'user', scopes: this.scopes, metadata: this.metadata, created_at: this.createdAt,
|
|
122
|
+
usage: usage(), payer: 'user', scopes: this.scopes, metadata: this.metadata, created_at: this.createdAt, fixed_subject: false,
|
|
123
123
|
...(this.settledAt ? { settled_at: this.settledAt } : {}),
|
|
124
124
|
latest_sequence: this.sequence, last_activity_at: this.lastActivityAt, activity: this.activity, worktree: null,
|
|
125
125
|
};
|
|
@@ -278,12 +278,26 @@ export class FakeRun {
|
|
|
278
278
|
const question = this.questions.get(questionId);
|
|
279
279
|
question.status = 'answered';
|
|
280
280
|
question.answer = responses;
|
|
281
|
+
question.settledAt = nowIso(this.host.now());
|
|
281
282
|
this.answered = true;
|
|
282
283
|
this.append('question.answered', { question_id: questionId, answer: responses });
|
|
283
284
|
}
|
|
284
285
|
/** The app canceled a question: the person dismissed it. */
|
|
285
|
-
cancelQuestion(questionId) {
|
|
286
|
-
this.questions.get(questionId)
|
|
286
|
+
cancelQuestion(questionId, reason) {
|
|
287
|
+
const question = this.questions.get(questionId);
|
|
288
|
+
question.status = 'canceled';
|
|
289
|
+
question.settledAt = nowIso(this.host.now());
|
|
290
|
+
if (reason !== undefined)
|
|
291
|
+
question.cancelReason = reason;
|
|
292
|
+
}
|
|
293
|
+
/** The settled questions of this run as `questions.history` lists them. */
|
|
294
|
+
questionHistory(since) {
|
|
295
|
+
return [...this.questions.values()]
|
|
296
|
+
.filter((q) => q.settledAt !== undefined && Date.parse(q.settledAt) >= since)
|
|
297
|
+
.map((q) => ({
|
|
298
|
+
question_id: q.question_id, run_id: this.id, title: q.title, kind: q.kind, settled_at: q.settledAt, state: q.status, settled_by: 'person',
|
|
299
|
+
...(q.cancelReason === undefined ? {} : { cancel_reason: q.cancelReason }),
|
|
300
|
+
}));
|
|
287
301
|
}
|
|
288
302
|
questionObject(questionId) {
|
|
289
303
|
const q = this.questions.get(questionId);
|
package/dist/version.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** This SDK's release version. Informational only: compatibility is the contract level, not this number. */
|
|
2
|
-
export declare const SDK_VERSION = "0.3.
|
|
2
|
+
export declare const SDK_VERSION = "0.3.854";
|
|
3
3
|
/** The release sent in `Crouter-Minimum-Runtime-Version` on every request. It is frozen, so a runtime from before the
|
|
4
4
|
* contract level existed (which only knows this header) refuses this SDK, while every later runtime accepts it. */
|
|
5
5
|
export declare const LEGACY_FLOOR = "0.3.423";
|
package/dist/version.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SDK_VERSION is written by scripts/release-version.mjs on every release; do not edit by hand.
|
|
2
2
|
/** This SDK's release version. Informational only: compatibility is the contract level, not this number. */
|
|
3
|
-
export const SDK_VERSION = '0.3.
|
|
3
|
+
export const SDK_VERSION = '0.3.854';
|
|
4
4
|
// LEGACY_FLOOR is written once by `scripts/contract.mjs release`, at the first release that carries the contract level
|
|
5
5
|
// (the `0.0.0` placeholder is replaced there and never again); do not edit by hand.
|
|
6
6
|
/** The release sent in `Crouter-Minimum-Runtime-Version` on every request. It is frozen, so a runtime from before the
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/sdk",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"crouterContract": "1.
|
|
3
|
+
"version": "0.3.854",
|
|
4
|
+
"crouterContract": "1.102",
|
|
5
5
|
"description": "Typed Node and browser client for running crouter agents through the crtrd /v1 API.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"prepublishOnly": "node -e \"if (process.env.npm_config_tag !== 'next') { console.error('@north-light/sdk publishes only with --tag next; scripts/promote-sdk.mjs is the only mover of latest.'); process.exit(1); }\""
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@north-light/api": "0.3.
|
|
48
|
-
"@north-light/identity": "0.3.
|
|
49
|
-
"@north-light/plugin": "0.3.
|
|
47
|
+
"@north-light/api": "0.3.854",
|
|
48
|
+
"@north-light/identity": "0.3.854",
|
|
49
|
+
"@north-light/plugin": "0.3.854",
|
|
50
50
|
"jose": "^6.2.1"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|