@gracefultools/astrid-sdk 0.8.2 → 1.0.1
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 +173 -127
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +13 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.d.ts +41 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +361 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +89 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +216 -0
- package/dist/client.js.map +1 -0
- package/dist/config/api-base.d.ts +21 -0
- package/dist/config/api-base.d.ts.map +1 -0
- package/dist/config/api-base.js +41 -0
- package/dist/config/api-base.js.map +1 -0
- package/dist/index.d.ts +13 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -57
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +103 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/verdict.d.ts +88 -0
- package/dist/verdict.d.ts.map +1 -0
- package/dist/verdict.js +90 -0
- package/dist/verdict.js.map +1 -0
- package/package.json +56 -65
- package/dist/adapters/astrid-oauth.d.ts +0 -114
- package/dist/adapters/astrid-oauth.d.ts.map +0 -1
- package/dist/adapters/astrid-oauth.js +0 -287
- package/dist/adapters/astrid-oauth.js.map +0 -1
- package/dist/channel/channel.d.ts +0 -33
- package/dist/channel/channel.d.ts.map +0 -1
- package/dist/channel/channel.js +0 -90
- package/dist/channel/channel.js.map +0 -1
- package/dist/channel/index.d.ts +0 -13
- package/dist/channel/index.d.ts.map +0 -1
- package/dist/channel/index.js +0 -23
- package/dist/channel/index.js.map +0 -1
- package/dist/channel/message-formatter.d.ts +0 -14
- package/dist/channel/message-formatter.d.ts.map +0 -1
- package/dist/channel/message-formatter.js +0 -71
- package/dist/channel/message-formatter.js.map +0 -1
- package/dist/channel/oauth-client.d.ts +0 -15
- package/dist/channel/oauth-client.d.ts.map +0 -1
- package/dist/channel/oauth-client.js +0 -45
- package/dist/channel/oauth-client.js.map +0 -1
- package/dist/channel/rest-client.d.ts +0 -16
- package/dist/channel/rest-client.d.ts.map +0 -1
- package/dist/channel/rest-client.js +0 -66
- package/dist/channel/rest-client.js.map +0 -1
- package/dist/channel/session-mapper.d.ts +0 -14
- package/dist/channel/session-mapper.d.ts.map +0 -1
- package/dist/channel/session-mapper.js +0 -37
- package/dist/channel/session-mapper.js.map +0 -1
- package/dist/channel/sse-client.d.ts +0 -33
- package/dist/channel/sse-client.d.ts.map +0 -1
- package/dist/channel/sse-client.js +0 -204
- package/dist/channel/sse-client.js.map +0 -1
- package/dist/channel/types.d.ts +0 -65
- package/dist/channel/types.d.ts.map +0 -1
- package/dist/channel/types.js +0 -3
- package/dist/channel/types.js.map +0 -1
- package/dist/config/agent-workflow.d.ts +0 -78
- package/dist/config/agent-workflow.d.ts.map +0 -1
- package/dist/config/agent-workflow.js +0 -217
- package/dist/config/agent-workflow.js.map +0 -1
- package/dist/config/index.d.ts +0 -194
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js +0 -284
- package/dist/config/index.js.map +0 -1
- package/dist/deploy/vercel.d.ts +0 -27
- package/dist/deploy/vercel.d.ts.map +0 -1
- package/dist/deploy/vercel.js +0 -268
- package/dist/deploy/vercel.js.map +0 -1
- package/dist/types/index.d.ts +0 -157
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -6
- package/dist/types/index.js.map +0 -1
- package/dist/utils/agent-config.d.ts +0 -56
- package/dist/utils/agent-config.d.ts.map +0 -1
- package/dist/utils/agent-config.js +0 -138
- package/dist/utils/agent-config.js.map +0 -1
- package/templates/.astrid.config.json +0 -60
- package/templates/ASTRID.template.md +0 -74
package/dist/client.js
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Typed REST client for the agent endpoints: the queue, claims, comments and
|
|
4
|
+
* the status and handback writes. One method per existing server route; it
|
|
5
|
+
* invents no endpoints and adds no fields.
|
|
6
|
+
*
|
|
7
|
+
* Two ways to authenticate, the same two the generated workflows use:
|
|
8
|
+
* - `{ token }`: an agent-bound token (`astrid_mcp_…` or an agent consent
|
|
9
|
+
* token), sent as `Authorization: Bearer`. Writes are signed as that agent
|
|
10
|
+
* and the claim route can tell which agent is claiming.
|
|
11
|
+
* - `{ clientId, clientSecret }`: client credentials, exchanged once at
|
|
12
|
+
* `/api/v1/oauth/token` and sent as `X-OAuth-Token`. Such a token carries
|
|
13
|
+
* no agent binding, so the generic claim route answers `forbidden`; use
|
|
14
|
+
* `claimFixallTask` or an agent-bound token for claims.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.AstridClient = exports.AstridApiError = void 0;
|
|
18
|
+
const api_base_js_1 = require("./config/api-base.js");
|
|
19
|
+
/** A response the server refused. `status` is the HTTP status; the message carries its reason. */
|
|
20
|
+
class AstridApiError extends Error {
|
|
21
|
+
status;
|
|
22
|
+
body;
|
|
23
|
+
constructor(status, message, body = null) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.status = status;
|
|
26
|
+
this.body = body;
|
|
27
|
+
this.name = 'AstridApiError';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.AstridApiError = AstridApiError;
|
|
31
|
+
const CLAIM_OUTCOMES = new Set([
|
|
32
|
+
'claimed', 'already_yours', 'released', 'renewed', 'conflict', 'not_ready', 'not_found', 'forbidden', 'binding_denied',
|
|
33
|
+
]);
|
|
34
|
+
function reasonOf(body) {
|
|
35
|
+
if (body && typeof body === 'object' && 'error' in body && typeof body.error === 'string')
|
|
36
|
+
return body.error;
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
async function readJson(response) {
|
|
40
|
+
return response.json().catch(() => null);
|
|
41
|
+
}
|
|
42
|
+
class AstridClient {
|
|
43
|
+
origin;
|
|
44
|
+
auth;
|
|
45
|
+
fetchImpl;
|
|
46
|
+
exchanged = null;
|
|
47
|
+
constructor(options) {
|
|
48
|
+
this.origin = (0, api_base_js_1.resolveOrigin)(options.origin);
|
|
49
|
+
this.auth = options.auth;
|
|
50
|
+
this.fetchImpl = options.fetch ?? globalThis.fetch;
|
|
51
|
+
}
|
|
52
|
+
async authHeaders() {
|
|
53
|
+
if ('token' in this.auth)
|
|
54
|
+
return { Authorization: `Bearer ${this.auth.token}` };
|
|
55
|
+
if (!this.exchanged || Date.now() >= this.exchanged.expiresAt) {
|
|
56
|
+
const response = await this.fetchImpl(`${this.origin}/api/v1/oauth/token`, {
|
|
57
|
+
method: 'POST',
|
|
58
|
+
headers: { 'Content-Type': 'application/json' },
|
|
59
|
+
body: JSON.stringify({
|
|
60
|
+
grant_type: 'client_credentials',
|
|
61
|
+
client_id: this.auth.clientId,
|
|
62
|
+
client_secret: this.auth.clientSecret,
|
|
63
|
+
...(this.auth.scope ? { scope: this.auth.scope } : {}),
|
|
64
|
+
}),
|
|
65
|
+
});
|
|
66
|
+
const body = await readJson(response);
|
|
67
|
+
if (!response.ok) {
|
|
68
|
+
throw new AstridApiError(response.status, `OAuth token request failed: HTTP ${response.status}`, body);
|
|
69
|
+
}
|
|
70
|
+
const { access_token: token, expires_in: expiresIn } = (body ?? {});
|
|
71
|
+
if (!token)
|
|
72
|
+
throw new AstridApiError(response.status, 'OAuth token response had no access_token', null);
|
|
73
|
+
// Refresh five minutes early, as the old clients did.
|
|
74
|
+
this.exchanged = { token, expiresAt: Date.now() + Math.max(0, (expiresIn ?? 3600) - 300) * 1000 };
|
|
75
|
+
}
|
|
76
|
+
return { 'X-OAuth-Token': this.exchanged.token };
|
|
77
|
+
}
|
|
78
|
+
/** One request; returns status and parsed body without judging either. */
|
|
79
|
+
async send(path, init = {}) {
|
|
80
|
+
const headers = { ...(await this.authHeaders()) };
|
|
81
|
+
if (init.body !== undefined)
|
|
82
|
+
headers['Content-Type'] = 'application/json';
|
|
83
|
+
const response = await this.fetchImpl(`${this.origin}${path}`, {
|
|
84
|
+
method: init.method ?? 'GET',
|
|
85
|
+
headers,
|
|
86
|
+
...(init.body !== undefined ? { body: JSON.stringify(init.body) } : {}),
|
|
87
|
+
});
|
|
88
|
+
return { status: response.status, ok: response.ok, body: await readJson(response) };
|
|
89
|
+
}
|
|
90
|
+
/** A request that must succeed. */
|
|
91
|
+
async request(path, init = {}) {
|
|
92
|
+
const { status, ok, body } = await this.send(path, init);
|
|
93
|
+
if (!ok) {
|
|
94
|
+
const reason = reasonOf(body);
|
|
95
|
+
throw new AstridApiError(status, `HTTP ${status} from ${path.split('?')[0]}${reason ? `: ${reason}` : ''}`, body);
|
|
96
|
+
}
|
|
97
|
+
return body;
|
|
98
|
+
}
|
|
99
|
+
/** `GET /api/v1/agent-queue`: Ready work plus unanswered comments and messages. */
|
|
100
|
+
async getQueue(query) {
|
|
101
|
+
const params = new URLSearchParams({ agent: query.agent });
|
|
102
|
+
if (query.listId)
|
|
103
|
+
params.set('listId', query.listId);
|
|
104
|
+
if (query.includeUnassigned)
|
|
105
|
+
params.set('includeUnassigned', 'true');
|
|
106
|
+
return this.request(`/api/v1/agent-queue?${params}`);
|
|
107
|
+
}
|
|
108
|
+
/** `GET /api/v1/lists`: the body as the server sent it, for a caller that resolves a board by name. */
|
|
109
|
+
async getLists() {
|
|
110
|
+
return this.request('/api/v1/lists');
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* `POST /api/v1/tasks/:id/claim`: atomic claim, resume or release. Every
|
|
114
|
+
* documented outcome is returned, not thrown, so a caller can branch on a
|
|
115
|
+
* conflict; only an undocumented answer throws.
|
|
116
|
+
*/
|
|
117
|
+
async claimTask(taskId, request) {
|
|
118
|
+
const { status, body } = await this.send(`/api/v1/tasks/${encodeURIComponent(taskId)}/claim`, {
|
|
119
|
+
method: 'POST',
|
|
120
|
+
body: {
|
|
121
|
+
action: request.action,
|
|
122
|
+
// The route compares the mailbox with the token identity's local part,
|
|
123
|
+
// so a Custom Agent address is sent without its domain.
|
|
124
|
+
...(request.agentMailbox ? { agentMailbox: request.agentMailbox.split('@')[0] } : {}),
|
|
125
|
+
...(request.leaseSeconds !== undefined ? { leaseSeconds: request.leaseSeconds } : {}),
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
if (body && typeof body === 'object' && 'outcome' in body && typeof body.outcome === 'string' && CLAIM_OUTCOMES.has(body.outcome)) {
|
|
129
|
+
const task = 'task' in body ? body.task : null;
|
|
130
|
+
return { status, outcome: body.outcome, task: task ?? null };
|
|
131
|
+
}
|
|
132
|
+
// The route is absent on this server (or an older one still gates it).
|
|
133
|
+
if ([404, 405, 501].includes(status))
|
|
134
|
+
return { status, outcome: 'unavailable', task: null };
|
|
135
|
+
const reason = reasonOf(body);
|
|
136
|
+
throw new AstridApiError(status, `HTTP ${status} from claim${reason ? `: ${reason}` : ''}`, body);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Renew this agent's claim lease. Send it every few minutes while working:
|
|
140
|
+
* a claim with no heartbeat for its lease (15 minutes by default) returns to
|
|
141
|
+
* Ready. `renewed` means keep going; anything else means the claim is gone.
|
|
142
|
+
*/
|
|
143
|
+
async heartbeatTask(taskId, options = {}) {
|
|
144
|
+
return this.claimTask(taskId, { action: 'heartbeat', ...options });
|
|
145
|
+
}
|
|
146
|
+
/** Give a Doing claim back: the task returns to Ready and this agent is unassigned. */
|
|
147
|
+
async releaseTask(taskId, agentMailbox) {
|
|
148
|
+
return this.claimTask(taskId, { action: 'release', ...(agentMailbox ? { agentMailbox } : {}) });
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* `POST /api/v1/tasks/:id/claim-fixall`: the claim Astrid's own scheduled
|
|
152
|
+
* loops use. Allowlisted boards and harness mailboxes only; works with
|
|
153
|
+
* client credentials. A 409 is returned as `claimed: false` with the
|
|
154
|
+
* server's reason.
|
|
155
|
+
*/
|
|
156
|
+
async claimFixallTask(taskId, request) {
|
|
157
|
+
const { status, ok, body } = await this.send(`/api/v1/tasks/${encodeURIComponent(taskId)}/claim-fixall`, {
|
|
158
|
+
method: 'POST',
|
|
159
|
+
body: {
|
|
160
|
+
action: request.action,
|
|
161
|
+
commentWatermark: request.commentWatermark ?? null,
|
|
162
|
+
...(request.agent ? { agent: request.agent } : {}),
|
|
163
|
+
...(request.resume !== undefined ? { resume: request.resume } : {}),
|
|
164
|
+
...(request.listId ? { listId: request.listId } : {}),
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
if (ok) {
|
|
168
|
+
const assigneeEmail = body && typeof body === 'object' && 'assigneeEmail' in body && typeof body.assigneeEmail === 'string'
|
|
169
|
+
? body.assigneeEmail : undefined;
|
|
170
|
+
return { status, claimed: true, ...(assigneeEmail ? { assigneeEmail } : {}) };
|
|
171
|
+
}
|
|
172
|
+
const reason = reasonOf(body);
|
|
173
|
+
if (status === 409)
|
|
174
|
+
return { status, claimed: false, ...(reason ? { error: reason } : {}) };
|
|
175
|
+
throw new AstridApiError(status, `HTTP ${status} from claim-fixall${reason ? `: ${reason}` : ''}`, body);
|
|
176
|
+
}
|
|
177
|
+
async getTask(taskId) {
|
|
178
|
+
const body = await this.request(`/api/v1/tasks/${encodeURIComponent(taskId)}`);
|
|
179
|
+
return body.task;
|
|
180
|
+
}
|
|
181
|
+
async getComments(taskId) {
|
|
182
|
+
const body = await this.request(`/api/v1/tasks/${encodeURIComponent(taskId)}/comments`);
|
|
183
|
+
return body.comments;
|
|
184
|
+
}
|
|
185
|
+
async addComment(taskId, content, options = {}) {
|
|
186
|
+
const body = await this.request(`/api/v1/tasks/${encodeURIComponent(taskId)}/comments`, {
|
|
187
|
+
method: 'POST',
|
|
188
|
+
body: { content, ...(options.aiAgentId ? { aiAgentId: options.aiAgentId } : {}) },
|
|
189
|
+
});
|
|
190
|
+
return body.comment;
|
|
191
|
+
}
|
|
192
|
+
/** Move the task's board column (`ready`, `doing`, `waiting`, or null for the Inbox). */
|
|
193
|
+
async setStatus(taskId, statusRole, options = {}) {
|
|
194
|
+
return this.updateTask(taskId, { statusRole }, options);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Hand the task back to a person: the Inbox, assigned to them, in one write
|
|
198
|
+
* (astrid-core's `handBack`). Never Waiting, which holds only tasks waiting
|
|
199
|
+
* on a date or another task. `completed` is left out so a task someone
|
|
200
|
+
* finished meanwhile is not reopened.
|
|
201
|
+
*/
|
|
202
|
+
async handBack(taskId, personId, options = {}) {
|
|
203
|
+
if (!personId.trim())
|
|
204
|
+
throw new Error('A handback needs the person to hand it to');
|
|
205
|
+
return this.updateTask(taskId, { statusRole: null, assigneeId: personId }, options);
|
|
206
|
+
}
|
|
207
|
+
async updateTask(taskId, fields, options) {
|
|
208
|
+
const body = await this.request(`/api/v1/tasks/${encodeURIComponent(taskId)}`, {
|
|
209
|
+
method: 'PUT',
|
|
210
|
+
body: { ...fields, ...(options.aiAgentId ? { aiAgentId: options.aiAgentId } : {}) },
|
|
211
|
+
});
|
|
212
|
+
return body.task;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
exports.AstridClient = AstridClient;
|
|
216
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEH,sDAAoD;AA0BpD,kGAAkG;AAClG,MAAa,cAAe,SAAQ,KAAK;IAClB;IAA0C;IAA/D,YAAqB,MAAc,EAAE,OAAe,EAAW,OAAgB,IAAI;QACjF,KAAK,CAAC,OAAO,CAAC,CAAA;QADK,WAAM,GAAN,MAAM,CAAQ;QAA4B,SAAI,GAAJ,IAAI,CAAgB;QAEjF,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAC9B,CAAC;CACF;AALD,wCAKC;AAED,MAAM,cAAc,GAAwB,IAAI,GAAG,CA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C,UAAU,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,OAAO,CAAC,CAAA;IACzD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,QAAQ,CAAC,MAAc,EAAE,QAAgB,EAAE,UAAuB,EAAE;QACxE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAA;QAClF,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAA;IACrF,CAAC;IAEO,KAAK,CAAC,UAAU,CAAC,MAAc,EAAE,MAA+B,EAAE,OAAoB;QAC5F,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAuB,iBAAiB,kBAAkB,CAAC,MAAM,CAAC,EAAE,EAAE;YACnG,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;SACpF,CAAC,CAAA;QACF,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;CACF;AApLD,oCAoLC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One place that decides which server the SDK talks to.
|
|
3
|
+
*
|
|
4
|
+
* There used to be three answers: `channel/rest-client.ts`,
|
|
5
|
+
* `channel/sse-client.ts` and `channel/oauth-client.ts` defaulted to
|
|
6
|
+
* `https://www.astrid.cc/api/v1`, while `adapters/astrid-oauth.ts` defaulted to
|
|
7
|
+
* `https://astrid.cc`. Those disagree about the HOST, not just the brand, so
|
|
8
|
+
* the SDK could hold a session on one origin and call the API on another —
|
|
9
|
+
* wrong on Astrid, and doubly wrong for anyone pointing it at their own
|
|
10
|
+
* deployment (task 979e1325).
|
|
11
|
+
*
|
|
12
|
+
* Resolution order, most specific first:
|
|
13
|
+
* 1. an explicit value passed by the caller
|
|
14
|
+
* 2. ASTRID_API_URL / ASTRID_API_BASE_URL in the environment
|
|
15
|
+
* 3. the Astrid production origin
|
|
16
|
+
*/
|
|
17
|
+
/** Origin only, e.g. `https://www.astrid.cc`. */
|
|
18
|
+
export declare function resolveOrigin(explicit?: string): string;
|
|
19
|
+
/** Versioned API base, e.g. `https://www.astrid.cc/api/v1`. */
|
|
20
|
+
export declare function resolveApiBase(explicit?: string): string;
|
|
21
|
+
//# sourceMappingURL=api-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-base.d.ts","sourceRoot":"","sources":["../../src/config/api-base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAeH,iDAAiD;AACjD,wBAAgB,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,+DAA+D;AAC/D,wBAAgB,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAGxD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* One place that decides which server the SDK talks to.
|
|
4
|
+
*
|
|
5
|
+
* There used to be three answers: `channel/rest-client.ts`,
|
|
6
|
+
* `channel/sse-client.ts` and `channel/oauth-client.ts` defaulted to
|
|
7
|
+
* `https://www.astrid.cc/api/v1`, while `adapters/astrid-oauth.ts` defaulted to
|
|
8
|
+
* `https://astrid.cc`. Those disagree about the HOST, not just the brand, so
|
|
9
|
+
* the SDK could hold a session on one origin and call the API on another —
|
|
10
|
+
* wrong on Astrid, and doubly wrong for anyone pointing it at their own
|
|
11
|
+
* deployment (task 979e1325).
|
|
12
|
+
*
|
|
13
|
+
* Resolution order, most specific first:
|
|
14
|
+
* 1. an explicit value passed by the caller
|
|
15
|
+
* 2. ASTRID_API_URL / ASTRID_API_BASE_URL in the environment
|
|
16
|
+
* 3. the Astrid production origin
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.resolveOrigin = resolveOrigin;
|
|
20
|
+
exports.resolveApiBase = resolveApiBase;
|
|
21
|
+
const FALLBACK_ORIGIN = 'https://www.astrid.cc';
|
|
22
|
+
function envOrigin() {
|
|
23
|
+
const env = globalThis.process?.env;
|
|
24
|
+
const configured = env?.ASTRID_API_URL || env?.ASTRID_API_BASE_URL;
|
|
25
|
+
return configured?.trim() || undefined;
|
|
26
|
+
}
|
|
27
|
+
/** Strip a trailing slash so callers can concatenate a leading-slash path safely. */
|
|
28
|
+
function normalize(origin) {
|
|
29
|
+
return origin.replace(/\/+$/, '');
|
|
30
|
+
}
|
|
31
|
+
/** Origin only, e.g. `https://www.astrid.cc`. */
|
|
32
|
+
function resolveOrigin(explicit) {
|
|
33
|
+
return normalize(explicit || envOrigin() || FALLBACK_ORIGIN);
|
|
34
|
+
}
|
|
35
|
+
/** Versioned API base, e.g. `https://www.astrid.cc/api/v1`. */
|
|
36
|
+
function resolveApiBase(explicit) {
|
|
37
|
+
if (explicit)
|
|
38
|
+
return normalize(explicit);
|
|
39
|
+
return `${resolveOrigin()}/api/v1`;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=api-base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-base.js","sourceRoot":"","sources":["../../src/config/api-base.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAgBH,sCAEC;AAGD,wCAGC;AAtBD,MAAM,eAAe,GAAG,uBAAuB,CAAA;AAE/C,SAAS,SAAS;IAChB,MAAM,GAAG,GAAI,UAAyE,CAAC,OAAO,EAAE,GAAG,CAAA;IACnG,MAAM,UAAU,GAAG,GAAG,EAAE,cAAc,IAAI,GAAG,EAAE,mBAAmB,CAAA;IAClE,OAAO,UAAU,EAAE,IAAI,EAAE,IAAI,SAAS,CAAA;AACxC,CAAC;AAED,qFAAqF;AACrF,SAAS,SAAS,CAAC,MAAc;IAC/B,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AACnC,CAAC;AAED,iDAAiD;AACjD,SAAgB,aAAa,CAAC,QAAiB;IAC7C,OAAO,SAAS,CAAC,QAAQ,IAAI,SAAS,EAAE,IAAI,eAAe,CAAC,CAAA;AAC9D,CAAC;AAED,+DAA+D;AAC/D,SAAgB,cAAc,CAAC,QAAiB;IAC9C,IAAI,QAAQ;QAAE,OAAO,SAAS,CAAC,QAAQ,CAAC,CAAA;IACxC,OAAO,GAAG,aAAa,EAAE,SAAS,CAAA;AACpC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @gracefultools/astrid-sdk
|
|
2
|
+
* @gracefultools/astrid-sdk — the Astrid agent runner and its typed client.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Two things, on purpose (AWTD-1691):
|
|
5
|
+
* - the `astrid-agent` command a scheduler or GitHub Actions job runs to
|
|
6
|
+
* check for work, claim it and release it (see ./cli.ts for exit codes);
|
|
7
|
+
* - `AstridClient`, the typed REST client that command is built on.
|
|
8
|
+
*
|
|
9
|
+
* It is not a library for building agents. The SSE channel now lives in
|
|
10
|
+
* @gracefultools/openclaw-astrid-channel, its only user.
|
|
5
11
|
*/
|
|
6
|
-
export
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export { deployToVercel, isVercelConfigured, type VercelDeployResult, } from './deploy/vercel.js';
|
|
12
|
-
export { AstridChannel, SSEClient, OAuthClient as ChannelOAuthClient, RestClient as ChannelRestClient, SessionMapper, taskToMessage, commentToMessage, responseToComment, type AstridChannelConfig, type AgentTask as ChannelAgentTask, type AgentComment as ChannelAgentComment, type AgentSSEEvent, type InboundMessage, type OutboundMessage, } from './channel/index.js';
|
|
12
|
+
export { AstridClient, AstridApiError, type AstridAuth, type AstridClientOptions, } from './client.js';
|
|
13
|
+
export type { AgentQueueQuery, AgentQueueResponse, AstridComment, AstridTask, ClaimAction, ClaimOutcome, ClaimRequest, ClaimResult, ClaimTaskSnapshot, FixallClaimAction, FixallClaimRequest, FixallClaimResult, SignedWrite, } from './types.js';
|
|
14
|
+
export { decideQueueVerdict, wakeKeys, type AttentionSnapshot, type QueueSnapshot, type QueueSnapshotTask, type QueueVerdict, type QueueVerdictReason, } from './verdict.js';
|
|
15
|
+
export { runCli, EXIT, USAGE, type CliIO } from './cli.js';
|
|
16
|
+
export { resolveApiBase, resolveOrigin } from './config/api-base.js';
|
|
13
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,KAAK,UAAU,EACf,KAAK,mBAAmB,GACzB,MAAM,aAAa,CAAA;AAEpB,YAAY,EACV,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,GACZ,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,kBAAkB,GACxB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAE1D,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,63 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* @gracefultools/astrid-sdk
|
|
3
|
+
* @gracefultools/astrid-sdk — the Astrid agent runner and its typed client.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Two things, on purpose (AWTD-1691):
|
|
6
|
+
* - the `astrid-agent` command a scheduler or GitHub Actions job runs to
|
|
7
|
+
* check for work, claim it and release it (see ./cli.ts for exit codes);
|
|
8
|
+
* - `AstridClient`, the typed REST client that command is built on.
|
|
9
|
+
*
|
|
10
|
+
* It is not a library for building agents. The SSE channel now lives in
|
|
11
|
+
* @gracefultools/openclaw-astrid-channel, its only user.
|
|
6
12
|
*/
|
|
7
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Object.defineProperty(exports, "
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, "
|
|
14
|
-
Object.defineProperty(exports, "
|
|
15
|
-
|
|
16
|
-
Object.defineProperty(exports, "
|
|
17
|
-
Object.defineProperty(exports, "
|
|
18
|
-
Object.defineProperty(exports, "
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Object.defineProperty(exports, "AI_AGENT_CONFIG", { enumerable: true, get: function () { return agent_config_js_1.AI_AGENT_CONFIG; } });
|
|
23
|
-
Object.defineProperty(exports, "SUGGESTED_MODELS", { enumerable: true, get: function () { return agent_config_js_1.SUGGESTED_MODELS; } });
|
|
24
|
-
Object.defineProperty(exports, "DEFAULT_MODELS", { enumerable: true, get: function () { return agent_config_js_1.DEFAULT_MODELS; } });
|
|
25
|
-
Object.defineProperty(exports, "getAgentConfig", { enumerable: true, get: function () { return agent_config_js_1.getAgentConfig; } });
|
|
26
|
-
Object.defineProperty(exports, "getAgentService", { enumerable: true, get: function () { return agent_config_js_1.getAgentService; } });
|
|
27
|
-
Object.defineProperty(exports, "getAgentModel", { enumerable: true, get: function () { return agent_config_js_1.getAgentModel; } });
|
|
28
|
-
Object.defineProperty(exports, "getAgentContextFile", { enumerable: true, get: function () { return agent_config_js_1.getAgentContextFile; } });
|
|
29
|
-
Object.defineProperty(exports, "isRegisteredAgent", { enumerable: true, get: function () { return agent_config_js_1.isRegisteredAgent; } });
|
|
30
|
-
Object.defineProperty(exports, "getRegisteredAgentEmails", { enumerable: true, get: function () { return agent_config_js_1.getRegisteredAgentEmails; } });
|
|
31
|
-
Object.defineProperty(exports, "getAllAgentConfigs", { enumerable: true, get: function () { return agent_config_js_1.getAllAgentConfigs; } });
|
|
32
|
-
// NOTE: Built-in AI executors (Claude, OpenAI, Gemini) have been removed.
|
|
33
|
-
// Astrid now dispatches to external agent runtimes (OpenClaw, Claude Code Remote)
|
|
34
|
-
// via webhooks and SSE instead of calling AI APIs directly.
|
|
35
|
-
// Astrid OAuth Client
|
|
36
|
-
var astrid_oauth_js_1 = require("./adapters/astrid-oauth.js");
|
|
37
|
-
Object.defineProperty(exports, "AstridOAuthClient", { enumerable: true, get: function () { return astrid_oauth_js_1.AstridOAuthClient; } });
|
|
38
|
-
// Agent Workflow Configuration
|
|
39
|
-
var agent_workflow_js_1 = require("./config/agent-workflow.js");
|
|
40
|
-
Object.defineProperty(exports, "getAgentWorkflowConfig", { enumerable: true, get: function () { return agent_workflow_js_1.getAgentWorkflowConfig; } });
|
|
41
|
-
Object.defineProperty(exports, "generateBranchName", { enumerable: true, get: function () { return agent_workflow_js_1.generateBranchName; } });
|
|
42
|
-
Object.defineProperty(exports, "generatePreviewSubdomain", { enumerable: true, get: function () { return agent_workflow_js_1.generatePreviewSubdomain; } });
|
|
43
|
-
Object.defineProperty(exports, "generatePreviewUrl", { enumerable: true, get: function () { return agent_workflow_js_1.generatePreviewUrl; } });
|
|
44
|
-
Object.defineProperty(exports, "buildWorkflowInstructions", { enumerable: true, get: function () { return agent_workflow_js_1.buildWorkflowInstructions; } });
|
|
45
|
-
Object.defineProperty(exports, "validateWorkflowConfig", { enumerable: true, get: function () { return agent_workflow_js_1.validateWorkflowConfig; } });
|
|
46
|
-
Object.defineProperty(exports, "logWorkflowConfig", { enumerable: true, get: function () { return agent_workflow_js_1.logWorkflowConfig; } });
|
|
47
|
-
// Vercel Deployment
|
|
48
|
-
var vercel_js_1 = require("./deploy/vercel.js");
|
|
49
|
-
Object.defineProperty(exports, "deployToVercel", { enumerable: true, get: function () { return vercel_js_1.deployToVercel; } });
|
|
50
|
-
Object.defineProperty(exports, "isVercelConfigured", { enumerable: true, get: function () { return vercel_js_1.isVercelConfigured; } });
|
|
51
|
-
// NOTE: Terminal executors have been removed as part of the architecture simplification.
|
|
52
|
-
// External agent runtimes handle execution directly.
|
|
53
|
-
// Channel Plugin (OpenClaw integration)
|
|
54
|
-
var index_js_2 = require("./channel/index.js");
|
|
55
|
-
Object.defineProperty(exports, "AstridChannel", { enumerable: true, get: function () { return index_js_2.AstridChannel; } });
|
|
56
|
-
Object.defineProperty(exports, "SSEClient", { enumerable: true, get: function () { return index_js_2.SSEClient; } });
|
|
57
|
-
Object.defineProperty(exports, "ChannelOAuthClient", { enumerable: true, get: function () { return index_js_2.OAuthClient; } });
|
|
58
|
-
Object.defineProperty(exports, "ChannelRestClient", { enumerable: true, get: function () { return index_js_2.RestClient; } });
|
|
59
|
-
Object.defineProperty(exports, "SessionMapper", { enumerable: true, get: function () { return index_js_2.SessionMapper; } });
|
|
60
|
-
Object.defineProperty(exports, "taskToMessage", { enumerable: true, get: function () { return index_js_2.taskToMessage; } });
|
|
61
|
-
Object.defineProperty(exports, "commentToMessage", { enumerable: true, get: function () { return index_js_2.commentToMessage; } });
|
|
62
|
-
Object.defineProperty(exports, "responseToComment", { enumerable: true, get: function () { return index_js_2.responseToComment; } });
|
|
14
|
+
exports.resolveOrigin = exports.resolveApiBase = exports.USAGE = exports.EXIT = exports.runCli = exports.wakeKeys = exports.decideQueueVerdict = exports.AstridApiError = exports.AstridClient = void 0;
|
|
15
|
+
var client_js_1 = require("./client.js");
|
|
16
|
+
Object.defineProperty(exports, "AstridClient", { enumerable: true, get: function () { return client_js_1.AstridClient; } });
|
|
17
|
+
Object.defineProperty(exports, "AstridApiError", { enumerable: true, get: function () { return client_js_1.AstridApiError; } });
|
|
18
|
+
var verdict_js_1 = require("./verdict.js");
|
|
19
|
+
Object.defineProperty(exports, "decideQueueVerdict", { enumerable: true, get: function () { return verdict_js_1.decideQueueVerdict; } });
|
|
20
|
+
Object.defineProperty(exports, "wakeKeys", { enumerable: true, get: function () { return verdict_js_1.wakeKeys; } });
|
|
21
|
+
var cli_js_1 = require("./cli.js");
|
|
22
|
+
Object.defineProperty(exports, "runCli", { enumerable: true, get: function () { return cli_js_1.runCli; } });
|
|
23
|
+
Object.defineProperty(exports, "EXIT", { enumerable: true, get: function () { return cli_js_1.EXIT; } });
|
|
24
|
+
Object.defineProperty(exports, "USAGE", { enumerable: true, get: function () { return cli_js_1.USAGE; } });
|
|
25
|
+
var api_base_js_1 = require("./config/api-base.js");
|
|
26
|
+
Object.defineProperty(exports, "resolveApiBase", { enumerable: true, get: function () { return api_base_js_1.resolveApiBase; } });
|
|
27
|
+
Object.defineProperty(exports, "resolveOrigin", { enumerable: true, get: function () { return api_base_js_1.resolveOrigin; } });
|
|
63
28
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,yCAKoB;AAJlB,yGAAA,YAAY,OAAA;AACZ,2GAAA,cAAc,OAAA;AAqBhB,2CAQqB;AAPnB,gHAAA,kBAAkB,OAAA;AAClB,sGAAA,QAAQ,OAAA;AAQV,mCAA0D;AAAjD,gGAAA,MAAM,OAAA;AAAE,8FAAA,IAAI,OAAA;AAAE,+FAAA,KAAK,OAAA;AAE5B,oDAAoE;AAA3D,6GAAA,cAAc,OAAA;AAAE,4GAAA,aAAa,OAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire types for the agent endpoints the client calls. Each mirrors a server
|
|
3
|
+
* contract in astrid-web; the client adds no fields of its own.
|
|
4
|
+
*/
|
|
5
|
+
import type { QueueSnapshot } from './verdict.js';
|
|
6
|
+
/** `GET /api/v1/agent-queue`. The verdict reads a subset; the rest passes through. */
|
|
7
|
+
export interface AgentQueueResponse extends QueueSnapshot {
|
|
8
|
+
/** `polling` or `webhook`/hosted: how the server delivers this agent's work. */
|
|
9
|
+
mode?: string;
|
|
10
|
+
truncated?: boolean;
|
|
11
|
+
/** Why the server would wake a run; absent on older servers. */
|
|
12
|
+
runnable?: {
|
|
13
|
+
reasons?: string[];
|
|
14
|
+
incomplete?: boolean;
|
|
15
|
+
} | null;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
export interface AgentQueueQuery {
|
|
19
|
+
/** Mailbox, e.g. `claude`, or a Custom Agent address. */
|
|
20
|
+
agent: string;
|
|
21
|
+
listId?: string;
|
|
22
|
+
/** Count unassigned Ready tasks as queued work too (the /fixall rule). */
|
|
23
|
+
includeUnassigned?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** `POST /api/v1/tasks/:id/claim` (docs/AGENT_CLAIM_API.md). */
|
|
26
|
+
export type ClaimAction = 'claim' | 'resume' | 'release' | 'heartbeat';
|
|
27
|
+
export type ClaimOutcome = 'claimed' | 'already_yours' | 'released'
|
|
28
|
+
/** A heartbeat renewed the claim lease. */
|
|
29
|
+
| 'renewed' | 'conflict' | 'not_ready' | 'not_found' | 'forbidden' | 'binding_denied';
|
|
30
|
+
export interface ClaimTaskSnapshot {
|
|
31
|
+
id: string;
|
|
32
|
+
statusRole: string | null;
|
|
33
|
+
completed: boolean;
|
|
34
|
+
assigneeId: string | null;
|
|
35
|
+
assigneeIds: string[];
|
|
36
|
+
updatedAt: string;
|
|
37
|
+
/** When the claim lease runs out unless renewed; absent from servers without leases. */
|
|
38
|
+
claimLeaseExpiresAt?: string | null;
|
|
39
|
+
}
|
|
40
|
+
export interface ClaimRequest {
|
|
41
|
+
action: ClaimAction;
|
|
42
|
+
/**
|
|
43
|
+
* Confirms an agent-bound token's mailbox; with client credentials, names
|
|
44
|
+
* the agent to claim for. Sent as its local part.
|
|
45
|
+
*/
|
|
46
|
+
agentMailbox?: string;
|
|
47
|
+
/** Lease length in seconds (60–3600) for claim and heartbeat; the server's default (900) when absent. */
|
|
48
|
+
leaseSeconds?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface ClaimResult {
|
|
51
|
+
/** HTTP status. */
|
|
52
|
+
status: number;
|
|
53
|
+
/**
|
|
54
|
+
* The server's outcome, or `unavailable` when the route is absent (a server
|
|
55
|
+
* older than the claim API, or one that still gates it behind a flag).
|
|
56
|
+
*/
|
|
57
|
+
outcome: ClaimOutcome | 'unavailable';
|
|
58
|
+
task: ClaimTaskSnapshot | null;
|
|
59
|
+
}
|
|
60
|
+
/** `POST /api/v1/tasks/:id/claim-fixall`: Astrid's own allowlisted boards and harnesses. */
|
|
61
|
+
export type FixallClaimAction = 'ready' | 'resume' | 'pause';
|
|
62
|
+
export interface FixallClaimRequest {
|
|
63
|
+
action: FixallClaimAction;
|
|
64
|
+
/** The harness mailbox; the server defaults to copilot when absent. */
|
|
65
|
+
agent?: string;
|
|
66
|
+
listId?: string;
|
|
67
|
+
/** Required by resume and pause; must be null for a ready claim. */
|
|
68
|
+
commentWatermark?: string | null;
|
|
69
|
+
/** Resume context, passed through as the server validates it. */
|
|
70
|
+
resume?: unknown;
|
|
71
|
+
}
|
|
72
|
+
export interface FixallClaimResult {
|
|
73
|
+
status: number;
|
|
74
|
+
claimed: boolean;
|
|
75
|
+
/** The server's reason on a refusal: a lost race and a missing agent account are both 409. */
|
|
76
|
+
error?: string;
|
|
77
|
+
assigneeEmail?: string;
|
|
78
|
+
}
|
|
79
|
+
export interface AstridTask {
|
|
80
|
+
id: string;
|
|
81
|
+
identifier?: string | null;
|
|
82
|
+
title: string;
|
|
83
|
+
description?: string | null;
|
|
84
|
+
statusRole?: string | null;
|
|
85
|
+
completed?: boolean;
|
|
86
|
+
assigneeId?: string | null;
|
|
87
|
+
assigneeIds?: string[];
|
|
88
|
+
listIds?: string[];
|
|
89
|
+
updatedAt?: string;
|
|
90
|
+
[key: string]: unknown;
|
|
91
|
+
}
|
|
92
|
+
export interface AstridComment {
|
|
93
|
+
id: string;
|
|
94
|
+
content: string;
|
|
95
|
+
createdAt?: string;
|
|
96
|
+
authorId?: string | null;
|
|
97
|
+
[key: string]: unknown;
|
|
98
|
+
}
|
|
99
|
+
/** Signs a write as an agent (AWTD-1620) instead of the OAuth client's owner. */
|
|
100
|
+
export interface SignedWrite {
|
|
101
|
+
aiAgentId?: string;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD,sFAAsF;AACtF,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACvD,gFAAgF;IAChF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,gEAAgE;IAChE,QAAQ,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAA;IAC9D,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM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client calls. Each mirrors a server
|
|
4
|
+
* contract in astrid-web; the client adds no fields of its own.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|