Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions sdk/typescript/src/cli/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,13 @@ export const HARNESS_CLI_COMMANDS: Array<TinyPlaceCliCommand> = [
name: "publish-card",
capability: "profile",
description: "Publish/update your discoverable Agent Card.",
usage: "[--name <name>] [--description <text>] [--skills a,b] [--endpoint <url>]",
usage: "[--name <name>] [--description <text>] [--skills tag-a,tag-b] [--endpoint <url>] [--data '<agent-card-json>']",
},
{
name: "card-update",
capability: "profile",
description: "Alias of publish-card.",
usage: "[--name <name>] [--description <text>] [--skills a,b] [--endpoint <url>]",
usage: "[--name <name>] [--description <text>] [--skills tag-a,tag-b] [--endpoint <url>] [--data '<agent-card-json>']",
},
{
name: "search",
Expand All @@ -276,8 +276,8 @@ export const HARNESS_CLI_COMMANDS: Array<TinyPlaceCliCommand> = [
{
name: "card",
capability: "directory",
description: "Get an agent card.",
usage: "<agentId>",
description: "Get an agent card by @handle or agent id.",
usage: "<@handle|agentId>",
},
{
name: "groups",
Expand Down
3 changes: 2 additions & 1 deletion sdk/typescript/src/cli/harness-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { createRequire } from "node:module";
import { homedir } from "node:os";
import { basename, dirname, join, resolve } from "node:path";
import { spawn as spawnPty, type IPty } from "node-pty";
import type { IPty } from "node-pty";

import {
publishKeys,
Expand Down Expand Up @@ -263,6 +263,7 @@ async function runPtyAgent(
let pty: IPty;
try {
fixNodePtyHelperPermissions();
const { spawn: spawnPty } = await import("node-pty");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep node-pty imports at module scope

For files under this SDK, sdk/typescript/AGENTS.md says, “Always use top-level imports. Never use dynamic import() inside functions.” This new function-scoped import runs on the normal PTY launch path for tinyplace codex/claude, so it violates the repository’s required import discipline; please keep node-pty loading at module scope or refactor the fallback without adding an in-function dynamic import.

Useful? React with 👍 / 👎.

pty = spawnPty(launch.command, launch.args, {
cols: terminalColumns(stdio.stdout),
cwd,
Expand Down
69 changes: 69 additions & 0 deletions sdk/typescript/tests/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,26 @@ describe("tinyplace CLI", () => {
});
});

it("short-circuits command-specific help before signer-dependent writes", async () => {
for (const args of [
["publish-card", "--help"],
["raw", "publish-card", "--help"],
]) {
const result = await runTinyPlaceCli(args, {
env: { TINYPLACE_ENDPOINT: "https://example.test" },
fetch: async () => {
throw new Error(
`help path should not touch the network: ${args.join(" ")}`,
);
},
});

expect(result.code, args.join(" ")).toBe(0);
expect(result.stderr, args.join(" ")).toBe("");
expect(result.stdout, args.join(" ")).toContain("publish-card");
}
});

it("maps payment challenges into parseable JSON errors", async () => {
const challenge = {
error: "x402 payment is required",
Expand Down Expand Up @@ -856,6 +876,55 @@ describe("tinyplace CLI", () => {
}
});

it("resolves @handles before raw agent-card lookup", async () => {
const requests: Array<Request> = [];
const result = await runTinyPlaceCli(["raw", "card", "@naturedesk"], {
env: { TINYPLACE_ENDPOINT: "https://example.test" },
fetch: async (input, init) => {
const request = new Request(input, init);
requests.push(request);
const url = new URL(request.url);
if (url.pathname === "/directory/resolve/%40naturedesk") {
return Response.json({
identity: {
username: "@naturedesk",
cryptoId: "A8sVmcaC5apxoUx1kCA4pPa9RttQK1HXmfkziSFf5dVg",
},
});
}
if (url.pathname === "/graphql") {
const body = (await request.clone().json()) as {
variables: { id?: string };
};
return Response.json({
data: {
agentCard: {
agentId: body.variables.id,
name: "NatureDesk",
},
},
});
}
return Response.json({ error: "unexpected route" }, { status: 500 });
},
});

expect(result.code).toBe(0);
expect(requests.map((request) => new URL(request.url).pathname)).toEqual([
"/directory/resolve/%40naturedesk",
"/graphql",
]);
const body = (await requests[1]!.clone().json()) as {
variables: { id?: string };
};
expect(body.variables.id).toBe(
"A8sVmcaC5apxoUx1kCA4pPa9RttQK1HXmfkziSFf5dVg",
);
expect(JSON.parse(result.stdout)).toMatchObject({
agentId: "A8sVmcaC5apxoUx1kCA4pPa9RttQK1HXmfkziSFf5dVg",
});
});

it("passes the bounties status filter as a GraphQL variable", async () => {
const requests: Array<Request> = [];
const result = await runTinyPlaceCli(
Expand Down
Loading