@notis_ai/cli 0.2.26 → 0.2.27
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/agent-hooks/notis-agent-hook.mjs +82 -12
- package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-spaces/references/context.md +3 -0
- package/dist/sdk/src/components/NotisSelectionBoundary.tsx +79 -25
- package/dist/skill-sync/index.js +81 -11
- package/dist/skill-sync-worker.mjs +87 -12
- package/dist/space-harness/host.js +71 -71
- package/dist/space-sdk/dist/index.js +1 -1
- package/dist/space-sdk/src/components/NotisSelectionBoundary.d.ts +19 -2
- package/dist/space-sdk/src/tailwind-candidates.d.ts +7 -1
- package/dist/view-renderer/dist/host.js +124 -124
- package/dist/view-renderer/src/dom.js +15 -2
- package/package.json +3 -3
- package/skills/notis-cli/AGENT_INSTRUCTIONS.md +1 -1
- package/src/runtime/skill-sync/cloud-client.ts +98 -15
- package/src/runtime/skill-sync/index.ts +22 -3
- package/src/runtime/skill-sync/types.ts +4 -0
- package/src/skill-sync-worker.js +5 -1
|
@@ -62,9 +62,10 @@ export function extractRenderedMarkdown({ baseUrl = document.baseURI } = {}) {
|
|
|
62
62
|
flush();
|
|
63
63
|
return '\n\n' + lines.join('\n') + '\n\n';
|
|
64
64
|
};
|
|
65
|
+
let skipped = null;
|
|
65
66
|
function walk(node) {
|
|
66
67
|
if (node.nodeType === Node.TEXT_NODE) return node.textContent || '';
|
|
67
|
-
if (node.nodeType !== Node.ELEMENT_NODE) return '';
|
|
68
|
+
if (node.nodeType !== Node.ELEMENT_NODE || node === skipped) return '';
|
|
68
69
|
const tag = node.tagName;
|
|
69
70
|
if (['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEMPLATE', 'LINK', 'META'].includes(tag)) return '';
|
|
70
71
|
const semantic = node.getAttribute('data-notis-render');
|
|
@@ -100,7 +101,19 @@ export function extractRenderedMarkdown({ baseUrl = document.baseURI } = {}) {
|
|
|
100
101
|
const content = children(node);
|
|
101
102
|
return ['P', 'DIV', 'SECTION', 'ARTICLE', 'HEADER', 'FOOTER', 'MAIN', 'UL', 'OL', 'FIGURE'].includes(tag) ? '\n\n' + content + '\n\n' : content;
|
|
102
103
|
}
|
|
103
|
-
|
|
104
|
+
const tidy = value => value.replace(/[ \t]+\n/g, '\n').replace(/\n{3,}/g, '\n\n').trim();
|
|
105
|
+
// A link that opens one item of a list (the SDK ListReader's reader) is a link to that item: its
|
|
106
|
+
// Markdown comes first, then the rest of the page. A reader that keeps only the start of a long
|
|
107
|
+
// page (a voice call keeps 12,000 characters) otherwise got the list and never the item.
|
|
108
|
+
const shown = node => {
|
|
109
|
+
for (let current = node; current; current = current.parentElement) if (!visible(current)) return false;
|
|
110
|
+
return node.getClientRects().length > 0;
|
|
111
|
+
};
|
|
112
|
+
const reader = [...document.querySelectorAll('.nui-lr-reader-body')].find(shown);
|
|
113
|
+
if (!reader) return tidy(walk(document.body));
|
|
114
|
+
const item = walk(reader);
|
|
115
|
+
skipped = reader;
|
|
116
|
+
return tidy(item + '\n\n' + walk(document.body));
|
|
104
117
|
}
|
|
105
118
|
|
|
106
119
|
/** Bounded capture expands clipped content; no 1500px crop or hidden inner scroll tail. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@notis_ai/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.27",
|
|
4
4
|
"description": "Agent-first Notis CLI for Spaces, Skills and generic tool execution",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"react-dom": "19.3.0"
|
|
53
53
|
},
|
|
54
54
|
"notisRelease": {
|
|
55
|
-
"sourceSha": "
|
|
55
|
+
"sourceSha": "7fda8d9020cc8bd18b3698e1ca4eb134d399b157",
|
|
56
56
|
"channel": "stable"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "7fda8d9020cc8bd18b3698e1ca4eb134d399b157"
|
|
59
59
|
}
|
|
@@ -29,7 +29,7 @@ Call these with `notis tools exec <TOOL>` (add `--get-schema` first when you nee
|
|
|
29
29
|
[
|
|
30
30
|
{
|
|
31
31
|
"name": "LOCAL_NOTIS_LOAD_CONVERSATION_HISTORY",
|
|
32
|
-
"description": "Read the current or specified owned topical conversation, including user replies, sent messages, attachments, saved voice transcripts with speaker roles and delivery state. Use LOCAL_NOTIS_SEARCH_THREADS to find another conversation when its thread_id is unknown. Raw provider payloads and developer/tool internals are not returned. Omit after and limit for full history; pass limit (1–200) to page from the start, then reuse next_cursor as after. Cursor reads default to 50 records and return immediately, even when empty. Merge records by record_id, replacing that record’s items on each revision; removed records delete prior items. Full reads and the first page (no after) also return agents, one entry per agent that worked in the thread: agent_id, name, provider (notis, codex or claude), intelligence, status, first_run_at, last_run_at, runs, skills it loaded, the interaction_ids it handled and a one-line last_result; read one agent's full work with LOCAL_NOTIS_LOAD_AGENT_CONTEXT. Cursor reads (after) omit agents. Reads are independent and never consume another agent’s replies. Poll as often as your task needs; sending is always a separate explicit action."
|
|
32
|
+
"description": "Read the current or specified owned topical conversation, including user replies, sent messages, attachments, saved voice transcripts with speaker roles and delivery state. Use LOCAL_NOTIS_SEARCH_THREADS to find another conversation when its thread_id is unknown. Raw provider payloads and developer/tool internals are not returned. Omit after and limit for full history; pass limit (1–200) to page from the start, then reuse next_cursor as after. To read what a conversation says now, pass latest (1–200) alone: the newest messages first, without change records. Cursor reads default to 50 records and return immediately, even when empty. Merge records by record_id, replacing that record’s items on each revision; removed records delete prior items. Full reads and the first page (no after) also return agents, one entry per agent that worked in the thread: agent_id, name, provider (notis, codex or claude), intelligence, status, first_run_at, last_run_at, runs, skills it loaded, the interaction_ids it handled and a one-line last_result; read one agent's full work with LOCAL_NOTIS_LOAD_AGENT_CONTEXT. Cursor reads (after) omit agents. Reads are independent and never consume another agent’s replies. Poll as often as your task needs; sending is always a separate explicit action."
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
"name": "LOCAL_NOTIS_LOAD_AGENT_CONTEXT",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { captureNativeSkillFiles, createSkillBundleBase64 } from './local-scanner';
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { checkedNativeReference } from './native-identity';
|
|
4
|
-
import type { AgentTargets, LocalSkill, NativeSkillReference, SyncPullResponse, SyncPushResponse, SyncSettings } from './types';
|
|
4
|
+
import type { AgentTargets, LocalSkill, NativeSkillReference, SkillSyncFailure, SyncPullResponse, SyncPushResponse, SyncSettings } from './types';
|
|
5
5
|
|
|
6
6
|
type JsonBody = Record<string, unknown> | undefined;
|
|
7
7
|
|
|
@@ -22,12 +22,33 @@ async function requestJson<T>(
|
|
|
22
22
|
|
|
23
23
|
if (!response.ok) {
|
|
24
24
|
const text = await response.text();
|
|
25
|
-
throw new
|
|
25
|
+
throw new SkillSyncHttpError(
|
|
26
|
+
`${options.method || 'POST'} ${url} → ${response.status}: ${text}`,
|
|
27
|
+
response.status,
|
|
28
|
+
response.headers.get('content-type'),
|
|
29
|
+
);
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
return response.json() as Promise<T>;
|
|
29
33
|
}
|
|
30
34
|
|
|
35
|
+
/**
|
|
36
|
+
* A non-2xx answer, classified so a status can be recorded without its body:
|
|
37
|
+
* `edge_blocked` for an HTML 403 (the edge in front of the API refused the
|
|
38
|
+
* request before it reached Notis), `http_<status>` otherwise.
|
|
39
|
+
*/
|
|
40
|
+
export class SkillSyncHttpError extends Error {
|
|
41
|
+
readonly status: number;
|
|
42
|
+
readonly code: string;
|
|
43
|
+
|
|
44
|
+
constructor(message: string, status: number, contentType: string | null) {
|
|
45
|
+
super(message);
|
|
46
|
+
this.name = 'SkillSyncHttpError';
|
|
47
|
+
this.status = status;
|
|
48
|
+
this.code = status === 403 && /text\/html/i.test(contentType || '') ? 'edge_blocked' : `http_${status}`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
31
52
|
export async function fetchSyncSettings(serverUrl: string, jwt: string): Promise<SyncSettings> {
|
|
32
53
|
return requestJson<SyncSettings>(`${serverUrl}/portal_skills/sync-settings`, jwt, {
|
|
33
54
|
body: {},
|
|
@@ -40,12 +61,11 @@ export async function pullSkills(serverUrl: string, jwt: string): Promise<SyncPu
|
|
|
40
61
|
});
|
|
41
62
|
}
|
|
42
63
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const payloadSkills = await Promise.all(changedSkills.map(async (skill) => ({
|
|
64
|
+
/** Largest sync-push body sent at once; a single larger skill goes alone. */
|
|
65
|
+
export const MAX_SYNC_PUSH_BODY_BYTES = 2 * 1024 * 1024;
|
|
66
|
+
|
|
67
|
+
async function skillPushPayload(skill: LocalSkill): Promise<Record<string, unknown>> {
|
|
68
|
+
return {
|
|
49
69
|
name: skill.name,
|
|
50
70
|
description: skill.description,
|
|
51
71
|
skill_md: skill.skillMd,
|
|
@@ -56,14 +76,77 @@ export async function pushChangedSkills(
|
|
|
56
76
|
...(skill.cloudId ? { cloud_id: skill.cloudId } : {}),
|
|
57
77
|
...(skill.nativeReference ? { native_reference: skill.nativeReference, display_name: skill.displayName,
|
|
58
78
|
native_scope: skill.nativeScope } : {}),
|
|
59
|
-
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
60
81
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
82
|
+
/** The request body around the skills array, counted in every batch's size. */
|
|
83
|
+
const SYNC_PUSH_ENVELOPE_BYTES = Buffer.byteLength(JSON.stringify({ skill_sync_protocol: 2, skills: [] }));
|
|
84
|
+
|
|
85
|
+
function pushBatches(payloads: Record<string, unknown>[], maxBodyBytes: number): Record<string, unknown>[][] {
|
|
86
|
+
const batches: Record<string, unknown>[][] = [];
|
|
87
|
+
let batch: Record<string, unknown>[] = [];
|
|
88
|
+
let batchBytes = SYNC_PUSH_ENVELOPE_BYTES;
|
|
89
|
+
for (const payload of payloads) {
|
|
90
|
+
// +1 for the comma between array items.
|
|
91
|
+
const bytes = Buffer.byteLength(JSON.stringify(payload)) + 1;
|
|
92
|
+
if (batch.length > 0 && batchBytes + bytes > maxBodyBytes) {
|
|
93
|
+
batches.push(batch);
|
|
94
|
+
batch = [];
|
|
95
|
+
batchBytes = SYNC_PUSH_ENVELOPE_BYTES;
|
|
96
|
+
}
|
|
97
|
+
batch.push(payload);
|
|
98
|
+
batchBytes += bytes;
|
|
99
|
+
}
|
|
100
|
+
if (batch.length > 0) batches.push(batch);
|
|
101
|
+
return batches;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function pushFailure(name: string, error: unknown): SkillSyncFailure {
|
|
105
|
+
if (error instanceof SkillSyncHttpError) {
|
|
106
|
+
return {
|
|
107
|
+
name,
|
|
108
|
+
error: error.code === 'edge_blocked'
|
|
109
|
+
? `Upload blocked before reaching Notis (HTTP ${error.status}); sync will retry`
|
|
110
|
+
: `Upload failed (HTTP ${error.status}); sync will retry`,
|
|
111
|
+
status: error.status,
|
|
112
|
+
code: error.code,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const code = typeof (error as { code?: unknown })?.code === 'string' ? (error as { code: string }).code : 'push_failed';
|
|
116
|
+
return { name, error: 'Upload failed; sync will retry', code };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Push changed skills in bodies of at most `maxBodyBytes` (one skill when it is
|
|
121
|
+
* larger alone). A batch the server or the edge refuses fails only its own skills,
|
|
122
|
+
* recorded with the HTTP status, and the other batches still push.
|
|
123
|
+
*/
|
|
124
|
+
export async function pushChangedSkills(
|
|
125
|
+
serverUrl: string,
|
|
126
|
+
jwt: string,
|
|
127
|
+
changedSkills: LocalSkill[],
|
|
128
|
+
options: { maxBodyBytes?: number } = {},
|
|
129
|
+
): Promise<SyncPushResponse> {
|
|
130
|
+
const payloadSkills = await Promise.all(changedSkills.map(skillPushPayload));
|
|
131
|
+
const saved: unknown[] = [];
|
|
132
|
+
const failed: SkillSyncFailure[] = [];
|
|
133
|
+
for (const batch of pushBatches(payloadSkills, options.maxBodyBytes ?? MAX_SYNC_PUSH_BODY_BYTES)) {
|
|
134
|
+
try {
|
|
135
|
+
const result = await requestJson<SyncPushResponse>(`${serverUrl}/portal_skills/sync-push`, jwt, {
|
|
136
|
+
body: {
|
|
137
|
+
skill_sync_protocol: 2,
|
|
138
|
+
skills: batch,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
saved.push(...(result.skills || []));
|
|
142
|
+
if (Array.isArray(result.failed)) failed.push(...result.failed);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
// A rejected sign-in fails every batch alike: stop and let the sync report it.
|
|
145
|
+
if (error instanceof SkillSyncHttpError && error.status === 401) throw error;
|
|
146
|
+
for (const payload of batch) failed.push(pushFailure(String(payload.name), error));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return { skills: saved, ...(failed.length ? { failed } : {}) };
|
|
67
150
|
}
|
|
68
151
|
|
|
69
152
|
export async function downloadSkillBundle(bundleUrl: string): Promise<Buffer> {
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
} from "./symlink-manager";
|
|
41
41
|
import { getPushCandidates, selectCloudSkillsToApply } from "./sync-plan";
|
|
42
42
|
import { writeCloudSkillWithBundleFallback } from "./write-cloud-skill";
|
|
43
|
-
export { fetchSyncSettings } from './cloud-client';
|
|
43
|
+
export { fetchSyncSettings, pushChangedSkills } from './cloud-client';
|
|
44
44
|
|
|
45
45
|
export interface RunSkillSyncResult {
|
|
46
46
|
syncEnabled: boolean;
|
|
@@ -403,6 +403,25 @@ function buildSyncState(
|
|
|
403
403
|
});
|
|
404
404
|
}
|
|
405
405
|
|
|
406
|
+
/**
|
|
407
|
+
* A local edit whose upload failed keeps the previously synced folder hash, so the
|
|
408
|
+
* next sync still sees it as changed and pushes it again instead of recording the
|
|
409
|
+
* unsent edit as synced.
|
|
410
|
+
*/
|
|
411
|
+
function keepFailedPushesPending(
|
|
412
|
+
state: NotisSyncState,
|
|
413
|
+
previousState: NotisSyncState,
|
|
414
|
+
failedPushes: readonly SkillSyncFailure[],
|
|
415
|
+
): NotisSyncState {
|
|
416
|
+
for (const { name } of failedPushes) {
|
|
417
|
+
const row = state.skills[name];
|
|
418
|
+
const previous = previousState.skills[name];
|
|
419
|
+
if (!row || !previous || row.nativeReference || previous.nativeReference) continue;
|
|
420
|
+
state.skills[name] = { ...row, folderHash: previous.folderHash };
|
|
421
|
+
}
|
|
422
|
+
return state;
|
|
423
|
+
}
|
|
424
|
+
|
|
406
425
|
function buildLocalSymlinkCandidates(
|
|
407
426
|
pullResponse: SyncPullResponse,
|
|
408
427
|
localSkills: LocalSkill[],
|
|
@@ -968,7 +987,7 @@ export async function runSkillSync(
|
|
|
968
987
|
const lastSyncedAt = pullResponse.last_synced_at || new Date().toISOString();
|
|
969
988
|
|
|
970
989
|
await deps.writeSyncState(
|
|
971
|
-
buildSyncState(
|
|
990
|
+
keepFailedPushesPending(buildSyncState(
|
|
972
991
|
pullResponse,
|
|
973
992
|
finalLocalSkills,
|
|
974
993
|
lastSyncedAt,
|
|
@@ -977,7 +996,7 @@ export async function runSkillSync(
|
|
|
977
996
|
collectAppliedCloudRevisions(pullResponse, previousState, writtenSkillNames),
|
|
978
997
|
collectAppliedFiles(pullResponse, previousState, appliedFilesByName),
|
|
979
998
|
previousState,
|
|
980
|
-
),
|
|
999
|
+
), previousState, failedPushes),
|
|
981
1000
|
syncPaths,
|
|
982
1001
|
);
|
|
983
1002
|
|
|
@@ -135,6 +135,10 @@ export interface SyncPullResponse {
|
|
|
135
135
|
export interface SkillSyncFailure {
|
|
136
136
|
name: string;
|
|
137
137
|
error: string;
|
|
138
|
+
/** HTTP status of a refused upload, when the push itself was answered non-2xx. */
|
|
139
|
+
status?: number;
|
|
140
|
+
/** Classified cause (e.g. `edge_blocked`, `http_413`); never a response body. */
|
|
141
|
+
code?: string;
|
|
138
142
|
}
|
|
139
143
|
|
|
140
144
|
export interface SyncPushResponse {
|
package/src/skill-sync-worker.js
CHANGED
|
@@ -106,7 +106,11 @@ export async function main(args = process.argv.slice(2), {
|
|
|
106
106
|
} catch (error) {
|
|
107
107
|
// Persist only a classified error, never a bearer, signed URL or response body.
|
|
108
108
|
const code = error.code || 'sync_failed';
|
|
109
|
-
|
|
109
|
+
// An HTTP refusal keeps its status, e.g. `edge_blocked` with 403 when the
|
|
110
|
+
// edge in front of the API refused the request before it reached Notis.
|
|
111
|
+
const httpStatus = Number.isInteger(error.status) ? { http_status: error.status } : {};
|
|
112
|
+
record({ status: 'error', code, ...httpStatus,
|
|
113
|
+
...(REJECTED_SIGN_IN_CODES.has(code) && signIn ? { sign_in: signIn } : {}) });
|
|
110
114
|
process.exitCode = 1;
|
|
111
115
|
} finally {
|
|
112
116
|
clearTimeout(deadline);
|