pi-cursor-sdk 0.5.3 → 0.5.5
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/CHANGELOG.md +61 -1
- package/README.md +62 -816
- package/dist/context.js +11 -5
- package/dist/cursor-agents-context.js +6 -6
- package/dist/cursor-api-key.js +1 -1
- package/dist/cursor-bridge-contract.js +1 -13
- package/dist/cursor-cloud-local-state.js +0 -1
- package/dist/cursor-config.js +1 -17
- package/dist/cursor-fallback-models.generated.js +424 -1
- package/dist/cursor-live-run-coordinator.js +1 -0
- package/dist/cursor-local-run-terminal-error.js +57 -0
- package/dist/cursor-mcp-timeout-override.js +6 -17
- package/dist/cursor-native-tool-display-replay.js +5 -5
- package/dist/cursor-native-tools.js +11 -0
- package/dist/cursor-pi-tool-bridge-env.js +25 -2
- package/dist/cursor-pi-tool-bridge-server.js +98 -48
- package/dist/cursor-pi-tool-bridge-snapshot.js +1 -1
- package/dist/cursor-pi-tool-bridge.js +4 -12
- package/dist/cursor-provider-errors.js +0 -6
- package/dist/cursor-provider-live-run-drain.js +8 -3
- package/dist/cursor-provider-overflow.js +7 -21
- package/dist/cursor-provider-turn-finalize.js +2 -0
- package/dist/cursor-provider-turn-prepare.js +8 -1
- package/dist/cursor-provider-turn-runner.js +17 -6
- package/dist/cursor-provider-turn-send.js +3 -0
- package/dist/cursor-provider.js +1 -4
- package/dist/cursor-runtime-state.js +3 -3
- package/dist/cursor-sdk-event-debug.js +2 -2
- package/dist/cursor-sdk-output-filter.js +1 -1
- package/dist/cursor-sdk-process-error-guard.js +1 -2
- package/dist/cursor-session-agent.js +6 -8
- package/dist/cursor-session-scope.js +1 -7
- package/dist/cursor-session-store.js +3 -2
- package/dist/cursor-state.js +9 -23
- package/dist/cursor-tool-lifecycle.js +0 -3
- package/dist/cursor-tool-manifest.js +3 -1
- package/dist/cursor-tool-presentation-registry.js +2 -4
- package/dist/cursor-tool-visibility.js +0 -3
- package/dist/cursor-transcript-tool-specs.js +1 -2
- package/dist/index.js +21 -0
- package/dist/model-discovery.js +0 -1
- package/dist/model-list-cache.js +4 -9
- package/docs/cursor-live-smoke-checklist.md +4 -4
- package/docs/cursor-model-ux-spec.md +18 -8
- package/docs/cursor-native-tool-replay.md +2 -2
- package/docs/cursor-native-tool-visual-audit.md +1 -1
- package/docs/cursor-testing-lessons.md +22 -4
- package/docs/cursor-tool-surfaces.md +32 -3
- package/docs/development.md +101 -0
- package/docs/platform-smoke-implementation.md +3 -2
- package/docs/reference.md +810 -0
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/package.json +1 -1
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/src/v4/core/compile.ts +9 -0
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/src/v4/core/schemas.ts +35 -1
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/src/v4/core/util.ts +13 -0
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/src/v4/core/versions.ts +1 -1
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/schemas.d.cts +3 -1
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/schemas.d.ts +3 -1
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/util.d.cts +2 -0
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/util.d.ts +2 -0
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/@modelcontextprotocol/core/node_modules/zod/v4/core/versions.js +1 -1
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/package.json +1 -1
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/src/v4/core/compile.ts +9 -0
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/src/v4/core/schemas.ts +35 -1
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/src/v4/core/util.ts +13 -0
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/src/v4/core/versions.ts +1 -1
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/schemas.d.cts +3 -1
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/schemas.d.ts +3 -1
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/util.d.cts +2 -0
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/util.d.ts +2 -0
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/@modelcontextprotocol/server/node_modules/zod/v4/core/versions.js +1 -1
- package/package.json +14 -6
- package/scripts/platform-smoke/artifact-secrets.mjs +13 -4
- package/scripts/platform-smoke/local-resume-runner.mjs +0 -1
- package/scripts/platform-smoke/target-runtime.mjs +4 -2
- package/scripts/platform-smoke/targets.mjs +0 -1
- package/scripts/steering-rpc-smoke.mjs +1 -1
- package/shared/cursor-sdk-output-filter.d.mts +2 -0
- package/shared/cursor-sdk-output-filter.mjs +92 -28
- package/shared/cursor-sensitive-text.d.mts +1 -0
- package/shared/cursor-sensitive-text.mjs +7 -0
- package/src/context.ts +16 -9
- package/src/cursor-agents-context.ts +6 -6
- package/src/cursor-api-key.ts +1 -1
- package/src/cursor-bridge-contract.ts +1 -15
- package/src/cursor-cloud-local-state.ts +0 -2
- package/src/cursor-config.ts +1 -24
- package/src/cursor-fallback-models.generated.ts +424 -1
- package/src/cursor-live-run-coordinator.ts +5 -0
- package/src/cursor-local-run-terminal-error.ts +58 -0
- package/src/cursor-mcp-timeout-override.ts +6 -30
- package/src/cursor-native-tool-display-replay.ts +4 -6
- package/src/cursor-native-tools.ts +14 -0
- package/src/cursor-pi-tool-bridge-env.ts +31 -2
- package/src/cursor-pi-tool-bridge-server.ts +89 -45
- package/src/cursor-pi-tool-bridge-snapshot.ts +0 -1
- package/src/cursor-pi-tool-bridge.ts +2 -18
- package/src/cursor-provider-errors.ts +0 -8
- package/src/cursor-provider-live-run-drain.ts +8 -2
- package/src/cursor-provider-overflow.ts +6 -24
- package/src/cursor-provider-turn-finalize.ts +2 -0
- package/src/cursor-provider-turn-prepare.ts +10 -1
- package/src/cursor-provider-turn-runner.ts +17 -6
- package/src/cursor-provider-turn-send.ts +2 -0
- package/src/cursor-provider.ts +0 -5
- package/src/cursor-runtime-state.ts +3 -3
- package/src/cursor-sdk-event-debug.ts +2 -2
- package/src/cursor-sdk-output-filter.ts +2 -1
- package/src/cursor-sdk-process-error-guard.ts +1 -3
- package/src/cursor-session-agent.ts +8 -8
- package/src/cursor-session-scope.ts +1 -9
- package/src/cursor-session-store.ts +3 -2
- package/src/cursor-state.ts +9 -36
- package/src/cursor-tool-lifecycle.ts +0 -4
- package/src/cursor-tool-manifest.ts +4 -1
- package/src/cursor-tool-presentation-registry.ts +3 -5
- package/src/cursor-tool-visibility.ts +0 -4
- package/src/cursor-transcript-tool-specs.ts +0 -3
- package/src/index.ts +18 -0
- package/src/model-discovery.ts +0 -1
- package/src/model-list-cache.ts +4 -10
|
@@ -1844,6 +1844,34 @@ export interface $ZodArrayInternals<T extends SomeType = $ZodType> extends _$Zod
|
|
|
1844
1844
|
|
|
1845
1845
|
export interface $ZodArray<T extends SomeType = $ZodType> extends $ZodType<any, any, $ZodArrayInternals<T>> {}
|
|
1846
1846
|
|
|
1847
|
+
// an oversized container fails its leading size checks before any element is parsed
|
|
1848
|
+
function capSize(inst: $ZodType, size: (input: any) => number): void {
|
|
1849
|
+
const caps = util.sizeCaps(inst._zod.def.checks);
|
|
1850
|
+
if (!caps.length) return;
|
|
1851
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
1852
|
+
const parse = inst._zod.parse;
|
|
1853
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1854
|
+
const n = size(payload.value);
|
|
1855
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
1856
|
+
for (const [max, ch] of util.sizeCaps(inst._zod.def.checks)) {
|
|
1857
|
+
if (n > max && ch._zod.def.when!(payload)) {
|
|
1858
|
+
const start = payload.issues.length;
|
|
1859
|
+
ch._zod.check(payload as ParsePayload<never>);
|
|
1860
|
+
// the value is still the raw input, so no later check may read it
|
|
1861
|
+
(payload.issues[start] as { continue?: boolean }).continue = false;
|
|
1862
|
+
util.attachSchema(payload.issues, start, inst);
|
|
1863
|
+
return payload;
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
return parse(payload, ctx);
|
|
1868
|
+
};
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
const arraySize = (input: unknown): number => (Array.isArray(input) ? input.length : -1);
|
|
1872
|
+
const mapSize = (input: unknown): number => (input instanceof Map ? input.size : -1);
|
|
1873
|
+
const setSize = (input: unknown): number => (input instanceof Set ? input.size : -1);
|
|
1874
|
+
|
|
1847
1875
|
function handleArrayResult(result: ParsePayload<any>, final: ParsePayload<any[]>, index: number) {
|
|
1848
1876
|
if (result.issues.length) {
|
|
1849
1877
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
@@ -1899,6 +1927,7 @@ export const $ZodArray: core.$constructor<$ZodArray> = /*@__PURE__*/ core.$const
|
|
|
1899
1927
|
|
|
1900
1928
|
return payload; //handleArrayResultsAsync(parseResults, final);
|
|
1901
1929
|
};
|
|
1930
|
+
capSize(inst, arraySize);
|
|
1902
1931
|
});
|
|
1903
1932
|
|
|
1904
1933
|
//////////////////////////////////////////
|
|
@@ -3218,8 +3247,11 @@ export type $InferZodRecordInput<
|
|
|
3218
3247
|
: Record<core.input<Key> & PropertyKey, core.input<Value>>;
|
|
3219
3248
|
|
|
3220
3249
|
export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
|
|
3221
|
-
extends $ZodTypeInternals
|
|
3250
|
+
extends $ZodTypeInternals {
|
|
3222
3251
|
def: $ZodRecordDef<Key, Value>;
|
|
3252
|
+
// members rather than base type arguments, which TypeScript 7.1 reports as circular for `z.json()`
|
|
3253
|
+
output: $InferZodRecordOutput<Key, Value>;
|
|
3254
|
+
input: $InferZodRecordInput<Key, Value>;
|
|
3223
3255
|
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
|
|
3224
3256
|
optin?: "optional" | undefined;
|
|
3225
3257
|
optout?: "optional" | undefined;
|
|
@@ -3480,6 +3512,7 @@ export const $ZodMap: core.$constructor<$ZodMap> = /*@__PURE__*/ core.$construct
|
|
|
3480
3512
|
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
3481
3513
|
return payload;
|
|
3482
3514
|
};
|
|
3515
|
+
capSize(inst, mapSize);
|
|
3483
3516
|
});
|
|
3484
3517
|
|
|
3485
3518
|
function handleMapResult(
|
|
@@ -3582,6 +3615,7 @@ export const $ZodSet: core.$constructor<$ZodSet> = /*@__PURE__*/ core.$construct
|
|
|
3582
3615
|
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
3583
3616
|
return payload;
|
|
3584
3617
|
};
|
|
3618
|
+
capSize(inst, setSize);
|
|
3585
3619
|
});
|
|
3586
3620
|
|
|
3587
3621
|
function handleSetResult(result: ParsePayload, final: ParsePayload<Set<any>>) {
|
|
@@ -935,6 +935,19 @@ export function unwrapMessage(message: string | { message: string } | undefined
|
|
|
935
935
|
}
|
|
936
936
|
|
|
937
937
|
/* A check holds no link back to the schema it is attached to — the same check instance is shared by every clone of that schema — so the owner is stamped onto the issues a check just raised, at the only point where both are in scope. Runs on the failure path only; `start` is the issue count from before the check ran. */
|
|
938
|
+
/** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
|
|
939
|
+
export function sizeCaps(defChecks: checks.$ZodCheck<never>[] | undefined): [number, checks.$ZodCheck<never>][] {
|
|
940
|
+
const caps: [number, checks.$ZodCheck<never>][] = [];
|
|
941
|
+
for (const ch of defChecks ?? []) {
|
|
942
|
+
const d = ch._zod.def as any;
|
|
943
|
+
// a later check may rewrite the value
|
|
944
|
+
if (!/_(length|size)$|_equals$/.test(d.check)) break;
|
|
945
|
+
const max = d.maximum ?? d.length ?? d.size;
|
|
946
|
+
if (max >= 0) caps.push([max, ch]);
|
|
947
|
+
}
|
|
948
|
+
return caps;
|
|
949
|
+
}
|
|
950
|
+
|
|
938
951
|
export function attachSchema(issues: errors.$ZodRawIssue[], start: number, inst: schemas.$ZodType): void {
|
|
939
952
|
for (let i = start; i < issues.length; i++) {
|
|
940
953
|
(issues[i] as any).schema ??= inst;
|
|
@@ -1241,9 +1241,15 @@ function generateNullableCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
1241
1241
|
doc.write(`}`);
|
|
1242
1242
|
return outputVar;
|
|
1243
1243
|
}
|
|
1244
|
+
function generateSizeGate(doc, schema, size) {
|
|
1245
|
+
for (const [max, check] of util.sizeCaps(schema._zod.def.checks)) {
|
|
1246
|
+
doc.write(`if (${size} > ${numericOperand(max, check._zod.def.check)}) return INVALID;`);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1244
1249
|
function generateArrayCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
1245
1250
|
const def = schema._zod.def;
|
|
1246
1251
|
doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
|
|
1252
|
+
generateSizeGate(doc, schema, `${accessor}.length`);
|
|
1247
1253
|
// Build a new array with validated/transformed elements.
|
|
1248
1254
|
const outputVar = buildsValue ? newVar(ctx) : null;
|
|
1249
1255
|
const iVar = newVar(ctx);
|
|
@@ -1707,6 +1713,7 @@ function literalPropertyKey(ctx, key) {
|
|
|
1707
1713
|
function generateMapCheck(doc, ctx, schema, accessor) {
|
|
1708
1714
|
const def = schema._zod.def;
|
|
1709
1715
|
doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
|
|
1716
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
1710
1717
|
const outputVar = newVar(ctx);
|
|
1711
1718
|
const kVar = newVar(ctx);
|
|
1712
1719
|
const valVar = newVar(ctx);
|
|
@@ -1723,6 +1730,7 @@ function generateMapCheck(doc, ctx, schema, accessor) {
|
|
|
1723
1730
|
function generateSetCheck(doc, ctx, schema, accessor) {
|
|
1724
1731
|
const def = schema._zod.def;
|
|
1725
1732
|
doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
|
|
1733
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
1726
1734
|
const outputVar = newVar(ctx);
|
|
1727
1735
|
const valVar = newVar(ctx);
|
|
1728
1736
|
doc.write(`const ${outputVar} = new Set();`);
|
|
@@ -1210,9 +1210,15 @@ function generateNullableCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
1210
1210
|
doc.write(`}`);
|
|
1211
1211
|
return outputVar;
|
|
1212
1212
|
}
|
|
1213
|
+
function generateSizeGate(doc, schema, size) {
|
|
1214
|
+
for (const [max, check] of util.sizeCaps(schema._zod.def.checks)) {
|
|
1215
|
+
doc.write(`if (${size} > ${numericOperand(max, check._zod.def.check)}) return INVALID;`);
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1213
1218
|
function generateArrayCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
1214
1219
|
const def = schema._zod.def;
|
|
1215
1220
|
doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
|
|
1221
|
+
generateSizeGate(doc, schema, `${accessor}.length`);
|
|
1216
1222
|
// Build a new array with validated/transformed elements.
|
|
1217
1223
|
const outputVar = buildsValue ? newVar(ctx) : null;
|
|
1218
1224
|
const iVar = newVar(ctx);
|
|
@@ -1676,6 +1682,7 @@ function literalPropertyKey(ctx, key) {
|
|
|
1676
1682
|
function generateMapCheck(doc, ctx, schema, accessor) {
|
|
1677
1683
|
const def = schema._zod.def;
|
|
1678
1684
|
doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
|
|
1685
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
1679
1686
|
const outputVar = newVar(ctx);
|
|
1680
1687
|
const kVar = newVar(ctx);
|
|
1681
1688
|
const valVar = newVar(ctx);
|
|
@@ -1692,6 +1699,7 @@ function generateMapCheck(doc, ctx, schema, accessor) {
|
|
|
1692
1699
|
function generateSetCheck(doc, ctx, schema, accessor) {
|
|
1693
1700
|
const def = schema._zod.def;
|
|
1694
1701
|
doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
|
|
1702
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
1695
1703
|
const outputVar = newVar(ctx);
|
|
1696
1704
|
const valVar = newVar(ctx);
|
|
1697
1705
|
doc.write(`const ${outputVar} = new Set();`);
|
|
@@ -860,6 +860,33 @@ exports.$ZodDate = core.$constructor("$ZodDate", (inst, def) => {
|
|
|
860
860
|
return payload;
|
|
861
861
|
};
|
|
862
862
|
});
|
|
863
|
+
// an oversized container fails its leading size checks before any element is parsed
|
|
864
|
+
function capSize(inst, size) {
|
|
865
|
+
const caps = util.sizeCaps(inst._zod.def.checks);
|
|
866
|
+
if (!caps.length)
|
|
867
|
+
return;
|
|
868
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
869
|
+
const parse = inst._zod.parse;
|
|
870
|
+
inst._zod.parse = (payload, ctx) => {
|
|
871
|
+
const n = size(payload.value);
|
|
872
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
873
|
+
for (const [max, ch] of util.sizeCaps(inst._zod.def.checks)) {
|
|
874
|
+
if (n > max && ch._zod.def.when(payload)) {
|
|
875
|
+
const start = payload.issues.length;
|
|
876
|
+
ch._zod.check(payload);
|
|
877
|
+
// the value is still the raw input, so no later check may read it
|
|
878
|
+
payload.issues[start].continue = false;
|
|
879
|
+
util.attachSchema(payload.issues, start, inst);
|
|
880
|
+
return payload;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
return parse(payload, ctx);
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
const arraySize = (input) => (Array.isArray(input) ? input.length : -1);
|
|
888
|
+
const mapSize = (input) => (input instanceof Map ? input.size : -1);
|
|
889
|
+
const setSize = (input) => (input instanceof Set ? input.size : -1);
|
|
863
890
|
function handleArrayResult(result, final, index) {
|
|
864
891
|
if (result.issues.length) {
|
|
865
892
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
@@ -905,6 +932,7 @@ exports.$ZodArray = core.$constructor("$ZodArray", (inst, def) => {
|
|
|
905
932
|
}
|
|
906
933
|
return payload; //handleArrayResultsAsync(parseResults, final);
|
|
907
934
|
};
|
|
935
|
+
capSize(inst, arraySize);
|
|
908
936
|
});
|
|
909
937
|
function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
910
938
|
const isPresent = key in input;
|
|
@@ -1942,6 +1970,7 @@ exports.$ZodMap = core.$constructor("$ZodMap", (inst, def) => {
|
|
|
1942
1970
|
return Promise.all(proms).then(() => payload);
|
|
1943
1971
|
return payload;
|
|
1944
1972
|
};
|
|
1973
|
+
capSize(inst, mapSize);
|
|
1945
1974
|
});
|
|
1946
1975
|
function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
1947
1976
|
if (keyResult.issues.length) {
|
|
@@ -2011,6 +2040,7 @@ exports.$ZodSet = core.$constructor("$ZodSet", (inst, def) => {
|
|
|
2011
2040
|
return Promise.all(proms).then(() => payload);
|
|
2012
2041
|
return payload;
|
|
2013
2042
|
};
|
|
2043
|
+
capSize(inst, setSize);
|
|
2014
2044
|
});
|
|
2015
2045
|
function handleSetResult(result, final) {
|
|
2016
2046
|
if (result.issues.length) {
|
|
@@ -834,8 +834,10 @@ export type $InferZodRecordOutput<Key extends $ZodRecordKey = $ZodRecordKey, Val
|
|
|
834
834
|
export type $InferZodRecordInput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<core.input<Key> & PropertyKey, core.input<Value>>> : [
|
|
835
835
|
Value
|
|
836
836
|
] extends [OptionalInSchema] ? Partial<Record<core.input<Key> & PropertyKey, core.input<Value>>> : Record<core.input<Key> & PropertyKey, core.input<Value>>;
|
|
837
|
-
export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeInternals
|
|
837
|
+
export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeInternals {
|
|
838
838
|
def: $ZodRecordDef<Key, Value>;
|
|
839
|
+
output: $InferZodRecordOutput<Key, Value>;
|
|
840
|
+
input: $InferZodRecordInput<Key, Value>;
|
|
839
841
|
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
|
|
840
842
|
optin?: "optional" | undefined;
|
|
841
843
|
optout?: "optional" | undefined;
|
|
@@ -834,8 +834,10 @@ export type $InferZodRecordOutput<Key extends $ZodRecordKey = $ZodRecordKey, Val
|
|
|
834
834
|
export type $InferZodRecordInput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<core.input<Key> & PropertyKey, core.input<Value>>> : [
|
|
835
835
|
Value
|
|
836
836
|
] extends [OptionalInSchema] ? Partial<Record<core.input<Key> & PropertyKey, core.input<Value>>> : Record<core.input<Key> & PropertyKey, core.input<Value>>;
|
|
837
|
-
export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeInternals
|
|
837
|
+
export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeInternals {
|
|
838
838
|
def: $ZodRecordDef<Key, Value>;
|
|
839
|
+
output: $InferZodRecordOutput<Key, Value>;
|
|
840
|
+
input: $InferZodRecordInput<Key, Value>;
|
|
839
841
|
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
|
|
840
842
|
optin?: "optional" | undefined;
|
|
841
843
|
optout?: "optional" | undefined;
|
|
@@ -816,6 +816,33 @@ export const $ZodDate = /*@__PURE__*/ core.$constructor("$ZodDate", (inst, def)
|
|
|
816
816
|
return payload;
|
|
817
817
|
};
|
|
818
818
|
});
|
|
819
|
+
// an oversized container fails its leading size checks before any element is parsed
|
|
820
|
+
function capSize(inst, size) {
|
|
821
|
+
const caps = util.sizeCaps(inst._zod.def.checks);
|
|
822
|
+
if (!caps.length)
|
|
823
|
+
return;
|
|
824
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
825
|
+
const parse = inst._zod.parse;
|
|
826
|
+
inst._zod.parse = (payload, ctx) => {
|
|
827
|
+
const n = size(payload.value);
|
|
828
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
829
|
+
for (const [max, ch] of util.sizeCaps(inst._zod.def.checks)) {
|
|
830
|
+
if (n > max && ch._zod.def.when(payload)) {
|
|
831
|
+
const start = payload.issues.length;
|
|
832
|
+
ch._zod.check(payload);
|
|
833
|
+
// the value is still the raw input, so no later check may read it
|
|
834
|
+
payload.issues[start].continue = false;
|
|
835
|
+
util.attachSchema(payload.issues, start, inst);
|
|
836
|
+
return payload;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
return parse(payload, ctx);
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
const arraySize = (input) => (Array.isArray(input) ? input.length : -1);
|
|
844
|
+
const mapSize = (input) => (input instanceof Map ? input.size : -1);
|
|
845
|
+
const setSize = (input) => (input instanceof Set ? input.size : -1);
|
|
819
846
|
function handleArrayResult(result, final, index) {
|
|
820
847
|
if (result.issues.length) {
|
|
821
848
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
@@ -861,6 +888,7 @@ export const $ZodArray = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def
|
|
|
861
888
|
}
|
|
862
889
|
return payload; //handleArrayResultsAsync(parseResults, final);
|
|
863
890
|
};
|
|
891
|
+
capSize(inst, arraySize);
|
|
864
892
|
});
|
|
865
893
|
function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
866
894
|
const isPresent = key in input;
|
|
@@ -1898,6 +1926,7 @@ export const $ZodMap = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) =>
|
|
|
1898
1926
|
return Promise.all(proms).then(() => payload);
|
|
1899
1927
|
return payload;
|
|
1900
1928
|
};
|
|
1929
|
+
capSize(inst, mapSize);
|
|
1901
1930
|
});
|
|
1902
1931
|
function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
1903
1932
|
if (keyResult.issues.length) {
|
|
@@ -1967,6 +1996,7 @@ export const $ZodSet = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) =>
|
|
|
1967
1996
|
return Promise.all(proms).then(() => payload);
|
|
1968
1997
|
return payload;
|
|
1969
1998
|
};
|
|
1999
|
+
capSize(inst, setSize);
|
|
1970
2000
|
});
|
|
1971
2001
|
function handleSetResult(result, final) {
|
|
1972
2002
|
if (result.issues.length) {
|
|
@@ -46,6 +46,7 @@ exports.aborted = aborted;
|
|
|
46
46
|
exports.explicitlyAborted = explicitlyAborted;
|
|
47
47
|
exports.prefixIssues = prefixIssues;
|
|
48
48
|
exports.unwrapMessage = unwrapMessage;
|
|
49
|
+
exports.sizeCaps = sizeCaps;
|
|
49
50
|
exports.attachSchema = attachSchema;
|
|
50
51
|
exports.finalizeIssue = finalizeIssue;
|
|
51
52
|
exports.getSizableOrigin = getSizableOrigin;
|
|
@@ -620,6 +621,20 @@ function unwrapMessage(message) {
|
|
|
620
621
|
return typeof message === "string" ? message : message?.message;
|
|
621
622
|
}
|
|
622
623
|
/* A check holds no link back to the schema it is attached to — the same check instance is shared by every clone of that schema — so the owner is stamped onto the issues a check just raised, at the only point where both are in scope. Runs on the failure path only; `start` is the issue count from before the check ran. */
|
|
624
|
+
/** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
|
|
625
|
+
function sizeCaps(defChecks) {
|
|
626
|
+
const caps = [];
|
|
627
|
+
for (const ch of defChecks ?? []) {
|
|
628
|
+
const d = ch._zod.def;
|
|
629
|
+
// a later check may rewrite the value
|
|
630
|
+
if (!/_(length|size)$|_equals$/.test(d.check))
|
|
631
|
+
break;
|
|
632
|
+
const max = d.maximum ?? d.length ?? d.size;
|
|
633
|
+
if (max >= 0)
|
|
634
|
+
caps.push([max, ch]);
|
|
635
|
+
}
|
|
636
|
+
return caps;
|
|
637
|
+
}
|
|
623
638
|
function attachSchema(issues, start, inst) {
|
|
624
639
|
var _a;
|
|
625
640
|
for (let i = start; i < issues.length; i++) {
|
|
@@ -221,6 +221,8 @@ export declare function prefixIssues(path: PropertyKey, issues: errors.$ZodRawIs
|
|
|
221
221
|
export declare function unwrapMessage(message: string | {
|
|
222
222
|
message: string;
|
|
223
223
|
} | undefined | null): string | undefined;
|
|
224
|
+
/** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
|
|
225
|
+
export declare function sizeCaps(defChecks: checks.$ZodCheck<never>[] | undefined): [number, checks.$ZodCheck<never>][];
|
|
224
226
|
export declare function attachSchema(issues: errors.$ZodRawIssue[], start: number, inst: schemas.$ZodType): void;
|
|
225
227
|
export declare function finalizeIssue(iss: errors.$ZodRawIssue, ctx: schemas.ParseContextInternal | undefined, config: $ZodConfig): errors.$ZodIssue;
|
|
226
228
|
export declare function getSizableOrigin(input: any): "set" | "map" | "file" | "unknown";
|
|
@@ -221,6 +221,8 @@ export declare function prefixIssues(path: PropertyKey, issues: errors.$ZodRawIs
|
|
|
221
221
|
export declare function unwrapMessage(message: string | {
|
|
222
222
|
message: string;
|
|
223
223
|
} | undefined | null): string | undefined;
|
|
224
|
+
/** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
|
|
225
|
+
export declare function sizeCaps(defChecks: checks.$ZodCheck<never>[] | undefined): [number, checks.$ZodCheck<never>][];
|
|
224
226
|
export declare function attachSchema(issues: errors.$ZodRawIssue[], start: number, inst: schemas.$ZodType): void;
|
|
225
227
|
export declare function finalizeIssue(iss: errors.$ZodRawIssue, ctx: schemas.ParseContextInternal | undefined, config: $ZodConfig): errors.$ZodIssue;
|
|
226
228
|
export declare function getSizableOrigin(input: any): "set" | "map" | "file" | "unknown";
|
|
@@ -550,6 +550,20 @@ export function unwrapMessage(message) {
|
|
|
550
550
|
return typeof message === "string" ? message : message?.message;
|
|
551
551
|
}
|
|
552
552
|
/* A check holds no link back to the schema it is attached to — the same check instance is shared by every clone of that schema — so the owner is stamped onto the issues a check just raised, at the only point where both are in scope. Runs on the failure path only; `start` is the issue count from before the check ran. */
|
|
553
|
+
/** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
|
|
554
|
+
export function sizeCaps(defChecks) {
|
|
555
|
+
const caps = [];
|
|
556
|
+
for (const ch of defChecks ?? []) {
|
|
557
|
+
const d = ch._zod.def;
|
|
558
|
+
// a later check may rewrite the value
|
|
559
|
+
if (!/_(length|size)$|_equals$/.test(d.check))
|
|
560
|
+
break;
|
|
561
|
+
const max = d.maximum ?? d.length ?? d.size;
|
|
562
|
+
if (max >= 0)
|
|
563
|
+
caps.push([max, ch]);
|
|
564
|
+
}
|
|
565
|
+
return caps;
|
|
566
|
+
}
|
|
553
567
|
export function attachSchema(issues, start, inst) {
|
|
554
568
|
var _a;
|
|
555
569
|
for (let i = start; i < issues.length; i++) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-cursor-sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "pi provider extension backed by @cursor/sdk local and cloud agents",
|
|
5
5
|
"author": "Mitch Fultz (https://github.com/fitchmultz)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -103,6 +103,8 @@
|
|
|
103
103
|
"scripts/lib/cursor-sdk-output-filter.d.mts",
|
|
104
104
|
"scripts/lib/ensure-built.mjs",
|
|
105
105
|
"README.md",
|
|
106
|
+
"docs/reference.md",
|
|
107
|
+
"docs/development.md",
|
|
106
108
|
"docs/cursor-model-ux-spec.md",
|
|
107
109
|
"docs/cursor-tool-surfaces.md",
|
|
108
110
|
"docs/cursor-live-smoke-checklist.md",
|
|
@@ -161,11 +163,12 @@
|
|
|
161
163
|
"smoke:platform:all": "npm run smoke:platform:doctor && node scripts/platform-smoke.mjs run --target macos,ubuntu,windows-native"
|
|
162
164
|
},
|
|
163
165
|
"dependencies": {
|
|
164
|
-
"@cursor/sdk": "1.0.
|
|
166
|
+
"@cursor/sdk": "1.0.40",
|
|
165
167
|
"@hono/node-server": "2.1.3",
|
|
166
168
|
"@modelcontextprotocol/hono": "2.0.2",
|
|
167
169
|
"@modelcontextprotocol/server": "2.3.1",
|
|
168
|
-
"hono": "4.13.13"
|
|
170
|
+
"hono": "4.13.13",
|
|
171
|
+
"zod": "4.6.6"
|
|
169
172
|
},
|
|
170
173
|
"bundledDependencies": [
|
|
171
174
|
"@hono/node-server",
|
|
@@ -181,9 +184,9 @@
|
|
|
181
184
|
},
|
|
182
185
|
"devDependencies": {
|
|
183
186
|
"@connectrpc/connect": "2.2.0",
|
|
184
|
-
"@earendil-works/pi-ai": "1.0
|
|
185
|
-
"@earendil-works/pi-coding-agent": "1.0
|
|
186
|
-
"@earendil-works/pi-tui": "1.0
|
|
187
|
+
"@earendil-works/pi-ai": "1.1.0",
|
|
188
|
+
"@earendil-works/pi-coding-agent": "1.1.0",
|
|
189
|
+
"@earendil-works/pi-tui": "1.1.0",
|
|
187
190
|
"@modelcontextprotocol/client": "2.3.1",
|
|
188
191
|
"@types/node": "24.19.1",
|
|
189
192
|
"@typescript/typescript6": "6.0.2",
|
|
@@ -195,6 +198,11 @@
|
|
|
195
198
|
"vitest": "5.0.3",
|
|
196
199
|
"yaml": "2.9.1"
|
|
197
200
|
},
|
|
201
|
+
"overrides": {
|
|
202
|
+
"@earendil-works/pi-coding-agent@1.1.0": {
|
|
203
|
+
"undici": "8.12.3"
|
|
204
|
+
}
|
|
205
|
+
},
|
|
198
206
|
"pi": {
|
|
199
207
|
"extensions": [
|
|
200
208
|
"./dist/index.js"
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { isUtf8 } from "node:buffer";
|
|
6
6
|
import { TextDecoder } from "node:util";
|
|
7
|
-
import { scrubSensitiveText } from "../../shared/cursor-sensitive-text.mjs";
|
|
7
|
+
import { hasCredentialUrlMarkers, scrubSensitiveText } from "../../shared/cursor-sensitive-text.mjs";
|
|
8
8
|
|
|
9
9
|
export const SECRET_PATTERNS = [
|
|
10
10
|
[/Authorization:\s*Bearer\s+[A-Za-z0-9\-._~+/]{20,}=*/gi, "Authorization header", "Authorization: Bearer [REDACTED_BEARER_TOKEN]"],
|
|
@@ -16,6 +16,10 @@ export const SECRET_PATTERNS = [
|
|
|
16
16
|
[/\b[^\s/:@]+:[^\s/]+@(?=[A-Za-z0-9.-]+(?::|\/|\s|$))/g, "credential-bearing SCP URL", "[REDACTED_CREDENTIAL_URL]"],
|
|
17
17
|
];
|
|
18
18
|
|
|
19
|
+
function isCredentialUrlPattern(label) {
|
|
20
|
+
return label === "credential-bearing URL" || label === "credential-bearing SCP URL";
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
const AUTH_ASSIGNMENT_PATTERN = /(?:^|[^A-Za-z0-9_$])(?:authorization|api[_-]?key|apiKey|access[_-]?token|refresh[_-]?token|token)["']?\s*[:=]\s*/gim;
|
|
20
24
|
const UNQUOTED_SECRET_CHARACTER = /^[A-Za-z0-9._~+/=-]$/;
|
|
21
25
|
|
|
@@ -65,7 +69,11 @@ export function redactSecrets(text) {
|
|
|
65
69
|
if (cursorKey && cursorKey.length > 10) {
|
|
66
70
|
redacted = redacted.split(cursorKey).join("[REDACTED_CURSOR_API_KEY]");
|
|
67
71
|
}
|
|
68
|
-
|
|
72
|
+
const credentialUrlPossible = hasCredentialUrlMarkers(redacted);
|
|
73
|
+
for (const [pattern, label, replacement] of SECRET_PATTERNS) {
|
|
74
|
+
// Global String.replace reset this state even on an impossible match.
|
|
75
|
+
pattern.lastIndex = 0;
|
|
76
|
+
if (!credentialUrlPossible && isCredentialUrlPattern(label)) continue;
|
|
69
77
|
redacted = redacted.replace(pattern, replacement);
|
|
70
78
|
}
|
|
71
79
|
return redacted;
|
|
@@ -195,13 +203,14 @@ export function scanForSecrets(value) {
|
|
|
195
203
|
)) {
|
|
196
204
|
violations.add("CURSOR_API_KEY literal found");
|
|
197
205
|
}
|
|
198
|
-
const patterns = SECRET_PATTERNS.filter(([, label]) =>
|
|
199
|
-
!binary || (label !== "credential-bearing URL" && label !== "credential-bearing SCP URL"));
|
|
206
|
+
const patterns = SECRET_PATTERNS.filter(([, label]) => !binary || !isCredentialUrlPattern(label));
|
|
200
207
|
const texts = buffer ? (binary ? binaryTextCandidates(buffer) : [buffer.toString("utf8")]) : [plainText];
|
|
201
208
|
for (const text of texts) {
|
|
202
209
|
if (authAssignmentSecretRanges(text).length > 0) violations.add("potential auth/token assignment");
|
|
210
|
+
const credentialUrlPossible = hasCredentialUrlMarkers(text);
|
|
203
211
|
for (const [pattern, label] of patterns) {
|
|
204
212
|
pattern.lastIndex = 0;
|
|
213
|
+
if (!credentialUrlPossible && isCredentialUrlPattern(label)) continue;
|
|
205
214
|
if (pattern.test(text)) violations.add(`potential ${label}`);
|
|
206
215
|
}
|
|
207
216
|
}
|
|
@@ -87,6 +87,7 @@ export function stopLeaseCheck(stopResult) {
|
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
/** Runs a suite command with Crabbox's full-stdout capture under suiteDir, retrying one transient SSH failure without sync. */
|
|
90
91
|
export async function runOnLeaseWithTransientRetry(
|
|
91
92
|
suiteDir,
|
|
92
93
|
targetName,
|
|
@@ -95,7 +96,8 @@ export async function runOnLeaseWithTransientRetry(
|
|
|
95
96
|
options,
|
|
96
97
|
run = runOnLease,
|
|
97
98
|
) {
|
|
98
|
-
const
|
|
99
|
+
const captured = { ...options, captureStdoutPath: resolve(suiteDir, ".crabbox.remote.stdout.raw") };
|
|
100
|
+
const first = await run(targetName, leaseId, command, captured);
|
|
99
101
|
if (!isTransientCrabboxSshFailure(first)) return first;
|
|
100
102
|
writeRedactedFile(
|
|
101
103
|
resolve(suiteDir, "crabbox.retry1.stdout.txt"),
|
|
@@ -106,7 +108,7 @@ export async function runOnLeaseWithTransientRetry(
|
|
|
106
108
|
first.stderr,
|
|
107
109
|
);
|
|
108
110
|
await new Promise((resolveRetry) => setTimeout(resolveRetry, 10_000));
|
|
109
|
-
return await run(targetName, leaseId, command, { ...
|
|
111
|
+
return await run(targetName, leaseId, command, { ...captured, sync: false });
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
const ARTIFACT_CHUNK_BYTES = 32 * 1024;
|
|
@@ -501,7 +501,6 @@ async function executeLiveSuite(config, targetName, suiteName, suiteDir, slug, l
|
|
|
501
501
|
shell: true,
|
|
502
502
|
timeout: 900_000,
|
|
503
503
|
allowEnv: ["CURSOR_API_KEY"],
|
|
504
|
-
captureStdoutPath: resolve(suiteDir, ".crabbox.remote.stdout.raw"),
|
|
505
504
|
sync: leaseSession?.sync,
|
|
506
505
|
config,
|
|
507
506
|
});
|
|
@@ -333,11 +333,11 @@ async function main() {
|
|
|
333
333
|
printHelp();
|
|
334
334
|
return;
|
|
335
335
|
}
|
|
336
|
-
ensureBuilt();
|
|
337
336
|
if (process.argv.includes("--self-test")) {
|
|
338
337
|
await runSelfTest();
|
|
339
338
|
return;
|
|
340
339
|
}
|
|
340
|
+
ensureBuilt();
|
|
341
341
|
|
|
342
342
|
const sessionDir = process.env.SMOKE_SESSION_DIR ?? join("/tmp", `pi-cursor-steer-smoke-${Date.now()}`);
|
|
343
343
|
const piBin = resolvePiBin();
|
|
@@ -6,3 +6,5 @@ export declare function suppressCursorSdkOutput<T>(operation: () => T): T;
|
|
|
6
6
|
export declare function withCursorSdkOutputNoticeHandler<T>(handler: CursorSdkOutputNoticeHandler | undefined, operation: () => T): T;
|
|
7
7
|
export declare function isCursorSdkStartupNoise(text: string): boolean;
|
|
8
8
|
export declare function installCursorSdkOutputFilter(): () => void;
|
|
9
|
+
export declare function installCursorSdkProcessOutputFilter(): void;
|
|
10
|
+
export declare const __testUtils: { resetProcessOutputFilter(): void };
|