@myspec/sdk 0.1.1 → 0.1.2

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/README.md CHANGED
@@ -42,7 +42,7 @@ if (state.pendingAction?.kind === 'spec-decision') {
42
42
 
43
43
  // Or let a policy drive it.
44
44
  const report = await runToCompletion(session, recommendedPolicy(), { autonomy: 'interview' });
45
- // Without `autonomy` the run is at 'full' and approves cards too (the MCP servers default to 'interview').
45
+ // Without `autonomy` the run is at 'full' and approves cards too, like the MCP servers' default.
46
46
  console.log(report.endReason);
47
47
  // completed | policy_stop | max_turns | handover | turn_error | agent_refused | error
48
48
  ```
@@ -66,7 +66,7 @@ A turn that ends with a stream error ends the run with `turn_error`. Pass `turnE
66
66
 
67
67
  `apiTokenAuth` signs in at `https://auth.myspec.dev` unless `authUrl` names another environment; a token works only where it was created. It keeps the access token until a minute before it expires, and trades again after a 401. A refused API token throws `ApiTokenRejectedError`, and every later call of that `getToken` throws it again without asking the host. Any other failed sign-in (a timeout, after 10 s by default; rate limiting, with `retryAfterSeconds`; a 5xx) throws `TokenExchangeError`, and the next call tries again. In tests and in-process runs, pass any `getToken` that returns a valid access token.
68
68
 
69
- `state.lastAssistantMessage` is the newest reply (`messageId`, `index`, `text`, `cardTypes`), `null` before the first. Read it when a turn outlasted your `waitMs`, and when the session waits on no card: it may have asked a question as text. `listMessages()` pages the whole transcript: pass `nextCursor` as `after`. A cursor the transcript no longer holds is a `SessionRequestError` with code `CURSOR_NOT_FOUND`.
69
+ A `spec-decision` pending action can carry `preview` (the diff against the previous revision, or the start of a first one), and `state.localBridge` says whether your `reverse` bridge is connected, which a brownfield turn needs. `state.lastAssistantMessage` is the newest reply (`messageId`, `index`, `text`, `cardTypes`), `null` before the first. Read it when a turn outlasted your `waitMs`, and when the session waits on no card: it may have asked a question as text. `listMessages()` pages the whole transcript: pass `nextCursor` as `after`. A cursor the transcript no longer holds is a `SessionRequestError` with code `CURSOR_NOT_FOUND`.
70
70
 
71
71
  Refusals a driver should handle are typed errors: `PendingActionMismatchError` (read the state again), `SessionBusyError` (wait for the running turn), `AgentTurnCapReachedError` and `AgentDrivingDisabledError` (a person must continue), `ReadOnlyTokenError` (use a read-write token). `runToCompletion` handles the first two itself and ends with `agent_refused` on the other three.
72
72
 
package/dist/index.d.ts CHANGED
@@ -11,4 +11,4 @@ export { AgentDrivingDisabledError, AgentTurnCapReachedError, InvalidDecisionErr
11
11
  export { isSay, recommendedPolicy, sayWhenIdle, scriptedPolicy, type Policy, type PolicyInfo, type PolicyResult, type Say, type ScriptStep, } from './src/policies.js';
12
12
  export { DRIVER_MAX_TURNS, INTERVIEW_AUTONOMY_KINDS, runToCompletion, type AutonomyLevel, type RunEndReason, type RunOptions, type RunReport, type RunTurnRecord, } from './src/run.js';
13
13
  export { readTurnStream, type TurnStream, type TurnStreamSnapshot } from './src/stream.js';
14
- export { DECISION_PART_TYPE, NO_PENDING_ACTION_ID, PENDING_ACTION_KINDS, type ArtifactRevisionCard, type CardByKind, type Decision, type DecisionDataByKind, type EditReviewCard, type McqFormCard, type McqOption, type McqQuestion, type PendingAction, type PendingActionKind, type ReviewFeedbackCard, type ReviewFeedbackItem, type SessionPhase, type LastAssistantMessage, type SessionMessage, type SessionMessageCard, type SessionMessagesPage, type SessionMessageToolCall, type SessionState, type SessionStateDecision, type SessionStateDecisionAttribution, type SessionStateMcqAnswer, type SessionStateSpecFile, type SitePlanCard, type SkillRecommendationCard, type SpecFileCard, type TurnResult, type TurnStreamError, type UserChoiceCard, } from './src/types.js';
14
+ export { DECISION_PART_TYPE, NO_PENDING_ACTION_ID, PENDING_ACTION_KINDS, type ArtifactRevisionCard, type CardByKind, type Decision, type DecisionDataByKind, type EditReviewCard, type McqFormCard, type McqOption, type McqQuestion, type PendingAction, type PendingActionKind, type ReviewFeedbackCard, type ReviewFeedbackItem, type SessionPhase, type LastAssistantMessage, type SessionMessage, type SessionMessageCard, type SessionMessagesPage, type SessionMessageToolCall, type SessionState, type SessionStateLocalBridge, type SpecFilePreview, type SessionStateDecision, type SessionStateDecisionAttribution, type SessionStateMcqAnswer, type SessionStateSpecFile, type SitePlanCard, type SkillRecommendationCard, type SpecFileCard, type TurnResult, type TurnStreamError, type UserChoiceCard, } from './src/types.js';
@@ -186,8 +186,28 @@ export type PendingAction = {
186
186
  kind: K;
187
187
  accepts: (typeof DECISION_PART_TYPE)[K];
188
188
  card: CardByKind[K] | null;
189
+ /**
190
+ * For a `spec-decision` card: the change against the previous revision,
191
+ * or the start of a first revision, when the server could read the file.
192
+ */
193
+ preview?: SpecFilePreview;
189
194
  };
190
195
  }[PendingActionKind];
196
+ /** A short preview of the spec file a `spec-decision` card asks about. */
197
+ export interface SpecFilePreview {
198
+ specFileId: string;
199
+ revisionNumber: number;
200
+ /** The revision the diff is against; absent for a first revision. */
201
+ previousRevisionNumber?: number;
202
+ linesAdded: number;
203
+ linesRemoved: number;
204
+ /** Unified-style diff: `+`, `-` and ` ` lines, `@@` between hunks. */
205
+ diff?: string;
206
+ /** The start of the file, for a first revision. */
207
+ excerpt?: string;
208
+ /** Present (and `true`) when the diff or the excerpt was cut. */
209
+ truncated?: true;
210
+ }
191
211
  export type SessionPhase = 'running' | 'awaiting_input' | 'idle' | 'completed';
192
212
  export interface SessionStateSpecFile {
193
213
  specType: string;
@@ -312,6 +332,20 @@ export interface SessionState {
312
332
  * field.
313
333
  */
314
334
  messageCount?: number;
335
+ /**
336
+ * Your own `reverse` bridge: a brownfield turn reads local files through
337
+ * the bridge of the account that sends it. Absent when the server cannot
338
+ * tell, or is older than this field.
339
+ */
340
+ localBridge?: SessionStateLocalBridge;
341
+ }
342
+ /** Whether your `reverse` bridge is connected to MySpec. */
343
+ export interface SessionStateLocalBridge {
344
+ connected: boolean;
345
+ /** When the connected bridge connected (ISO-8601). */
346
+ connectedSince?: string;
347
+ /** When MySpec last heard from it (ISO-8601). */
348
+ lastSeenAt?: string;
315
349
  }
316
350
  /** The newest assistant message of a session, as the state read reports it. */
317
351
  export interface LastAssistantMessage {
@@ -330,6 +364,10 @@ export interface SessionMessageToolCall {
330
364
  name: string;
331
365
  /** How far it got (`output-available`, `output-error`, ...), when known. */
332
366
  state?: string;
367
+ /** `key=value` pairs of its main arguments (a path, a query), when recorded. */
368
+ summary?: string;
369
+ /** `true` when its result was an error. */
370
+ failed?: true;
333
371
  }
334
372
  /** A card or a decision of a message. */
335
373
  export interface SessionMessageCard {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myspec/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "MySpec session driver: read what a chat session waits on and answer it, from a script, a test or an agent",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",