Ask → session → artifact
Full Ask journey: start with a pinned workflow, wait for execution, download
session-report.md.
Ask journeys use the API token only (no webhook token).
| Step | What the SDK does |
|---|---|
| 1. Start | POST /guild/api/v1/guild/ask/start |
| 2. Poll | Wait until execution settles |
| 3. Artifact | Poll session artifacts, then download to a local path |
Minimal — one SDK call
from stackgen import StackgenClient, StackgenConfig
client = StackgenClient(
StackgenConfig(
base_url="https://app.stackgen.com",
api_token="stackgen_…",
org_id="<project-uuid>",
)
)
result = client.aiden.run_ask_and_download_artifact(
"Run triage for checkout CPU alert",
entity_refs=[{"name": "incident-triage", "type": "workflow"}],
)
print(result.trace_id, result.session_id, result.output_path)import { StackgenClient, StackgenConfig } from "stackgen-sdk";
const client = new StackgenClient(
new StackgenConfig({
baseUrl: "https://app.stackgen.com",
apiToken: "stackgen_…",
orgId: "<project-uuid>",
}),
);
const result = await client.aiden.runAskAndDownloadArtifact({
message: "Run triage for checkout CPU alert",
entityRefs: [{ name: "incident-triage", type: "workflow" }],
});
console.log(result.traceId, result.sessionId, result.outputPath);Runnable CLI
#!/usr/bin/env python3
"""Ask Guild → wait → download session artifact (CI-friendly, no webhook token)."""
from __future__ import annotations
import argparse
import sys
from stackgen import StackgenClient, StackgenConfig
def main() -> int:
parser = argparse.ArgumentParser(
description="Start Ask Guild, poll execution, download a session artifact.",
)
parser.add_argument("--base-url", required=True, help="Mothership URL (no /guild suffix)")
parser.add_argument("--api-token", required=True, help="API token (stackgen_…)")
parser.add_argument("--org-id", required=True, help="Project / org UUID (orgId)")
parser.add_argument("--message", required=True, help="Natural-language task for Ask")
parser.add_argument(
"--workflow-name",
required=True,
help="Workflow skill name to pin via entity_refs",
)
parser.add_argument(
"--artifact-name",
default="session-report.md",
help="Session artifact filename to download",
)
parser.add_argument(
"--output-path",
default="session-report.md",
help="Local path to write the artifact",
)
args = parser.parse_args()
client = StackgenClient(
StackgenConfig(
base_url=args.base_url,
api_token=args.api_token,
org_id=args.org_id,
artifact_name=args.artifact_name,
output_path=args.output_path,
)
)
result = client.aiden.run_ask_and_download_artifact(
args.message,
entity_refs=[{"name": args.workflow_name, "type": "workflow"}],
artifact_name=args.artifact_name,
output_path=args.output_path,
)
print(
f"trace_id={result.trace_id} session_id={result.session_id} "
f"output={result.output_path}",
file=sys.stderr,
)
return 0
if __name__ == "__main__":
raise SystemExit(main())/**
* Ask Guild → wait → download session artifact (CI-friendly, no webhook token).
*
* Docs: https://appcd-dev.github.io/stackgen-sdk/code-samples/ask-artifact/
*
* Usage:
* npx tsx ask-download-report.ts \
* --base-url https://app.stackgen.com \
* --api-token stackgen_… \
* --org-id <project-uuid> \
* --message 'Run triage for checkout CPU alert' \
* --workflow-name incident-triage
*/
import { parseArgs } from "node:util";
import { StackgenClient, StackgenConfig } from "stackgen-sdk";
async function main(): Promise<void> {
const { values } = parseArgs({
options: {
"base-url": { type: "string" },
"api-token": { type: "string" },
"org-id": { type: "string" },
message: { type: "string" },
"workflow-name": { type: "string" },
"artifact-name": { type: "string", default: "session-report.md" },
"output-path": { type: "string", default: "session-report.md" },
},
});
if (
!values["base-url"] ||
!values["api-token"] ||
!values["org-id"] ||
!values.message ||
!values["workflow-name"]
) {
throw new Error("require --base-url, --api-token, --org-id, --message, --workflow-name");
}
const client = new StackgenClient(
new StackgenConfig({
baseUrl: values["base-url"],
apiToken: values["api-token"],
orgId: values["org-id"],
artifactName: values["artifact-name"],
outputPath: values["output-path"],
}),
);
const result = await client.aiden.runAskAndDownloadArtifact(values.message, {
entityRefs: [{ name: values["workflow-name"], type: "workflow" }],
artifactName: values["artifact-name"],
outputPath: values["output-path"],
});
console.error(
`traceId=${result.traceId} sessionId=${result.sessionId} output=${result.outputPath}`,
);
}
main().catch((err) => {
console.error(err instanceof Error ? err.message : err);
process.exit(1);
});Related: Ask → execution — poll only, no download.